svn commit: r604030 - in /ofbiz/trunk/applications/accounting: config/payment.properties src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java

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

svn commit: r604030 - in /ofbiz/trunk/applications/accounting: config/payment.properties src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java

mrisaliti
Author: mrisaliti
Date: Thu Dec 13 13:23:39 2007
New Revision: 604030

URL: http://svn.apache.org/viewvc?rev=604030&view=rev
Log:
My patch fixed the issue PayPalEvents does not create order payment preference (OFBIZ-1009)

Modified:
    ofbiz/trunk/applications/accounting/config/payment.properties
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java

Modified: ofbiz/trunk/applications/accounting/config/payment.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/payment.properties?rev=604030&r1=604029&r2=604030&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/payment.properties (original)
+++ ofbiz/trunk/applications/accounting/config/payment.properties Thu Dec 13 13:23:39 2007
@@ -242,25 +242,29 @@
 payment.paypal.business=[hidden email]
 
 # PayPal Notify URL
-payment.paypal.notify=http://ofbiz.apache.org:8080/ecommerce/control/payPalNotify
+payment.paypal.notify=http://demo.hotwaxmedia.com/ecommerce/control/payPalNotify
 
 # PayPal Return URL
-payment.paypal.return=http://ofbiz.apache.org:8080/ecommerce/control/orderhistory
+payment.paypal.return=http://demo.hotwaxmedia.com/ecommerce/control/orderhistory
 
 # PayPal Return On Cancel URL
-payment.paypal.cancelReturn=http://ofbiz.apache.org:8080/ecommerce/control/payPalCancel/main
+payment.paypal.cancelReturn=http://demo.hotwaxmedia.com/ecommerce/control/payPalCancel/main
 
 # Image To Use On PayPal
-payment.paypal.image=<a href="http://www.ofbiz:org:8080/images/ofb_logo.gif">http://www.ofbiz:org:8080/images/ofb_logo.gif
+payment.paypal.image=http://demo.hotwaxmedia.com/images/ofbiz_logo.jpg
 
 # Thank-You / Confirm Order Template (rendered via Freemarker)
 payment.paypal.confirmTemplate=/order/emailconfirmation.ftl
 
-# PayPal Redirect URL
-payment.paypal.redirect=https://www.paypal.com/cgi-bin/webscr
-
-# PayPal Confirm URL (JSSE must be configured to use SSL)
-payment.paypal.confirm=http://www.paypal.com/cgi-bin/webscr
+# Production PayPal Redirect URL
+#payment.paypal.redirect=https://www.paypal.com/cgi-bin/webscr
+# Sandbox PayPal Redirect URL
+payment.paypal.redirect=https://www.sandbox.paypal.com/us/cgi-bin/webscr
+
+# Production PayPal Confirm URL (JSSE must be configured to use SSL)
+#payment.paypal.confirm=http://www.paypal.com/cgi-bin/webscr
+# Sandbox PayPal Confirm URL (JSSE must be configured to use SSL)
+payment.paypal.confirm=https://www.sandbox.paypal.com/us/cgi-bin/webscr
 
 ############################################
 # PCCharge Configuration

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java?rev=604030&r1=604029&r2=604030&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java Thu Dec 13 13:23:39 2007
@@ -185,7 +185,11 @@
               
         // get the confirm URL
         String confirmUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.confirm");
-        if (confirmUrl == null) {
+        
+        // get the redirect URL
+        String redirectUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.redirect");
+              
+        if (confirmUrl == null || redirectUrl == null) {
             Debug.logError("Payment properties is not configured properly, no confirm URL defined!", module);
             request.setAttribute("_ERROR_MESSAGE_", "PayPal has not been configured, please contact customer service.");
             return "error";
@@ -200,7 +204,7 @@
 
         try {
             String str = UtilHttp.urlEncodeArgs(parametersMap);
-            URL u = new URL("http://www.paypal.com/cgi-bin/webscr");
+            URL u = new URL(redirectUrl);
             URLConnection uc = u.openConnection();
             uc.setDoOutput(true);
             uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
@@ -278,7 +282,7 @@
         String paymentStatus = request.getParameter("payment_status");
 
         // attempt to start a transaction
-        boolean okay = false;
+        boolean okay = true;
         boolean beganTransaction = false;
         try {
             beganTransaction = TransactionUtil.begin();
@@ -423,6 +427,8 @@
         paymentPreference.set("maxAmount", new Double(paymentAmount));
         if (paymentStatus.equals("Completed")) {
             paymentPreference.set("statusId", "PAYMENT_RECEIVED");
+        } else if (paymentStatus.equals("Pending")) {
+            paymentPreference.set("statusId", "PAYMENT_NOT_RECEIVED");
         } else {
             paymentPreference.set("statusId", "PAYMENT_CANCELLED");
         }
@@ -449,6 +455,13 @@
         response.set("transactionDate", authDate);
         toStore.add(response);
 
+        try {
+            delegator.storeAll(toStore);
+        } catch (GenericEntityException e) {
+            Debug.logError(e, "Cannot set payment preference/payment info", module);
+            return false;
+        }
+        
         // create a payment record too
         Map results = null;
         try {
@@ -466,12 +479,6 @@
             return false;
         }
 
-        try {
-            delegator.storeAll(toStore);
-        } catch (GenericEntityException e) {
-            Debug.logError(e, "Cannot set payment preference/payment info", module);
-            return false;
-        }
         return true;            
     }