From 375fb2eb69eeaabcc91d1b5dca40d7dcf7f57333 Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Thu, 17 Feb 2011 06:57:51 +0000 Subject: [PATCH] update to cybersource payment gateway: added a properties setting that orders are still accepted but put into the created stage when a credit card fails authorisation. The default is the current setting: order is not created git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1071517 13f79535-47bb-0310-9956-ffa450edef68 --- .../accounting/config/payment.properties | 6 +++++ .../servicedef/services_paymentmethod.xml | 2 ++ .../payment/PaymentGatewayServices.java | 4 ++++ .../cybersource/IcsPaymentServices.java | 7 +++++- .../order/shoppingcart/CheckOutHelper.java | 24 ++++++++++++++++--- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/applications/accounting/config/payment.properties b/applications/accounting/config/payment.properties index c825d87eba..c9c617d52e 100644 --- a/applications/accounting/config/payment.properties +++ b/applications/accounting/config/payment.properties @@ -118,6 +118,12 @@ payment.cybersource.ignoreAvs=false # AVS Decline Codes -- May not be supported any longer #payment.cybersource.avsDeclineCodes= +# Ignore status of cybersource transaction reply (Y|N) (if cybersource response transaction status not equals "ACCEPT" then OFBiz will still create the order but in status 'created'. +# default N = Don't create order if cybersource reported transaction status not equals "ACCEPT". +payment.cybersource.ignoreStatus=N +# It happens pretty often that a creditcard is rejected for not valid reasons, one can check to Cybersource fraud queue and after that the order can still be rejected or approved. + + ############################################ # ClearCommerce Configuration ############################################ diff --git a/applications/accounting/servicedef/services_paymentmethod.xml b/applications/accounting/servicedef/services_paymentmethod.xml index e33a5ae94f..83775de2b7 100644 --- a/applications/accounting/servicedef/services_paymentmethod.xml +++ b/applications/accounting/servicedef/services_paymentmethod.xml @@ -267,6 +267,7 @@ under the License. + + reply, Map result) { String decision = getDecision(reply); + String checkModeStatus = UtilProperties.getPropertyValue("payment.properties", "payment.cybersource.ignoreStatus"); if ("ACCEPT".equalsIgnoreCase(decision)) { result.put("authCode", reply.get("ccAuthReply_authorizationCode")); result.put("authResult", Boolean.TRUE); } else { result.put("authCode", decision); - result.put("authResult", Boolean.FALSE); + if ("N".equals(checkModeStatus)) { + result.put("authResult", Boolean.FALSE); + } else { + result.put("authResult", Boolean.TRUE); + } // TODO: based on reasonCode populate the following flags as applicable: resultDeclined, resultNsf, resultBadExpire, resultBadCardNumber } diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java index 94a004e765..1ffd035c37 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java @@ -1067,9 +1067,27 @@ public class CheckOutHelper { // set the order and item status to approved if (autoApproveOrder) { - boolean ok = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId, manualHold); - if (!ok) { - throw new GeneralException("Problem with order change; see above error"); + List productStorePaymentSettingList = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStore.getString("productStoreId"), "paymentMethodTypeId", "CREDIT_CARD", "paymentService", "cyberSourceCCAuth")); + if (productStorePaymentSettingList.size() > 0) { + String decision = (String) paymentResult.get("authCode"); + if (UtilValidate.isNotEmpty(decision)) { + if ("ACCEPT".equalsIgnoreCase(decision)) { + boolean ok = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId, manualHold); + if (!ok) { + throw new GeneralException("Problem with order change; see above error"); + } + } + } else { + boolean ok = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId, manualHold); + if (!ok) { + throw new GeneralException("Problem with order change; see above error"); + } + } + } else { + boolean ok = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId, manualHold); + if (!ok) { + throw new GeneralException("Problem with order change; see above error"); + } } } } else if (authResp.equals("ERROR")) {