[OFBiz] SVN: r6749 - in trunk/applications/accounting/src/org/ofbiz/accounting: payment thirdparty/verisign

jaz@svn.ofbiz.org jaz at svn.ofbiz.org
Thu Feb 16 10:00:47 CST 2006


Author: jaz
Date: 2006-02-16 10:00:28 -0600 (Thu, 16 Feb 2006)
New Revision: 6749

Modified:
   trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
   trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java
Log:
few changes to pass the capture ID to verisign for refunds.


Modified: trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
===================================================================
--- trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java	2006-02-16 07:42:20 UTC (rev 6748)
+++ trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java	2006-02-16 16:00:28 UTC (rev 6749)
@@ -1818,6 +1818,23 @@
         return ServiceUtil.returnSuccess();
     }
 
+    public static GenericValue getCaptureTransaction(GenericValue orderPaymentPreference) {
+        GenericValue capTrans = null;
+        try {
+            List order = UtilMisc.toList("-transactionDate");
+            List transactions = orderPaymentPreference.getRelated("PaymentGatewayResponse", null, order);
+
+            List exprs = UtilMisc.toList(new EntityExpr("paymentServiceTypeEnumId", EntityOperator.EQUALS, "PRDS_PAY_CAPTURE"));
+
+            List capTransactions = EntityUtil.filterByAnd(transactions, exprs);
+
+            capTrans = EntityUtil.getFirst(capTransactions);
+        } catch (GenericEntityException e) {
+            Debug.logError(e, "ERROR: Problem getting capture information from PaymentGatewayResponse", module);
+        }
+        return capTrans;
+    }
+
     public static GenericValue getAuthTransaction(GenericValue orderPaymentPreference) {
         GenericValue authTrans = null;
         try {
@@ -2211,20 +2228,33 @@
         return result;
     }
 
-     /**
-      * Test refund service (returns true)
-      */
-     public static Map testRefund(DispatchContext dctx, Map context) {
-         Map result = ServiceUtil.returnSuccess();
-         long nowTime = new Date().getTime();
-         Debug.logInfo("Test Refund Process", module);
+    /**
+     * Test refund service (returns true)
+     */
+    public static Map testRefund(DispatchContext dctx, Map context) {
+        Map result = ServiceUtil.returnSuccess();
+        long nowTime = new Date().getTime();
+        Debug.logInfo("Test Refund Process", module);
 
-         result.put("refundResult", new Boolean(true));
-         result.put("refundAmount", context.get("refundAmount"));
-         result.put("refundRefNum", new Long(nowTime).toString());
-         result.put("refundFlag", "R");
-         result.put("refundMessage", "This is a test refund; no money was transferred");
-         return result;
-     }
+        result.put("refundResult", new Boolean(true));
+        result.put("refundAmount", context.get("refundAmount"));
+        result.put("refundRefNum", new Long(nowTime).toString());
+        result.put("refundFlag", "R");
+        result.put("refundMessage", "This is a test refund; no money was transferred");
+        return result;
+    }
 
+    public static Map testRefundFailure(DispatchContext dctx, Map context) {
+        Map result = ServiceUtil.returnSuccess();
+        long nowTime = new Date().getTime();
+        Debug.logInfo("Test Refund Process", module);
+
+        result.put("refundResult", new Boolean(false));
+        result.put("refundAmount", context.get("refundAmount"));
+        result.put("refundRefNum", new Long(nowTime).toString());
+        result.put("refundFlag", "R");
+        result.put("refundMessage", "This is a test refund failure; no money was transferred");
+        return result;
+    }
+
 }

Modified: trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java
===================================================================
--- trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java	2006-02-16 07:42:20 UTC (rev 6748)
+++ trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java	2006-02-16 16:00:28 UTC (rev 6749)
@@ -262,23 +262,21 @@
 
     public static Map ccRefund(DispatchContext dctx, Map context) {
         GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
-        GenericValue authTrans = (GenericValue) context.get("authTrans");
         Double amount = (Double) context.get("refundAmount");
         String configString = (String) context.get("paymentConfig");
         if (configString == null) {
             configString = "payment.properties";
         }
 
-        if (authTrans == null){
-        	authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);
-        }
+        GenericValue captureTrans = PaymentGatewayServices.getCaptureTransaction(paymentPref);
 
-        if (authTrans == null) {
-            return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot capture");
+
+        if (captureTrans == null) {
+            return ServiceUtil.returnError("No capture transaction found for the OrderPaymentPreference; cannot refund");
         }
 
         // auth ref number
-        String refNum = authTrans.getString("referenceNum");
+        String refNum = captureTrans.getString("referenceNum");
         Map data = UtilMisc.toMap("ORIGID", refNum);
 
         // tx type (Credit)



More information about the Svn mailing list