You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2009/08/12 15:55:14 UTC

svn commit: r803513 - in /ofbiz/trunk: applications/accounting/servicedef/ applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/ applications/order/src/org/ofbiz/order/thirdparty/paypal/ specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/

Author: lektran
Date: Wed Aug 12 13:55:14 2009
New Revision: 803513

URL: http://svn.apache.org/viewvc?rev=803513&view=rev
Log:
A few fixes for Express Checkout, including a wonderfully undocumented typo in PayPal's API - L_SHIPPINGOPTIONLABEL needs to be L_SHIPINGPOPTIONLABEL

Modified:
    ofbiz/trunk/applications/accounting/servicedef/services_paypal.xml
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml

Modified: ofbiz/trunk/applications/accounting/servicedef/services_paypal.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_paypal.xml?rev=803513&r1=803512&r2=803513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_paypal.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_paypal.xml Wed Aug 12 13:55:14 2009
@@ -34,6 +34,11 @@
              location="org.ofbiz.accounting.thirdparty.paypal.PayPalServices" invoke="doExpressCheckout">
         <implements service="payPalDoExpressCheckoutInterface"/>
     </service>
+    <service name="payPalCheckoutUpdate" engine="java" auth="false"
+             location="org.ofbiz.accounting.thirdparty.paypal.PayPalServices" invoke="payPalCheckoutUpdate">
+        <attribute name="request" mode="IN" type="javax.servlet.http.HttpServletRequest"/>
+        <attribute name="response" mode="IN" type="javax.servlet.http.HttpServletResponse"/>
+    </service>
     
     <service name="payPalProcessor" engine="java"
              location="org.ofbiz.accounting.thirdparty.paypal.PayPalServices" invoke="doAuthorization">

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java?rev=803513&r1=803512&r2=803513&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java Wed Aug 12 13:55:14 2009
@@ -120,7 +120,7 @@
             encoder.add("L_SHIPPINGOPTIONISDEFAULT0", "true");
             encoder.add("L_SHIPPINGOPTIONNAME0", "NO_SHIPPING@_NA_");
             //TODO: This isn't working
-            encoder.add("L_SHIPPINGOPTIONLABEL0", "Calculated Offline");
+            encoder.add("L_SHIPINGPOPTIONLABEL0", "Calculated Offline");
             encoder.add("L_SHIPPINGOPTIONAMOUNT0", "0.00");
         }
         encoder.add("ALLOWNOTE", "1");
@@ -161,21 +161,21 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public Map<String, Object> payPalExpressCheckoutUpdate(DispatchContext dctx, Map<String, Object> context) {
+    public static Map<String, Object> payPalCheckoutUpdate(DispatchContext dctx, Map context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator delegator = dctx.getDelegator();
         HttpServletRequest request = (HttpServletRequest) context.get("request");
         HttpServletResponse response = (HttpServletResponse) context.get("response");
-        String remoteHost = request.getRemoteHost();
-        if (!remoteHost.endsWith(".paypal.com")) {
-            try {
-                response.sendError(HttpServletResponse.SC_FORBIDDEN);
-                Debug.logError("An Express Checkout Update request was received from a host other than *.paypal.com, responded with 403 Forbidden", module);
-            } catch (IOException e) {
-                Debug.logError(e, module);
-            }
-            return ServiceUtil.returnSuccess();
-        }
+//        String remoteHost = request.getRemoteHost();
+//        if (!remoteHost.endsWith(".paypal.com")) {
+//            try {
+//                response.sendError(HttpServletResponse.SC_FORBIDDEN);
+//                Debug.logError("An Express Checkout Update request was received from a host other than *.paypal.com, responded with 403 Forbidden", module);
+//            } catch (IOException e) {
+//                Debug.logError(e, module);
+//            }
+//            return ServiceUtil.returnSuccess();
+//        }
         
         String requestMessage = null;
         try {
@@ -331,11 +331,11 @@
             line++;
         }
         encoder.add("ITEMAMT", cart.getSubTotal().add(otherAdjustments).setScale(2).toPlainString());
-        encoder.add("SHIPPINGAMT", "1.00");
+        encoder.add("SHIPPINGAMT", "0.00");
         encoder.add("TAXAMT", "0.00");
-        encoder.add("AMT", cart.getSubTotal().add(otherAdjustments).add(BigDecimal.ONE).setScale(2).toPlainString());
+        encoder.add("AMT", cart.getSubTotal().add(otherAdjustments).setScale(2).toPlainString());
         //NOTE: The docs say this is optional but then won't work without it
-        encoder.add("MAXAMT", cart.getSubTotal().add(otherAdjustments).add(BigDecimal.ONE).setScale(2).toPlainString());
+        encoder.add("MAXAMT", cart.getSubTotal().add(otherAdjustments).setScale(2).toPlainString());
     }
     
     public static Map<String, Object> getExpressCheckout(DispatchContext dctx, Map<String, Object> context) {

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java?rev=803513&r1=803512&r2=803513&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java Wed Aug 12 13:55:14 2009
@@ -99,6 +99,22 @@
         return "success";
     }
     
+    public static String expressCheckoutUpdate(HttpServletRequest request, HttpServletResponse response) {
+        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+        CheckoutType checkoutType = determineCheckoutType(request);
+        if (checkoutType.equals(CheckoutType.STANDARD)) {
+            Map<String, Object> inMap = FastMap.newInstance();
+            inMap.put("request", request);
+            inMap.put("response", response);
+            try {
+                dispatcher.runSync("payPalCheckoutUpdate", inMap);
+            } catch (GenericServiceException e) {
+                Debug.logError(e, module);
+            }
+        }
+        return "success";
+    }
+
     public static String getExpressCheckoutDetails(HttpServletRequest request, HttpServletResponse response) {
         Locale locale = UtilHttp.getLocale(request);
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");

Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=803513&r1=803512&r2=803513&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Wed Aug 12 13:55:14 2009
@@ -810,8 +810,8 @@
     </request-map>
     <request-map uri="payPalCheckoutUpdate">
         <description>Handles callbacks from PayPal's Express Checkout Instant Update API</description>
-        <security auth="false" https="true"/>
-        <event type="service" invoke="payPalExpressCheckoutUpdate"/>
+        <security auth="false" https="false"/>
+        <event type="java" path="org.ofbiz.order.thirdparty.paypal.ExpressCheckoutEvents" invoke="expressCheckoutUpdate"/>
         <response name="success" type="none"/>
     </request-map>