svn commit: r1071517 - in /ofbiz/trunk/applications: accounting/config/ accounting/servicedef/ accounting/src/org/ofbiz/accounting/payment/ accounting/src/org/ofbiz/accounting/thirdparty/cybersource/ order/src/org/ofbiz/order/shoppingcart/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1071517 - in /ofbiz/trunk/applications: accounting/config/ accounting/servicedef/ accounting/src/org/ofbiz/accounting/payment/ accounting/src/org/ofbiz/accounting/thirdparty/cybersource/ order/src/org/ofbiz/order/shoppingcart/

hansbak-2
Author: hansbak
Date: Thu Feb 17 06:57:51 2011
New Revision: 1071517

URL: http://svn.apache.org/viewvc?rev=1071517&view=rev
Log:
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

Modified:
    ofbiz/trunk/applications/accounting/config/payment.properties
    ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java

Modified: ofbiz/trunk/applications/accounting/config/payment.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/payment.properties?rev=1071517&r1=1071516&r2=1071517&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/payment.properties (original)
+++ ofbiz/trunk/applications/accounting/config/payment.properties Thu Feb 17 06:57:51 2011
@@ -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
 ############################################

Modified: ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml?rev=1071517&r1=1071516&r2=1071517&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml Thu Feb 17 06:57:51 2011
@@ -267,6 +267,7 @@ under the License.
         <attribute name="errors" type="Boolean" mode="OUT" optional="false"/>
         <attribute name="messages" type="List" mode="OUT" optional="true"/>
         <attribute name="processAmount" type="BigDecimal" mode="OUT" optional="true"/>
+        <attribute name="authCode" type="String" mode="OUT" optional="true"/>
     </service>
 
     <service name="authOrderPayments" engine="java"
@@ -276,6 +277,7 @@ under the License.
         <attribute name="processResult" type="String" mode="OUT" optional="false"/>
         <attribute name="authResultMsgs" type="List" mode="OUT" optional="true"/>
         <attribute name="reAuth" type="Boolean" mode="IN" optional="true"/>
+        <attribute name="authCode" type="String" mode="OUT" optional="true"/>
     </service>
 
     <service name="releaseOrderPayments" engine="java"

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=1071517&r1=1071516&r2=1071517&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Thu Feb 17 06:57:51 2011
@@ -201,6 +201,7 @@ public class PaymentGatewayServices {
                         results.put("processAmount", thisAmount);
                         results.put("finished", Boolean.TRUE);
                         results.put("errors", Boolean.FALSE);
+                        results.put("authCode", authPaymentResult.get("authCode"));
                         return results;
                     } else {
                         boolean needsNsfRetry = needsNsfRetry(orderPaymentPreference, authPaymentResult, delegator);
@@ -399,6 +400,9 @@ public class PaymentGatewayServices {
                 continue;
             }
 
+            // add authorization code to the result
+            result.put("authCode", results.get("authCode"));
+
             if (ServiceUtil.isError(results)) {
                 hadError += 1;
                 messages.add("Could not authorize OrderPaymentPreference [" + paymentPref.getString("orderPaymentPreferenceId") + "] for order [" + orderId + "]: " + results.get(ModelService.ERROR_MESSAGE));

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java?rev=1071517&r1=1071516&r2=1071517&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java Thu Feb 17 06:57:51 2011
@@ -536,12 +536,17 @@ public class IcsPaymentServices {
 
     private static void processAuthResult(Map<String, Object> reply, Map<String, Object> 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
         }
 

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=1071517&r1=1071516&r2=1071517&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Thu Feb 17 06:57:51 2011
@@ -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<GenericValue> 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")) {