You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ar...@apache.org on 2017/10/28 09:30:17 UTC

svn commit: r1813598 - in /ofbiz/ofbiz-framework/trunk/applications/order: config/OrderErrorUiLabels.xml src/main/java/org/apache/ofbiz/order/shoppingcart/CheckOutEvents.java src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java

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) {