You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2009/04/28 21:47:23 UTC

svn commit: r769513 - in /ofbiz/trunk/applications/accounting: config/ data/ entitydef/ script/org/ofbiz/accounting/payment/ servicedef/ src/org/ofbiz/accounting/thirdparty/cybersource/ widget/

Author: mrisaliti
Date: Tue Apr 28 19:47:21 2009
New Revision: 769513

URL: http://svn.apache.org/viewvc?rev=769513&view=rev
Log:
Support of CyberSource v5.0.2 and use the new Payment Gateway Config features (OFBIZ-2370)

Modified:
    ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
    ofbiz/trunk/applications/accounting/config/payment.properties
    ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
    ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_cybersource.xml
    ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java
    ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml
    ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml

Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original)
+++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Tue Apr 28 19:47:21 2009
@@ -2086,6 +2086,70 @@
         <value xml:lang="th">ลูกค้า</value>
         <value xml:lang="zh">客户</value>
     </property>
+    <property key="AccountingCyberSourceApiVersion">
+        <value xml:lang="en">CyberSource API Version</value>
+        <value xml:lang="it">Versione API CyberSource</value>
+    </property>
+    <property key="AccountingCyberSourceAutoBill">
+        <value xml:lang="en">Auto-Bill In Authorization (Capture)</value>
+        <value xml:lang="it">Cattura automaticamente durante autorizzazione</value>
+    </property>
+    <property key="AccountingCyberSourceAvsDeclineCodes">
+        <value xml:lang="en">Avs Decline Codes -- May not be supported any longer</value>
+        <value xml:lang="it">Codici rifiuto AVS -- potrebbe essere non più supportato</value>
+    </property>
+    <property key="AccountingCyberSourceDisableBillAvs">
+        <value xml:lang="en">Disable AVS for Capture -- May not be supported any longer</value>
+        <value xml:lang="it">Disabilita AVS durante la cattura -- potrebbe essere non più supportato</value>
+    </property>
+    <property key="AccountingCyberSourceEnableDav">
+        <value xml:lang="en">Use DAV In Authorization -- May not be supported any longer</value>
+        <value xml:lang="it">Usa DAV durante autorizzazione -- potrebbe essere non più supportato</value>
+    </property>
+    <property key="AccountingCyberSourceFraudScore">
+        <value xml:lang="en">Use Fraud Scoring In Authorization -- May not be supported any longer</value>
+        <value xml:lang="it">Usa punteggio frode in autorizzazione --  potrebbe essere non più supportato</value>
+    </property>
+    <property key="AccountingCyberSourceIgnoreAvs">
+        <value xml:lang="en">Ignore AVS Results</value>
+        <value xml:lang="it">Ignora risultati AVS</value>
+    </property>
+    <property key="AccountingCyberSourceKeysDir">
+        <value xml:lang="en">Directory of the keys from CyberSource (Generate using online tools)</value>
+        <value xml:lang="it">Directory delle chiavi di CyberSource (Generate usado gli strumenti online)</value>
+    </property>
+    <property key="AccountingCyberSourceKeysFile">
+        <value xml:lang="en">Name of the keystore (if different then "merchantID.p12")</value>
+        <value xml:lang="it">Name keystore (se diverso da "merchantID.p12")</value>
+    </property>
+    <property key="AccountingCyberSourceLogDir">
+        <value xml:lang="en">Log directory</value>
+        <value xml:lang="it">Directory log</value>
+    </property>
+    <property key="AccountingCyberSourceLogEnable">
+        <value xml:lang="en">Log transaction information</value>
+        <value xml:lang="it">Abilita log</value>
+    </property>
+    <property key="AccountingCyberSourceLogFile">
+        <value xml:lang="en">Log File Name</value>
+        <value xml:lang="it">Nome file di log</value>
+    </property>
+    <property key="AccountingCyberSourceLogSize">
+        <value xml:lang="en">Max log size (megabytes)</value>
+        <value xml:lang="it">Ampiezza massima log (megabytes)</value>
+    </property>
+    <property key="AccountingCyberSourceMerchantContact">
+        <value xml:lang="en">Merchant Contact</value>
+        <value xml:lang="it">Contatto negoziante</value>
+    </property>
+    <property key="AccountingCyberSourceMerchantDescr">
+        <value xml:lang="en">Merchant Description</value>
+        <value xml:lang="it">Descrizione negoziante</value>
+    </property>
+    <property key="AccountingCyberSourceProduction">
+        <value xml:lang="en">Enable Production Mode</value>
+        <value xml:lang="it">Abilita modalità di produzione</value>
+    </property>
     <property key="AccountingDataExchange">
         <value xml:lang="ar">تبادل المعلومات</value>
         <value xml:lang="de">Datenaustausch</value>
@@ -8853,6 +8917,10 @@
         <value xml:lang="ru">Макс. кол-во</value>
         <value xml:lang="th">จำนวนมากสุด</value>
     </property>
+    <property key="FormFieldTitle_merchantId">
+        <value xml:lang="en">Merchant Id</value>
+        <value xml:lang="it">Codice negoziante</value>
+    </property>
     <property key="FormFieldTitle_minItemPrice">
         <value xml:lang="en">Min Item Price</value>
         <value xml:lang="es">Precio mínimo de elemento</value>
@@ -9575,7 +9643,7 @@
         <value xml:lang="zh">编排人工服务标识</value>
     </property>
     <property key="FormFieldTitle_serverURL">
-        <value xml:lang="en">serverURL</value>
+        <value xml:lang="en">Server URL</value>
         <value xml:lang="it">URL server</value>
     </property>
     <property key="FormFieldTitle_settlementTermId">
@@ -10897,6 +10965,10 @@
         <value xml:lang="en">Update Payment Gateway Config Clear Commerce</value>
         <value xml:lang="it">Aggiorna configurazione gateway pagamento Clear Commerce</value>
     </property>
+    <property key="PageTitleUpdatePaymentGatewayConfigCyberSource">
+        <value xml:lang="en">Update Payment Gateway Config CyberSource</value>
+        <value xml:lang="it">Aggiorna configurazione gateway pagamento CyberSource</value>
+    </property>
     <property key="PageTitleUpdatePaymentGatewayConfigPayflowPro">
         <value xml:lang="en">Update Payment Gateway Config Payflow Pro</value>
         <value xml:lang="it">Aggiorna configurazione gateway pagamento Payflow Pro</value>

Modified: ofbiz/trunk/applications/accounting/config/payment.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/payment.properties?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/payment.properties (original)
+++ ofbiz/trunk/applications/accounting/config/payment.properties Tue Apr 28 19:47:21 2009
@@ -69,7 +69,7 @@
 payment.cybersource.merchantID=[MerchantID]
 
 # target API version
-payment.cybersource.api.version=1.37
+payment.cybersource.api.version=1.43
 
 # enable production "mode" (true|false)
 payment.cybersource.production=false
@@ -84,7 +84,7 @@
 payment.cybersource.log=true
 
 # log directory
-payment.cybersource.log.dir=runtime/logs
+payment.cybersource.log.dir=${sys:getProperty('ofbiz.home')}/runtime/logs
 
 # log file name
 payment.cybersource.log.file=cybersource.log

Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Tue Apr 28 19:47:21 2009
@@ -666,6 +666,10 @@
     <PaymentType description="POS Paid In" hasTable="N" parentTypeId="RECEIPT" paymentTypeId="POS_PAID_IN"/>
 
     <!-- Payment Gateway Config -->
+    <PaymentGatewayConfigType paymentGatewayConfigTypeId="CYBERSOURCE" hasTable="N" description="CyberSource Payment Gateway"/>
+    <PaymentGatewayConfig paymentGatewayConfigId="CYBERSOURCE_CONFIG" paymentGatewayConfigTypeId="CYBERSOURCE" description="CyberSource Config"/>
+    <PaymentGatewayCyberSource paymentGatewayConfigId="CYBERSOURCE_CONFIG" merchantId="[MerchantID]" apiVersion="1.43" production="false" keysDir="${sys:getProperty('ofbiz.home')}/applications/accounting/icskeys" keysFile="merchantID.p12" logEnabled="true" logDir="${sys:getProperty('ofbiz.home')}/runtime/logs" logFile="cybersource.log" logSize="10" merchantDescr="Some Nice Web Store" merchantContact="" autoBill="false" enableDav="N" fraudScore="N" ignoreAvs="false" disableBillAvs="Y" avsDeclineCodes=""/>
+    
     <PaymentGatewayConfigType paymentGatewayConfigTypeId="PAYFLOWPRO" hasTable="N" description="Payflow Pro Payment Gateway"/>
     <PaymentGatewayConfig paymentGatewayConfigId="PAYFLOWPRO_CONFIG" paymentGatewayConfigTypeId="PAYFLOWPRO" description="Payflow Pro Config"/>
     <PaymentGatewayPayflowPro paymentGatewayConfigId="PAYFLOWPRO_CONFIG" certsPath="${sys:getProperty('ofbiz.home')}/applications/accounting/pfcerts" hostAddress="test-payflow.verisign.com" hostPort="443" timeout="80" proxyAddress="" proxyPort="80" proxyLogon="" proxyPassword="" vendor="[Vendor]" userId="[PayFlow UserID]" pwd="[PayFlow Password]" partner="[PayFlow Partner]" checkAvs="Y" checkCvv2="Y" preAuth="Y" enableTransmit="true" logFileName="${sys:getProperty('ofbiz.home')}/runtime/logs/payflow_java.log" loggingLevel="6" maxLogFileSize="1000000" stackTraceOn="N"/>

Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Tue Apr 28 19:47:21 2009
@@ -2966,8 +2966,8 @@
       </relation>
     </entity>
     <entity entity-name="PaymentGatewayConfigType"
-        package-name="org.ofbiz.accounting.payment"
-        title="Payment Gateway Config Type">
+            package-name="org.ofbiz.accounting.payment"
+            title="Payment Gateway Config Type">
       <field name="paymentGatewayConfigTypeId" type="id-ne"></field>
       <field name="parentTypeId" type="id"></field>
       <field name="hasTable" type="indicator"></field>
@@ -2981,8 +2981,8 @@
       </relation>
     </entity>
     <entity entity-name="PaymentGatewayConfig"
-        package-name="org.ofbiz.accounting.payment"
-        title="Payment Gateway Config">
+            package-name="org.ofbiz.accounting.payment"
+            title="Payment Gateway Config">
       <field name="paymentGatewayConfigId" type="id-ne"></field>
       <field name="paymentGatewayConfigTypeId" type="id-ne"></field>
       <field name="description" type="description"></field>
@@ -2991,9 +2991,35 @@
         <key-map field-name="paymentGatewayConfigTypeId" rel-field-name="paymentGatewayConfigTypeId"/>
       </relation>
     </entity>
+    <entity entity-name="PaymentGatewayCyberSource"
+            package-name="org.ofbiz.accounting.payment"
+            title="CyberSource Payment Gateway Configuration">
+      <field name="paymentGatewayConfigId" type="id-ne"></field>
+      <field name="merchantId" type="value"><description>You merchant ID</description></field>
+      <field name="apiVersion" type="short-varchar"><description>Target CyberSource API version</description></field>
+      <field name="production" type="short-varchar"><description>Enable production "mode" (true|false)</description></field>
+      <field name="keysDir" type="value"><description>Directory of the keys from CyberSource (Generate using online tools)</description></field>
+      <field name="keysFile" type="value"><description>Name of the keystore (if different then "merchantID".p12)</description></field>
+      <field name="logEnabled" type="short-varchar"><description>Log transaction information (true|false)</description></field>
+      <field name="logDir" type="value"><description>Log directory</description></field>
+      <field name="logFile" type="value"><description>Log file name</description></field>
+      <field name="logSize" type="numeric"><description>Max log size (megabytes)</description></field>
+      <field name="merchantDescr" type="value"><description>Merchant Description - Shown on credit card statement</description></field>
+      <field name="merchantContact" type="value"><description>Merchant Description Contact Information - Shown on credit card statement</description></field>
+      <field name="autoBill" type="short-varchar"><description>Auto-Bill In Authorization (true|false)</description></field>
+      <field name="enableDav" type="indicator"><description>Use DAV In Authorization -- May not be supported any longer</description></field>
+      <field name="fraudScore" type="indicator"><description>Use Fraud Scoring In Authorization -- May not be supported any longer</description></field>
+      <field name="ignoreAvs" type="short-varchar"><description>Ignore AVS results (true|false)</description></field>
+      <field name="disableBillAvs" type="indicator"><description>Disable AVS for Capture -- May not be supported any longer</description></field>
+      <field name="avsDeclineCodes" type="value"><description>AVS Decline Codes -- May not be supported any longer</description></field>
+      <prim-key field="paymentGatewayConfigId"/>
+      <relation type="one" fk-name="PGCS_PGC" rel-entity-name="PaymentGatewayConfig">
+        <key-map field-name="paymentGatewayConfigId"/>
+      </relation>
+    </entity>
     <entity entity-name="PaymentGatewayPayflowPro"
-        package-name="org.ofbiz.accounting.payment"
-        title="Payflow Pro Payment Gateway Config">
+            package-name="org.ofbiz.accounting.payment"
+            title="Payflow Pro Payment Gateway Config">
       <field name="paymentGatewayConfigId" type="id-ne"></field>
       <field name="certsPath" type="value"><description>Path the the VeriSign Certificate</description></field>
       <field name="hostAddress" type="value"><description>Address of the payment processor</description></field>
@@ -3021,8 +3047,8 @@
       </relation>
     </entity>
     <entity entity-name="PaymentGatewayPayPal"
-        package-name="org.ofbiz.accounting.payment"
-        title="PayPal Payment Gateway Config">
+            package-name="org.ofbiz.accounting.payment"
+            title="PayPal Payment Gateway Config">
         <field name="paymentGatewayConfigId" type="id-ne"></field>
         <field name="businessEmail" type="value"><description>Business e-mail</description></field>
         <field name="notifyUrl" type="value"><description>Notify URL</description></field>
@@ -3038,8 +3064,8 @@
         </relation>
     </entity>
     <entity entity-name="PaymentGatewayClearCommerce"
-        package-name="org.ofbiz.accounting.payment"
-        title="Clear Commerce Payment Gateway Config">
+            package-name="org.ofbiz.accounting.payment"
+            title="Clear Commerce Payment Gateway Config">
       <field name="paymentGatewayConfigId" type="id-ne"></field>
       <field name="sourceId" type="short-varchar"><description>Useful for tagging transactions</description></field>
       <field name="groupId" type="short-varchar"><description>Useful for grouping transactions</description></field>

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml Tue Apr 28 19:47:21 2009
@@ -26,20 +26,26 @@
         <store-value value-field="lookedUpValue"/>
     </simple-method>
     
-    <simple-method method-name="updatePaymentGatewayConfigPayflowPro" short-description="Update Payment Gateway Config Payflow Pro">
-        <entity-one entity-name="PaymentGatewayPayflowPro" value-field="lookedUpValue"/>
+    <simple-method method-name="updatePaymentGatewayConfigClearCommerce" short-description="Update Payment Gateway Config Clear Commerce">
+        <entity-one entity-name="PaymentGatewayClearCommerce" value-field="lookedUpValue"/>
         <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
         <store-value value-field="lookedUpValue"/>
     </simple-method>
     
-    <simple-method method-name="updatePaymentGatewayConfigPayPal" short-description="Update Payment Gateway Config PayPal">
-        <entity-one entity-name="PaymentGatewayPayPal" value-field="lookedUpValue"/>
+    <simple-method method-name="updatePaymentGatewayConfigCyberSource" short-description="Update Payment Gateway Config CyberSource">
+        <entity-one entity-name="PaymentGatewayCyberSource" value-field="lookedUpValue"/>
         <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
         <store-value value-field="lookedUpValue"/>
     </simple-method>
     
-    <simple-method method-name="updatePaymentGatewayConfigClearCommerce" short-description="Update Payment Gateway Config Clear Commerce">
-        <entity-one entity-name="PaymentGatewayClearCommerce" value-field="lookedUpValue"/>
+    <simple-method method-name="updatePaymentGatewayConfigPayflowPro" short-description="Update Payment Gateway Config Payflow Pro">
+        <entity-one entity-name="PaymentGatewayPayflowPro" value-field="lookedUpValue"/>
+        <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
+        <store-value value-field="lookedUpValue"/>
+    </simple-method>
+    
+    <simple-method method-name="updatePaymentGatewayConfigPayPal" short-description="Update Payment Gateway Config PayPal">
+        <entity-one entity-name="PaymentGatewayPayPal" value-field="lookedUpValue"/>
         <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
         <store-value value-field="lookedUpValue"/>
     </simple-method>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_cybersource.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_cybersource.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_cybersource.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_cybersource.xml Tue Apr 28 19:47:21 2009
@@ -27,27 +27,27 @@
     <!-- CyberSource Implementations -->
     <service name="cyberSourceCCAuth" engine="java"
             location="org.ofbiz.accounting.thirdparty.cybersource.IcsPaymentServices" invoke="ccAuth">
-        <description>Credit Card Processing</description>
+        <description>CyberSource Credit Card Authorization</description>
         <implements service="ccAuthInterface"/>
     </service>
     <service name="cyberSourceCCCapture" engine="java"
             location="org.ofbiz.accounting.thirdparty.cybersource.IcsPaymentServices" invoke="ccCapture">
-        <description>Credit Card Processing</description>
+        <description>CyberSource Credit Card Capture</description>
         <implements service="ccCaptureInterface"/>
     </service>
     <service name="cyberSourceCCRelease" engine="java"
             location="org.ofbiz.accounting.thirdparty.cybersource.IcsPaymentServices" invoke="ccRelease">
-        <description>Credit Card Processing</description>
+        <description>CyberSource Credit Card Credit</description>
         <implements service="paymentReleaseInterface"/>
     </service>
     <service name="cyberSourceCCRefund" engine="java"
             location="org.ofbiz.accounting.thirdparty.cybersource.IcsPaymentServices" invoke="ccRefund">
-        <description>Credit Card Processing</description>
+        <description>CyberSource Credit Card Refund</description>
         <implements service="paymentRefundInterface"/>
     </service>
     <service name="cyberSourceCCCredit" engine="java"
             location="org.ofbiz.accounting.thirdparty.cybersource.IcsPaymentServices" invoke="ccCredit">
-        <description>Credit Card Processing</description>
+        <description>CyberSource Credit Card Credit</description>
         <implements service="ccCreditInterface"/>
     </service>
 </services>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml Tue Apr 28 19:47:21 2009
@@ -31,6 +31,18 @@
         <auto-attributes entity-name="PaymentGatewayConfig" include="nonpk" mode="IN" optional="true"/>
     </service>
     
+    <service name="updatePaymentGatewayConfigClearCommerce" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigClearCommerce">
+        <description>Update Payment Gateway Config Clear Commerce</description>
+        <auto-attributes entity-name="PaymentGatewayClearCommerce" include="pk" mode="IN" optional="false"/>
+        <auto-attributes entity-name="PaymentGatewayClearCommerce" include="nonpk" mode="IN" optional="true"/>
+    </service>
+    
+    <service name="updatePaymentGatewayConfigCyberSource" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigCyberSource">
+        <description>Update Payment Gateway Config CyberSource</description>
+        <auto-attributes entity-name="PaymentGatewayCyberSource" include="pk" mode="IN" optional="false"/>
+        <auto-attributes entity-name="PaymentGatewayCyberSource" include="nonpk" mode="IN" optional="true"/>
+    </service>
+    
     <service name="updatePaymentGatewayConfigPayflowPro" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigPayflowPro">
         <description>Update Payment Gateway Config Payflow Pro</description>
         <auto-attributes entity-name="PaymentGatewayPayflowPro" include="pk" mode="IN" optional="false"/>
@@ -43,12 +55,6 @@
         <auto-attributes entity-name="PaymentGatewayPayPal" include="nonpk" mode="IN" optional="true"/>
     </service>
     
-    <service name="updatePaymentGatewayConfigClearCommerce" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigClearCommerce">
-        <description>Update Payment Gateway Config Clear Commerce</description>
-        <auto-attributes entity-name="PaymentGatewayClearCommerce" include="pk" mode="IN" optional="false"/>
-        <auto-attributes entity-name="PaymentGatewayClearCommerce" include="nonpk" mode="IN" optional="true"/>
-    </service>
-    
     <service name="updatePaymentGatewayConfigType" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigType">
         <description>Update Payment Gateway Config Type</description>
         <auto-attributes entity-name="PaymentGatewayConfigType" include="pk" mode="IN" optional="false"/>

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java Tue Apr 28 19:47:21 2009
@@ -19,12 +19,12 @@
 package org.ofbiz.accounting.thirdparty.cybersource;
 
 import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import javolution.util.FastMap;
+
 import com.cybersource.ws.client.Client;
 import com.cybersource.ws.client.ClientException;
 import com.cybersource.ws.client.FaultException;
@@ -33,11 +33,13 @@
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.SSLUtil;
 import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilNumber;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
+import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.service.DispatchContext;
@@ -51,26 +53,27 @@
     public static final String module = IcsPaymentServices.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
     private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
-
+    
     // load the JSSE properties
     static {
         SSLUtil.loadJsseProperties();
     }
-
-    public static Map ccAuth(DispatchContext dctx, Map context) {
+    
+    public static Map<String, Object> ccAuth(DispatchContext dctx, Map<String, ? extends Object> context) {
+        GenericDelegator delegator = dctx.getDelegator();
         // generate the request/properties
-        Properties props = buildCsProperties(context);
+        Properties props = buildCsProperties(context, delegator);
         if (props == null) {
             return ServiceUtil.returnError("ERROR: Getting Cybersource property configuration");
         }
-
-        Map<String, Object> request = buildAuthRequest(context);
+        
+        Map<String, Object> request = buildAuthRequest(context, delegator);
         request.put("merchantID", props.get("merchantID"));
-
+        
         // transmit the request
-        Map reply;
+        Map<String, Object> reply;
         try {
-            reply = Client.runTransaction(request, props);
+            reply = UtilGenerics.cast(Client.runTransaction(request, props));
         } catch (FaultException e) {
             Debug.logError(e, "ERROR: Fault from CyberSource", module);
             Debug.logError(e, "Fault : " + e.getFaultString(), module);
@@ -79,44 +82,40 @@
             Debug.logError(e, "ERROR: CyberSource Client exception : " + e.getMessage(), module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
         }
-
         // process the reply
         Map<String, Object> result = ServiceUtil.returnSuccess();
         processAuthResult(reply, result);
         return result;
     }
-
-    public static Map ccReAuth(DispatchContext dctx, Map context) {
+    
+    public static Map<String, Object> ccReAuth(DispatchContext dctx, Map<String, ? extends Object> context) {
         return ServiceUtil.returnSuccess();
     }
-
-    public static Map ccCapture(DispatchContext dctx, Map context) {
+    
+    public static Map<String, Object> ccCapture(DispatchContext dctx, Map<String, ? extends Object> context) {
+        GenericDelegator delegator = dctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
-
         //lets see if there is a auth transaction already in context
         GenericValue authTransaction = (GenericValue) context.get("authTrans");
-
         if (authTransaction == null) {
             authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         }
-
         if (authTransaction == null) {
             return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot capture");
         }
-
         // generate the request/properties
-        Properties props = buildCsProperties(context);
+        Properties props = buildCsProperties(context, delegator);
         if (props == null) {
             return ServiceUtil.returnError("ERROR: Getting Cybersource property configuration");
         }
-
-        Map<String, Object> request = buildCaptureRequest(context, authTransaction);
+        
+        Map<String, Object> request = buildCaptureRequest(context, authTransaction, delegator);
         request.put("merchantID", props.get("merchantID"));
-
+        
         // transmit the request
-        Map reply;
+        Map<String, Object> reply;
         try {
-            reply = Client.runTransaction(request, props);
+            reply = UtilGenerics.cast(Client.runTransaction(request, props));
         } catch (FaultException e) {
             Debug.logError(e, "ERROR: Fault from CyberSource", module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
@@ -124,33 +123,33 @@
             Debug.logError(e, "ERROR: CyberSource Client exception : " + e.getMessage(), module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
         }
-
         // process the reply
         Map<String, Object> result = ServiceUtil.returnSuccess();
         processCaptureResult(reply, result);
         return result;
     }
-
-    public static Map ccRelease(DispatchContext dctx, Map context) {
+    
+    public static Map<String, Object> ccRelease(DispatchContext dctx, Map<String, ? extends Object> context) {
+        GenericDelegator delegator = dctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
             return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot release");
         }
-
+        
         // generate the request/properties
-        Properties props = buildCsProperties(context);
+        Properties props = buildCsProperties(context, delegator);
         if (props == null) {
             return ServiceUtil.returnError("ERROR: Getting Cybersource property configuration");
         }
-
+        
         Map<String, Object> request = buildReleaseRequest(context, authTransaction);
         request.put("merchantID", props.get("merchantID"));
-
+        
         // transmit the request
-        Map reply;
+        Map<String, Object> reply;
         try {
-            reply = Client.runTransaction(request, props);
+            reply = UtilGenerics.cast(Client.runTransaction(request, props));
         } catch (FaultException e) {
             Debug.logError(e, "ERROR: Fault from CyberSource", module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
@@ -158,33 +157,33 @@
             Debug.logError(e, "ERROR: CyberSource Client exception : " + e.getMessage(), module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
         }
-
         // process the reply
         Map<String, Object> result = ServiceUtil.returnSuccess();
         processReleaseResult(reply, result);
         return result;
     }
-
-    public static Map ccRefund(DispatchContext dctx, Map context) {
+    
+    public static Map<String, Object> ccRefund(DispatchContext dctx, Map<String, ? extends Object> context) {
+        GenericDelegator delegator = dctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
             return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot refund");
         }
-
+        
         // generate the request/properties
-        Properties props = buildCsProperties(context);
+        Properties props = buildCsProperties(context, delegator);
         if (props == null) {
             return ServiceUtil.returnError("ERROR: Getting Cybersource property configuration");
         }
-
-        Map<String, Object> request = buildRefundRequest(context, authTransaction);
+        
+        Map<String, Object> request = buildRefundRequest(context, authTransaction, delegator);
         request.put("merchantID", props.get("merchantID"));
-
+        
         // transmit the request
-        Map reply;
+        Map<String, Object> reply;
         try {
-            reply = Client.runTransaction(request, props);
+            reply = UtilGenerics.cast(Client.runTransaction(request, props));
         } catch (FaultException e) {
             Debug.logError(e, "ERROR: Fault from CyberSource", module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
@@ -192,27 +191,28 @@
             Debug.logError(e, "ERROR: CyberSource Client exception : " + e.getMessage(), module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
         }
-
+        
         // process the reply
         Map<String, Object> result = ServiceUtil.returnSuccess();
         processRefundResult(reply, result);
         return result;
     }
-
-    public static Map ccCredit(DispatchContext dctx, Map context) {
+    
+    public static Map<String, Object> ccCredit(DispatchContext dctx, Map<String, ? extends Object> context) {
+        GenericDelegator delegator = dctx.getDelegator();
         // generate the request/properties
-        Properties props = buildCsProperties(context);
+        Properties props = buildCsProperties(context, delegator);
         if (props == null) {
             return ServiceUtil.returnError("ERROR: Getting Cybersource property configuration");
         }
-
+        
         Map<String, Object> request = buildCreditRequest(context);
         request.put("merchantID", props.get("merchantID"));
-
+        
         // transmit the request
-        Map reply;
+        Map<String, Object> reply;
         try {
-            reply = Client.runTransaction(request, props);
+            reply = UtilGenerics.cast(Client.runTransaction(request, props));
         } catch (FaultException e) {
             Debug.logError(e, "ERROR: Fault from CyberSource", module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
@@ -220,118 +220,108 @@
             Debug.logError(e, "ERROR: CyberSource Client exception : " + e.getMessage(), module);
             return ServiceUtil.returnError("Unable to communicate with CyberSource");
         }
-
+        
         // process the reply
         Map<String, Object> result = ServiceUtil.returnSuccess();
         processCreditResult(reply, result);
         return result;
     }
-
-    private static Properties buildCsProperties(Map context) {
+    
+    private static Properties buildCsProperties(Map<String, ? extends Object> context, GenericDelegator delegator) {
+        String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId");
         String configString = (String) context.get("paymentConfig");
         if (configString == null) {
             configString = "payment.properties";
         }
-
-        String merchantId = UtilProperties.getPropertyValue(configString, "payment.cybersource.merchantID");
-        String targetApi = UtilProperties.getPropertyValue(configString, "payment.cybersource.api.version");
-        String production = UtilProperties.getPropertyValue(configString, "payment.cybersource.production");
-        String enableLog = UtilProperties.getPropertyValue(configString, "payment.cybersource.log");
-        String logSize = UtilProperties.getPropertyValue(configString, "payment.cybersource.log.size");
-        String logFile = UtilProperties.getPropertyValue(configString, "payment.cybersource.log.file");
-        String logDir = UtilProperties.getPropertyValue(configString, "payment.cybersource.log.dir");
-
-        String keysPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue(configString, "payment.cybersource.keysDir"), context);
-        String keysFile = UtilProperties.getPropertyValue(configString, "payment.cybersource.keysFile");
-
+        String merchantId = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "merchantId", configString, "payment.cybersource.merchantID");
+        String targetApi = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "apiVersion", configString, "payment.cybersource.api.version");
+        String production = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "production", configString, "payment.cybersource.production");
+        String enableLog = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "logEnabled", configString, "payment.cybersource.log");
+        String logSize = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "logSize", configString, "payment.cybersource.log.size");
+        String logFile = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "logFile", configString, "payment.cybersource.log.file");
+        String logDir = FlexibleStringExpander.expandString(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "logDir", configString, "payment.cybersource.log.dir"), context);
+        String keysDir = FlexibleStringExpander.expandString(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "keysDir", configString, "payment.cybersource.keysDir"), context);
+        String keysFile = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "keysFile", configString, "payment.cybersource.keysFile");
         // some property checking
         if (UtilValidate.isEmpty(merchantId)) {
-            Debug.logWarning("The merchantId property in [" + configString + "] is not configured", module);
+            Debug.logWarning("The merchantId property is not configured", module);
             return null;
         }
-        if (UtilValidate.isEmpty(keysPath)) {
-            Debug.logWarning("The keysDir property in [" + configString + "] is not configured", module);
+        if (UtilValidate.isEmpty(keysDir)) {
+            Debug.logWarning("The keysDir property is not configured", module);
             return null;
         }
-
         // create some properties for CS Client
         Properties props = new Properties();
         props.put("merchantID", merchantId);
-        props.put("keysDirectory", keysPath);
+        props.put("keysDirectory", keysDir);
         props.put("targetAPIVersion", targetApi);
         props.put("sendToProduction", production);
         props.put("enableLog", enableLog);
         props.put("logDirectory", logDir);
         props.put("logFilename", logFile);
         props.put("logMaximumSize", logSize);
-
         if (keysFile != null && keysFile.length() > 0) {
             props.put("alternateKeyFilename", keysFile);
         }
-        //Debug.logInfo("Created CyberSource Properties : " + props, module);
-
+        Debug.log("Created CyberSource Properties : " + props, module);
         return props;
     }
-
-    private static Map<String, Object> buildAuthRequest(Map context) {
+    
+    private static Map<String, Object> buildAuthRequest(Map<String, ? extends Object> context, GenericDelegator delegator) {
+        String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId");
         String configString = (String) context.get("paymentConfig");
         String currency = (String) context.get("currency");
         if (configString == null) {
             configString = "payment.properties";
         }
-
         // make the request map
-        String capture = UtilProperties.getPropertyValue(configString, "payment.cybersource.autoBill", "false");
+        String capture = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "autoBill", configString, "payment.cybersource.autoBill", "false");
         String orderId = (String) context.get("orderId");
-
-        Map<String, Object> request = new HashMap<String, Object>();
+        Map<String, Object> request = FastMap.newInstance();
         request.put("ccAuthService_run", "true");              // run auth service
         request.put("ccCaptureService_run", capture);          // run capture service (i.e. sale)
         request.put("merchantReferenceCode", orderId);         // set the order ref number
         request.put("purchaseTotals_currency", currency);      // set the order currency
         appendFullBillingInfo(request, context);               // add in all address info
         appendItemLineInfo(request, context, "processAmount"); // add in the item info
-        appendAvsRules(request, context);                      // add in the AVS flags and decline codes
-
+        appendAvsRules(request, context, delegator);           // add in the AVS flags and decline codes
         return request;
     }
-
-    private static Map<String, Object> buildCaptureRequest(Map context, GenericValue authTransaction) {
+    
+    private static Map<String, Object> buildCaptureRequest(Map<String, ? extends Object> context, GenericValue authTransaction, GenericDelegator delegator) {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
+        String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId");
         String configString = (String) context.get("paymentConfig");
         String currency = (String) context.get("currency");
         if (configString == null) {
             configString = "payment.properties";
         }
-        String merchantDesc = UtilProperties.getPropertyValue(configString, "payment.cybersource.merchantDescr", null);
-        String merchantCont = UtilProperties.getPropertyValue(configString, "payment.cybersource.merchantContact", null);
-
-        Map<String, Object> request = new HashMap<String, Object>();
+        String merchantDesc = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "merchantDescr", configString, "payment.cybersource.merchantDescr", null);
+        String merchantCont = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "merchantContact", configString, "payment.cybersource.merchantContact", null);
+        Map<String, Object> request = FastMap.newInstance();
         request.put("ccCaptureService_run", "true");
         request.put("ccCaptureService_authRequestID", authTransaction.getString("referenceNum"));
         request.put("item_0_unitPrice", getAmountString(context, "captureAmount"));
         request.put("merchantReferenceCode", orderPaymentPreference.getString("orderId"));
         request.put("purchaseTotals_currency", currency);
-
+        
         // TODO: add support for verbal authorizations
         //request.put("ccCaptureService_authType", null);   -- should be 'verbal'
         //request.put("ccCaptureService_verbalAuthCode", null); -- code from verbal auth
-
         if (merchantDesc != null) {
             request.put("invoiceHeader_merchantDescriptor", merchantDesc);        // merchant description
         }
         if (merchantCont != null) {
             request.put("invoiceHeader_merchantDescriptorContact", merchantCont); // merchant contact info
         }
-
         return request;
     }
-
-    private static Map<String, Object> buildReleaseRequest(Map context, GenericValue authTransaction) {
+    
+    private static Map<String, Object> buildReleaseRequest(Map<String, ? extends Object> context, GenericValue authTransaction) {
+        Map<String, Object> request = FastMap.newInstance();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         String currency = (String) context.get("currency");
-
-        Map<String, Object> request = new HashMap<String, Object>();
         request.put("ccAuthReversalService_run", "true");
         request.put("ccAuthReversalService_authRequestID", authTransaction.getString("referenceNum"));
         request.put("item_0_unitPrice", getAmountString(context, "releaseAmount"));
@@ -339,56 +329,52 @@
         request.put("purchaseTotals_currency", currency);
         return request;
     }
-
-    private static Map<String, Object> buildRefundRequest(Map context, GenericValue authTransaction) {
+    
+    private static Map<String, Object> buildRefundRequest(Map<String, ? extends Object> context, GenericValue authTransaction, GenericDelegator delegator) {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
+        String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId");
         String configString = (String) context.get("paymentConfig");
-        String currency = (String) context.get("currency");
         if (configString == null) {
             configString = "payment.properties";
         }
-        String merchantDesc = UtilProperties.getPropertyValue(configString, "payment.cybersource.merchantDescr", null);
-        String merchantCont = UtilProperties.getPropertyValue(configString, "payment.cybersource.merchantContact", null);
-
-        Map<String, Object> request = new HashMap<String, Object>();
+        String currency = (String) context.get("currency");
+        String merchantDesc = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "merchantDescr", configString, "payment.cybersource.merchantDescr", null);
+        String merchantCont = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "merchantContact", configString, "payment.cybersource.merchantContact", null);
+        Map<String, Object> request = FastMap.newInstance();
         request.put("ccCreditService_run", "true");
         request.put("ccCreditService_captureRequestID", authTransaction.getString("referenceNum"));
         request.put("item_0_unitPrice", getAmountString(context, "refundAmount"));
         request.put("merchantReferenceCode", orderPaymentPreference.getString("orderId"));
         request.put("purchaseTotals_currency", currency);
-
         if (merchantDesc != null) {
             request.put("invoiceHeader_merchantDescriptor", merchantDesc);        // merchant description
         }
         if (merchantCont != null) {
             request.put("invoiceHeader_merchantDescriptorContact", merchantCont); // merchant contact info
         }
-
         return request;
     }
-
-    private static Map<String, Object> buildCreditRequest(Map context) {
+    
+    private static Map<String, Object> buildCreditRequest(Map<String, ? extends Object> context) {
         String refCode = (String) context.get("referenceCode");
-
-        Map<String, Object> request = new HashMap<String, Object>();
+        Map<String, Object> request = FastMap.newInstance();
         request.put("ccCreditService_run", "true");            // run credit service
         request.put("merchantReferenceCode", refCode);         // set the ref number could be order id
         appendFullBillingInfo(request, context);               // add in all address info
         appendItemLineInfo(request, context, "creditAmount");  // add in the item info
         return request;
     }
-
-    private static void appendAvsRules(Map<String, Object> request, Map context) {
+    
+    private static void appendAvsRules(Map<String, Object> request, Map<String, ? extends Object> context, GenericDelegator delegator) {
+        String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId");
         String configString = (String) context.get("paymentConfig");
         if (configString == null) {
             configString = "payment.properties";
         }
-        String avsCodes = UtilProperties.getPropertyValue(configString, "payment.cybersource.avsDeclineCodes", null);
-
+        String avsCodes = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "avsDeclineCodes", configString, "payment.cybersource.avsDeclineCodes", null);
         GenericValue party = (GenericValue) context.get("billToParty");
         if (party != null) {
             GenericValue avsOverride = null;
-
             try {
                 avsOverride = party.getDelegator().findByPrimaryKey("PartyIcsAvsOverride",
                         UtilMisc.toMap("partyId", party.getString("partyId")));
@@ -402,19 +388,14 @@
                 }
             }
         }
-
         if (avsCodes != null && avsCodes.length() > 0) {
             request.put("businessRules_declineAVSFlags", avsCodes);
         }
-
-        String avsIgnore = UtilProperties.getPropertyValue(configString, "payment.cybersource.avsDeclineCodes", "false");
+        String avsIgnore = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "ignoreAvs", configString, "payment.cybersource.ignoreAvs", "false");
         request.put("businessRules_ignoreAVS", avsIgnore);
     }
-
-    private static void appendFullBillingInfo(Map<String, Object> request, Map context) {
-        // person info
-        GenericValue party = (GenericValue) context.get("billToParty");
-
+    
+    private static void appendFullBillingInfo(Map<String, Object> request, Map<String, ? extends Object> context) {
         // contact info
         GenericValue email = (GenericValue) context.get("billToEmail");
         if (email != null) {
@@ -422,14 +403,12 @@
         } else {
             Debug.logWarning("Email not defined; Cybersource will fail.", module);
         }
-
         // phone number seems to not be used; possibly only for reporting.
-
+        
         // CC payment info
         GenericValue creditCard = (GenericValue) context.get("creditCard");
         if (creditCard != null) {
-            List expDateList = StringUtil.split(creditCard.getString("expireDate"), "/");
-
+            List<String> expDateList = StringUtil.split(creditCard.getString("expireDate"), "/");
             request.put("billTo_firstName", creditCard.getString("firstNameOnCard"));
             request.put("billTo_lastName", creditCard.getString("lastNameOnCard"));
             request.put("card_accountNumber", creditCard.getString("cardNumber"));
@@ -438,7 +417,6 @@
         } else {
             Debug.logWarning("CreditCard not defined; Cybersource will fail.", module);
         }
-
         // CCV info
         String cvNum = (String) context.get("cardSecurityCode");
         String cvSet = UtilValidate.isEmpty(cvNum) ? "1" : "0";
@@ -446,10 +424,9 @@
         if ("1".equals(cvNum)) {
             request.put("card_cvNumber", cvNum);
         }
-
         // payment contact info
         GenericValue billingAddress = (GenericValue) context.get("billingAddress");
-
+        
         if (billingAddress != null) {
             request.put("billTo_street1", billingAddress.getString("address1"));
             if (billingAddress.get("address2") != null) {
@@ -457,7 +434,6 @@
             }
             request.put("billTo_city", billingAddress.getString("city"));
             String bCountry = billingAddress.get("countryGeoId") != null ? billingAddress.getString("countryGeoId") : "USA";
-
             request.put("billTo_country", bCountry);
             request.put("billTo_postalCode", billingAddress.getString("postalCode"));
             if (billingAddress.get("stateProvinceGeoId") != null) {
@@ -466,7 +442,6 @@
         } else {
             Debug.logWarning("BillingAddress not defined; Cybersource will fail.", module);
         }
-
         // order shipping information
         GenericValue shippingAddress = (GenericValue) context.get("shippingAddress");
         if (shippingAddress != null) {
@@ -475,14 +450,12 @@
                 request.put("shipTo_firstName", creditCard.getString("firstNameOnCard"));
                 request.put("shipTo_lastName", creditCard.getString("lastNameOnCard"));
             }
-
             request.put("shipTo_street1", shippingAddress.getString("address1"));
             if (shippingAddress.get("address2") != null) {
                 request.put("shipTo_street2", shippingAddress.getString("address2"));
             }
             request.put("shipTo_city", shippingAddress.getString("city"));
             String sCountry = shippingAddress.get("countryGeoId") != null ? shippingAddress.getString("countryGeoId") : "USA";
-
             request.put("shipTo_country", sCountry);
             request.put("shipTo_postalCode", shippingAddress.getString("postalCode"));
             if (shippingAddress.get("stateProvinceGeoId") != null) {
@@ -490,21 +463,17 @@
             }
         }
     }
-
-    private static void appendItemLineInfo(Map<String, Object> request, Map context, String amountField) {
+    
+    private static void appendItemLineInfo(Map<String, Object> request, Map<String, ? extends Object> context, String amountField) {
         // send over a line item total offer w/ the total for billing; don't trust CyberSource for calc
         String currency = (String) context.get("currency");
-
         int lineNumber = 0;
         request.put("item_" + lineNumber + "_unitPrice", getAmountString(context, amountField));
-
         // the currency
         request.put("purchaseTotals_currency", currency);
-
         // create the offers (one for each line item)
-        List orderItems = (List) context.get("orderItems");
+        List<GenericValue> orderItems = UtilGenerics.cast(context.get("orderItems"));
         if (orderItems != null) {
-
             for (Object orderItem : orderItems) {
                 lineNumber++;
                 GenericValue item = (GenericValue) orderItem;
@@ -514,7 +483,6 @@
                 } catch (GenericEntityException e) {
                     Debug.logError(e, "ERROR: Unable to get Product from OrderItem, not passing info to CyberSource");
                 }
-
                 if (product != null) {
                     request.put("item_" + lineNumber + "_productName", product.getString("productName"));
                     request.put("item_" + lineNumber + "_productSKU", product.getString("productId"));
@@ -522,29 +490,26 @@
                     // no product; just send the item description -- non product items
                     request.put("item_" + lineNumber + "_productName", item.getString("description"));
                 }
-
                 // get the quantity..
                 BigDecimal quantity = item.getBigDecimal("quantity");
-
                 // test quantity if INT pass as is; if not pass as 1
                 if (quantity.scale() > 0) {
                     request.put("item_" + lineNumber + "_quantity", "1");
                 } else {
                     request.put("", Integer.toString(quantity.intValue()));
                 }
-
                 // set the amount to 0.0000 -- we will send a total too.
                 request.put("item_" + lineNumber + "_unitPrice", "0.0000");
             }
         }
     }
-
-    private static String getAmountString(Map context, String amountField) {
+    
+    private static String getAmountString(Map<String, ? extends Object> context, String amountField) {
         BigDecimal processAmount = (BigDecimal) context.get(amountField);
         return processAmount.setScale(decimals, rounding).toPlainString();
     }
-
-    private static void processAuthResult(Map reply, Map<String, Object> result) {
+    
+    private static void processAuthResult(Map<String, Object> reply, Map<String, Object> result) {
         String decision = getDecision(reply);
         if ("ACCEPT".equalsIgnoreCase(decision)) {
             result.put("authCode", reply.get("ccAuthReply_authorizationCode"));
@@ -554,13 +519,12 @@
             result.put("authResult", Boolean.FALSE);
             // TODO: based on reasonCode populate the following flags as applicable: resultDeclined, resultNsf, resultBadExpire, resultBadCardNumber
         }
-
+        
         if (reply.get("ccAuthReply_amount") != null) {
             result.put("processAmount", new BigDecimal((String) reply.get("ccAuthReply_amount")));
         } else {
             result.put("processAmount", BigDecimal.ZERO);
         }
-
         result.put("authRefNum", reply.get("requestID"));
         result.put("authFlag", reply.get("ccAuthReply_reasonCode"));
         result.put("authMessage", reply.get("ccAuthReply_processorResponse"));
@@ -572,21 +536,19 @@
         if (Debug.infoOn())
             Debug.logInfo("CC [Cybersource] authorization result : " + result, module);
     }
-
-    private static void processCaptureResult(Map reply, Map<String, Object> result) {
+    
+    private static void processCaptureResult(Map<String, Object> reply, Map<String, Object> result) {
         String decision = getDecision(reply);
         if ("ACCEPT".equalsIgnoreCase(decision)) {
             result.put("captureResult", Boolean.TRUE);
         } else {
             result.put("captureResult", Boolean.FALSE);
         }
-
         if (reply.get("ccCaptureReply_amount") != null) {
             result.put("captureAmount", new BigDecimal((String) reply.get("ccCaptureReply_amount")));
         } else {
             result.put("captureAmount", BigDecimal.ZERO);
         }
-
         result.put("captureRefNum", reply.get("requestID"));
         result.put("captureCode", reply.get("ccCaptureReply_reconciliationID"));
         result.put("captureFlag", reply.get("ccCaptureReply_reasonCode"));
@@ -594,43 +556,39 @@
         if (Debug.infoOn())
             Debug.logInfo("CC [Cybersource] capture result : " + result, module);
     }
-
-    private static void processReleaseResult(Map reply, Map<String, Object> result) {
+    
+    private static void processReleaseResult(Map<String, Object> reply, Map<String, Object> result) {
         String decision = getDecision(reply);
         if ("ACCEPT".equalsIgnoreCase(decision)) {
             result.put("releaseResult", Boolean.TRUE);
         } else {
             result.put("releaseResult", Boolean.FALSE);
         }
-
         if (reply.get("ccAuthReversalReply_amount") != null) {
             result.put("releaseAmount", new BigDecimal((String) reply.get("ccAuthReversalReply_amount")));
         } else {
             result.put("releaseAmount", BigDecimal.ZERO);
         }
-
         result.put("releaseRefNum", reply.get("requestID"));
-        result.put("releaseCode", reply.get("ccAuthReversalReply_authorizationCode"));
-        result.put("releaseFlag", reply.get("ccAuthReversalReply_reasonCode"));
+        result.put("releaseCode", reply.get("ccAuthReversalReply_reasonCode"));
+        result.put("releaseFlag", reply.get("reasonCode"));
         result.put("releaseMessage", reply.get("decision"));
         if (Debug.infoOn())
             Debug.logInfo("CC [Cybersource] release result : " + result, module);
     }
-
-    private static void processRefundResult(Map reply, Map<String, Object> result) {
+    
+    private static void processRefundResult(Map<String, Object> reply, Map<String, Object> result) {
         String decision = getDecision(reply);
         if ("ACCEPT".equalsIgnoreCase(decision)) {
             result.put("refundResult", Boolean.TRUE);
         } else {
             result.put("refundResult", Boolean.FALSE);
         }
-
         if (reply.get("ccCreditReply_amount") != null) {
             result.put("refundAmount", new BigDecimal((String) reply.get("ccCreditReply_amount")));
         } else {
             result.put("refundAmount", BigDecimal.ZERO);
         }
-
         result.put("refundRefNum", reply.get("requestID"));
         result.put("refundCode", reply.get("ccCreditReply_reconciliationID"));
         result.put("refundFlag", reply.get("ccCreditReply_reasonCode"));
@@ -638,21 +596,21 @@
         if (Debug.infoOn())
             Debug.logInfo("CC [Cybersource] refund result : " + result, module);
     }
-
-    private static void processCreditResult(Map reply, Map<String, Object> result) {
+    
+    private static void processCreditResult(Map<String, Object> reply, Map<String, Object> result) {
         String decision = (String) reply.get("decision");
         if ("ACCEPT".equalsIgnoreCase(decision)) {
             result.put("creditResult", Boolean.TRUE);
         } else {
             result.put("creditResult", Boolean.FALSE);
         }
-
+        
         if (reply.get("ccCreditReply_amount") != null) {
             result.put("creditAmount", new BigDecimal((String) reply.get("ccCreditReply_amount")));
         } else {
             result.put("creditAmount", BigDecimal.ZERO);
         }
-
+        
         result.put("creditRefNum", reply.get("requestID"));
         result.put("creditCode", reply.get("ccCreditReply_reconciliationID"));
         result.put("creditFlag", reply.get("ccCreditReply_reasonCode"));
@@ -660,8 +618,8 @@
         if (Debug.infoOn())
             Debug.logInfo("CC [Cybersource] credit result : " + result, module);
     }
-
-    private static String getDecision(Map reply) {
+    
+    private static String getDecision(Map<String, Object> reply) {
         String decision = (String) reply.get("decision");
         String reasonCode = (String) reply.get("reasonCode");
         if (!"ACCEPT".equalsIgnoreCase(decision)) {
@@ -670,4 +628,37 @@
         }
         return decision;
     }
+    
+    private static String getPaymentGatewayConfigValue(GenericDelegator delegator, String paymentGatewayConfigId, String paymentGatewayConfigParameterName,
+                                                       String resource, String parameterName) {
+        String returnValue = "";
+        if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) {
+            try {
+                GenericValue cyberSource = delegator.findOne("PaymentGatewayCyberSource", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false);
+                if (UtilValidate.isNotEmpty(cyberSource)) {
+                    Object cyberSourceField = cyberSource.get(paymentGatewayConfigParameterName);
+                    if (cyberSourceField != null) {
+                        returnValue = cyberSourceField.toString().trim();
+                    }
+                }
+            } catch (GenericEntityException e) {
+                Debug.logError(e, module);
+            }
+        } else {
+            String value = UtilProperties.getPropertyValue(resource, parameterName);
+            if (value != null) {
+                returnValue = value.trim();
+            }
+        }
+        return returnValue;
+    }
+    
+    private static String getPaymentGatewayConfigValue(GenericDelegator delegator, String paymentGatewayConfigId, String paymentGatewayConfigParameterName,
+                                                       String resource, String parameterName, String defaultValue) {
+        String returnValue = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, paymentGatewayConfigParameterName, resource, parameterName);
+        if (UtilValidate.isEmpty(returnValue)) {
+            returnValue = defaultValue;
+        }
+        return returnValue;
+    }
 }

Modified: ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml Tue Apr 28 19:47:21 2009
@@ -66,6 +66,67 @@
         </field>
     </form>
     
+    <form name="EditPaymentGatewayConfigCyberSource" type="single" target="UpdatePaymentGatewayConfigCyberSource" default-map-name="paymentGatewayCyberSource" header-row-style="header-row" default-table-style="basic-table">
+        <auto-fields-entity entity-name="PaymentGatewayCyberSource" default-field-type="edit"/>
+        <field name="paymentGatewayConfigId"><hidden/></field>
+        <field name="apiVersion" title="${uiLabelMap.AccountingCyberSourceApiVersion}">
+            <text size="10" maxlength="10"/>
+        </field>
+        <field name="production" title="${uiLabelMap.AccountingCyberSourceProduction}">
+            <drop-down>
+                <option key="true" description="${uiLabelMap.CommonTrue}"/>
+                <option key="false" description="${uiLabelMap.CommonFalse}"/>
+            </drop-down>
+        </field>
+        <field name="keysDir" title="${uiLabelMap.AccountingCyberSourceKeysDir}"><text size="80" maxlength="80"/></field>
+        <field name="keysFile" title="${uiLabelMap.AccountingCyberSourceKeysFile}"><text size="80" maxlength="80"/></field>
+        <field name="logEnabled" title="${uiLabelMap.AccountingCyberSourceLogEnable}">
+            <drop-down>
+                <option key="true" description="${uiLabelMap.CommonTrue}"/>
+                <option key="false" description="${uiLabelMap.CommonFalse}"/>
+            </drop-down>
+        </field>
+        <field name="logDir" title="${uiLabelMap.AccountingCyberSourceLogDir}"><text size="80" maxlength="80"/></field>
+        <field name="logFile" title="${uiLabelMap.AccountingCyberSourceLogFile}"><text size="80" maxlength="80"/></field>
+        <field name="logSize" title="${uiLabelMap.AccountingCyberSourceLogSize}"><text size="20" maxlength="20"/></field>
+        <field name="merchantDescr" title="${uiLabelMap.AccountingCyberSourceMerchantDescr}"><text size="80" maxlength="80"/></field>
+        <field name="merchantContact" title="${uiLabelMap.AccountingCyberSourceMerchantContact}"><text size="80" maxlength="80"/></field>
+        <field name="autoBill" title="${uiLabelMap.AccountingCyberSourceAutoBill}">
+            <drop-down>
+                <option key="true" description="${uiLabelMap.CommonTrue}"/>
+                <option key="false" description="${uiLabelMap.CommonFalse}"/>
+            </drop-down>
+        </field>
+        <field name="ignoreAvs" title="${uiLabelMap.AccountingCyberSourceIgnoreAvs}">
+            <drop-down>
+                <option key="true" description="${uiLabelMap.CommonTrue}"/>
+                <option key="false" description="${uiLabelMap.CommonFalse}"/>
+            </drop-down>
+        </field>
+        <field name="enableDav" title="${uiLabelMap.AccountingCyberSourceEnableDav}">
+            <drop-down>
+                <option key="Y" description="${uiLabelMap.CommonYes}"/>
+                <option key="N" description="${uiLabelMap.CommonNo}"/>
+            </drop-down>
+        </field>
+        <field name="fraudScore" title="${uiLabelMap.AccountingCyberSourceFraudScore}">
+            <drop-down>
+                <option key="Y" description="${uiLabelMap.CommonYes}"/>
+                <option key="N" description="${uiLabelMap.CommonNo}"/>
+            </drop-down>
+        </field>
+        <field name="disableBillAvs" title="${uiLabelMap.AccountingCyberSourceDisableBillAvs}">
+            <drop-down>
+                <option key="Y" description="${uiLabelMap.CommonYes}"/>
+                <option key="N" description="${uiLabelMap.CommonNo}"/>
+            </drop-down>
+        </field>
+        <field name="avsDeclineCodes" title="${uiLabelMap.AccountingCyberSourceAvsDeclineCodes}"><text size="20" maxlength="20"/></field>
+        <field name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit">
+            <submit button-type="button"/>
+        </field>
+    </form>
+    
     <form name="EditPaymentGatewayConfigPayflowPro" type="single" target="UpdatePaymentGatewayConfigPayflowPro" default-map-name="paymentGatewayPayflowPro" header-row-style="header-row" default-table-style="basic-table">
         <auto-fields-entity entity-name="PaymentGatewayPayflowPro" default-field-type="edit"/>
         <field name="certsPath"><text size="80" maxlength="80"/></field>

Modified: ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml?rev=769513&r1=769512&r2=769513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml Tue Apr 28 19:47:21 2009
@@ -85,6 +85,9 @@
                 
                 <set field="paymentGatewayConfigId" from-field="parameters.paymentGatewayConfigId"/>
                 <entity-one entity-name="PaymentGatewayConfig" value-field="paymentGatewayConfig"/>
+                <entity-one entity-name="PaymentGatewayCyberSource" value-field="paymentGatewayCyberSource">
+                    <field-map field-name="paymentGatewayConfigId" from-field="parameters.paymentGatewayConfigId"/>
+                </entity-one>
                 <entity-one entity-name="PaymentGatewayPayflowPro" value-field="paymentGatewayPayflowPro">
                     <field-map field-name="paymentGatewayConfigId" from-field="parameters.paymentGatewayConfigId"/>
                 </entity-one>
@@ -114,6 +117,27 @@
                         </container>
                         <section>
                             <condition>
+                                <not><if-empty field="paymentGatewayCyberSource"/></not>
+                            </condition>
+                            <widgets>
+                                <container style="screenlet">
+                                    <container style="screenlet-title-bar">
+                                        <container style="h3">
+                                            <label text="${uiLabelMap.PageTitleUpdatePaymentGatewayConfigCyberSource}"/>
+                                        </container>
+                                    </container>
+                                    <container style="screenlet-body">
+                                        <section>
+                                            <widgets>
+                                                <include-form name="EditPaymentGatewayConfigCyberSource" location="component://accounting/widget/PaymentGatewayConfigForms.xml"/>
+                                            </widgets>
+                                        </section>
+                                    </container>
+                                </container>
+                            </widgets>
+                        </section>
+                        <section>
+                            <condition>
                                 <not><if-empty field="paymentGatewayPayflowPro"/></not>
                             </condition>
                             <widgets>