svn commit: r796669 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

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

svn commit: r796669 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

lektran
Author: lektran
Date: Wed Jul 22 11:17:38 2009
New Revision: 796669

URL: http://svn.apache.org/viewvc?rev=796669&view=rev
Log:
Work around a PayPal restriction whereby you can have only one outstanding authorization against an order at a time.  

Changed processCaptureSplitPayment to not actually request a new auth against paypal payments but instead just copy
the existing auth into the new paymentpref with the remaining amount.

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=796669&r1=796668&r2=796669&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Wed Jul 22 11:17:38 2009
@@ -163,7 +163,7 @@
         if ((transAmount != null) && (transAmount.compareTo(BigDecimal.ZERO) <= 0)) {
             Map<String, Object> results = ServiceUtil.returnSuccess();
             results.put("finished", Boolean.TRUE); // finished is true since there is nothing to do
-            results.put("errors", Boolean.FALSE); // errors is false since no error occured
+            results.put("errors", Boolean.FALSE); // errors is false since no error occurred
             return results;
         }
 
@@ -1369,7 +1369,12 @@
         String orderId = paymentPref.getString("orderId");
         OrderReadHelper orh = new OrderReadHelper(delegator, orderId);
 
-        String statusId = ("EXT_BILLACT".equals(paymentPref.getString("paymentMethodTypeId"))? "PAYMENT_NOT_RECEIVED": "PAYMENT_NOT_AUTH");
+        String statusId = "PAYMENT_NOT_AUTH";
+        if ("EXT_BILLACT".equals(paymentPref.getString("paymentMethodTypeId"))) {
+            statusId = "PAYMENT_NOT_RECEIVED";
+        } else if ("EXT_PAYPAL".equals(paymentPref.get("paymentMethodTypeId"))) {
+            statusId = "PAYMENT_AUTHORIZED";
+        }
         // create a new payment preference
         Debug.logInfo("Creating payment preference split", module);
         String newPrefId = delegator.getNextSeqId("OrderPaymentPreference");
@@ -1390,7 +1395,17 @@
             // create the new payment preference
             delegator.create(newPref);
 
-            if ("PAYMENT_NOT_AUTH".equals(statusId)) {
+            // PayPal requires us to reuse the existing authorization, so we'll
+            // fake it and copy the existing auth with the remaining amount
+            if ("EXT_PAYPAL".equals(paymentPref.get("paymentMethodTypeId"))) {
+                String newAuthId = delegator.getNextSeqId("PaymentGatewayResponse");
+                GenericValue authTrans = getAuthTransaction(paymentPref);
+                GenericValue newAuthTrans = delegator.makeValue("PaymentGatewayResponse", authTrans);
+                newAuthTrans.set("paymentGatewayResponseId", newAuthId);
+                newAuthTrans.set("orderPaymentPreferenceId", newPref.get("orderPaymentPreferenceId"));
+                newAuthTrans.set("amount", splitAmount);
+                savePgr(dctx, newAuthTrans);
+            } else if ("PAYMENT_NOT_AUTH".equals(statusId)) {
                 // authorize the new preference
                 processorResult = authPayment(dispatcher, userLogin, orh, newPref, splitAmount, false, null);
                 if (processorResult != null) {