You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2010/12/06 13:31:55 UTC
svn commit: r1042606 - in
/ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order:
shoppingcart/CheckOutEvents.java thirdparty/paypal/ExpressCheckoutEvents.java
Author: ashish
Date: Mon Dec 6 12:31:55 2010
New Revision: 1042606
URL: http://svn.apache.org/viewvc?rev=1042606&view=rev
Log:
Applied fix from r949465.
The paypal checkout should not always redirect to sandbox while you are in production environment, It should be taken from configuration settings. Contribution from Divesh & Pranay - Thanks Guys.
Thanks Atul for the reminder for committing it to release branch.
Modified:
ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java
Modified: ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1042606&r1=1042605&r2=1042606&view=diff
==============================================================================
--- ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original)
+++ ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java Mon Dec 6 12:31:55 2010
@@ -639,7 +639,7 @@ public class CheckOutEvents {
GenericValue payPalProdStorePaySetting = EntityUtil.getFirst(payPalProdStorePaySettings);
if (payPalProdStorePaySetting != null) {
GenericValue gatewayConfig = payPalProdStorePaySetting.getRelatedOne("PaymentGatewayConfig");
- if (gatewayConfig != null && "PAYFLOWPRO".equals(gatewayConfig.getString("paymentGatewayConfigTypeId"))) {
+ if (gatewayConfig != null && ("PAYFLOWPRO".equals(gatewayConfig.getString("paymentGatewayConfigTypeId")) || "PAYPAL".equals(gatewayConfig.getString("paymentGatewayConfigTypeId")))) {
return "paypal";
}
}
Modified: ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java?rev=1042606&r1=1042605&r2=1042606&view=diff
==============================================================================
--- ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java (original)
+++ ofbiz/branches/release10.04/applications/order/src/org/ofbiz/order/thirdparty/paypal/ExpressCheckoutEvents.java Mon Dec 6 12:31:55 2010
@@ -81,13 +81,38 @@ 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);
+ }
+ }
+ StringBuilder redirectUrl = new StringBuilder("");
+ if (payPalGatewayConfig == null) {
+ redirectUrl = new StringBuilder("https://www.sandbox.paypal.com/cgi-bin/webscr");
+ } else {
+ redirectUrl = new StringBuilder(payPalGatewayConfig.getString("redirectUrl"));
+ }
redirectUrl.append("?cmd=_express-checkout&token=");
redirectUrl.append(token);
try {