svn commit: r572817 - /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: r572817 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

sichen
Author: sichen
Date: Tue Sep  4 14:44:05 2007
New Revision: 572817

URL: http://svn.apache.org/viewvc?rev=572817&view=rev
Log:
Replacing direct entity ops to update a payment with a service call.

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?rev=572817&r1=572816&r2=572817&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 Tue Sep  4 14:44:05 2007
@@ -853,6 +853,8 @@
 
     public static Map processReleaseResult(DispatchContext dctx, Map context) {
         GenericDelegator delegator = dctx.getDelegator();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
 
         GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
         Boolean releaseResponse = (Boolean) context.get("releaseResult");
@@ -915,11 +917,13 @@
                 Iterator pi = paymentList.iterator();
                 while (pi.hasNext()) {
                     GenericValue pay = (GenericValue) pi.next();
-                    pay.set("statusId", "PMNT_CANCELLED");
                     try {
-                        pay.store();
-                    } catch (GenericEntityException e) {
-                        Debug.logError(e, "Unable to store Payment : " + pay, module);
+                        Map cancelResults = dispatcher.runSync("setPaymentStatus", UtilMisc.toMap("userLogin", userLogin, "paymentId", pay.get("paymentId"), "statusId", "PMNT_CANCELLED"));
+                        if (ServiceUtil.isError(cancelResults)) {
+                            throw new GenericServiceException(ServiceUtil.getErrorMessage(cancelResults));
+                        }
+                    } catch (GenericServiceException e) {
+                        Debug.logError(e, "Unable to cancel Payment : " + pay, module);
                     }
                 }
             }