[OFBiz] SVN: r7220 - trunk/applications/accounting/src/org/ofbiz/accounting/payment

sichen@svn.ofbiz.org sichen at svn.ofbiz.org
Thu Apr 6 20:04:19 CDT 2006


Author: sichen
Date: 2006-04-06 20:04:17 -0500 (Thu, 06 Apr 2006)
New Revision: 7220

Modified:
   trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
Log:
capture payment service now checks the actual capture service to see if it uses captureAmount or processAmount and uses the right field when calling it

Modified: trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
===================================================================
--- trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java	2006-04-06 21:01:40 UTC (rev 7219)
+++ trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java	2006-04-07 01:04:17 UTC (rev 7220)
@@ -33,6 +33,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Calendar;
+import java.util.Set;
 import java.sql.Timestamp;
 
 import org.ofbiz.accounting.invoice.InvoiceWorker;
@@ -1095,9 +1096,24 @@
         captureContext.put("userLogin", userLogin);
         captureContext.put("orderPaymentPreference", paymentPref);
         captureContext.put("paymentConfig", paymentConfig);
-        captureContext.put("captureAmount", new Double(amount));
         captureContext.put("currency", orh.getCurrency());
 
+        // this is necessary because the ccCaptureInterface uses "captureAmount" but the paymentProcessInterface uses "processAmount"
+        try {
+            ModelService captureService = dctx.getModelService(serviceName);
+            Set inParams = captureService.getInParamNames();
+            if (inParams.contains("captureAmount")) {
+                captureContext.put("captureAmount", new Double(amount));    
+            } else if (inParams.contains("processAmount")) {
+                captureContext.put("processAmount", new Double(amount));    
+            } else {
+                return ServiceUtil.returnError("Service [" + serviceName + "] does not have a captureAmount or processAmount.  Its parameters are: " + inParams);
+            }
+        } catch (GenericServiceException ex) {
+            return ServiceUtil.returnError("Cannot get model service for " + serviceName);
+        }
+        
+        
         if (authTrans != null) {
             captureContext.put("authTrans", authTrans);
         }



More information about the Svn mailing list