From 4586c8eefe0ffc03a79d3beb9dbbcae8686fa7de Mon Sep 17 00:00:00 2001 From: Si Chen Date: Tue, 4 Sep 2007 21:44:05 +0000 Subject: [PATCH] Replacing direct entity ops to update a payment with a service call. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@572817 13f79535-47bb-0310-9956-ffa450edef68 --- .../accounting/payment/PaymentGatewayServices.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java index bed1280fdc..b8625c50b4 100644 --- a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java @@ -853,6 +853,8 @@ public class PaymentGatewayServices { 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 @@ public class PaymentGatewayServices { 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); } } }