Author: mrisaliti
Date: Thu May 21 17:57:48 2009 New Revision: 777203 URL: http://svn.apache.org/viewvc?rev=777203&view=rev Log: Integration of new RBS WorldPay Select Junior and support of new Payment Gateway Config entity (OFBIZ-2498) Removed: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java Modified: ofbiz/trunk/applications/accounting/build.xml ofbiz/trunk/applications/accounting/config/AccountingEntityLabels.xml ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml 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_paymentgateway.xml ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml ofbiz/trunk/specialpurpose/ecommerce/data/DemoRentalProduct.xml ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Modified: ofbiz/trunk/applications/accounting/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/build.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/build.xml (original) +++ ofbiz/trunk/applications/accounting/build.xml Thu May 21 17:57:48 2009 @@ -47,7 +47,6 @@ <fileset dir="../product/build/lib" includes="*.jar"/> <fileset dir="../marketing/build/lib" includes="*.jar"/> <fileset dir="../order/build/lib" includes="*.jar"/> - <!-- <fileset dir="lib/worldpay" includes="*.jar"/> --> <!-- <fileset dir="lib/cybersource" includes="*.jar"/> --> <fileset dir="lib" includes="*.jar"/> </path> @@ -61,7 +60,6 @@ <!-- exclude the payment processor packages; comment this out to not exclude if you have libs --> <exclude name="org/ofbiz/accounting/thirdparty/verisign/**"/> <exclude name="org/ofbiz/accounting/thirdparty/cybersource/**"/> - <exclude name="org/ofbiz/accounting/thirdparty/worldpay/**"/> </javac15> </target> Modified: ofbiz/trunk/applications/accounting/config/AccountingEntityLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingEntityLabels.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingEntityLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingEntityLabels.xml Thu May 21 17:57:48 2009 @@ -2425,15 +2425,15 @@ <value xml:lang="zh">è´å®</value> </property> <property key="PaymentMethodType.description.EXT_WORLDPAY"> - <value xml:lang="de">WorldPay-Konto</value> - <value xml:lang="en">WorldPay</value> - <value xml:lang="fr">WorldPay</value> - <value xml:lang="it">WorldPay</value> - <value xml:lang="nl">WorldPay</value> - <value xml:lang="ro">WorldPay</value> - <value xml:lang="ru">WorldPay</value> - <value xml:lang="th">WorldPay</value> - <value xml:lang="zh">WorldPay</value> + <value xml:lang="de">RBS WorldPay-Konto</value> + <value xml:lang="en">RBS WorldPay</value> + <value xml:lang="fr">RBS WorldPay</value> + <value xml:lang="it">RBS WorldPay</value> + <value xml:lang="nl">RBS WorldPay</value> + <value xml:lang="ro">RBS WorldPay</value> + <value xml:lang="ru">RBS WorldPay</value> + <value xml:lang="th">RBS WorldPay</value> + <value xml:lang="zh">RBS WorldPay</value> </property> <property key="PaymentMethodType.description.FIN_ACCOUNT"> <value xml:lang="en">Financial Account</value> Modified: ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingErrorUiLabels.xml Thu May 21 17:57:48 2009 @@ -68,4 +68,36 @@ <value xml:lang="nl">Problemen verkrijgen orderkop.</value> <value xml:lang="th">à¸à¸±à¸à¸«à¸²à¸à¸²à¸£à¹à¸£à¸µà¸¢à¸à¹à¸à¹à¸«à¸±à¸§à¸à¹à¸à¸£à¸²à¸¢à¸à¸²à¸£à¸ªà¸±à¹à¸à¸à¸·à¹à¸</value> </property> + <property key="worldPayEvents.failedToExecuteServiceCreatePaymentFromPreference"> + <value xml:lang="en">Failed To Execute Service CreatePaymentFromPreference</value> + <value xml:lang="it">Fallita esecuzione servizio CreatePaymentFromPreference</value> + </property> + <property key="worldPayEvents.noValidOrderIdReturned"> + <value xml:lang="en">No Valid OrderId Returned</value> + <value xml:lang="it">Nessun numero ordine restituito</value> + </property> + <property key="worldPayEvents.problemsConnectingWithWorldPay"> + <value xml:lang="en">Problems Connecting With WorldPay</value> + <value xml:lang="it">Problema nella connessione con WorldPay</value> + </property> + <property key="worldPayEvents.problemsGettingAuthenticationUser"> + <value xml:lang="en">Problems Getting Authentication User</value> + <value xml:lang="it">Problema durante l'autenticazione utente</value> + </property> + <property key="worldPayEvents.problemsGettingInstId"> + <value xml:lang="en">Problems Getting Inst Id</value> + <value xml:lang="it">Problema nel ricavare il parametro Inst Id</value> + </property> + <property key="worldPayEvents.problemsGettingInstIdToInteger"> + <value xml:lang="en">Problems Getting Inst Id To Integer</value> + <value xml:lang="it">Problema nel convertire il parametro Inst Id ad intero</value> + </property> + <property key="worldPayEvents.problemsGettingMerchantConfiguration"> + <value xml:lang="en">Problems Getting Merchant Configuration</value> + <value xml:lang="it">Problema nel ricavare la configurazione del negoziante</value> + </property> + <property key="worldPayEvents.problemsGettingOrderHeader"> + <value xml:lang="en">Problems Getting OrderHeader</value> + <value xml:lang="it">Problema nel ricavare la testata ordine</value> + </property> </resource> Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Thu May 21 17:57:48 2009 @@ -6065,6 +6065,10 @@ <value xml:lang="nl">Betaling via PayPal</value> <value xml:lang="th">Payment receive via PayPal</value> </property> + <property key="AccountingPaymentReceiveViaWorldPay"> + <value xml:lang="en">Payment receive via WorldPay</value> + <value xml:lang="it">Pagamento ricevuto da WorldPay</value> + </property> <property key="AccountingPaymentRecordNotFound"> <value xml:lang="en">Payment [${paymentId}] record not found....</value> <value xml:lang="es">Pago [${paymentId}] registro no encontrado....</value> @@ -7528,6 +7532,62 @@ <value xml:lang="th">à¸à¸±à¸à¸£à¹à¸à¸£à¸à¸´à¸: วีà¸à¹à¸²/มาสà¹à¸à¸à¸£à¹à¸à¸²à¸£à¹à¸/Amex/à¸à¹à¸à¸«à¸²</value> <value xml:lang="zh">ä¿¡ç¨å¡ï¼Visa/Mastercard/Amex/Discover</value> </property> + <property key="AccountingWorldPayApprove"> + <value xml:lang="en">Approve</value> + <value xml:lang="it">Approva</value> + </property> + <property key="AccountingWorldPayAuthMode"> + <value xml:lang="en">Authorization Mode</value> + <value xml:lang="it">Modalità autorizzazione</value> + </property> + <property key="AccountingWorldPayCancelled"> + <value xml:lang="en">Cancelled</value> + <value xml:lang="it">Cancella</value> + </property> + <property key="AccountingWorldPayFixContact"> + <value xml:lang="en">Contact details non-editable</value> + <value xml:lang="it">Dettagli contatto non-editabili</value> + </property> + <property key="AccountingWorldPayFullAuth"> + <value xml:lang="en">Full-authorize</value> + <value xml:lang="it">Autorizzazione completa</value> + </property> + <property key="AccountingWorldPayInstId"> + <value xml:lang="en">WorldPay instance Id</value> + <value xml:lang="it">Id Istanza WorldPay</value> + </property> + <property key="AccountingWorldPayHideContact"> + <value xml:lang="en">Contact details to be hidden</value> + <value xml:lang="it">Dettagli contatto nascosti</value> + </property> + <property key="AccountingWorldPayHideCurrency"> + <value xml:lang="en">Currency drop-down to be hidden</value> + <value xml:lang="it">Drop-down valuta nascosto</value> + </property> + <property key="AccountingWorldPayLangId"> + <value xml:lang="en">Shopper language Id</value> + <value xml:lang="it">Id Lingua negozio</value> + </property> + <property key="AccountingWorldPayLive"> + <value xml:lang="en">Live</value> + <value xml:lang="it">Produzione</value> + </property> + <property key="AccountingWorldPayNoLanguageMenu"> + <value xml:lang="en">Suppress Language Menu</value> + <value xml:lang="it">Elimina menù lingua</value> + </property> + <property key="AccountingWorldPayPreAuth"> + <value xml:lang="en">Pre-Auth</value> + <value xml:lang="it">Pre-Autorizzazione</value> + </property> + <property key="AccountingWorldPayTestMode"> + <value xml:lang="en">Test Mode</value> + <value xml:lang="it">Modalità di test</value> + </property> + <property key="AccountingWorldPayWithDelivery"> + <value xml:lang="en">Delivery Address Editable</value> + <value xml:lang="it">Indirizzo di spedizione editabile</value> + </property> <property key="AcctgAssignGlAccount"> <value xml:lang="ar">تعÙÙ٠اÙØساب اÙÙ ØاسبÙ</value> <value xml:lang="de">zuweisen Hauptbuchkonto</value> @@ -11025,6 +11085,10 @@ <value xml:lang="en">Update Payment Gateway Config PayPal</value> <value xml:lang="it">Aggiorna configurazione gateway pagamento PayPal</value> </property> + <property key="PageTitleUpdatePaymentGatewayConfigWorldPay"> + <value xml:lang="en">Update Payment Gateway Config RBS WorldPay</value> + <value xml:lang="it">Aggiorna configurazione gateway pagamento RBS WorldPay</value> + </property> <property key="PageTitleViewAccountingTransaction"> <value xml:lang="en">View Accounting Transaction</value> <value xml:lang="es">Ver Tansacción de Contabilidad</value> Modified: ofbiz/trunk/applications/accounting/config/payment.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/payment.properties?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/payment.properties (original) +++ ofbiz/trunk/applications/accounting/config/payment.properties Thu May 21 17:57:48 2009 @@ -218,6 +218,8 @@ ############################################ # WorldPay Select Pro Configuration ############################################ +# Redirect URL +payment.worldpay.redirectUrl=https://select-test.worldpay.com/wcc/purchase # Worldpay instance Id payment.worldpay.instId=[WorldPay InstID] @@ -231,14 +233,20 @@ # HideContact - Will hide the contact info completely payment.worldpay.hideContact=N -# TestMode (100: approve / 101: cancelled / 0: Live Mode (no test) -payment.worldpay.testMode=100 +# HideCurrency - this causes the currency drop down to be no hidden, so fixing the currency that the shopper must value purchase in +payment.worldpay.hideCurrency=N -# Timeout length - The amount of time to wait for payment in milliseconds (0 for worldpay default timeout) -payment.worldpay.timeout=1800000 +# langId - The shopper's language choice, as a 2-character ISO 639 code, with optional regionalisation using 2-character country code separated by hyphen +payment.worldpay.langId= -# Thank-You / Confirm Order Template (rendered via Freemarker) -payment.worldpay.confirmTemplate=/order/emailconfirmation.ftl +# noLanguageMenu - This suppresses the display of the language menu if noLanguageMenu no you have a choice of languages enabled for your value installation +payment.worldpay.noLanguageMenu=N + +# withDelivery - Displays input fields for delivery address and withDelivery no mandate that they be filled in +payment.worldpay.withDelivery=N + +# TestMode (100: approve / 101: cancelled / 0: Live Mode (no test) +payment.worldpay.testMode=100 ############################################ # PayPal Configuration Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original) +++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Thu May 21 17:57:48 2009 @@ -640,7 +640,7 @@ <PaymentMethodType description="eBay" paymentMethodTypeId="EXT_EBAY"/> <PaymentMethodType description="Offline Payment" paymentMethodTypeId="EXT_OFFLINE"/> <PaymentMethodType description="PayPal" paymentMethodTypeId="EXT_PAYPAL"/> - <PaymentMethodType description="WorldPay" paymentMethodTypeId="EXT_WORLDPAY"/> + <PaymentMethodType description="RBS WorldPay" paymentMethodTypeId="EXT_WORLDPAY"/> <PaymentType description="Disbursement" hasTable="N" parentTypeId="" paymentTypeId="DISBURSEMENT"/> <PaymentType description="Customer Refund" hasTable="N" parentTypeId="DISBURSEMENT" paymentTypeId="CUSTOMER_REFUND"/> <!-- a refund TO the customer --> @@ -686,6 +686,10 @@ <PaymentGatewayConfig paymentGatewayConfigId="CLEARCOMMERCE_CONFIG" paymentGatewayConfigTypeId="CLEARCOMMERCE" description="Clear Commerce Config"/> <PaymentGatewayClearCommerce paymentGatewayConfigId="CLEARCOMMERCE_CONFIG" sourceId="mySource" groupId="myGroup" clientId="[ClearCommerce clientId]" username="[ClearCommerce username]" pwd="[ClearCommerce password]" userAlias="[ClearCommerce alias]" effectiveAlias="" processMode="P" serverURL="https://test5x.clearcommerce.com:11500" enableCVM="N"/> + <PaymentGatewayConfigType paymentGatewayConfigTypeId="WORLDPAY" hasTable="N" description="RBS WorldPay Payment Gateway"/> + <PaymentGatewayConfig paymentGatewayConfigId="WORLDPAY_CONFIG" paymentGatewayConfigTypeId="WORLDPAY" description="RBS WorldPay Config"/> + <PaymentGatewayWorldPay paymentGatewayConfigId="WORLDPAY_CONFIG" redirectUrl="https://select-test.worldpay.com/wcc/purchase" instId="" authMode="A" fixContact="N" hideContact="N" hideCurrency="N" langId="" noLanguageMenu="N" withDelivery="N" testMode="100"/> + <!-- Credit Card methods by type --> <CustomMethodType customMethodTypeId="CC_AUTH" parentTypeId="" hasTable="N" description="Credit Card authorize methods"/> <CustomMethodType customMethodTypeId="CC_CAPTURE" parentTypeId="" hasTable="N" description="Credit Card capture methods"/> Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Thu May 21 17:57:48 2009 @@ -3105,6 +3105,25 @@ <key-map field-name="paymentGatewayConfigId"/> </relation> </entity> + <entity entity-name="PaymentGatewayWorldPay" + package-name="org.ofbiz.accounting.payment" + title="RBS WorldPay Payment Gateway Config"> + <field name="paymentGatewayConfigId" type="id-ne"></field> + <field name="redirectUrl" type="value"><description>Redirect URL</description></field> + <field name="instId" type="value" encrypt="true"><description>Worldpay instance Id</description></field> + <field name="authMode" type="indicator"><description>Authorization Mode (A: Full-Auth / E: Pre-Auth)</description></field> + <field name="fixContact" type="indicator"><description>Will displace contact info on WorldPay in non-editable format</description></field> + <field name="hideContact" type="indicator"><description>Will hide the contact info completely</description></field> + <field name="hideCurrency" type="indicator"><description>This causes the currency drop down to be no hidden, so fixing the currency that the shopper must value purchase in</description></field> + <field name="langId" type="short-varchar"><description>The shopper's language choice, as a 2-character ISO 639 code, with optional regionalisation using 2-character country code separated by hyphen</description></field> + <field name="noLanguageMenu" type="indicator"><description>This suppresses the display of the language menu if noLanguageMenu no you have a choice of languages enabled for your value installation</description></field> + <field name="withDelivery" type="indicator"><description>Displays input fields for delivery address and withDelivery no mandate that they be filled in</description></field> + <field name="testMode" type="numeric"><description>Test Mode (100: approve / 101: cancelled / 0: Live Mode (no test)</description></field> + <prim-key field="paymentGatewayConfigId"/> + <relation type="one" fk-name="PGWP_PGC" rel-entity-name="PaymentGatewayConfig"> + <key-map field-name="paymentGatewayConfigId"/> + </relation> + </entity> <entity entity-name="PaymentGatewayRespMsg" package-name="org.ofbiz.accounting.payment" title="Payment Gateway Response Message"> 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=777203&r1=777202&r2=777203&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 Thu May 21 17:57:48 2009 @@ -56,6 +56,12 @@ <store-value value-field="lookedUpValue"/> </simple-method> + <simple-method method-name="updatePaymentGatewayConfigWorldPay" short-description="Update Payment Gateway Config RBS WorldPay"> + <entity-one entity-name="PaymentGatewayWorldPay" value-field="lookedUpValue"/> + <set-nonpk-fields map="parameters" value-field="lookedUpValue"/> + <store-value value-field="lookedUpValue"/> + </simple-method> + <simple-method method-name="updatePaymentGatewayConfigType" short-description="Update Payment Gateway Config Type"> <entity-one entity-name="PaymentGatewayConfigType" value-field="lookedUpValue"/> <set-nonpk-fields map="parameters" value-field="lookedUpValue"/> Modified: ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml Thu May 21 17:57:48 2009 @@ -25,43 +25,49 @@ <version>1.0</version> <!-- Payment Gateway Config Method services --> - <service name="updatePaymentGatewayConfig" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfig"> + <service name="updatePaymentGatewayConfig" engine="simple" location="component://accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfig"> <description>Update Payment Gateway Config</description> <auto-attributes entity-name="PaymentGatewayConfig" include="pk" mode="IN" optional="false"/> <auto-attributes entity-name="PaymentGatewayConfig" include="nonpk" mode="IN" optional="true"/> </service> - <service name="updatePaymentGatewayConfigAuthorizeNet" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigAuthorizeNet"> + <service name="updatePaymentGatewayConfigAuthorizeNet" engine="simple" location="component://accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigAuthorizeNet"> <description>Update Payment Gateway Config Authorize Dot Net</description> <auto-attributes entity-name="PaymentGatewayAuthorizeNet" include="pk" mode="IN" optional="false"/> <auto-attributes entity-name="PaymentGatewayAuthorizeNet" include="nonpk" mode="IN" optional="true"/> </service> - <service name="updatePaymentGatewayConfigClearCommerce" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigClearCommerce"> + <service name="updatePaymentGatewayConfigClearCommerce" engine="simple" location="component://accounting/script/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"> + <service name="updatePaymentGatewayConfigCyberSource" engine="simple" location="component://accounting/script/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"> + <service name="updatePaymentGatewayConfigPayflowPro" engine="simple" location="component://accounting/script/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"/> <auto-attributes entity-name="PaymentGatewayPayflowPro" include="nonpk" mode="IN" optional="true"/> </service> - <service name="updatePaymentGatewayConfigPayPal" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigPayPal"> + <service name="updatePaymentGatewayConfigPayPal" engine="simple" location="component://accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigPayPal"> <description>Update Payment Gateway Config PayPal</description> <auto-attributes entity-name="PaymentGatewayPayPal" include="pk" mode="IN" optional="false"/> <auto-attributes entity-name="PaymentGatewayPayPal" include="nonpk" mode="IN" optional="true"/> </service> - <service name="updatePaymentGatewayConfigType" engine="simple" location="org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigType"> + <service name="updatePaymentGatewayConfigWorldPay" engine="simple" location="component://accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigWorldPay"> + <description>Update Payment Gateway Config WorldPay</description> + <auto-attributes entity-name="PaymentGatewayWorldPay" include="pk" mode="IN" optional="false"/> + <auto-attributes entity-name="PaymentGatewayWorldPay" include="nonpk" mode="IN" optional="true"/> + </service> + + <service name="updatePaymentGatewayConfigType" engine="simple" location="component://accounting/script/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"/> <auto-attributes entity-name="PaymentGatewayConfigType" include="nonpk" mode="IN" optional="true"/> Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java Thu May 21 17:57:48 2009 @@ -19,306 +19,518 @@ package org.ofbiz.accounting.thirdparty.worldpay; import java.io.IOException; +import java.math.BigDecimal; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; -import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.transaction.GenericTransactionException; +import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.entity.util.EntityUtil; -import org.ofbiz.product.catalog.CatalogWorker; +import org.ofbiz.order.order.OrderChangeHelper; import org.ofbiz.product.store.ProductStoreWorker; +import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; - -import com.worldpay.core.ArgumentException; -import com.worldpay.protocols.http.HTTPURL; -import com.worldpay.protocols.http.URLParameters; -import com.worldpay.select.PurchaseToken; -import com.worldpay.select.Select; -import com.worldpay.select.SelectCurrency; -import com.worldpay.select.SelectDefs; -import com.worldpay.select.SelectException; -import com.worldpay.util.Currency; -import com.worldpay.util.CurrencyAmount; +import org.ofbiz.service.ModelService; /** - * WorldPay Select Pro Events/Services + * WorldPay Select Junior Integration Events/Services */ public class WorldPayEvents { - + + public static final String resource = "AccountingUiLabels"; + public static final String resourceErr = "AccountingErrorUiLabels"; + public static final String commonResource = "CommonUiLabels"; public static final String module = WorldPayEvents.class.getName(); - + public static String worldPayRequest(HttpServletRequest request, HttpServletResponse response) { - ServletContext application = ((ServletContext) request.getAttribute("servletContext")); + Locale locale = UtilHttp.getLocale(request); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); - LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); - - // we need the websiteId for the correct properties file - String webSiteId = CatalogWorker.getWebSiteId(request); - // get the orderId from the request, stored by previous event(s) String orderId = (String) request.getAttribute("orderId"); - - if (orderId == null) { - Debug.logError("Problems getting orderId, was not found in request", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>OrderID not found, please contact customer service."); - return "error"; - } - - // get the order header for total and other information + // get the order header GenericValue orderHeader = null; try { - orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); + orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); } catch (GenericEntityException e) { - Debug.logError(e, "Cannot not get OrderHeader from datasource", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting order information, please contact customer service."); + Debug.logError(e, "Cannot get the order header for order: " + orderId, module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingOrderHeader", locale)); return "error"; } - + // get the order total + String orderTotal = orderHeader.getBigDecimal("grandTotal").toPlainString(); + // get the product store + GenericValue productStore = ProductStoreWorker.getProductStore(request); + if (productStore == null) { + Debug.logError("ProductStore is null", module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingMerchantConfiguration", locale)); + return "error"; + } + // get the payment properties file + GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_WORLDPAY", null, true); + String configString = null; + String paymentGatewayConfigId = null; + if (paymentConfig != null) { + paymentGatewayConfigId = paymentConfig.getString("paymentGatewayConfigId"); + configString = paymentConfig.getString("paymentPropertiesPath"); + } + if (configString == null) { + configString = "payment.properties"; + } + String redirectURL = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "redirectUrl", configString, "payment.worldpay.redirectUrl", ""); + String instId = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "instId", configString, "payment.worldpay.instId", "NONE"); + String authMode = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "authMode", configString, "payment.worldpay.authMode", "A"); + String fixContact = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "fixContact", configString, "payment.worldpay.fixContact", "N"); + String hideContact = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "hideContact", configString, "payment.worldpay.hideContact", "N"); + String hideCurrency = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "hideCurrency", configString, "payment.worldpay.hideCurrency", "N"); + String langId = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "langId", configString, "payment.worldpay.langId", ""); + String noLanguageMenu = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "noLanguageMenu", configString, "payment.worldpay.noLanguageMenu", "N"); + String withDelivery = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "withDelivery", configString, "payment.worldpay.withDelivery", "N"); + String testMode = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "testMode", configString, "payment.worldpay.testMode", "100"); // get the contact address to pass over GenericValue contactAddress = null; - try { - List addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "BILLING_LOCATION")); - if (addresses.size() == 0) - addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "SHIPPING_LOCATION")); + GenericValue contactAddressShip = null; + List<GenericValue> addresses = null; + List<GenericValue> shippingAddresses = null; + try { + addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "BILLING_LOCATION")); + shippingAddresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "SHIPPING_LOCATION")); + if (addresses.size() == 0) { + addresses = shippingAddresses; + } GenericValue contactMech = EntityUtil.getFirst(addresses); - contactAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", contactMech.getString("contactMechId"))); + contactAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", contactMech.getString("contactMechId")), false); } catch (GenericEntityException e) { Debug.logWarning(e, "Problems getting order contact information", module); } - // get the country geoID GenericValue countryGeo = null; + String country = ""; if (contactAddress != null) { try { countryGeo = contactAddress.getRelatedOne("CountryGeo"); + if (countryGeo != null) { + country = countryGeo.getString("geoCode"); + } } catch (GenericEntityException e) { Debug.logWarning(e, "Problems getting country geo entity", module); } } - // string of customer's name - String name = null; + String name = ""; if (contactAddress != null) { if (contactAddress.get("attnName") != null && contactAddress.getString("attnName").length() > 0) name = contactAddress.getString("attnName"); else if (contactAddress.get("toName") != null && contactAddress.getString("toName").length() > 0) name = contactAddress.getString("toName"); } - // build an address string - StringBuilder address = null; + StringBuilder address = new StringBuilder(); + String postalCode = ""; if (contactAddress != null) { - address = new StringBuilder(); if (contactAddress.get("address1") != null) { address.append(contactAddress.getString("address1").trim()); } if (contactAddress.get("address2") != null) { - if (address.length() > 0) + if (address.length() > 0) { address.append(" "); + } address.append(contactAddress.getString("address2").trim()); } if (contactAddress.get("city") != null) { - if (address.length() > 0) + if (address.length() > 0) { address.append(" "); + } address.append(contactAddress.getString("city").trim()); } if (contactAddress.get("stateProvinceGeoId") != null) { - if (contactAddress.get("city") != null) + if (contactAddress.get("city") != null) { address.append(", "); + } address.append(contactAddress.getString("stateProvinceGeoId").trim()); } + if (contactAddress.get("postalCode") != null) { + postalCode = contactAddress.getString("postalCode"); + } } - - // get the telephone number to pass over - String phoneNumber = null; - GenericValue phoneContact = null; - // get the email address to pass over String emailAddress = null; GenericValue emailContact = null; try { - List emails = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "ORDER_EMAIL")); + List<GenericValue> emails = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "ORDER_EMAIL")); GenericValue firstEmail = EntityUtil.getFirst(emails); - emailContact = delegator.findByPrimaryKey("ContactMech", UtilMisc.toMap("contactMechId", firstEmail.getString("contactMechId"))); + emailContact = delegator.findOne("ContactMech", UtilMisc.toMap("contactMechId", firstEmail.getString("contactMechId")), false); emailAddress = emailContact.getString("infoString"); } catch (GenericEntityException e) { Debug.logWarning(e, "Problems getting order email address", module); } - - // get the product store - GenericValue productStore = null; - try { - productStore = orderHeader.getRelatedOne("ProductStore"); - } catch (GenericEntityException e) { - Debug.logError(e, "Unable to get ProductStore from OrderHeader", module); - - } - if (productStore == null) { - Debug.logError("ProductStore is null", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service."); - return "error"; - } - - // get the payment properties file - GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_WORLDPAY", null, true); - String configString = null; - if (paymentConfig != null) { - configString = paymentConfig.getString("paymentPropertiesPath"); - } - - if (configString == null) { - configString = "payment.properties"; + // build an shipping address string + StringBuilder shipAddress = new StringBuilder(); + String shipPostalCode = ""; + String shipName = ""; + if (shippingAddresses != null) { + try { + GenericValue contactMechShip = EntityUtil.getFirst(shippingAddresses); + contactAddressShip = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", contactMechShip.getString("contactMechId")), false); + if (UtilValidate.isNotEmpty(contactAddressShip)) { + if (contactAddressShip.get("attnName") != null && contactAddressShip.getString("attnName").length() > 0) { + shipName = contactAddressShip.getString("attnName"); + } else if (contactAddressShip.get("toName") != null && contactAddressShip.getString("toName").length() > 0) { + shipName = contactAddressShip.getString("toName"); + } + if (contactAddressShip.get("address1") != null) { + shipAddress.append(contactAddressShip.getString("address1").trim()); + } + if (contactAddressShip.get("address2") != null) { + if (shipAddress.length() > 0) { + shipAddress.append(" "); + } + shipAddress.append(contactAddressShip.getString("address2").trim()); + } + if (contactAddressShip.get("city") != null) { + if (shipAddress.length() > 0) { + shipAddress.append(" "); + } + shipAddress.append(contactAddressShip.getString("city").trim()); + } + if (contactAddressShip.get("stateProvinceGeoId") != null) { + if (contactAddressShip.get("city") != null) { + shipAddress.append(", "); + } + shipAddress.append(contactAddressShip.getString("stateProvinceGeoId").trim()); + } + if (contactAddressShip.get("postalCode") != null) { + shipPostalCode = contactAddressShip.getString("postalCode"); + } + } + } catch (GenericEntityException e) { + Debug.logWarning(e, "Problems getting shipping address", module); + } } - - String instId = UtilProperties.getPropertyValue(configString, "payment.worldpay.instId", "NONE"); - String authMode = UtilProperties.getPropertyValue(configString, "payment.worldpay.authMode", "A"); - String testMode = UtilProperties.getPropertyValue(configString, "payment.worldpay.testMode", "100"); - String fixContact = UtilProperties.getPropertyValue(configString, "payment.worldpay.fixContact", "N"); - String hideContact = UtilProperties.getPropertyValue(configString, "payment.worldpay.hideContact", "N"); - String confirmTemplate = UtilProperties.getPropertyValue(configString, "payment.worldpay.confirmTemplate", ""); - String timeout = UtilProperties.getPropertyValue(configString, "payment.worldpay.timeout", "0"); + // get the company name String company = UtilFormatOut.checkEmpty(productStore.getString("companyName"), ""); + // get the currency String defCur = UtilFormatOut.checkEmpty(productStore.getString("defaultCurrencyUomId"), "USD"); - // order description - String description = "Order #" + orderId; - if (company != null && company.length() > 0) - description = description + " from " + company; - + String description = UtilProperties.getMessage(resource, "AccountingOrderNr", locale) + orderId + " " + + (company != null ? UtilProperties.getMessage(commonResource, "CommonFrom", locale) + " "+ company : ""); // check the instId - very important if (instId == null || instId.equals("NONE")) { Debug.logError("Worldpay InstId not found, cannot continue", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service."); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingInstId", locale)); return "error"; } - - int instIdInt = 0; try { - instIdInt = Integer.parseInt(instId); + Integer.parseInt(instId); } catch (NumberFormatException nfe) { Debug.logError(nfe, "Problem converting instId string to integer", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service."); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingInstIdToInteger", locale)); return "error"; } - // check the testMode - int testModeInt = -1; if (testMode != null) { try { - testModeInt = Integer.parseInt(testMode); + Integer.parseInt(testMode); } catch (NumberFormatException nfe) { Debug.logWarning(nfe, "Problems getting the testMode value, setting to 0", module); - testModeInt = 0; } } - - // create the purchase link - String purchaseURL = null; - HTTPURL link = null; - URLParameters linkParms = null; - try { - purchaseURL = Select.getPurchaseURL(); - link = new HTTPURL(purchaseURL); - linkParms = link.getParameters(); - } catch (SelectException e) { - Debug.logError(e, "Problems creating the purchase url", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service."); - return "error"; - } catch (ArgumentException e) { - Debug.logError(e, "Problems creating HTTPURL link", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service."); - return "error"; + // create the redirect string + Map<String, Object> parameters = FastMap.newInstance(); + parameters.put("instId", instId); + parameters.put("cartId", orderId); + parameters.put("currency", defCur); + parameters.put("amount", orderTotal); + parameters.put("desc", description); + parameters.put("testMode", testMode); + parameters.put("authMode", authMode); + parameters.put("name", name); + parameters.put("address", address.toString()); + parameters.put("country", country); + parameters.put("postcode", postalCode); + parameters.put("email", emailAddress); + if (UtilValidate.isNotEmpty(shipName)) { + parameters.put("M_shipping_name", shipName); + if (UtilValidate.isNotEmpty(shipAddress.toString())) { + parameters.put("M_shipping_address", shipAddress.toString()); + } + if (UtilValidate.isNotEmpty(shipPostalCode)) { + parameters.put("M_shipping_postcode", shipPostalCode); + } } - - // create the currency amount - double orderTotal = orderHeader.getDouble("grandTotal").doubleValue(); - CurrencyAmount currencyAmount = null; + if ("Y".equals(fixContact)) { + parameters.put("fixContact", ""); + } + if ("Y".equals(hideContact)) { + parameters.put("hideContact", ""); + } + if ("Y".equals(hideCurrency)) { + parameters.put("hideCurrency", ""); + } + if ("Y".equals(noLanguageMenu)) { + parameters.put("noLanguageMenu", ""); + } + if ("Y".equals(withDelivery)) { + parameters.put("withDelivery", ""); + } + if (UtilValidate.isNotEmpty(langId)) { + parameters.put("langId", langId); + } + // create the redirect URL + String encodedParameters = UtilHttp.urlEncodeArgs(parameters, false); + String redirectString = redirectURL + "?" + encodedParameters; + // redirect to WorldPay try { - Currency currency = SelectCurrency.getInstanceByISOCode(defCur); - currencyAmount = new CurrencyAmount(orderTotal, currency); - } catch (ArgumentException ae) { - Debug.logError(ae, "Problems building CurrencyAmount", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Merchant Configuration Error, please contact customer service."); + response.sendRedirect(redirectString); + } catch (IOException e) { + Debug.logError(e, "Problems redirecting to WorldPay", module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsConnectingWithWorldPay", locale)); return "error"; } - - // create a purchase token - PurchaseToken token = null; - try { - token = new PurchaseToken(instIdInt, currencyAmount, orderId); - } catch (SelectException e) { - Debug.logError(e, "Cannot create purchase token", module); - } catch (ArgumentException e) { - Debug.logError(e, "Cannot create purchase token", module); + return "success"; + } + + /** WorldPay notification */ + public static String worldPayNotify(HttpServletRequest request, HttpServletResponse response) { + Locale locale = UtilHttp.getLocale(request); + GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + Map <String, Object> parametersMap = UtilHttp.getParameterMap(request); + String orderId = request.getParameter("cartId"); + Set<String> keySet = parametersMap.keySet(); + Iterator<String> i = keySet.iterator(); + while (i.hasNext()) { + String name = (String) i.next(); + String value = request.getParameter(name); + Debug.logError("### Param: " + name + " => " + value, module); + } + // get the user + if (userLogin == null) { + String userLoginId = "system"; + try { + userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + } catch (GenericEntityException e) { + Debug.logError(e, "Cannot get UserLogin for: " + userLoginId + "; cannot continue", module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingAuthenticationUser", locale)); + return "error"; + } } - if (token == null) { - request.setAttribute("_ERROR_MESSAGE_", "<li>Problems creating a purchase token, please contact customer service."); - return "error"; + // get the order header + GenericValue orderHeader = null; + if (UtilValidate.isNotEmpty(orderId)) { + try { + orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); + } catch (GenericEntityException e) { + Debug.logError(e, "Cannot get the order header for order: " + orderId, module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingOrderHeader", locale)); + return "error"; + } + } else { + Debug.logError("WorldPay did not callback with a valid orderId!", module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.noValidOrderIdReturned", locale)); + return "error"; + } + if (orderHeader == null) { + Debug.logError("Cannot get the order header for order: " + orderId, module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingOrderHeader", locale)); + return "error"; + } + // get the transaction status + String paymentStatus = request.getParameter("transStatus"); + // attempt to start a transaction + boolean okay = true; + boolean beganTransaction = false; + try { + beganTransaction = TransactionUtil.begin(); + // authorized + if ("Y".equals(paymentStatus)) { + okay = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId); + // cancelled + } else if ("C".equals(paymentStatus)) { + okay = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId); + } + if (okay) { + // set the payment preference + okay = setPaymentPreferences(delegator, dispatcher, userLogin, orderId, request); + } + } catch (Exception e) { + String errMsg = "Error handling WorldPay notification"; + Debug.logError(e, errMsg, module); + try { + TransactionUtil.rollback(beganTransaction, errMsg, e); + } catch (GenericTransactionException gte2) { + Debug.logError(gte2, "Unable to rollback transaction", module); + } + } finally { + if (!okay) { + try { + TransactionUtil.rollback(beganTransaction, "Failure in processing WorldPay callback", null); + } catch (GenericTransactionException gte) { + Debug.logError(gte, "Unable to rollback transaction", module); + } + } else { + try { + TransactionUtil.commit(beganTransaction); + } catch (GenericTransactionException gte) { + Debug.logError(gte, "Unable to commit transaction", module); + } + } } - - // set the auth/test modes - try { - token.setAuthorisationMode(authMode); - } catch (SelectException e) { - Debug.logWarning(e, "Problems setting the authorization mode", module); + if (okay) { + // attempt to release the offline hold on the order (workflow) + OrderChangeHelper.releaseInitialOrderHold(dispatcher, orderId); + // call the email confirm service + Map<String, String> emailContext = UtilMisc.toMap("orderId", orderId, "userLogin", userLogin); + try { + dispatcher.runSync("sendOrderConfirmation", emailContext); + } catch (GenericServiceException e) { + Debug.logError(e, "Problems sending email confirmation", module); + } } - token.setTestMode(testModeInt); - - // set the token to the purchase link + return "success"; + } + + private static boolean setPaymentPreferences(GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, String orderId, HttpServletRequest request) { + Debug.logVerbose("Setting payment preferences..", module); + List<GenericValue> paymentPrefs = null; try { - linkParms.setValue(SelectDefs.SEL_purchase, token.produce()); - } catch (SelectException e) { - Debug.logError(e, "Problems producing token", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problems producing purchase token, please contact customer service."); - return "error"; + Map<String, String> paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED"); + paymentPrefs = delegator.findByAnd("OrderPaymentPreference", paymentFields); + } catch (GenericEntityException e) { + Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); + return false; } - - // set the customer data in the link - linkParms.setValue(SelectDefs.SEL_desc, description); - linkParms.setValue(SelectDefs.SEL_name, name != null ? name : ""); - linkParms.setValue(SelectDefs.SEL_address, address != null ? address.toString() : ""); - linkParms.setValue(SelectDefs.SEL_postcode, contactAddress != null ? contactAddress.getString("postalCode") : ""); - linkParms.setValue(SelectDefs.SEL_country, countryGeo.getString("geoCode")); - linkParms.setValue(SelectDefs.SEL_tel, phoneNumber != null ? phoneNumber : ""); - linkParms.setValue(SelectDefs.SEL_email, emailAddress != null ? emailAddress : ""); - - // set some optional data - if (fixContact != null && fixContact.toUpperCase().startsWith("Y")) { - linkParms.setValue(SelectDefs.SEL_fixContact, "Y"); + if (paymentPrefs.size() > 0) { + Iterator<GenericValue> i = paymentPrefs.iterator(); + while (i.hasNext()) { + GenericValue pref = (GenericValue) i.next(); + boolean okay = setPaymentPreference(dispatcher, userLogin, pref, request); + if (!okay) { + return false; + } + } } - if (hideContact != null && hideContact.toUpperCase().startsWith("Y")) { - linkParms.setValue("hideContact", "Y"); // why is this not in SelectDefs?? + return true; + } + + private static boolean setPaymentPreference(LocalDispatcher dispatcher, GenericValue userLogin, GenericValue paymentPreference, HttpServletRequest request) { + Locale locale = UtilHttp.getLocale(request); + String paymentStatus = request.getParameter("transStatus"); + String paymentAmount = request.getParameter("authAmount"); + Long paymentDate = new Long(request.getParameter("transTime")); + String transactionId = request.getParameter("transId"); + String gatewayFlag = request.getParameter("rawAuthCode"); + String avs = request.getParameter("AVS"); + List<GenericValue> toStore = new LinkedList<GenericValue>(); + java.sql.Timestamp authDate = null; + try { + authDate = new java.sql.Timestamp(paymentDate.longValue()); + } catch (Exception e) { + Debug.logError(e, "Cannot create date from long: " + paymentDate, module); + authDate = UtilDateTime.nowTimestamp(); + } + paymentPreference.set("maxAmount", new BigDecimal(paymentAmount)); + if ("Y".equals(paymentStatus)) { + paymentPreference.set("statusId", "PAYMENT_RECEIVED"); + } else if ("C".equals(paymentStatus)) { + paymentPreference.set("statusId", "PAYMENT_CANCELLED"); + } else { + paymentPreference.set("statusId", "PAYMENT_NOT_RECEIVED"); + } + toStore.add(paymentPreference); + GenericDelegator delegator = paymentPreference.getDelegator(); + // create the PaymentGatewayResponse + String responseId = delegator.getNextSeqId("PaymentGatewayResponse"); + GenericValue response = delegator.makeValue("PaymentGatewayResponse"); + response.set("paymentGatewayResponseId", responseId); + response.set("paymentServiceTypeEnumId", "PRDS_PAY_EXTERNAL"); + response.set("orderPaymentPreferenceId", paymentPreference.get("orderPaymentPreferenceId")); + response.set("paymentMethodTypeId", paymentPreference.get("paymentMethodTypeId")); + response.set("paymentMethodId", paymentPreference.get("paymentMethodId")); + // set the auth info + response.set("amount", new BigDecimal(paymentAmount)); + response.set("referenceNum", transactionId); + response.set("gatewayCode", paymentStatus); + response.set("gatewayFlag", gatewayFlag); + response.set("transactionDate", authDate); + response.set("gatewayAvsResult", avs); + response.set("gatewayCvResult", avs.substring(0, 1)); + + toStore.add(response); + try { + delegator.storeAll(toStore); + } catch (GenericEntityException e) { + Debug.logError(e, "Cannot set payment preference/payment info", module); + return false; } - - // now set some send-back parameters - linkParms.setValue("M_controlPath", (String)request.getAttribute("_CONTROL_PATH_")); - linkParms.setValue("M_userLoginId", userLogin.getString("userLoginId")); - linkParms.setValue("M_dispatchName", dispatcher.getName()); - linkParms.setValue("M_delegatorName", delegator.getDelegatorName()); - linkParms.setValue("M_webSiteId", webSiteId); - linkParms.setValue("M_localLocale", UtilHttp.getLocale(request).toString()); - linkParms.setValue("M_confirmTemplate", confirmTemplate != null ? confirmTemplate : ""); - - // redirect to worldpay + // create a payment record too + Map<String, Object> results = null; try { - response.sendRedirect(link.produce()); - } catch (IOException e) { - Debug.logError(e, "Problems redirecting to Worldpay", module); - request.setAttribute("_ERROR_MESSAGE_", "<li>Problems connecting with WorldPay, please contact customer service."); - return "error"; + String comment = UtilProperties.getMessage(resource, "AccountingPaymentReceiveViaWorldPay", locale); + results = dispatcher.runSync("createPaymentFromPreference", UtilMisc.toMap("userLogin", userLogin, + "orderPaymentPreferenceId", paymentPreference.get("orderPaymentPreferenceId"), "comments", comment)); + } catch (GenericServiceException e) { + Debug.logError(e, "Failed to execute service createPaymentFromPreference", module); + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.failedToExecuteServiceCreatePaymentFromPreference", locale)); + return false; + } + if ((results == null) || (results.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR))) { + Debug.logError((String) results.get(ModelService.ERROR_MESSAGE), module); + request.setAttribute("_ERROR_MESSAGE_", (String) results.get(ModelService.ERROR_MESSAGE)); + return false; } - - return "success"; + return true; + } + + private static String getPaymentGatewayConfigValue(GenericDelegator delegator, String paymentGatewayConfigId, String paymentGatewayConfigParameterName, + String resource, String parameterName) { + String returnValue = ""; + if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { + try { + GenericValue worldPay = delegator.findOne("PaymentGatewayWorldPay", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + if (UtilValidate.isNotEmpty(worldPay)) { + Object worldPayField = worldPay.get(paymentGatewayConfigParameterName); + if (worldPayField != null) { + returnValue = worldPayField.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/webapp/accounting/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Thu May 21 17:57:48 2009 @@ -451,6 +451,12 @@ <response name="success" type="view" value="EditPaymentGatewayConfig"/> <response name="error" type="view" value="EditPaymentGatewayConfig"/> </request-map> + <request-map uri="UpdatePaymentGatewayConfigWorldPay"> + <security https="true" auth="true"/> + <event type="service" invoke="updatePaymentGatewayConfigWorldPay"/> + <response name="success" type="view" value="EditPaymentGatewayConfig"/> + <response name="error" type="view" value="EditPaymentGatewayConfig"/> + </request-map> <request-map uri="FindPaymentGatewayConfigTypes"> <security https="true" auth="true"/> <response name="success" type="view" value="FindPaymentGatewayConfigTypes"/> Modified: ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml (original) +++ ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml Thu May 21 17:57:48 2009 @@ -254,6 +254,62 @@ </field> </form> + <form name="EditPaymentGatewayConfigWorldPay" type="single" target="UpdatePaymentGatewayConfigWorldPay" default-map-name="paymentGatewayWorldPay" header-row-style="header-row" default-table-style="basic-table"> + <auto-fields-entity entity-name="PaymentGatewayWorldPay" default-field-type="edit"/> + <field name="paymentGatewayConfigId"><hidden/></field> + <field name="redirectUrl"><text size="60" maxlength="60"/></field> + <field name="instId" title="${uiLabelMap.AccountingWorldPayInstId}"><text size="10" maxlength="10"/></field> + <field name="authMode" title="${uiLabelMap.AccountingWorldPayAuthMode}"> + <drop-down> + <option key="A" description="${uiLabelMap.AccountingWorldPayFullAuth}"/> + <option key="E" description="${uiLabelMap.AccountingWorldPayPreAuth}"/> + </drop-down> + </field> + <field name="fixContact" title="${uiLabelMap.AccountingWorldPayFixContact}"> + <drop-down> + <option key="Y" description="${uiLabelMap.CommonYes}"/> + <option key="N" description="${uiLabelMap.CommonNo}"/> + </drop-down> + </field> + <field name="hideContact" title="${uiLabelMap.AccountingWorldPayHideContact}"> + <drop-down> + <option key="Y" description="${uiLabelMap.CommonYes}"/> + <option key="N" description="${uiLabelMap.CommonNo}"/> + </drop-down> + </field> + <field name="hideCurrency" title="${uiLabelMap.AccountingWorldPayHideCurrency}"> + <drop-down> + <option key="Y" description="${uiLabelMap.CommonYes}"/> + <option key="N" description="${uiLabelMap.CommonNo}"/> + </drop-down> + </field> + <field name="langId" title="${uiLabelMap.AccountingWorldPayLangId}"> + <text size="6" maxlength="6"/> + </field> + <field name="noLanguageMenu" title="${uiLabelMap.AccountingWorldPayNoLanguageMenu}"> + <drop-down> + <option key="Y" description="${uiLabelMap.CommonYes}"/> + <option key="N" description="${uiLabelMap.CommonNo}"/> + </drop-down> + </field> + <field name="withDelivery" title="${uiLabelMap.AccountingWorldPayWithDelivery}"> + <drop-down> + <option key="Y" description="${uiLabelMap.CommonYes}"/> + <option key="N" description="${uiLabelMap.CommonNo}"/> + </drop-down> + </field> + <field name="testMode" title="${uiLabelMap.AccountingWorldPayTestMode}"> + <drop-down> + <option key="100" description="${uiLabelMap.AccountingWorldPayApprove}"/> + <option key="101" description="${uiLabelMap.AccountingWorldPayCancelled}"/> + <option key="0" description="${uiLabelMap.AccountingWorldPayLive}"/> + </drop-down> + </field> + <field name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit"> + <submit button-type="button"/> + </field> + </form> + <form name="FindPaymentGatewayConfigTypes" type="single" target="FindPaymentGatewayConfigTypes" header-row-style="header-row" default-table-style="basic-table"> <field name="paymentGatewayConfigTypeId" title="${uiLabelMap.AccountingPaymentGatewayConfigTypeId}"><text-find default-option="contains" ignore-case="true"/></field> <field name="description" title="${uiLabelMap.AccountingPaymentGatewayConfigDescription}"><text-find default-option="contains" ignore-case="true"/></field> Modified: ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml (original) +++ ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml Thu May 21 17:57:48 2009 @@ -100,6 +100,9 @@ <entity-one entity-name="PaymentGatewayClearCommerce" value-field="paymentGatewayClearCommerce"> <field-map field-name="paymentGatewayConfigId" from-field="parameters.paymentGatewayConfigId"/> </entity-one> + <entity-one entity-name="PaymentGatewayWorldPay" value-field="paymentGatewayWorldPay"> + <field-map field-name="paymentGatewayConfigId" from-field="parameters.paymentGatewayConfigId"/> + </entity-one> </actions> <widgets> <decorator-screen name="GenericPaymentGatewayConfigDecorator"> @@ -223,6 +226,27 @@ </container> </widgets> </section> + <section> + <condition> + <not><if-empty field="paymentGatewayWorldPay"/></not> + </condition> + <widgets> + <container style="screenlet"> + <container style="screenlet-title-bar"> + <container style="h3"> + <label text="${uiLabelMap.PageTitleUpdatePaymentGatewayConfigWorldPay}"/> + </container> + </container> + <container style="screenlet-body"> + <section> + <widgets> + <include-form name="EditPaymentGatewayConfigWorldPay" location="component://accounting/widget/PaymentGatewayConfigForms.xml"/> + </widgets> + </section> + </container> + </container> + </widgets> + </section> </decorator-section> </decorator-screen> </widgets> Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoProduct.xml Thu May 21 17:57:48 2009 @@ -70,7 +70,7 @@ <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="GIFT_CARD" paymentServiceTypeEnumId="PRDS_PAY_RELEASE" paymentService="testGCRelease" paymentCustomMethodId="GIFT_RELEASE_TEST"/> <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="EXT_PAYPAL" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId="" paymentGatewayConfigId="PAYPAL_CONFIG"/> - <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="EXT_WORLDPAY" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId=""/> + <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="EXT_WORLDPAY" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId="" paymentGatewayConfigId="WORLDPAY_CONFIG"/> <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="EXT_OFFLINE" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId=""/> <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="EXT_COD" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId=""/> <ProductStorePaymentSetting productStoreId="9000" paymentMethodTypeId="EXT_BILLACT" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId=""/> Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoRentalProduct.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoRentalProduct.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/data/DemoRentalProduct.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoRentalProduct.xml Thu May 21 17:57:48 2009 @@ -43,7 +43,7 @@ <ProductStorePaymentSetting productStoreId="RentalStore" paymentMethodTypeId="GIFT_CARD" paymentServiceTypeEnumId="PRDS_PAY_AUTH" paymentService="alwaysApproveGCProcessor" paymentCustomMethodId="GIFT_AUTH_ALWAYSAPPR"/> <ProductStorePaymentSetting productStoreId="RentalStore" paymentMethodTypeId="GIFT_CARD" paymentServiceTypeEnumId="PRDS_PAY_RELEASE" paymentService="testGCRelease" paymentCustomMethodId="GIFT_RELEASE_TEST"/> <ProductStorePaymentSetting productStoreId="RentalStore" paymentMethodTypeId="EXT_PAYPAL" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId="" paymentGatewayConfigId="PAYPAL_CONFIG"/> - <ProductStorePaymentSetting productStoreId="RentalStore" paymentMethodTypeId="EXT_WORLDPAY" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId=""/> + <ProductStorePaymentSetting productStoreId="RentalStore" paymentMethodTypeId="EXT_WORLDPAY" paymentServiceTypeEnumId="PRDS_PAY_EXTERNAL" paymentService="" paymentCustomMethodId="" paymentGatewayConfigId="WORLDPAY_CONFIG"/> <ProductStoreEmailSetting productStoreId="RentalStore" emailType="PRDS_ODR_CONFIRM" bodyScreenLocation="component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNotice" xslfoAttachScreenLocation="component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNoticePdf" subject="OFBiz Demo - Order Confirmation #${orderId}" bccAddress="[hidden email]" fromAddress="[hidden email]"/> <ProductStoreEmailSetting productStoreId="RentalStore" emailType="PRDS_ODR_COMPLETE" bodyScreenLocation="component://ecommerce/widget/EmailOrderScreens.xml#OrderCompleteNotice" subject="OFBiz Demo - Your Order Is Complete #${orderId}" fromAddress="[hidden email]"/> Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=777203&r1=777202&r2=777203&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Thu May 21 17:57:48 2009 @@ -756,6 +756,12 @@ <response name="success" type="none"/> <response name="error" type="view" value="checkoutreview"/> </request-map> + <request-map uri="worldPayNotify"> + <security https="false"/> + <event type="java" path="org.ofbiz.accounting.thirdparty.worldpay.WorldPayEvents" invoke="worldPayNotify"/> + <response name="success" type="none"/> + <response name="error" type="view" value="checkoutreview"/> + </request-map> <request-map uri="callPayPal"> <security https="true" direct-request="false"/> |
Free forum by Nabble | Edit this page |