Author: hansbak
Date: Mon Oct 18 10:56:30 2010 New Revision: 1023735 URL: http://svn.apache.org/viewvc?rev=1023735&view=rev Log: add the securepay payment processor Added: ofbiz/trunk/applications/accounting/servicedef/services_securepay.xml ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java Modified: ofbiz/trunk/.classpath ofbiz/trunk/OPTIONAL_LIBRARIES ofbiz/trunk/applications/accounting/build.xml ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml ofbiz/trunk/applications/accounting/config/payment.properties ofbiz/trunk/applications/accounting/config/paymentTest.properties ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml ofbiz/trunk/applications/accounting/lib/README ofbiz/trunk/applications/accounting/ofbiz-component.xml ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml ofbiz/trunk/applications/accounting/testdef/paymenttests.xml ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml Modified: ofbiz/trunk/.classpath URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/.classpath (original) +++ ofbiz/trunk/.classpath Mon Oct 18 10:56:30 2010 @@ -197,7 +197,7 @@ <classpathentry kind="lib" path="specialpurpose/ebaystore/lib/ebaycalls.jar"/> <classpathentry kind="lib" path="specialpurpose/ebaystore/lib/ebaysdkcore.jar"/> <classpathentry kind="lib" path="specialpurpose/ebaystore/lib/helper.jar"/> - <classpathentry kind="src" path="applications/accounting/src" excluding="org/ofbiz/accounting/thirdparty/cybersource/**|org/ofbiz/accounting/thirdparty/verisign/**|org/ofbiz/accounting/thirdparty/worldpay/**|org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java|org/ofbiz/accounting/thirdparty/orbital/**"/> + <classpathentry kind="src" path="applications/accounting/src" excluding="org/ofbiz/accounting/thirdparty/cybersource/**|org/ofbiz/accounting/thirdparty/verisign/**|org/ofbiz/accounting/thirdparty/worldpay/**|org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java|org/ofbiz/accounting/thirdparty/orbital/**|org/ofbiz/accounting/thirdparty/securepay/**"/> <classpathentry kind="src" path="applications/content/src" excluding="org/ofbiz/content/openoffice/|org/ofbiz/content/report/"/> <classpathentry kind="src" path="applications/manufacturing/src"/> <classpathentry kind="src" path="applications/marketing/src"/> Modified: ofbiz/trunk/OPTIONAL_LIBRARIES URL: http://svn.apache.org/viewvc/ofbiz/trunk/OPTIONAL_LIBRARIES?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/OPTIONAL_LIBRARIES (original) +++ ofbiz/trunk/OPTIONAL_LIBRARIES Mon Oct 18 10:56:30 2010 @@ -168,6 +168,14 @@ on the old Undersun SVN server in the sp cybssecurity.jar TO BUILD comment out exclude: applications/accounting/build.xml:org/ofbiz/accounting/thirdparty/cybersource/** +-Securepay + applications/accounting/lib/cybersource: + Base64.jar + securepayxmlapi_obf.jar + xercesImpl-2.4.0.jar + xmlParserAPIs-2.4.0.jar + TO BUILD comment out exclude: applications/accounting/build.xml:org/ofbiz/accounting/thirdparty/securepay/** + -WorldPay applications/accounting/lib/worldpay: config Modified: ofbiz/trunk/applications/accounting/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/build.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/build.xml (original) +++ ofbiz/trunk/applications/accounting/build.xml Mon Oct 18 10:56:30 2010 @@ -48,6 +48,7 @@ under the License. <fileset dir="../marketing/build/lib" includes="*.jar"/> <fileset dir="../order/build/lib" includes="*.jar"/> <!-- <fileset dir="lib/cybersource" includes="*.jar"/> --> + <!-- <fileset dir="lib/securepay" includes="*.jar"/> --> <fileset dir="lib" includes="*.jar"/> </path> @@ -61,6 +62,7 @@ under the License. <exclude name="org/ofbiz/accounting/thirdparty/cybersource/**"/> <exclude name="org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java"/> <exclude name="org/ofbiz/accounting/thirdparty/orbital/**"/> + <exclude name="org/ofbiz/accounting/thirdparty/securepay/**"/> </patternset> </target> Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original) +++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Mon Oct 18 10:56:30 2010 @@ -14134,4 +14134,23 @@ <value xml:lang="en">Could not update credit card (write failure) : </value> <value xml:lang="it">Non è possibile aggiornare la carta di credito (fallimento in scrittura) : </value> </property> + <property key="PageTitleUpdatePaymentGatewayConfigSecurePay"> + <value xml:lang="en">Update Payment Gateway Config SecurePay</value> + <value xml:lang="hi_IN">à¤à¥à¤à¤¤à¤¾à¤¨ à¤à¥à¤à¤µà¥ विनà¥à¤¯à¤¾à¤¸ SecurePay à¤à¤¨à¥à¤¨à¤¤ à¤à¤°à¥</value> + <value xml:lang="it">Aggiorna configurazione gateway pagamento SecurePay</value> + </property> + <property key="AccountingPayWithSecurePay"> + <value xml:lang="cs">Platba prostÅednictvÃm SecurePay</value> + <value xml:lang="de">Bezahlung mit SecurePay</value> + <value xml:lang="en">Pay With SecurePay</value> + <value xml:lang="es">Pagar con SecurePay</value> + <value xml:lang="fr">Paiement avec SecurePay</value> + <value xml:lang="it">Paga con SecurePay</value> + <value xml:lang="ja">Pay With SecurePay</value> + <value xml:lang="nl">Betaal met SecurePay</value> + <value xml:lang="pt_PT">Pagar Com SecurePay</value> + <value xml:lang="ro">Plateste cu SecurePay</value> + <value xml:lang="ru">ÐлаÑиÑÑ ÑеÑез SecurePay</value> + <value xml:lang="th">à¸à¸³à¸£à¸°à¹à¸à¸´à¸à¸à¹à¸²à¸ SecurePay</value> + </property> </resource> Modified: ofbiz/trunk/applications/accounting/config/payment.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/payment.properties?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/payment.properties (original) +++ ofbiz/trunk/applications/accounting/config/payment.properties Mon Oct 18 10:56:30 2010 @@ -383,3 +383,20 @@ payment.authorizedotnet.transdescription # payment.authorizedotnet.login=realaccountid # payment.authorizedotnet.password=realpassword # Note that you need a valid authorize.net account even for testing. + +############################################ +# Securepay Configuration +############################################ + +# Account information +payment.securepay.merchantID=[SecurePay MerchantID] +payment.securepay.pwd=[SecurePay Password] + +# Timeout of the payment processor +payment.securepay.processtimeout=80 + +# Server URL of the payment processor +payment.securepay.serverurl=https://api.securepay.com.au/xmlapi/payment + +#Enable rounds the currency amount to .00 (Y For test server / N for live server) +payment.securepay.enableamountround=N Modified: ofbiz/trunk/applications/accounting/config/paymentTest.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/paymentTest.properties?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/config/paymentTest.properties (original) +++ ofbiz/trunk/applications/accounting/config/paymentTest.properties Mon Oct 18 10:56:30 2010 @@ -48,3 +48,21 @@ payment.clearcommerce.enableCVM=N # currency code 826 is UK payment.clearcommerce.currencyCode=826 + +############################################ +# Securepay Test Configuration +############################################ + +# Account information +payment.securepay.merchantID=testuser +payment.securepay.pwd=xxxxxxx + +# Timeout of the payment processor +payment.securepay.processtimeout=80 + +# Server URL of the payment processor +payment.securepay.serverurl=https://test.securepay.com.au/xmlapi/payment + +#Enable rounds the currency amount to .00 (Y For test server / N for live server) +payment.securepay.enableamountround=Y + Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original) +++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Mon Oct 18 10:56:30 2010 @@ -737,6 +737,10 @@ under the License. <PaymentGatewayConfigType paymentGatewayConfigTypeId="ORBITAL" hasTable="N" description="Orbital Payment Gateway"/> <PaymentGatewayConfig paymentGatewayConfigId="ORBITAL_CONFIG" paymentGatewayConfigTypeId="ORBITAL" description="Orbital Config"/> <PaymentGatewayOrbital paymentGatewayConfigId="ORBITAL_CONFIG" username="ofbizuser" connectionPassword="ofbizpwd" merchantId="785240009879" engineClass="com.paymentech.orbital.sdk.engine.https.HttpsEngine" hostName="orbitalvar1.paymentech.net" port="443" hostNameFailover="orbitalvar2.paymentech.net" portFailover="443" connectionTimeoutSeconds="90" readTimeoutSeconds="90" authorizationURI="/authorize" sdkVersion="PaymentechSDK_6.3.0" sslSocketFactory="default" responseType="gateway"/> + + <PaymentGatewayConfigType paymentGatewayConfigTypeId="SECUREPAY" hasTable="N" description="SecurePay Payment Gateway"/> + <PaymentGatewayConfig paymentGatewayConfigId="SECUREPAY_CONFIG" paymentGatewayConfigTypeId="SECUREPAY" description="SecurePay Config"/> + <PaymentGatewaySecurePay paymentGatewayConfigId="SECUREPAY_CONFIG" merchantId="[SecurePay MerchantID]" pwd="[SecurePay Password]" serverURL="[SecurePay serverURL]" processTimeout="80" enableAmountRound="N"/> <!-- Credit Card methods by type --> <CustomMethodType customMethodTypeId="CC_AUTH" parentTypeId="" hasTable="N" description="Credit Card authorize methods"/> @@ -856,6 +860,12 @@ under the License. <CustomMethod customMethodId="PAYPAL_RELEASE_PFP" customMethodTypeId="PAYPAL_RELEASE" customMethodName="payflowPayPalVoid" description="Payflow PayPal Order release"/> <CustomMethod customMethodId="PAYPAL_RELEASE" customMethodTypeId="PAYPAL_RELEASE" customMethodName="payPalVoid" description="PayPal Order Release"/> + + <CustomMethod customMethodId="SECURE_AUTH_OFBIZ" customMethodTypeId="CC_AUTH" customMethodName="ofbScAuthorize" description="SecurePay payment authorize"/> + <CustomMethod customMethodId="SECURE_CAPTURE_OFBIZ" customMethodTypeId="CC_CAPTURE" customMethodName="ofbScCapture" description="SecurePay payment capture"/> + <CustomMethod customMethodId="SECURE_REFUND_OFBIZ" customMethodTypeId="CC_REFUND" customMethodName="ofbScRefund" description="SecurePay payment refund"/> + <CustomMethod customMethodId="SECURE_RELEASE_OFBIZ" customMethodTypeId="CC_RELEASE" customMethodName="ofbScRelease" description="SecurePay payment release"/> + <CustomMethod customMethodId="SECURE_CREDIT_OFBIZ" customMethodTypeId="CC_CREDIT" customMethodName="ofbScCCCredit" description="SecurePay Credit Card"/> <!-- Credit Cart Types --> <EnumerationType description="Credit Card Type" enumTypeId="CREDIT_CARD_TYPE" hasTable="N" parentTypeId=""/> Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Mon Oct 18 10:56:30 2010 @@ -3410,6 +3410,20 @@ under the License. <key-map field-name="paymentGatewayConfigId"/> </relation> </entity> + <entity entity-name="PaymentGatewaySecurePay" + package-name="org.ofbiz.accounting.payment" + title="SecurePay Payment Gateway Config"> + <field name="paymentGatewayConfigId" type="id-ne"></field> + <field name="merchantId" type="value"><description>You merchant ID</description></field> + <field name="pwd" type="value" encrypt="true"><description>SecurePay Password of account information</description></field> + <field name="serverURL" type="value"><description>Server URL of the payment processor</description></field> + <field name="processTimeout" type="numeric"><description>Process Timeout</description></field> + <field name="enableAmountRound" type="indicator"><description>Enable rounds the currency amount to .00 (Y / N)</description></field> + <prim-key field="paymentGatewayConfigId"/> + <relation type="one" fk-name="PGSCP_PGC" rel-entity-name="PaymentGatewayConfig"> + <key-map field-name="paymentGatewayConfigId"/> + </relation> + </entity> <entity entity-name="PaymentGatewayRespMsg" package-name="org.ofbiz.accounting.payment" Modified: ofbiz/trunk/applications/accounting/lib/README URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/lib/README?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/lib/README (original) +++ ofbiz/trunk/applications/accounting/lib/README Mon Oct 18 10:56:30 2010 @@ -1,3 +1,3 @@ -To use the cybersource or worldpay libraries you can copy them to this directory. +To use the cybersource or worldpay or securepay libraries you can copy them to this directory. See the ofbiz/OPTIONAL_LIBRARIES file for more information. Modified: ofbiz/trunk/applications/accounting/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/ofbiz-component.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/ofbiz-component.xml (original) +++ ofbiz/trunk/applications/accounting/ofbiz-component.xml Mon Oct 18 10:56:30 2010 @@ -25,6 +25,7 @@ under the License. <classpath type="jar" location="build/lib/*"/> <classpath type="dir" location="config"/> <classpath type="jar" location="lib/*"/> + <classpath type="jar" location="lib/securepay/*"/> <classpath type="jar" location="lib/cybersource/*"/> <classpath type="jar" location="lib/worldpay/*"/> <classpath type="dir" location="lib/worldpay"/> @@ -78,6 +79,7 @@ under the License. <service-resource type="model" loader="main" location="servicedef/services_valuelink.xml"/> <service-resource type="model" loader="main" location="servicedef/services_verisign.xml"/> <service-resource type="model" loader="main" location="servicedef/services_orbital.xml"/> + <service-resource type="model" loader="main" location="servicedef/services_securepay.xml"/> <!-- Accounting Permission Services --> <service-resource type="model" loader="main" location="servicedef/services_perm.xml"/> 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=1023735&r1=1023734&r2=1023735&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 Mon Oct 18 10:56:30 2010 @@ -73,4 +73,10 @@ under the License. <set-nonpk-fields map="parameters" value-field="lookedUpValue"/> <store-value value-field="lookedUpValue"/> </simple-method> + + <simple-method method-name="updatePaymentGatewayConfigSecurePay" short-description="Update Payment Gateway Config SecurePay"> + <entity-one entity-name="PaymentGatewaySecurePay" value-field="lookedUpValue"/> + <set-nonpk-fields map="parameters" value-field="lookedUpValue"/> + <store-value value-field="lookedUpValue"/> + </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_paymentgateway.xml Mon Oct 18 10:56:30 2010 @@ -78,4 +78,10 @@ under the License. <auto-attributes entity-name="PaymentGatewayConfigType" include="pk" mode="IN" optional="false"/> <auto-attributes entity-name="PaymentGatewayConfigType" include="nonpk" mode="IN" optional="true"/> </service> + + <service name="updatePaymentGatewayConfigSecurePay" engine="simple" location="component://accounting/script/org/ofbiz/accounting/payment/PaymentGatewayConfigServices.xml" invoke="updatePaymentGatewayConfigSecurePay"> + <description>Update Payment Gateway Config SecurePay</description> + <auto-attributes entity-name="PaymentGatewaySecurePay" include="pk" mode="IN" optional="false"/> + <auto-attributes entity-name="PaymentGatewaySecurePay" include="nonpk" mode="IN" optional="true"/> + </service> </services> Added: ofbiz/trunk/applications/accounting/servicedef/services_securepay.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_securepay.xml?rev=1023735&view=auto ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_securepay.xml (added) +++ ofbiz/trunk/applications/accounting/servicedef/services_securepay.xml Mon Oct 18 10:56:30 2010 @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd"> + <description>Accounting Services</description> + <vendor>OFBiz</vendor> + <version>1.0</version> + + <!-- SecurePay Implementations --> + <service name="ofbScAuthorize" engine="java" + location="org.ofbiz.accounting.thirdparty.securepay.SecurePayPaymentServices" invoke="doAuth"> + <description>SecurePay Credit Card Authorization</description> + <implements service="ccAuthInterface"/> + </service> + <service name="ofbScCapture" engine="java" + location="org.ofbiz.accounting.thirdparty.securepay.SecurePayPaymentServices" invoke="doCapture"> + <description>SecurePay Credit Card Capture</description> + <implements service="ccCaptureInterface"/> + </service> + <service name="ofbScRelease" engine="java" + location="org.ofbiz.accounting.thirdparty.securepay.SecurePayPaymentServices" invoke="doVoid"> + <description>SecurePay Order Payment Void</description> + <implements service="paymentReleaseInterface"/> + </service> + <service name="ofbScRefund" engine="java" + location="org.ofbiz.accounting.thirdparty.securepay.SecurePayPaymentServices" invoke="doRefund"> + <description>SecurePay Credit Card Refund</description> + <implements service="paymentRefundInterface"/> + </service> + <service name="ofbScCCCredit" engine="java" + location="org.ofbiz.accounting.thirdparty.securepay.SecurePayPaymentServices" invoke="doCredit"> + <description>SecurePay Credit Card Credit</description> + <implements service="ccCreditInterface"/> + </service> +</services> Added: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java?rev=1023735&view=auto ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java (added) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java Mon Oct 18 10:56:30 2010 @@ -0,0 +1,495 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.accounting.thirdparty.securepay; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.ofbiz.accounting.payment.PaymentGatewayServices; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; + + +import securepay.jxa.api.Payment; +import securepay.jxa.api.Txn; + +public class SecurePayPaymentServices { + + public static final String module = SecurePayPaymentServices.class.getName(); + + public static Map<String, Object> doAuth(DispatchContext dctx, Map<String, Object> context) { + Delegator delegator = dctx.getDelegator(); + String orderId = (String) context.get("orderId"); + BigDecimal processAmount = (BigDecimal) context.get("processAmount"); + // generate the request/properties + Properties props = buildScProperties(context, delegator); + if (props == null) { + return ServiceUtil.returnError("ERROR: Getting SecurePay property configuration"); + } + + String merchantId = props.getProperty("merchantID"); + String serverURL = props.getProperty("serverurl"); + String processtimeout = props.getProperty("processtimeout"); + String pwd = props.getProperty("pwd"); + String enableamountround = props.getProperty("enableamountround"); + String currency = (String) context.get("currency"); + BigDecimal multiplyAmount = new BigDecimal(100); + BigDecimal newAmount = null; + int amont; + + if (enableamountround.equals("Y")) { + newAmount = new BigDecimal(processAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00"); + } else { + newAmount = processAmount; + } + + if (currency.equals("JPY")) { + amont = newAmount.intValue(); + } else { + amont = newAmount.multiply(multiplyAmount).intValue(); + } + + GenericValue creditCard = (GenericValue) context.get("creditCard"); + String expiryDate = (String) creditCard.get("expireDate"); + String cardSecurityCode = (String) context.get("cardSecurityCode"); + Payment payment = new Payment(); + payment.setServerURL(serverURL); + payment.setProcessTimeout(Integer.valueOf(processtimeout)); + payment.setMerchantId(merchantId); + + Txn txn = payment.addTxn(10, orderId); + txn.setTxnSource(8); + txn.setAmount(Integer.toString(amont)); + if (UtilValidate.isNotEmpty(currency)) { + txn.setCurrencyCode(currency); + } else { + txn.setCurrencyCode("AUD"); + } + + txn.setCardNumber((String) creditCard.get("cardNumber")); + txn.setExpiryDate(expiryDate.substring(0, 3) + expiryDate.substring(5)); + if (UtilValidate.isNotEmpty(cardSecurityCode)) { + txn.setCVV(cardSecurityCode); + } + // Send payment to SecurePay for processing + boolean processed = payment.process(pwd); + + Map<String, Object> result = ServiceUtil.returnSuccess(); + if (UtilValidate.isEmpty(processed)) { + return ServiceUtil.returnError("Payment was not sent to server."); + } else { + if (payment.getCount() == 1) { + Txn resp = payment.getTxn(0); + boolean approved = resp.getApproved(); + if (approved == false){ + result.put("authResult", new Boolean(false)); + result.put("authRefNum", "N/A"); + result.put("processAmount", BigDecimal.ZERO); + } else { + result.put("authRefNum", resp.getTxnId()); + result.put("authResult", new Boolean(true)); + result.put("processAmount", processAmount); + } + result.put("authCode", resp.getResponseCode()); + result.put("authMessage", resp.getResponseText()); + } + } + return result; + } + + public static Map<String, Object> ccReAuth(DispatchContext dctx, Map<String, ? extends Object> context) { + return ServiceUtil.returnSuccess(); + } + + public static Map<String, Object> doCapture(DispatchContext dctx, Map<String, Object> context) { + Delegator delegator = dctx.getDelegator(); + GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); + 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"); + } + + Properties props = buildScProperties(context, delegator); + if (props == null) { + return ServiceUtil.returnError("ERROR: Getting SecurePay property configuration"); + } + + String merchantId = props.getProperty("merchantID"); + String serverURL = props.getProperty("serverurl"); + String processtimeout = props.getProperty("processtimeout"); + String pwd = props.getProperty("pwd"); + String enableamountround = props.getProperty("enableamountround"); + String currency = authTransaction.getString("currencyUomId"); + BigDecimal captureAmount = (BigDecimal) context.get("captureAmount"); + BigDecimal multiplyAmount = new BigDecimal(100); + BigDecimal newAmount = null; + int amont; + + if (enableamountround.equals("Y")) { + newAmount = new BigDecimal(captureAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00"); + } else { + newAmount = captureAmount; + } + + if (currency.equals("JPY")) { + amont = newAmount.intValue(); + } else { + amont = newAmount.multiply(multiplyAmount).intValue(); + } + + Payment payment = new Payment(); + payment.setServerURL(serverURL); + payment.setProcessTimeout(Integer.valueOf(processtimeout)); + payment.setMerchantId(merchantId); + Txn txn = payment.addTxn(11, (String) orderPaymentPreference.get("orderId")); + txn.setTxnSource(8); + txn.setAmount(Integer.toString(amont)); + txn.setPreauthId(authTransaction.getString("referenceNum")); + + // Send payment to SecurePay for processing + boolean processed = payment.process(pwd); + + Map<String, Object> result = ServiceUtil.returnSuccess(); + if (UtilValidate.isEmpty(processed)) { + return ServiceUtil.returnError("Payment was not sent to server."); + } else { + if (payment.getCount() == 1){ + Txn resp = payment.getTxn(0); + boolean approved = resp.getApproved(); + if (approved == false){ + result.put("captureResult", false); + result.put("captureRefNum", authTransaction.getString("referenceNum")); + result.put("captureAmount", BigDecimal.ZERO); + } else { + result.put("captureResult", true); + result.put("captureAmount", captureAmount); + result.put("captureRefNum", resp.getTxnId()); + } + result.put("captureFlag", "C"); + result.put("captureCode", resp.getResponseCode()); + result.put("captureMessage", resp.getResponseText()); + } + } + return result; + } + + public static Map<String, Object> doVoid(DispatchContext dctx, Map<String, Object> context) { + Delegator delegator = dctx.getDelegator(); + GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); + 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 Release"); + } + + Properties props = buildScProperties(context, delegator); + if (props == null) { + return ServiceUtil.returnError("ERROR: Getting SecurePay property configuration"); + } + + String merchantId = props.getProperty("merchantID"); + String serverURL = props.getProperty("serverurl"); + String processtimeout = props.getProperty("processtimeout"); + String pwd = props.getProperty("pwd"); + String enableamountround = props.getProperty("enableamountround"); + String currency = authTransaction.getString("currencyUomId"); + BigDecimal releaseAmount = (BigDecimal) context.get("releaseAmount"); + BigDecimal multiplyAmount = new BigDecimal(100); + BigDecimal newAmount = null; + int amont; + + if (enableamountround.equals("Y")) { + newAmount = new BigDecimal(releaseAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00"); + } else { + newAmount = releaseAmount; + } + + if (currency.equals("JPY")) { + amont = newAmount.intValue(); + } else { + amont = newAmount.multiply(multiplyAmount).intValue(); + } + + Payment payment = new Payment(); + payment.setServerURL(serverURL); + payment.setProcessTimeout(Integer.valueOf(processtimeout)); + payment.setMerchantId(merchantId); + Txn txn = payment.addTxn(6, (String) orderPaymentPreference.get("orderId")); + txn.setTxnSource(8); + txn.setAmount(Integer.toString(amont)); + txn.setTxnId(authTransaction.getString("referenceNum")); + + // Send payment to SecurePay for processing + boolean processed = payment.process(pwd); + + Map<String, Object> result = ServiceUtil.returnSuccess(); + if (UtilValidate.isEmpty(processed)) { + return ServiceUtil.returnError("Payment was not sent to server."); + } else { + if (payment.getCount() == 1){ + Txn resp = payment.getTxn(0); + boolean approved = resp.getApproved(); + if (approved == false){ + result.put("releaseResult", false); + result.put("releaseRefNum", authTransaction.getString("referenceNum")); + result.put("releaseAmount", BigDecimal.ZERO); + } else { + result.put("releaseResult", true); + result.put("releaseAmount", releaseAmount); + result.put("releaseRefNum", resp.getTxnId()); + } + result.put("releaseFlag", "U"); + result.put("releaseCode", resp.getResponseCode()); + result.put("releaseMessage", resp.getResponseText()); + } + } + return result; + } + + public static Map<String, Object> doRefund(DispatchContext dctx, Map<String, Object> context) { + Delegator 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"); + } + + List<GenericValue> paymentGatewayResponse = null; + String referenceNum = null; + try { + paymentGatewayResponse = delegator.findByAnd("PaymentGatewayResponse", UtilMisc.toMap( + "orderPaymentPreferenceId", authTransaction.getString("orderPaymentPreferenceId"), + "paymentServiceTypeEnumId", "PRDS_PAY_CAPTURE")); + if (paymentGatewayResponse.size() > 0) { + referenceNum = (String) paymentGatewayResponse.get(0).get("referenceNum"); + } else { + referenceNum = authTransaction.getString("referenceNum"); + } + } catch (GenericEntityException e) { + e.printStackTrace(); + } + + Properties props = buildScProperties(context, delegator); + if (props == null) { + return ServiceUtil.returnError("ERROR: Getting SecurePay property configuration"); + } + + String merchantId = props.getProperty("merchantID"); + String serverURL = props.getProperty("serverurl"); + String processtimeout = props.getProperty("processtimeout"); + String pwd = props.getProperty("pwd"); + String enableamountround = props.getProperty("enableamountround"); + String currency = authTransaction.getString("currencyUomId"); + BigDecimal refundAmount = (BigDecimal) context.get("refundAmount"); + BigDecimal multiplyAmount = new BigDecimal(100); + BigDecimal newAmount = null; + + if (enableamountround.equals("Y")) { + newAmount = new BigDecimal(refundAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00"); + } else { + newAmount = refundAmount; + } + + int amont; + if (currency.equals("JPY")) { + amont = newAmount.intValue(); + } else { + amont = newAmount.multiply(multiplyAmount).intValue(); + } + + Payment payment = new Payment(); + payment.setServerURL(serverURL); + payment.setProcessTimeout(Integer.valueOf(processtimeout)); + payment.setMerchantId(merchantId); + Txn txn = payment.addTxn(4, (String) orderPaymentPreference.get("orderId")); + txn.setTxnSource(8); + txn.setAmount(Integer.toString(amont)); + txn.setTxnId(referenceNum); + + // Send payment to SecurePay for processing + boolean processed = payment.process(pwd); + + Map<String, Object> result = ServiceUtil.returnSuccess(); + if (UtilValidate.isEmpty(processed)) { + return ServiceUtil.returnError("Payment was not sent to server."); + } else { + if (payment.getCount() == 1){ + Txn resp = payment.getTxn(0); + boolean approved = resp.getApproved(); + if (approved == false){ + result.put("refundResult", false); + result.put("refundRefNum", authTransaction.getString("referenceNum")); + result.put("refundAmount", BigDecimal.ZERO); + } else { + result.put("refundResult", true); + result.put("refundAmount", refundAmount); + result.put("refundRefNum", resp.getTxnId()); + } + result.put("refundCode", resp.getResponseCode()); + result.put("refundMessage", resp.getResponseText()); + result.put("refundFlag", "R"); + } + } + return result; + } + + public static Map<String, Object> doCredit(DispatchContext dctx, Map<String, Object> context) { + Delegator delegator = dctx.getDelegator(); + // generate the request/properties + Properties props = buildScProperties(context, delegator); + if (props == null) { + return ServiceUtil.returnError("ERROR: Getting SecurePay property configuration"); + } + + String merchantId = props.getProperty("merchantID"); + String serverURL = props.getProperty("serverurl"); + String processtimeout = props.getProperty("processtimeout"); + String pwd = props.getProperty("pwd"); + String enableamountround = props.getProperty("enableamountround"); + String referenceCode = (String) context.get("referenceCode"); + String currency = (String) context.get("currency"); + String cardSecurityCode = (String) context.get("cardSecurityCode"); + BigDecimal creditAmount = (BigDecimal) context.get("creditAmount"); + BigDecimal multiplyAmount = new BigDecimal(100); + BigDecimal newAmount = null; + int amont; + + if (enableamountround.equals("Y")) { + newAmount = new BigDecimal(creditAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00"); + } else { + newAmount = creditAmount; + } + + if (currency.equals("JPY")) { + amont = newAmount.intValue(); + } else { + amont = newAmount.multiply(multiplyAmount).intValue(); + } + + GenericValue creditCard = (GenericValue) context.get("creditCard"); + Payment payment = new Payment(); + payment.setServerURL(serverURL); + payment.setProcessTimeout(Integer.valueOf(processtimeout)); + payment.setMerchantId(merchantId); + + Txn txn = payment.addTxn(0, referenceCode); + txn.setTxnSource(8); + txn.setAmount(Integer.toString(amont)); + txn.setCardNumber((String) creditCard.get("cardNumber")); + String expiryDate = (String) creditCard.get("expireDate"); + txn.setExpiryDate(expiryDate.substring(0, 3) + expiryDate.substring(5)); + if (UtilValidate.isNotEmpty(cardSecurityCode)) { + txn.setCVV(cardSecurityCode); + } + + // Send payment to SecurePay for processing + boolean processed = payment.process(pwd); + + Map<String, Object> result = ServiceUtil.returnSuccess(); + if (UtilValidate.isEmpty(processed)) { + return ServiceUtil.returnError("Payment was not sent to server."); + } else { + if (payment.getCount() == 1) { + Txn resp = payment.getTxn(0); + boolean approved = resp.getApproved(); + if (approved == false){ + result.put("creditResult", false); + result.put("creditRefNum", "N/A"); + result.put("creditAmount", BigDecimal.ZERO); + } else { + result.put("creditResult", true); + result.put("creditAmount", creditAmount); + result.put("creditRefNum", resp.getTxnId()); + } + result.put("creditCode", resp.getResponseCode()); + result.put("creditMessage", resp.getResponseText()); + } + } + return result; + } + + private static Properties buildScProperties(Map<String, ? extends Object> context, Delegator delegator) { + String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); + String configString = (String) context.get("paymentConfig"); + if (configString == null) { + configString = "payment.properties"; + } + + String merchantId = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "merchantId", configString, "payment.securepay.merchantID", null); + String pwd = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "pwd", configString, "payment.securepay.pwd", null); + String serverURL = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "serverURL", configString, "payment.securepay.serverurl", null); + String processTimeout = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "processTimeout", configString, "payment.securepay.processtimeout", null); + String enableAmountRound = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableAmountRound", configString, "payment.securepay.enableamountround", null); + + Properties props = new Properties(); + props.put("merchantID", merchantId); + props.put("pwd", pwd); + props.put("serverurl", serverURL); + props.put("processtimeout", processTimeout); + props.put("enableamountround", enableAmountRound); + return props; + } + + private static String getPaymentGatewayConfigValue(Delegator delegator, String paymentGatewayConfigId, String paymentGatewayConfigParameterName,String resource, String parameterName) { + String returnValue = ""; + if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { + try { + GenericValue securePay = delegator.findOne("PaymentGatewaySecurePay", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + if (UtilValidate.isNotEmpty(securePay)) { + Object securePayField = securePay.get(paymentGatewayConfigParameterName); + if (securePayField != null) { + returnValue = securePayField.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(Delegator 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; + } +} \ No newline at end of file Added: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java?rev=1023735&view=auto ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java (added) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java Mon Oct 18 10:56:30 2010 @@ -0,0 +1,260 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ + +package org.ofbiz.accounting.thirdparty.securepay; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +import junit.framework.TestCase; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.GenericServiceException; +import org.ofbiz.service.ModelService; +import org.ofbiz.service.testtools.OFBizTestCase; + +public class SecurePayServiceTest extends OFBizTestCase{ + + public SecurePayServiceTest(String name) { + super(name); + } + + public static final String module = SecurePayServiceTest.class.getName(); + + // test data + protected GenericValue emailAddr = null; + protected String orderId = null; + protected GenericValue creditCard = null; + protected GenericValue billingAddress = null; + protected GenericValue shippingAddress = null; + protected BigDecimal creditAmount = null; + protected String configFile = null; + protected GenericValue orderPaymentPreference = null; + protected List orderItems = null; + protected Map orderItemMap = null; + protected GenericValue billToParty = null; + protected String paymentGatewayConfigId = null; + protected BigDecimal refundAmount = null; + protected GenericValue paymentGatewayResponse = null; + protected String releaseRefNum = null; + + @Override + protected void setUp() throws Exception { + // populate test data + configFile = "paymentTest.properties"; + creditAmount = new BigDecimal("234.51"); + emailAddr = delegator.makeValue("ContactMech", UtilMisc.toMap( + "infoString","[hidden email]")); + orderId = "Demo1002"; + creditCard = delegator.makeValue("CreditCard", UtilMisc.toMap( + "cardType","VISA", + "expireDate","10/2011", // mm/yyyy, gets converted to mm/yy + "cardNumber","4444333322221111")); + billingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap( + "toName","The customer Name", + "address1","The customer billingAddress1", + "address2","The customer billingAddress2", + "city","The customer city", + "stateProvinceGeoId", "NLD")); + shippingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap( + "toName","The customer Name", + "address1","The customer shippingStreet1", + "address2","The customer shippingStreet2", + "city","The customer city", + "stateProvinceGeoId", "NLD", + "postalCode","12345")); + orderItemMap = UtilMisc.toMap( + "orderId", "Demo1002", + "orderItemSeqId", "00001", + "orderItemTypeId", "PRODUCT_ORDER_ITEM", + "productId", "GZ-1000", + "prodCatalogId", "DemoCatalog", + "quantity" , new BigDecimal("2.000000"), + "unitPrice", new BigDecimal("59.00"), + "statusId" ,"ITEM_COMPLETED" + ); + orderItems = UtilMisc.toList(orderItemMap); + billToParty = delegator.makeValue("Party" , UtilMisc.toMap("partyId", "DemoCustomer")); + paymentGatewayConfigId = "SECUREPAY_CONFIG"; + refundAmount = new BigDecimal("100.08"); + orderPaymentPreference = delegator.makeValue("OrderPaymentPreference", UtilMisc.toMap( + "orderPaymentPreferenceId", "testOrder1000_01", + "orderId", "Demo1002", + "paymentMethodTypeId", "CREDIT_CARD", + "maxAmount", new BigDecimal("200.00"), + "statusId", "PAYMENT_AUTHORIZED")); + + GenericValue checkOrderPaymentPreference = delegator.findOne("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", "testOrder1000_01"), false); + if (UtilValidate.isEmpty(checkOrderPaymentPreference)) { + orderPaymentPreference.create(); + } + } + + public void testAuth() throws Exception{ + Debug.logInfo("=====[testAuth] starting....", module); + try { + Map serviceInput = UtilMisc.toMap( + "paymentConfig", configFile, + "billToParty", billToParty, + "billToEmail", emailAddr, + "orderPaymentPreference", orderPaymentPreference, + "orderItems", orderItems, + "creditCard", creditCard, + "billingAddress", billingAddress, + "shippingAddress", shippingAddress, + "orderId", orderId, + "currency", "AUD" + ); + serviceInput.put("processAmount", new BigDecimal("100.08")); + + // run the service + Map result = dispatcher.runSync("ofbScAuthorize",serviceInput); + + // verify the results + String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE); + Debug.logInfo("[testCCAuth] responseMessage: " + responseMessage, module); + TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage); + + if (((Boolean) result.get("authResult")).equals(new Boolean(false))) { // returnCode ok? + Debug.logInfo("[testAuth] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module); + TestCase.fail("Returned messages:" + result.get("internalRespMsgs")); + } else { + Debug.logInfo("[testAuth] Result from SecurePay: " + result, module); + String authRefNum = (String) result.get("authRefNum"); + BigDecimal processAmount = (BigDecimal) result.get("processAmount"); + paymentGatewayResponse = delegator.makeValue("PaymentGatewayResponse" , UtilMisc.toMap( + "paymentGatewayResponseId", "testOrder1000_01", + "orderPaymentPreferenceId", "testOrder1000_01", + "amount" , processAmount, + "referenceNum", authRefNum, + "paymentMethodTypeId", "CREDIT_CARD", + "paymentServiceTypeEnumId", "PRDS_PAY_AUTH", + "currencyUomId", "AUD" + )); + GenericValue checkPaymentGatewayResponse = delegator.findOne("PaymentGatewayResponse", UtilMisc.toMap("paymentGatewayResponseId", "testOrder1000_01"), false); + if (UtilValidate.isEmpty(checkPaymentGatewayResponse)) { + paymentGatewayResponse.create(); + } + } + } catch (GenericServiceException ex) { + TestCase.fail(ex.getMessage()); + } + } + + public void testdoCapture() throws Exception { + Debug.logInfo("=====[testdoCapture] starting....", module); + GenericValue paymentGatewayResponse = delegator.findOne("PaymentGatewayResponse", UtilMisc.toMap("paymentGatewayResponseId", "testOrder1000_01"), false); + try { + Map serviceInput = UtilMisc.toMap( + "paymentConfig", configFile, + "orderPaymentPreference", orderPaymentPreference, + "authTrans", paymentGatewayResponse + ); + serviceInput.put("captureAmount", refundAmount); + + // run the service + Map result = dispatcher.runSync("ofbScCapture",serviceInput); + + // verify the results + String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE); + Debug.logInfo("[testdoCapture] responseMessage: " + responseMessage, module); + TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage); + + if (((Boolean) result.get("captureResult")).equals(new Boolean(false))) { // returnCode ok? + Debug.logInfo("[testdoCapture] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module); + TestCase.fail("Returned messages:" + result.get("internalRespMsgs")); + } else { + String captureRefNum = (String) result.get("captureRefNum"); + GenericValue checkPaymentGatewayResponse = delegator.findOne("PaymentGatewayResponse", UtilMisc.toMap("paymentGatewayResponseId", "testOrder1000_01"), false); + checkPaymentGatewayResponse.set("referenceNum", captureRefNum); + checkPaymentGatewayResponse.store(); + Debug.logInfo("[testdoCapture] Result from SecurePay: " + result, module); + } + + } catch (GenericServiceException ex) { + TestCase.fail(ex.getMessage()); + } + } + + public void testdoRefund() throws Exception { + Debug.logInfo("=====[testdoRefund] starting....", module); + try { + Map serviceInput = UtilMisc.toMap( + "paymentConfig", configFile, + "orderPaymentPreference", orderPaymentPreference + ); + serviceInput.put("refundAmount", refundAmount); + // run the service + Map result = dispatcher.runSync("ofbScRefund",serviceInput); + + // verify the results + String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE); + Debug.logInfo("[testdoRefund] responseMessage: " + responseMessage, module); + TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage); + + if (((Boolean) result.get("refundResult")).equals(new Boolean(false))) { // returnCode ok? + Debug.logInfo("[testdoRefund] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module); + TestCase.fail("Returned messages:" + result.get("internalRespMsgs")); + } else { + Debug.logInfo("[testdoRefund] Result from SecurePay: " + result, module); + } + + } catch (GenericServiceException ex) { + TestCase.fail(ex.getMessage()); + } + } + + public void testdoCredit() throws Exception{ + Debug.logInfo("=====[testdoCredit] starting....", module); + try { + Map serviceInput = UtilMisc.toMap( + "paymentConfig", configFile, + "billToParty", billToParty, + "billToEmail", emailAddr, + "orderItems", orderItems, + "creditCard", creditCard, + "billingAddress", billingAddress, + "referenceCode", orderId, + "currency", "AUD" + ); + serviceInput.put("creditAmount", creditAmount); + // run the service + Map result = dispatcher.runSync("ofbScCCCredit",serviceInput); + // verify the results + String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE); + Debug.logInfo("[testdoCredit] responseMessage: " + responseMessage, module); + TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage); + + if (((Boolean) result.get("creditResult")).equals(new Boolean(false))) { // returnCode ok? + Debug.logInfo("[testdoCredit] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module); + TestCase.fail("Returned messages:" + result.get("internalRespMsgs")); + } else { + Debug.logInfo("[testdoCredit] Result from SecurePay: " + result, module); + } + + } catch (GenericServiceException ex) { + TestCase.fail(ex.getMessage()); + } + } +} Modified: ofbiz/trunk/applications/accounting/testdef/paymenttests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/testdef/paymenttests.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/testdef/paymenttests.xml (original) +++ ofbiz/trunk/applications/accounting/testdef/paymenttests.xml Mon Oct 18 10:56:30 2010 @@ -26,4 +26,9 @@ <simple-method-test location="component://accounting/script/org/ofbiz/accounting/test/AutoPaymentTests.xml"/> </test-case> + <!-- enable when sandbox is available and configured --> + <!-- test-case case-name="cc-tests"> + <junit-test-suite class-name="org.ofbiz.accounting.thirdparty.securepay.SecurePayServiceTest"/> + </test-case--> + </test-suite> 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=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Mon Oct 18 10:56:30 2010 @@ -560,6 +560,13 @@ under the License. <response name="error" type="view" value="EditPaymentGatewayConfigType"/> </request-map> + <request-map uri="UpdatePaymentGatewayConfigSecurePay"> + <security https="true" auth="true"/> + <event type="service" invoke="updatePaymentGatewayConfigSecurePay"/> + <response name="success" type="view" value="EditPaymentGatewayConfig"/> + <response name="error" type="view" value="EditPaymentGatewayConfig"/> + </request-map> + <!-- TO BE REMOVED <request-map uri="TransactionReports"> <security https="true" auth="true"/> @@ -2886,3 +2893,4 @@ under the License. <!-- end of view mappings --> </site-conf> + Modified: ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml (original) +++ ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigForms.xml Mon Oct 18 10:56:30 2010 @@ -418,4 +418,12 @@ under the License. <submit button-type="button"/> </field> </form> + + <form name="EditPaymentGatewayConfigSecurePay" type="single" target="UpdatePaymentGatewayConfigSecurePay" default-map-name="paymentGatewaySecurePay" header-row-style="header-row" default-table-style="basic-table"> + <auto-fields-entity entity-name="PaymentGatewaySecurePay" default-field-type="edit"/> + <field name="paymentGatewayConfigId"><hidden/></field> + <field name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit"> + <submit button-type="button"/> + </field> + </form> </forms> Modified: ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml?rev=1023735&r1=1023734&r2=1023735&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml (original) +++ ofbiz/trunk/applications/accounting/widget/PaymentGatewayConfigScreens.xml Mon Oct 18 10:56:30 2010 @@ -107,6 +107,9 @@ under the License. <entity-one entity-name="PaymentGatewayWorldPay" value-field="paymentGatewayWorldPay"> <field-map field-name="paymentGatewayConfigId" from-field="parameters.paymentGatewayConfigId"/> </entity-one> + <entity-one entity-name="PaymentGatewaySecurePay" value-field="paymentGatewaySecurePay"> + <field-map field-name="paymentGatewayConfigId" from-field="parameters.paymentGatewayConfigId"/> + </entity-one> </actions> <widgets> <decorator-screen name="GenericPaymentGatewayConfigDecorator"> @@ -195,6 +198,16 @@ under the License. </screenlet> </widgets> </section> + <section> + <condition> + <not><if-empty field="paymentGatewaySecurePay"/></not> + </condition> + <widgets> + <screenlet title="${uiLabelMap.PageTitleUpdatePaymentGatewayConfigSecurePay}"> + <include-form name="EditPaymentGatewayConfigSecurePay" location="component://accounting/widget/PaymentGatewayConfigForms.xml"/> + </screenlet> + </widgets> + </section> </decorator-section> </decorator-screen> </widgets> |
Free forum by Nabble | Edit this page |