svn commit: r536137 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

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

svn commit: r536137 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

jacopoc
Author: jacopoc
Date: Tue May  8 02:22:08 2007
New Revision: 536137

URL: http://svn.apache.org/viewvc?view=rev&rev=536137
Log:
A few fixes needed after recent refactoring of the payment processing service done by Andy.

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.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?view=diff&rev=536137&r1=536136&r2=536137
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Tue May  8 02:22:08 2007
@@ -807,7 +807,9 @@
             Map releaseResRes;
             try {
                 ModelService model = dctx.getModelService("processReleaseResult");
-                Map resCtx = model.makeValid(result, ModelService.IN_PARAM);
+                releaseResult.put("orderPaymentPreference", paymentPref);
+                releaseResult.put("userLogin", userLogin);
+                Map resCtx = model.makeValid(releaseResult, ModelService.IN_PARAM);
                 releaseResRes = dispatcher.runSync(model.name,  resCtx);
             } catch (GenericServiceException e) {
                 Debug.logError(e, module);
@@ -1018,7 +1020,16 @@
         }
 
         OrderReadHelper orh = new OrderReadHelper(orderHeader);
-        
+
+        BigDecimal orderGrandTotal = orh.getOrderGrandTotalBd();
+        orderGrandTotal = orderGrandTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
+
+        BigDecimal totalPayments = PaymentWorker.getPaymentsTotal(orh.getOrderPayments());
+        totalPayments = totalPayments.setScale(2, BigDecimal.ROUND_HALF_UP);
+
+        BigDecimal remainingTotalBd = orderGrandTotal.subtract(totalPayments);
+        if (Debug.infoOn()) Debug.logInfo("Capture Remaining Total: " + remainingTotalBd, module);
+
         // See if there is a billing account first.  If so, just charge the captureAmount to the billing account via PaymentApplication
         GenericValue billingAccount = null;
         BigDecimal billingAccountAvail = null;
@@ -1079,15 +1090,6 @@
             return result;
         }
 
-        BigDecimal orderGrandTotal = orh.getOrderGrandTotalBd();
-        orderGrandTotal = orderGrandTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
-
-        BigDecimal totalPayments = PaymentWorker.getPaymentsTotal(orh.getOrderPayments());
-        totalPayments = totalPayments.setScale(2, BigDecimal.ROUND_HALF_UP);
-
-        BigDecimal remainingTotalBd = orderGrandTotal.subtract(totalPayments);
-        if (Debug.infoOn()) Debug.logInfo("Capture Remaining Total: " + remainingTotalBd, module);
-
         BigDecimal amountToCapture = ZERO;
         if (captureAmountBd == null) {
             amountToCapture = remainingTotalBd;
@@ -2113,6 +2115,10 @@
                     refundResCtx.put("currencyUomId", orh.getCurrency());
                     refundResCtx.put("payToPartyId", payToPartyId);
                     refundResCtx.put("payFromPartyId", payFromPartyId);
+                    refundResCtx.put("refundRefNum", refundResponse.get("refundRefNum"));
+                    refundResCtx.put("refundResult", refundResponse.get("refundResult"));
+                    // TODO: should we uncomment the following line?
+                    //refundResCtx.put("refundAmount", (Double)refundResponse.get("refundAmount"));
                     refundResRes = dispatcher.runSync(model.name, refundResCtx);
                 } catch (GenericServiceException e) {
                     Debug.logError(e, module);