I was checking out the jira OFBIZ-3895
and ran across this in orders.
there is also one done by Scott in accounting.
should these be merged and put in one place.

=========================
BJ Freeman  <http://bjfreeman.elance.com>
Strategic Power Office with Supplier Automation  
<http://www.businessesnetwork.com/automation/viewforum.php?f=52>
Specialtymarket.com  <http://www.specialtymarket.com/>
Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man


[email protected] sent the following on 5/29/2010 8:25 PM:
Author: ashish
Date: Sun May 30 03:25:35 2010
New Revision: 949465

URL: http://svn.apache.org/viewvc?rev=949465&view=rev
Log:
The paypal checkout should always redirect to sandbox while you are in production 
environment. Contribution from Divesh&  Pranay - Thanks Guys.

Modified:
     
ofbiz/trunk/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java

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=949465&r1=949464&r2=949465&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
 Sun May 30 03:25:35 2010
@@ -81,13 +81,37 @@ public class ExpressCheckoutEvents {
      }

      public static String expressCheckoutRedirect(HttpServletRequest request, 
HttpServletResponse response) {
+        Delegator delegator = (Delegator) request.getAttribute("delegator");
          ShoppingCart cart = ShoppingCartEvents.getCartObject(request);
          String token = (String) cart.getAttribute("payPalCheckoutToken");
+        String paymentGatewayConfigId = null;
+        GenericValue payPalGatewayConfig = null;
+        String productStoreId = null;
          if (UtilValidate.isEmpty(token)) {
              Debug.logError("No ExpressCheckout token found in cart, you must do a 
successful setExpressCheckout before redirecting.", module);
              return "error";
          }
-        StringBuilder redirectUrl = new 
StringBuilder("https://www.sandbox.paypal.com/cgi-bin/webscr";);
+        if (cart != null) {
+            productStoreId = cart.getProductStoreId();
+        }
+        if (productStoreId != null) {
+            GenericValue payPalPaymentSetting = 
ProductStoreWorker.getProductStorePaymentSetting(delegator, productStoreId, 
"EXT_PAYPAL", null, true);
+            if (payPalPaymentSetting != null) {
+                paymentGatewayConfigId = 
payPalPaymentSetting.getString("paymentGatewayConfigId");
+            }
+        }
+        if (paymentGatewayConfigId != null) {
+            try {
+                payPalGatewayConfig = delegator.findOne("PaymentGatewayPayPal", true, 
"paymentGatewayConfigId", paymentGatewayConfigId);
+            } catch (GenericEntityException e) {
+                Debug.logError(e, module);
+            }
+        }
+        if (payPalGatewayConfig == null) {
+            request.setAttribute("_EVENT_MESSAGE_", "Couldn't retrieve a 
PaymentGatewayConfigPayPal record for Express Checkout, cannot continue.");
+            return "error";
+        }
+        StringBuilder redirectUrl = new 
StringBuilder(payPalGatewayConfig.getString("redirectUrl"));
          redirectUrl.append("?cmd=_express-checkout&token=");
          redirectUrl.append(token);
          try {




Reply via email to