Author: jleroux
Date: Sun Apr 20 10:14:45 2014
New Revision: 1588734

URL: http://svn.apache.org/r1588734
Log:
"Applied fix from trunk for revision: 1588733  " 
------------------------------------------------------------------------
r1588733 | jleroux | 2014-04-20 12:13:44 +0200 (dim. 20 avr. 2014) | 6 lignes

A patch from Ritu Raj Lakhera  for "Authorize.net payment services are not 
handling  run time exceptions correctly" 
https://issues.apache.org/jira/browse/OFBIZ-5617

System is creating the order in CREATED status before processing the payment. 
But if payment processing encounters a run time exception then system throws 
the error and does not change the order status to REJECTED. Because 
Authorize.net payment services are not handling these exceptions correctly.

Ex: If authorize.net payment gateway call get interrupt then method processCard 
of AIMPaymentServices.java is returning the result map without the 'authResult' 
kay.
And subsequent method (processAuthTransResult) is trying to access this and 
thus service is throwing NullPointerException.
------------------------------------------------------------------------


Modified:
    ofbiz/branches/release13.07/   (props changed)
    
ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java

Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1588733

Modified: 
ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java?rev=1588734&r1=1588733&r2=1588734&view=diff
==============================================================================
--- 
ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
 (original)
+++ 
ofbiz/branches/release13.07/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
 Sun Apr 20 10:14:45 2014
@@ -642,21 +642,28 @@ public class AIMPaymentServices {
 
     private static void processAuthTransResult(Map<String, Object> request, 
Map<String, Object> reply, Map<String, Object> results) {
         AuthorizeResponse ar = (AuthorizeResponse) 
reply.get("authorizeResponse");
-        Boolean authResult = (Boolean) reply.get("authResult");
-        results.put("authResult", new Boolean(authResult.booleanValue()));
-        results.put("authFlag", ar.getReasonCode());
-        results.put("authMessage", ar.getReasonText());
-        if (authResult.booleanValue()) { //passed
-            results.put("authCode", ar.getAuthorizationCode());
-            results.put("authRefNum", ar.getTransactionId());
-            results.put("cvCode", ar.getCvResult());
-            results.put("avsCode", ar.getAvsResult());
-            if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
-                results.put("processAmount", getXAmount(request));
+        try {
+            Boolean authResult = (Boolean) reply.get("authResult");
+            results.put("authResult", new Boolean(authResult.booleanValue()));
+            results.put("authFlag", ar.getReasonCode());
+            results.put("authMessage", ar.getReasonText());
+            if (authResult.booleanValue()) { //passed
+                results.put("authCode", ar.getAuthorizationCode());
+                results.put("authRefNum", ar.getTransactionId());
+                results.put("cvCode", ar.getCvResult());
+                results.put("avsCode", ar.getAvsResult());
+                if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
+                    results.put("processAmount", getXAmount(request));
+                } else {
+                    results.put("processAmount", ar.getAmount());
+                }
             } else {
-                results.put("processAmount", ar.getAmount());
+                results.put("authCode", ar.getResponseCode());
+                results.put("processAmount", BigDecimal.ZERO);
+                results.put("authRefNum", AuthorizeResponse.ERROR);
             }
-        } else {
+        } catch (Exception ex) {
+            Debug.logError(ex, module);
             results.put("authCode", ar.getResponseCode());
             results.put("processAmount", BigDecimal.ZERO);
             results.put("authRefNum", AuthorizeResponse.ERROR);
@@ -666,40 +673,50 @@ public class AIMPaymentServices {
 
     private static void processCaptureTransResult(Map<String, Object> request, 
Map<String, Object> reply, Map<String, Object> results) {
         AuthorizeResponse ar = (AuthorizeResponse) 
reply.get("authorizeResponse");
-        Boolean captureResult = (Boolean) reply.get("authResult");
-        results.put("captureResult", new 
Boolean(captureResult.booleanValue()));
-        results.put("captureFlag", ar.getReasonCode());
-        results.put("captureMessage", ar.getReasonText());
-        results.put("captureRefNum", ar.getTransactionId());
-        if (captureResult.booleanValue()) { //passed
-            results.put("captureCode", ar.getAuthorizationCode());
-            if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
-                results.put("captureAmount", getXAmount(request));
+        try {
+            Boolean captureResult = (Boolean) reply.get("authResult");
+            results.put("captureResult", new 
Boolean(captureResult.booleanValue()));
+            results.put("captureFlag", ar.getReasonCode());
+            results.put("captureMessage", ar.getReasonText());
+            results.put("captureRefNum", ar.getTransactionId());
+            if (captureResult.booleanValue()) { //passed
+                results.put("captureCode", ar.getAuthorizationCode());
+                if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
+                    results.put("captureAmount", getXAmount(request));
+                } else {
+                    results.put("captureAmount", ar.getAmount());
+                }
             } else {
-                results.put("captureAmount", ar.getAmount());
+                results.put("captureAmount", BigDecimal.ZERO);
             }
-        } else {
+        } catch (Exception ex) {
+            Debug.logError(ex, module);
             results.put("captureAmount", BigDecimal.ZERO);
         }
-        Debug.logInfo("processCaptureTransResult: " + 
results.toString(),module);
+        Debug.logInfo("captureRefNum: " + results.toString(),module);
     }
 
     private static Map<String, Object> processRefundTransResult(Map<String, 
Object> request, Map<String, Object> reply) {
         Map<String, Object> results = FastMap.newInstance();
         AuthorizeResponse ar = (AuthorizeResponse) 
reply.get("authorizeResponse");
-        Boolean captureResult = (Boolean) reply.get("authResult");
-        results.put("refundResult", new Boolean(captureResult.booleanValue()));
-        results.put("refundFlag", ar.getReasonCode());
-        results.put("refundMessage", ar.getReasonText());
-        results.put("refundRefNum", ar.getTransactionId());
-        if (captureResult.booleanValue()) { //passed
-            results.put("refundCode", ar.getAuthorizationCode());
-            if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
-                results.put("refundAmount", getXAmount(request));
+        try {
+            Boolean captureResult = (Boolean) reply.get("authResult");
+            results.put("refundResult", new 
Boolean(captureResult.booleanValue()));
+            results.put("refundFlag", ar.getReasonCode());
+            results.put("refundMessage", ar.getReasonText());
+            results.put("refundRefNum", ar.getTransactionId());
+            if (captureResult.booleanValue()) { //passed
+                results.put("refundCode", ar.getAuthorizationCode());
+                if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
+                    results.put("refundAmount", getXAmount(request));
+                } else {
+                    results.put("refundAmount", ar.getAmount());
+                }
             } else {
-                results.put("refundAmount", ar.getAmount());
+                results.put("refundAmount", BigDecimal.ZERO);
             }
-        } else {
+        } catch (Exception ex) {
+            Debug.logError(ex, module);
             results.put("refundAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processRefundTransResult: " + 
results.toString(),module);
@@ -709,19 +726,24 @@ public class AIMPaymentServices {
     private static Map<String, Object> processReleaseTransResult(Map<String, 
Object> request, Map<String, Object> reply) {
         Map<String, Object> results = FastMap.newInstance();
         AuthorizeResponse ar = (AuthorizeResponse) 
reply.get("authorizeResponse");
-        Boolean captureResult = (Boolean) reply.get("authResult");
-        results.put("releaseResult", new 
Boolean(captureResult.booleanValue()));
-        results.put("releaseFlag", ar.getReasonCode());
-        results.put("releaseMessage", ar.getReasonText());
-        results.put("releaseRefNum", ar.getTransactionId());
-        if (captureResult.booleanValue()) { //passed
-            results.put("releaseCode", ar.getAuthorizationCode());
-            if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
-                results.put("releaseAmount", getXAmount(request));
+        try {
+            Boolean captureResult = (Boolean) reply.get("authResult");
+            results.put("releaseResult", new 
Boolean(captureResult.booleanValue()));
+            results.put("releaseFlag", ar.getReasonCode());
+            results.put("releaseMessage", ar.getReasonText());
+            results.put("releaseRefNum", ar.getTransactionId());
+            if (captureResult.booleanValue()) { //passed
+                results.put("releaseCode", ar.getAuthorizationCode());
+                if (BigDecimal.ZERO.compareTo(ar.getAmount()) == 0) {
+                    results.put("releaseAmount", getXAmount(request));
+                } else {
+                    results.put("releaseAmount", ar.getAmount());
+                }
             } else {
-                results.put("releaseAmount", ar.getAmount());
+                results.put("releaseAmount", BigDecimal.ZERO);
             }
-        } else {
+        } catch (Exception ex) {
+            Debug.logError(ex, module);
             results.put("releaseAmount", BigDecimal.ZERO);
         }
         Debug.logInfo("processReleaseTransResult: " + 
results.toString(),module);
@@ -730,6 +752,7 @@ public class AIMPaymentServices {
 
     private static void processAuthCaptureTransResult(Map<String, Object> 
request, Map<String, Object> reply, Map<String, Object> results) {
         AuthorizeResponse ar = (AuthorizeResponse) 
reply.get("authorizeResponse");
+        try {
         Boolean authResult = (Boolean) reply.get("authResult");
         results.put("authResult", new Boolean(authResult.booleanValue()));
         results.put("authFlag", ar.getReasonCode());
@@ -753,6 +776,12 @@ public class AIMPaymentServices {
             results.put("processAmount", BigDecimal.ZERO);
             results.put("authRefNum", AuthorizeResponse.ERROR);
         }
+        } catch (Exception ex) {
+            Debug.logError(ex, module);
+            results.put("authCode", ar.getResponseCode());
+            results.put("processAmount", BigDecimal.ZERO);
+            results.put("authRefNum", AuthorizeResponse.ERROR);
+        }
         Debug.logInfo("processAuthTransResult: " + results.toString(),module);
     }
 


Reply via email to