|
Author: jaz
Date: Tue Nov 23 20:14:57 2010 New Revision: 1038317 URL: http://svn.apache.org/viewvc?rev=1038317&view=rev Log: addressing JIRA OFBIZ-4029; where the CNP response was being clobbered by the CP response; this addresses the issue and includes a few minor clean-ups Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java?rev=1038317&r1=1038316&r2=1038317&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java Tue Nov 23 20:14:57 2010 @@ -306,7 +306,7 @@ public class AIMPaymentServices { } // card present has a different layout from standard AIM; this determines how to parse the response - int apiType = props.get("cpMarketType") == null ? AuthorizeResponse.AIM_RESPONSE : AuthorizeResponse.CP_RESPONSE; + int apiType = UtilValidate.isEmpty(props.get("cpMarketType")) ? AuthorizeResponse.AIM_RESPONSE : AuthorizeResponse.CP_RESPONSE; try { HttpClient httpClient = new HttpClient(url, request); @@ -529,7 +529,7 @@ public class AIMPaymentServices { String expDate = UtilFormatOut.checkNull(cc.getString("expireDate")); String cardSecurityCode = (String) params.get("cardSecurityCode"); AIMRequest.put("x_Amount", amount); - AIMRequest.put("x_Currency_Code", currency); + AIMRequest.put("x_Currency_Code", currency); AIMRequest.put("x_Method", props.getProperty("method")); AIMRequest.put("x_Type", props.getProperty("transType")); AIMRequest.put("x_Card_Num", number); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java?rev=1038317&r1=1038316&r2=1038317&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMRespPositions.java Tue Nov 23 20:14:57 2010 @@ -6,6 +6,7 @@ import javolution.util.FastMap; public class AIMRespPositions extends AuthorizeResponse.RespPositions { + // AIM v3.1 response positions private static Map<String, Integer> positions = FastMap.newInstance(); static { positions.put(AuthorizeResponse.RESPONSE_CODE, 1); @@ -29,6 +30,6 @@ public class AIMRespPositions extends Au @Override public String getApprovalString() { - return "APPROVED"; + return "1"; } } Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java?rev=1038317&r1=1038316&r2=1038317&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AuthorizeResponse.java Tue Nov 23 20:14:57 2010 @@ -20,13 +20,12 @@ package org.ofbiz.accounting.thirdparty.authorizedotnet; import java.math.BigDecimal; -import java.util.*; import org.ofbiz.base.util.UtilValidate; public class AuthorizeResponse { - private List<String> response = new ArrayList<String>(); + private String[] response; private RespPositions pos; private String rawResp; @@ -54,12 +53,13 @@ public class AuthorizeResponse { private static final CPRespPositions cpPos = new CPRespPositions(); public AuthorizeResponse(String resp, int responseType) { - this(resp, "|", responseType); + this(resp, "\\|", responseType); } public AuthorizeResponse(String resp, String delim, int responseType) { this.rawResp = resp; - this.response = splitResp(resp, delim); + this.response = resp.split(delim); + if (responseType == CP_RESPONSE) { pos = cpPos; } else { @@ -120,35 +120,14 @@ public class AuthorizeResponse { } private String getResponseField(int position) { - if (response.size() < position) { + if (response.length < position) { return null; } else { - return response.get(position); + // positions always start at 1; arrays start at 0 + return response[position-1]; } } - - private List<String> splitResp(String r, String delim) { - int s1=0, s2=-1; - List<String> out = new ArrayList<String>(40); - out.add("empty"); - while (true) { - s2 = r.indexOf(delim, s1); - if (s2 != -1) { - out.add(r.substring(s1, s2)); - } else { - //the end part of the string (string not pattern terminated) - String _ = r.substring(s1); - if (_ != null && !_.equals("")) { - out.add(_); - } - break; - } - s1 = s2; - s1 += delim.length(); - } - return out; - } - + @Override public String toString() { return response.toString(); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java?rev=1038317&r1=1038316&r2=1038317&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/CPRespPositions.java Tue Nov 23 20:14:57 2010 @@ -6,6 +6,7 @@ import javolution.util.FastMap; public class CPRespPositions extends AuthorizeResponse.RespPositions { + // Card-Present v1.0 response positions private static Map<String, Integer> positions = FastMap.newInstance(); static { positions.put(AuthorizeResponse.RESPONSE_CODE, 2); |
| Free forum by Nabble | Edit this page |
