You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2006/12/20 00:00:29 UTC
svn commit: r488848 - in
/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart:
CheckOutHelper.java ShoppingCart.java
Author: sichen
Date: Tue Dec 19 15:00:28 2006
New Revision: 488848
URL: http://svn.apache.org/viewvc?view=rev&rev=488848
Log:
Clear out rejected payment methods from cart so they don't get re-authorized.
Modified:
incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?view=diff&rev=488848&r1=488847&r2=488848
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Tue Dec 19 15:00:28 2006
@@ -922,6 +922,9 @@
throw new GeneralException("Problem with order change; see above error");
}
+ // clear out the rejected payment methods from the cart, so they don't get re-authorized
+ cart.clearDeclinedPaymentMethodsFromOrder(delegator, orderId);
+
// null out the orderId for next pass.
cart.setOrderId(null);
if (messages == null || messages.size() == 0) {
Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=488848&r1=488847&r2=488848
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Tue Dec 19 15:00:28 2006
@@ -1513,6 +1513,35 @@
paymentInfo.clear();
}
+ /** remove all the paymentMethods based on the paymentMethodIds */
+ public void clearPaymentMethodsById(List paymentMethodIdsToRemove) {
+ if (UtilValidate.isEmpty(paymentMethodIdsToRemove)) return;
+ for (Iterator iter = paymentInfo.iterator(); iter.hasNext(); ) {
+ CartPaymentInfo info = (CartPaymentInfo) iter.next();
+ if (paymentMethodIdsToRemove.contains(info.paymentMethodId)) {
+ iter.remove();
+ }
+ }
+ }
+
+ /** remove declined payment methods for an order from cart. The idea is to call this after an attempted order is rejected */
+ public void clearDeclinedPaymentMethodsFromOrder(GenericDelegator delegator, String orderId) {
+ try {
+ List declinedPaymentMethods = delegator.findByAnd("OrderPaymentPreference", UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_DECLINED"));
+ if (!UtilValidate.isEmpty(declinedPaymentMethods)) {
+ List paymentMethodIdsToRemove = new ArrayList();
+ for (Iterator iter = declinedPaymentMethods.iterator(); iter.hasNext(); ) {
+ GenericValue opp = (GenericValue) iter.next();
+ paymentMethodIdsToRemove.add(opp.getString("paymentMethodId"));
+ }
+ clearPaymentMethodsById(paymentMethodIdsToRemove);
+ }
+ } catch (GenericEntityException ex) {
+ Debug.logError("Unable to remove declined payment methods from cart due to " + ex.getMessage(), module);
+ return;
+ }
+ }
+
private void expireSingleUsePayments() {
Timestamp now = UtilDateTime.nowTimestamp();
Iterator i = paymentInfo.iterator();