diff --git a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java index 1ae90335e8..9ef261fe63 100644 --- a/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java +++ b/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java @@ -1000,8 +1000,6 @@ public class PaymentGatewayServices { Double captureAmount = (Double) context.get("captureAmount"); BigDecimal captureAmountBd = new BigDecimal(captureAmount.doubleValue()); - Map result = new HashMap(); - // get the order header and payment preferences GenericValue orderHeader = null; List paymentPrefs = null; @@ -1015,9 +1013,7 @@ public class PaymentGatewayServices { paymentPrefs = delegator.findByAnd("OrderPaymentPreference", lookupMap, orderList); } catch (GenericEntityException gee) { Debug.logError(gee, "Problems getting entity record(s), see stack trace", module); - result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); - result.put(ModelService.ERROR_MESSAGE, "ERROR: Could not get order information (" + gee.toString() + ")."); - return result; + return ServiceUtil.returnError("ERROR: Could not get order information (" + gee.toString() + ")."); } // error if no order was found @@ -1069,7 +1065,7 @@ public class PaymentGatewayServices { captureAmount = new Double(outstandingAmount.doubleValue()); } else { Debug.logInfo("Amount to capture [" + captureAmount + "] was fully captured in Payment [" + tmpResult.get("paymentId") + "].", module); - result = ServiceUtil.returnSuccess(); + Map result = ServiceUtil.returnSuccess(); result.put("processResult", "COMPLETE"); return result; } @@ -1082,8 +1078,8 @@ public class PaymentGatewayServices { // return complete if no payment prefs were found if (paymentPrefs == null || paymentPrefs.size() == 0) { Debug.logWarning("No orderPaymentPreferences available to capture", module); + Map result = ServiceUtil.returnSuccess(); result.put("processResult", "COMPLETE"); - result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); return result; } @@ -1243,11 +1239,18 @@ public class PaymentGatewayServices { } if (amountToCapture > 0.00) { - result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); + GenericValue productStore = orh.getProductStore(); + if (! UtilValidate.isEmpty(productStore)) { + boolean shipIfCaptureFails = UtilValidate.isEmpty(productStore.get("shipIfCaptureFails")) || "Y".equalsIgnoreCase(productStore.getString("shipIfCaptureFails")); + if(! shipIfCaptureFails) { + return ServiceUtil.returnError("Cannot ship order because credit card captures were unsuccessful"); + } + } + Map result = ServiceUtil.returnSuccess(); result.put("processResult", "FAILED"); return result; } else { - result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); + Map result = ServiceUtil.returnSuccess(); result.put("processResult", "COMPLETE"); return result; } diff --git a/applications/ecommerce/data/DemoProduct.xml b/applications/ecommerce/data/DemoProduct.xml index bf9466236b..17b4328e17 100644 --- a/applications/ecommerce/data/DemoProduct.xml +++ b/applications/ecommerce/data/DemoProduct.xml @@ -49,7 +49,7 @@ under the License. authFraudMessage="Your order has been rejected and your account has been disabled due to fraud." authErrorMessage="Problem connecting to payment processor; we will continue to retry and notify you by email." storeCreditValidDays="90" - styleSheet="/images/ecommain.css" headerLogo="/images/ofbiz_logo.jpg" autoApproveInvoice="Y"/> + styleSheet="/images/ecommain.css" headerLogo="/images/ofbiz_logo.jpg" autoApproveInvoice="Y" shipIfCaptureFails="Y"/> diff --git a/applications/ecommerce/data/DemoRentalProduct.xml b/applications/ecommerce/data/DemoRentalProduct.xml index 1ae29d081e..fdf6b5470a 100644 --- a/applications/ecommerce/data/DemoRentalProduct.xml +++ b/applications/ecommerce/data/DemoRentalProduct.xml @@ -28,7 +28,7 @@ under the License. authDeclinedMessage="There has been a problem with your method of payment. Please try a different method or call customer service." authFraudMessage="Your order has been rejected and your account has been disabled due to fraud." authErrorMessage="Problem connecting to payment processor; we will continue to retry and notify you by email." - styleSheet="/images/ecommain.css" headerLogo="/images/opentravelsystem_logo.jpg" autoApproveInvoice="Y"/> + styleSheet="/images/ecommain.css" headerLogo="/images/opentravelsystem_logo.jpg" autoApproveInvoice="Y" shipIfCaptureFails="Y"/> diff --git a/applications/product/entitydef/entitymodel.xml b/applications/product/entitydef/entitymodel.xml index a6e62d5dc7..db1690d813 100644 --- a/applications/product/entitydef/entitymodel.xml +++ b/applications/product/entitydef/entitymodel.xml @@ -3149,6 +3149,7 @@ under the License. For auto-orders if Credit Cards fails for NSF try again how many times? How many days that store credit is valid for. Null value implies no expiration. If Y or empty, sales invoices created from orders will be marked ready. + If N, the captureOrderPayments will cause a service error if credit card capture fails. diff --git a/specialpurpose/pos/data/DemoRetail.xml b/specialpurpose/pos/data/DemoRetail.xml index 69a6e8c802..0e2620e583 100644 --- a/specialpurpose/pos/data/DemoRetail.xml +++ b/specialpurpose/pos/data/DemoRetail.xml @@ -53,7 +53,7 @@ authDeclinedMessage="There has been a problem with your method of payment. Please try a different method or call customer service." authFraudMessage="Your order has been rejected and your account has been disabled due to fraud." authErrorMessage="Problem connecting to payment processor; we will continue to retry and notify you by email." - styleSheet="" headerLogo="" autoApproveInvoice="Y"/> + styleSheet="" headerLogo="" autoApproveInvoice="Y" shipIfCaptureFails="Y"/>