svn commit: r558633 - in /ofbiz/trunk/applications/accounting: servicedef/services_paymentmethod.xml 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: r558633 - in /ofbiz/trunk/applications/accounting: servicedef/services_paymentmethod.xml src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

apatel-2
Author: apatel
Date: Mon Jul 23 00:28:49 2007
New Revision: 558633

URL: http://svn.apache.org/viewvc?view=rev&rev=558633
Log:
adding optional parameter to authOrderPayments service. Is nice to have in case we are doing shipment quite sometime after order was approved and want to make sure that payment Auth is still valid.

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

Modified: ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml?view=diff&rev=558633&r1=558632&r2=558633
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml Mon Jul 23 00:28:49 2007
@@ -247,6 +247,7 @@
         <attribute name="orderId" type="String" mode="IN" optional="false"/>
         <attribute name="processResult" type="String" mode="OUT" optional="false"/>
         <attribute name="authResultMsgs" type="List" mode="OUT" optional="true"/>
+        <attribute name="reAuth" type="Boolean" mode="IN" optional="true"/>
     </service>
 
     <service name="releaseOrderPayments" engine="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?view=diff&rev=558633&r1=558632&r2=558633
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Mon Jul 23 00:28:49 2007
@@ -292,7 +292,10 @@
         LocalDispatcher dispatcher = dctx.getDispatcher();
         String orderId = (String) context.get("orderId");
         Map result = new HashMap();
-
+        boolean reAuth = false;
+        if(context.get("reAuth") != null) {
+            reAuth = ((Boolean)context.get("reAuth")).booleanValue();
+        }
         // get the order header and payment preferences
         GenericValue orderHeader = null;
         List paymentPrefs = null;
@@ -305,6 +308,11 @@
             Map lookupMap = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_AUTH");
             List orderList = UtilMisc.toList("maxAmount");
             paymentPrefs = delegator.findByAnd("OrderPaymentPreference", lookupMap, orderList);
+            if(reAuth) {
+                lookupMap.put("orderId", orderId);
+                lookupMap.put("statusId", "PAYMENT_AUTHORIZED");
+                paymentPrefs.addAll(delegator.findByAnd("OrderPaymentPreference", lookupMap, orderList));
+            }
         } catch (GenericEntityException gee) {
             Debug.logError(gee, "Problems getting the order information", module);
             result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
@@ -330,7 +338,22 @@
         Iterator payments = paymentPrefs.iterator();
         while (payments.hasNext()) {
             GenericValue paymentPref = (GenericValue) payments.next();
-
+            if (reAuth && "PAYMENT_AUTHORIZED".equals(paymentPref.getString("statusId"))) {
+                String paymentConfig = null;
+                // get the payment settings i.e. serviceName and config properties file name
+                GenericValue paymentSettings = getPaymentSettings(orh.getOrderHeader(), paymentPref, AUTH_SERVICE_TYPE, false);
+                if (paymentSettings != null) {
+                    paymentConfig = paymentSettings.getString("paymentPropertiesPath");
+                    if (paymentConfig == null || paymentConfig.length() == 0) {
+                        paymentConfig = "payment.properties";
+                    }
+                }
+                // check the validity of the authorization; re-auth if necessary
+                if (PaymentGatewayServices.checkAuthValidity(paymentPref, paymentConfig)) {
+                    finished += 1;
+                    continue;
+                }
+            }
             Map authContext = new HashMap();
             authContext.put("orderPaymentPreferenceId", paymentPref.getString("orderPaymentPreferenceId"));
             authContext.put("userLogin", context.get("userLogin"));