Hi all,
I'm in the process of testing the following scenario (a customer
reported some weird things, but I'm still not sure by what they are caused):
1) order with credit card payment preference
2) the payment *authorization* is succesful (the order is created and
approved)
3) when the order is shipped, the payment capture is declined by the
payment processor
In order to test it I've created a new service named
"alwaysDeclineCCCapture" (can I commit it into trunk?).
I've noticed that the declined response is never stored in the
PaymentGatewayResponse entity by the
PaymentGatewayServices.processCaptureResult(...) method; the attached
patch will fix this: can I commit this one?
Going on with my tests.
Jacopo
Index: applications/accounting/servicedef/services_paymentmethod.xml
===================================================================
--- applications/accounting/servicedef/services_paymentmethod.xml (revision 551510)
+++ applications/accounting/servicedef/services_paymentmethod.xml (working copy)
@@ -567,6 +567,11 @@
<description>Credit Card Processing</description>
<implements service="ccAuthInterface"/>
</service>
+ <service name="alwaysDeclineCCCapture" engine="java"
+ location="org.ofbiz.accounting.payment.PaymentGatewayServices" invoke="alwaysDeclineCCCapture">
+ <description>Credit Card Processing - always decline a cc capture request</description>
+ <implements service="ccCaptureInterface"/>
+ </service>
<service name="alwaysNsfCCProcessor" engine="java"
location="org.ofbiz.accounting.payment.PaymentGatewayServices" invoke="alwaysNsfProcessor">
<description>Credit Card Processing</description>
Index: applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
===================================================================
--- applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (revision 551510)
+++ applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (working copy)
@@ -1856,25 +1856,23 @@
BigDecimal amtBd = new BigDecimal(amount.doubleValue());
amtBd = amtBd.setScale(decimals, rounding);
- if (captureResult.booleanValue()) {
- // capture returned true (passed)
- result.put("orderPaymentPreference", paymentPreference);
- result.put("userLogin", userLogin);
- result.put("serviceTypeEnum", authServiceType);
+ result.put("orderPaymentPreference", paymentPreference);
+ result.put("userLogin", userLogin);
+ result.put("serviceTypeEnum", authServiceType);
- ModelService model = dctx.getModelService("processCaptureResult");
- Map context = model.makeValid(result, ModelService.IN_PARAM);
- Map capRes;
- try {
- capRes = dispatcher.runSync("processCaptureResult", context);
- } catch (GenericServiceException e) {
- Debug.logError(e, module);
- throw e;
- }
- if (capRes != null && ServiceUtil.isError(capRes)) {
- throw new GeneralException(ServiceUtil.getErrorMessage(capRes));
- }
- } else {
+ ModelService model = dctx.getModelService("processCaptureResult");
+ Map context = model.makeValid(result, ModelService.IN_PARAM);
+ Map capRes;
+ try {
+ capRes = dispatcher.runSync("processCaptureResult", context);
+ } catch (GenericServiceException e) {
+ Debug.logError(e, module);
+ throw e;
+ }
+ if (capRes != null && ServiceUtil.isError(capRes)) {
+ throw new GeneralException(ServiceUtil.getErrorMessage(capRes));
+ }
+ if (!captureResult.booleanValue()) {
// capture returned false (error)
try {
processReAuthFromCaptureFailure(dctx, result, amtBd, userLogin, paymentPreference);
@@ -2991,6 +2989,25 @@
return result;
}
+ /**
+ * Always decline processor
+ */
+ public static Map alwaysDeclineCCCapture(DispatchContext dctx, Map context) {
+ Map result = ServiceUtil.returnSuccess();
+ Double processAmount = (Double) context.get("captureAmount");
+ Debug.logInfo("Test Processor Declining Credit Card capture", module);
+
+ String refNum = UtilDateTime.nowAsString();
+
+ result.put("captureResult", Boolean.FALSE);
+ result.put("captureAmount", processAmount);
+ result.put("captureRefNum", refNum);
+ result.put("captureAltRefNum", refNum);
+ result.put("captureFlag", "D");
+ result.put("captureMessage", "This is a test processor; no payments were captured or authorized");
+ return result;
+ }
+
public static Map testCaptureWithReAuth(DispatchContext dctx, Map context) {
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = (GenericValue) context.get("authTrans");