svn commit: r502340 - in /ofbiz/trunk/applications/order: src/org/ofbiz/order/shoppingcart/ webapp/ordermgr/WEB-INF/ webapp/ordermgr/WEB-INF/actions/entry/ webapp/ordermgr/entry/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r502340 - in /ofbiz/trunk/applications/order: src/org/ofbiz/order/shoppingcart/ webapp/ordermgr/WEB-INF/ webapp/ordermgr/WEB-INF/actions/entry/ webapp/ordermgr/entry/

sichen
Author: sichen
Date: Thu Feb  1 12:02:51 2007
New Revision: 502340

URL: http://svn.apache.org/viewvc?view=rev&rev=502340
Log:
Workflow improvements in ordermgr checkout:

- Directing successful create-customer requests to the EditShipAddress screen, via the new checkout parameter 'finalizeReqNewShipAddress'

- Adding COD as a payment option in the non-quick checkout flows. This required a restructuring of the form that appears when no payment methods are available to the customer - now a Javascript directs the browser either to the finalizeOrder request (if EXT_OFFLINE or EXT_COD are selected) or to the setBilling request (if CC or EFT are selected, to create a new payment method).

- Directing successful payment method creation ahead in the checkout. Includes a fix for OFBIZ-583 (using a similar but lighter approach to the one proposed by Anil Patel and Iain Fogg) via detection of the paymentMethodId request attribute. The newly-created CC/EFT account becomes selected as the only payment method for the order.

- Directing errors in payment setting or creation to the payment settings screen instead of all the way back to orderentry, by discriminating between the 'error' response and a new 'paymentError' response from CheckOutEvents.finalizeOrderEntry()

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/billsettings.bsh
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/custsettings.ftl

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?view=diff&rev=502340&r1=502339&r2=502340
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java Thu Feb  1 12:02:51 2007
@@ -30,13 +30,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.GeneralRuntimeException;
-import org.ofbiz.base.util.UtilHttp;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilProperties;
-import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.*;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
@@ -741,6 +735,13 @@
                 return "error";
             }
 
+            // If the user has just created a new payment method, add it to the map with a null amount, so that
+            //  it becomes the sole payment method for the order.
+            String newPaymentMethodId = (String) request.getAttribute("paymentMethodId");
+            if(! UtilValidate.isEmpty(newPaymentMethodId)) {
+                selectedPaymentMethods.put(newPaymentMethodId, null);
+            }
+            
             String billingAccountId = request.getParameter("billingAccountId");
             String currencyFormat = UtilProperties.getPropertyValue("general.properties", "currency.decimal.format", "##0.00");
             DecimalFormat formatter = new DecimalFormat(currencyFormat);
@@ -775,7 +776,7 @@
             ServiceUtil.getMessages(request, callResult, null);
             // determine whether it was a success or not
             if (callResult.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) {
-                return "error";
+                return "paymentError";
             }
         }
         // determine where to direct the browser
@@ -794,6 +795,7 @@
         // determine where to direct the browser
         // these are the default values
         boolean requireCustomer = true;
+        boolean requireNewShippingAddress = false;
         boolean requireShipping = true;
         boolean requireOptions = true;
         boolean requireShipGroups = false;
@@ -804,6 +806,7 @@
         // these options are not available to anonymous shoppers (security)
         if (userLogin != null && !"anonymous".equals(userLogin.getString("userLoginId"))) {
             String requireCustomerStr = request.getParameter("finalizeReqCustInfo");
+            String requireNewShippingAddressStr = request.getParameter("finalizeReqNewShipAddress");
             String requireShippingStr = request.getParameter("finalizeReqShipInfo");
             String requireOptionsStr = request.getParameter("finalizeReqOptions");
             String requirePaymentStr = request.getParameter("finalizeReqPayInfo");
@@ -812,6 +815,7 @@
             String requireShipGroupsStr = request.getParameter("finalizeReqShipGroups");
             String singleUsePaymentStr = request.getParameter("singleUsePayment");
             requireCustomer = requireCustomerStr == null || requireCustomerStr.equalsIgnoreCase("true");
+            requireNewShippingAddress = requireNewShippingAddressStr != null && requireNewShippingAddressStr.equalsIgnoreCase("true");
             requireShipping = requireShippingStr == null || requireShippingStr.equalsIgnoreCase("true");
             requireOptions = requireOptionsStr == null || requireOptionsStr.equalsIgnoreCase("true");
             requireShipGroups = requireShipGroupsStr != null && requireShipGroupsStr.equalsIgnoreCase("true");
@@ -861,8 +865,12 @@
                 }
             }
             else if (currProcess.equals("shipping")) {
-                if (requireShipping && !shippingAddressSet) {
-                    return "shipping";
+                if (requireShipping) {
+                    if (requireNewShippingAddress) {
+                        return "shippingAddress";
+                    } else if (!shippingAddressSet) {
+                        return "shipping";
+                    }
                 }
             }
             else if (currProcess.equals("shipGroups")) {

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/billsettings.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/billsettings.bsh?view=diff&rev=502340&r1=502339&r2=502340
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/billsettings.bsh (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/billsettings.bsh Thu Feb  1 12:02:51 2007
@@ -35,6 +35,13 @@
 // nuke the event messages
 request.removeAttribute("_EVENT_MESSAGE_");
 
+// If there's a paymentMethodId request attribute, the user has just created a new payment method,
+//  so put the new paymentMethodId in the context for the UI
+newPaymentMethodId=request.getAttribute("paymentMethodId");
+if(! UtilValidate.isEmpty(newPaymentMethodId)) {
+    context.put("checkOutPaymentId", newPaymentMethodId);
+}
+
 if (orderPartyId != null && !orderPartyId.equals("_NA_")) {
     orderParty = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", orderPartyId));
     orderPerson = orderParty.getRelatedOne("Person");
@@ -74,9 +81,6 @@
                 paymentMethodType = "EFT";
                 account = paymentMethod.getRelatedOne("EftAccount");
                 context.put("eftAccount", account);
-                context.put("paymentMethodType", paymentMethodType);
-            } else {
-                paymentMethodType = "offline";
                 context.put("paymentMethodType", paymentMethodType);
             }
             if (account != null) {

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?view=diff&rev=502340&r1=502339&r2=502340
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Thu Feb  1 12:02:51 2007
@@ -569,8 +569,10 @@
         <response name="addparty" type="view" value="setAdditionalParty"/>
         <response name="customer" type="view" value="custsetting"/>
         <response name="shipping" type="view" value="shipsetting"/>
+        <response name="shippingAddress" type="view" value="EditShipAddress"/>
         <response name="options" type="view" value="optionsetting"/>
         <response name="payment" type="request" value="calcShippingBeforePayment"/>
+        <response name="paymentError" type="request" value="calcShippingBeforePayment"/>
         <response name="term" type="view" value="orderTerm"/>
         <response name="shipGroups" type="view" value="SetItemShipGroups"/>
         <response name="sales" type="request" value="calcShipping"/>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl?view=diff&rev=502340&r1=502339&r2=502340
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/billsettings.ftl Thu Feb  1 12:02:51 2007
@@ -46,7 +46,7 @@
 <#if security.hasEntityPermission("ORDERMGR", "_CREATE", session) || security.hasEntityPermission("ORDERMGR", "_PURCHASE_CREATE", session)>
 <div class="screenlet">
     <div class="screenlet-body">
-        <#if (paymentMethodList?has_content || billingAccountList?has_content) && !requestParameters.createNew?exists>
+        <#if request.getAttribute("paymentMethodId")?exists || ( (paymentMethodList?has_content || billingAccountList?has_content) && !requestParameters.createNew?exists)>
           <#-- initial screen when we have a associated party -->
           <form method="post" action="<@ofbizUrl>finalizeOrder</@ofbizUrl>" name="checkoutsetupform">
             <input type="hidden" name="finalizeMode" value="payment"/>
@@ -66,6 +66,15 @@
                 </td>
               </tr>
              <tr><td colspan="3"><hr class="sepbar"/></td></tr>                  
+              <tr>
+                <td width="1%">
+                  <input type="radio" name="checkOutPaymentId" value="EXT_COD" <#if checkOutPaymentId?exists && checkOutPaymentId == "EXT_COD">checked="checked"</#if>/>
+                </td>
+                <td colspan="2" width="50%">
+                  <span class="tabletext">${uiLabelMap.OrderCOD}</span>
+                </td>
+              </tr>
+             <tr><td colspan="3"><hr class="sepbar"/></td></tr>                  
               <#if billingAccountList?has_content>
                 <tr>
                   <td width="1%">
@@ -493,24 +502,42 @@
           </table>                                                                                        
         <#else>
           <#-- initial screen show a list of options -->
-          <form method="post" action="<@ofbizUrl>finalizeOrder</@ofbizUrl>" name="checkoutsetupform">
-            <input type="hidden" name="finalizeMode" value="payoption"/>
+            
+          <script type="text/javascript">
+            
+              function setCheckoutPaymentId( selectedValue ) {
+                  checkoutForm = document.getElementById('checkoutsetupform');
+                  if( selectedValue.match('^EXT_.*') ) {
+                      checkoutForm.action = '<@ofbizUrl>finalizeOrder</@ofbizUrl>?checkOutPaymentId=' + selectedValue ;
+                  } else {
+                      checkoutForm.action = '<@ofbizUrl>setBilling</@ofbizUrl>?paymentMethodType=' + selectedValue ;
+                  }
+              }
+          </script>
+
+          <form method="post" action="<@ofbizUrl>finalizeOrder</@ofbizUrl>" name="checkoutsetupform" id="checkoutsetupform">
+            <input type="hidden" name="finalizeMode" value="payment"/>
             <input type="hidden" name="createNew" value="Y"/>
             <table width="100%" border="0" cellpadding="1" cellspacing="0">
               <#if !requestParameters.createNew?exists>                                    
               <tr>
-                <td width='1%' nowrap><input type="radio" name="paymentMethodType" value="offline" <#if paymentMethodType?exists && paymentMethodType == "offline">checked="checked"</#if>/></td>
+                <td width='1%' nowrap><input type="radio" name="paymentMethodTypeAndId" value="EXT_OFFLINE" <#if checkOutPaymentId?exists && checkOutPaymentId == "EXT_OFFLINE">checked="checked"</#if> onchange="setCheckoutPaymentId(this.value)"/></td>
                 <td width='50%'nowrap><div class="tabletext">${uiLabelMap.OrderPaymentOfflineCheckMoney}</div></td>
               </tr>
               <tr><td colspan="2"><hr class="sepbar"/></td></tr>
               </#if>
               <tr>
-                <td width='1%' nowrap><input type="radio" name="paymentMethodType" value="CC"/>
+                <td width="1%" nowrap><input type="radio" name="paymentMethodTypeAndId" value="EXT_COD" <#if checkOutPaymentId?exists && checkOutPaymentId == "EXT_COD">checked="checked"</#if> onchange="setCheckoutPaymentId(this.value)"/></td>
+                <td width="50%"nowrap><div class="tabletext">${uiLabelMap.OrderCOD}</div></td>
+              </tr>
+              <tr><td colspan="2"><hr class="sepbar"/></td></tr>
+              <tr>
+                <td width='1%' nowrap><input type="radio" name="paymentMethodTypeAndId" value="CC" onchange="setCheckoutPaymentId(this.value)"/>
                 <td width='50%' nowrap><div class="tabletext">${uiLabelMap.AccountingVisaMastercardAmexDiscover}</div></td>
               </tr>
               <tr><td colspan="2"><hr class="sepbar"/></td></tr>
               <tr>
-                <td width='1%' nowrap><input type="radio" name="paymentMethodType" value="EFT"/>
+                <td width='1%' nowrap><input type="radio" name="paymentMethodTypeAndId" value="EFT" onchange="setCheckoutPaymentId(this.value)"/>
                 <td width='50%' nowrap><div class="tabletext">${uiLabelMap.AccountingAHCElectronicCheck}</div></td>
               </tr>
             </table>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/custsettings.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/custsettings.ftl?view=diff&rev=502340&r1=502339&r2=502340
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/custsettings.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/custsettings.ftl Thu Feb  1 12:02:51 2007
@@ -43,6 +43,7 @@
       <table width="100%" border="0" cellspacing="0" cellpadding="0" class="boxbottom">
         <form name="checkoutsetupform" method="post" action="<@ofbizUrl>createCustomer</@ofbizUrl>">
         <input type="hidden" name="finalizeMode" value="cust">
+        <input type="hidden" name="finalizeReqNewShipAddress" value="true">
         <tr>
           <td>
             <table width="100%" border="0" cellpadding="1" cellspacing="0">