Author: arunpatidar
Date: Sat Oct 28 09:30:16 2017 New Revision: 1813598 URL: http://svn.apache.org/viewvc?rev=1813598&view=rev Log: Credit card valdation does not work properly during anonymous quick checkout process. ShoppingCart's 'getPaymentMethodTypes' method should use 'getPaymentMethodTypeIds' internally instead of 'getPaymentMethodIds' Merged patches from ticket OFBIZ-1585 and OFBIZ-9755 Thanks Amit Gadaley, Deepak Dixit, Divesh Dutta and Mridul Pathak for your contribution. Modified: ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java Modified: ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml?rev=1813598&r1=1813597&r2=1813598&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/config/OrderErrorUiLabels.xml Sat Oct 28 09:30:16 2017 @@ -2097,6 +2097,9 @@ <value xml:lang="zh">没æ订å头ï¼æ æ³å建æ¯ä»</value> <value xml:lang="zh-TW">æ²æè¨å®é ï¼ç¡æ³åµå»ºæ¯ä»</value> </property> + <property key="OrderNoPaymentMethodTypeSelected"> + <value xml:lang="en">No Payment Method Type selected</value> + </property> <property key="OrderNoPayToPartyIdSetOnProductStore"> <value xml:lang="ar">ÙÙ ÙÙضع دÙÙ٠طر٠اÙدÙع عÙÙ Ù Ø٠اÙسÙعة : ${productStoreId}</value> <value xml:lang="de">Kein 'Zahlung An'-Akteur bei Laden ${productStoreId} eingestellt</value> @@ -2178,6 +2181,9 @@ <value xml:lang="zh">没ææ¾å°è®¾ç½®</value> <value xml:lang="zh-TW">æ²ææ¾å°è¨ç½®</value> </property> + <property key="OrderNoShipmentMethodSelected"> + <value xml:lang="en">No Shipment Method selected</value> + </property> <property key="OrderNoShoppingListAvailable"> <value xml:lang="ar">Ùائ٠ة اÙتسÙ٠غÙر ٠تÙÙرة</value> <value xml:lang="de">Keine Einkaufsliste vorhanden</value> Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1813598&r1=1813597&r2=1813598&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java Sat Oct 28 09:30:16 2017 @@ -420,7 +420,23 @@ public class CheckOutEvents { return "success"; } - + // Check for payment method and shipping method exist for checkout process of anonymous user + public static String checkoutValidation(HttpServletRequest request, HttpServletResponse response) { + ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("shoppingCart"); + List<GenericValue> paymentMethodTypes = cart.getPaymentMethodTypes(); + if (UtilValidate.isEmpty(paymentMethodTypes)) { + String errMsg = UtilProperties.getMessage(resource_error, "OrderNoPaymentMethodTypeSelected", (cart != null ? cart.getLocale() : UtilHttp.getLocale(request))); + request.setAttribute("_ERROR_MESSAGE_",errMsg); + return "error"; + } + String shipmentMethod = cart.getShipmentMethodTypeId(); + if (UtilValidate.isEmpty(shipmentMethod)) { + String errMsg = UtilProperties.getMessage(resource_error, "OrderNoShipmentMethodSelected", (cart != null ? cart.getLocale() : UtilHttp.getLocale(request))); + request.setAttribute("_ERROR_MESSAGE_",errMsg); + return "error"; + } + return "success"; + } // Create order event - uses createOrder service for processing public static String createOrder(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); @@ -430,6 +446,8 @@ public class CheckOutEvents { GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); CheckOutHelper checkOutHelper = new CheckOutHelper(dispatcher, delegator, cart); Map<String, Object> callResult; + String result = checkoutValidation(request,response); + if ("error".equals(result)) return "error"; if (UtilValidate.isEmpty(userLogin)) { userLogin = cart.getUserLogin(); Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1813598&r1=1813597&r2=1813598&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java Sat Oct 28 09:30:16 2017 @@ -1781,7 +1781,7 @@ public class ShoppingCart implements Ite return pmi; } - /** Returns the Payment Method Ids */ + /** Returns the Payment Method Type Ids */ public List<String> getPaymentMethodTypeIds() { List<String> pmt = new LinkedList<String>(); for (CartPaymentInfo inf : paymentInfo) { @@ -1817,7 +1817,7 @@ public class ShoppingCart implements Ite public List<GenericValue> getPaymentMethodTypes() { List<GenericValue> types = new LinkedList<GenericValue>(); if (UtilValidate.isNotEmpty(paymentInfo)) { - for (String id : getPaymentMethodIds()) { + for (String id : getPaymentMethodTypeIds()) { try { types.add(this.getDelegator().findOne("PaymentMethodType", UtilMisc.toMap("paymentMethodTypeId", id), true)); } catch (GenericEntityException e) { |
Free forum by Nabble | Edit this page |