Author: jaz
Date: Wed Mar 28 15:51:37 2007
New Revision: 523494
URL:
http://svn.apache.org/viewvc?view=rev&rev=523494Log:
added test cc processor which 1/4 the time will decline (randomly)
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=523494&r1=523493&r2=523494==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_paymentmethod.xml Wed Mar 28 15:51:37 2007
@@ -483,6 +483,11 @@
<description>Credit Card Processing</description>
<implements service="ccAuthInterface"/>
</service>
+ <service name="testRandomAuthorize" engine="java"
+ location="org.ofbiz.accounting.payment.PaymentGatewayServices" invoke="testRandomAuthorize">
+ <description>Credit Card Processing</description>
+ <implements service="ccAuthInterface"/>
+ </service>
<service name="alwaysApproveCCProcessor" engine="java"
location="org.ofbiz.accounting.payment.PaymentGatewayServices" invoke="alwaysApproveProcessor">
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=523494&r1=523493&r2=523494==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Wed Mar 28 15:51:37 2007
@@ -20,15 +20,7 @@
import java.text.DecimalFormat;
import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Calendar;
-import java.util.Set;
+import java.util.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
@@ -2593,6 +2585,30 @@
return result;
}
+ /**
+ * Test authorize - does random declines
+ */
+ public static Map testRandomAuthorize(DispatchContext dctx, Map context) {
+ Map result = ServiceUtil.returnSuccess();
+ String refNum = UtilDateTime.nowAsString();
+ Random r = new Random();
+ int i = r.nextInt(9);
+ if (i < 5 || i % 2 == 0) {
+ result.put("authResult", Boolean.TRUE);
+ result.put("authFlag", "A");
+ } else {
+ result.put("authResult", Boolean.FALSE);
+ result.put("authFlag", "D");
+ }
+
+ result.put("processAmount", context.get("processAmount"));
+ result.put("authRefNum", refNum);
+ result.put("authAltRefNum", refNum);
+ result.put("authCode", "100");
+ result.put("authMessage", "This is a test processor; no payments were captured or authorized.");
+
+ return result;
+ }
/**
* Always approve processor.