Author: sichen
Date: Fri Sep 28 15:40:57 2007
New Revision: 580500
URL: http://svn.apache.org/viewvc?rev=580500&view=rev
Log:
Fix serious bug in Authorize.net capture service. For some reason, the
getRelatedOne() function fails to return a value for both the opp and cc
address. The fix is to use the creditCard that is passed in from the context
and to check for null more rigorously.
Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.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=580500&r1=580499&r2=580500&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
Fri Sep 28 15:40:57 2007
@@ -475,17 +475,23 @@
if (params.get("orderPaymentPreference") != null) {
GenericValue opp = (GenericValue)
params.get("orderPaymentPreference");
if
("CREDIT_CARD".equals(opp.getString("paymentMethodTypeId"))) {
- GenericValue creditCard = opp.getRelatedOne("CreditCard");
+ // sometimes the ccAuthCapture interface is used, in which
case the creditCard is passed directly
+ GenericValue creditCard = (GenericValue)
params.get("creditCard");
+ if (creditCard == null || !
(opp.get("paymentMethodId").equals(creditCard.get("paymentMethodId")))) {
+ creditCard = opp.getRelatedOne("CreditCard");
+ }
AIMRequest.put("x_First_Name",UtilFormatOut.checkNull(creditCard.getString("firstNameOnCard")));
AIMRequest.put("x_Last_Name",UtilFormatOut.checkNull(creditCard.getString("lastNameOnCard")));
AIMRequest.put("x_Company",UtilFormatOut.checkNull(creditCard.getString("companyNameOnCard")));
if
(UtilValidate.isNotEmpty(creditCard.getString("contactMechId"))) {
GenericValue address =
creditCard.getRelatedOne("PostalAddress");
-
AIMRequest.put("x_Address",UtilFormatOut.checkNull(address.getString("address1")));
-
AIMRequest.put("x_City",UtilFormatOut.checkNull(address.getString("city")));
-
AIMRequest.put("x_State",UtilFormatOut.checkNull(address.getString("stateProvinceGeoId")));
-
AIMRequest.put("x_Zip",UtilFormatOut.checkNull(address.getString("postalCode")));
-
AIMRequest.put("x_Country",UtilFormatOut.checkNull(address.getString("countryGeoId")));
+ if (address != null) {
+
AIMRequest.put("x_Address",UtilFormatOut.checkNull(address.getString("address1")));
+
AIMRequest.put("x_City",UtilFormatOut.checkNull(address.getString("city")));
+
AIMRequest.put("x_State",UtilFormatOut.checkNull(address.getString("stateProvinceGeoId")));
+
AIMRequest.put("x_Zip",UtilFormatOut.checkNull(address.getString("postalCode")));
+
AIMRequest.put("x_Country",UtilFormatOut.checkNull(address.getString("countryGeoId")));
+ }
}
} else {
Debug.logWarning("Payment preference " + opp + " is not a
credit card", module);