You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2006/10/20 18:35:32 UTC
svn commit: r466193 -
/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
Author: sichen
Date: Fri Oct 20 09:35:30 2006
New Revision: 466193
URL: http://svn.apache.org/viewvc?view=rev&rev=466193
Log:
Improved Authorize.NET payment gateway, by sending order and address info on capture transactions as well
Modified:
incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
Modified: incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java?view=diff&rev=466193&r1=466192&r2=466193
==============================================================================
--- incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java (original)
+++ incubator/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java Fri Oct 20 09:35:30 2006
@@ -84,7 +84,9 @@
Properties props = buildAIMProperties(context);
buildMerchantInfo(context,props,request);
buildGatewayResponeConfig(context,props,request);
+ buildCustomerBillingInfo(context,props,request);
buildEmailSettings(context,props,request);
+ request.put("x_Invoice_Num","Order " + orderPaymentPreference.getString("orderId"));
//props.put("transType","PRIOR_AUTH_CAPTURE");
props.put("transType","CAPTURE_ONLY");
props.put("cardtype", (String)creditCard.get("cardType"));
@@ -344,17 +346,45 @@
}
private static void buildCustomerBillingInfo(Map params, Properties props, Map AIMRequest) {
- GenericValue cp = (GenericValue)params.get("billToParty");
- GenericValue ba = (GenericValue)params.get("billingAddress");
-
- AIMRequest.put("x_First_Name",UtilFormatOut.checkNull(cp.getString("firstName")));
- AIMRequest.put("x_Last_Name",UtilFormatOut.checkNull(cp.getString("lastName")));
- AIMRequest.put("x_Address",UtilFormatOut.checkNull(ba.getString("address1")));
- AIMRequest.put("x_City",UtilFormatOut.checkNull(ba.getString("city")));
- AIMRequest.put("x_State",UtilFormatOut.checkNull(ba.getString("stateProvinceGeoId")));
- AIMRequest.put("x_Zip",UtilFormatOut.checkNull(ba.getString("postalCode")));
- AIMRequest.put("x_Country",UtilFormatOut.checkNull(ba.getString("countryGeoId")));
- return;
+ try {
+ // this would be used in the case of a capture, where one of the parameters is an OrderPaymentPreference
+ if (params.get("orderPaymentPreference") != null) {
+ GenericValue opp = (GenericValue) params.get("orderPaymentPreference");
+ if ("CREDIT_CARD".equals(opp.getString("paymentMethodTypeId"))) {
+ GenericValue 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")));
+ }
+ } else {
+ Debug.logWarning("Payment preference " + opp + " is not a credit card", module);
+ }
+ } else {
+ // this would be the case for an authorization
+ GenericValue cp = (GenericValue)params.get("billToParty");
+ GenericValue ba = (GenericValue)params.get("billingAddress");
+
+ AIMRequest.put("x_First_Name",UtilFormatOut.checkNull(cp.getString("firstName")));
+ AIMRequest.put("x_Last_Name",UtilFormatOut.checkNull(cp.getString("lastName")));
+ AIMRequest.put("x_Address",UtilFormatOut.checkNull(ba.getString("address1")));
+ AIMRequest.put("x_City",UtilFormatOut.checkNull(ba.getString("city")));
+ AIMRequest.put("x_State",UtilFormatOut.checkNull(ba.getString("stateProvinceGeoId")));
+ AIMRequest.put("x_Zip",UtilFormatOut.checkNull(ba.getString("postalCode")));
+ AIMRequest.put("x_Country",UtilFormatOut.checkNull(ba.getString("countryGeoId")));
+ }
+ return;
+
+ } catch (GenericEntityException ex) {
+ Debug.logError("Cannot build customer information for " + params + " due to error: " + ex.getMessage(), module);
+ return;
+ }
}
private static void buildEmailSettings(Map params, Properties props, Map AIMRequest) {