svn commit: r1060070 [3/3] - in /ofbiz/trunk/applications/accounting: config/ src/org/ofbiz/accounting/payment/ src/org/ofbiz/accounting/thirdparty/authorizedotnet/ src/org/ofbiz/accounting/thirdparty/clearcommerce/ src/org/ofbiz/accounting/thirdparty/...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1060070 [3/3] - in /ofbiz/trunk/applications/accounting: config/ src/org/ofbiz/accounting/payment/ src/org/ofbiz/accounting/thirdparty/authorizedotnet/ src/org/ofbiz/accounting/thirdparty/clearcommerce/ src/org/ofbiz/accounting/thirdparty/...

mrisaliti
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=1060070&r1=1060069&r2=1060070&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 Mon Jan 17 20:10:56 2011
@@ -21,8 +21,8 @@ package org.ofbiz.accounting.thirdparty.
 
 import java.math.BigDecimal;
 import java.sql.Timestamp;
-import com.ibm.icu.util.Calendar;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 
@@ -44,9 +44,12 @@ import org.ofbiz.service.DispatchContext
 import org.ofbiz.service.ModelService;
 import org.ofbiz.service.ServiceUtil;
 
+import com.ibm.icu.util.Calendar;
+
 public class AIMPaymentServices {
 
     public static final String module = AIMPaymentServices.class.getName();
+    public final static String resource = "AccountingUiLabels";
 
     // The list of refund failure response codes that would cause the ccRefund service
     // to attempt to void the refund's associated authorization transaction.  This list
@@ -75,6 +78,7 @@ public class AIMPaymentServices {
 
     public static Map<String, Object> ccAuth(DispatchContext ctx, Map<String, Object> context) {
         Delegator delegator = ctx.getDelegator();
+        Locale locale = (Locale) context.get("locale");
         Map<String, Object> results = ServiceUtil.returnSuccess();
         Map<String, Object> request = FastMap.newInstance();
         Properties props = buildAIMProperties(context, delegator);
@@ -91,13 +95,14 @@ public class AIMPaymentServices {
             results.put(ModelService.ERROR_MESSAGE, "Validation Failed - invalid values");
             return results;
         }
-        Map<String, Object> reply = processCard(request, props);
+        Map<String, Object> reply = processCard(request, props, locale);
         //now we need to process the result
         processAuthTransResult(reply, results);
         return results;
     }
 
     public static Map<String, Object> ccCapture(DispatchContext ctx, Map<String, Object> context) {
+        Locale locale = (Locale) context.get("locale");
         Delegator delegator = ctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue creditCard = null;
@@ -105,11 +110,13 @@ public class AIMPaymentServices {
             creditCard = delegator.getRelatedOne("CreditCard",orderPaymentPreference);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
-            return ServiceUtil.returnError("Unable to obtain cc information from payment preference");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentUnableToGetCCInfo", locale));
         }
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot Capture");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
         }
         context.put("creditCard", creditCard);
         context.put("authTransaction", authTransaction);
@@ -133,7 +140,7 @@ public class AIMPaymentServices {
             results.put(ModelService.ERROR_MESSAGE, "Validation Failed - invalid values");
             return results;
         }
-        Map<String, Object> reply = processCard(request, props);
+        Map<String, Object> reply = processCard(request, props, locale);
         processCaptureTransResult(reply, results);
         // if there is no captureRefNum, then the capture failed
         if (results.get("captureRefNum") == null) {
@@ -143,6 +150,7 @@ public class AIMPaymentServices {
     }
 
     public static Map<String, Object> ccRefund(DispatchContext ctx, Map<String, Object> context) {
+        Locale locale = (Locale) context.get("locale");
         Delegator delegator = ctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue creditCard = null;
@@ -150,11 +158,13 @@ public class AIMPaymentServices {
             creditCard = delegator.getRelatedOne("CreditCard", orderPaymentPreference);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
-            return ServiceUtil.returnError("Unable to obtain cc information from payment preference");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentUnableToGetCCInfo", locale));
         }
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot Refund");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
         }
         context.put("creditCard",creditCard);
         context.put("authTransaction",authTransaction);
@@ -173,7 +183,7 @@ public class AIMPaymentServices {
             results.put(ModelService.ERROR_MESSAGE, "Validation Failed - invalid values");
             return results;
         }
-        Map<String, Object> reply = processCard(request, props);
+        Map<String, Object> reply = processCard(request, props, locale);
         results.putAll(processRefundTransResult(reply));
         boolean refundResult = ((Boolean)results.get("refundResult")).booleanValue();
         String refundFlag = (String)results.get("refundFlag");
@@ -216,7 +226,9 @@ public class AIMPaymentServices {
                 } else {
                     // TODO: Modify the code to (a) do a void of the whole transaction, and (b)
                     // create a new auth-capture of the difference.
-                    return ServiceUtil.returnFailure("Cannot perform a VOID transaction: authAmount [" + authAmount + "] is different than voidAmount [" + refundAmount + "]");
+                    return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                            "AccountingAuthorizeNetCannotPerformVoidTransaction",
+                            UtilMisc.toMap("authAmount", authAmount, "refundAmount", refundAmount), locale));
                 }
             }
         }
@@ -224,11 +236,13 @@ public class AIMPaymentServices {
     }
 
     public static Map<String, Object> ccRelease(DispatchContext ctx, Map<String, Object> context) {
+        Locale locale = (Locale) context.get("locale");
         Delegator delegator = ctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference [ID = " + orderPaymentPreference.getString("orderPaymentPreferenceId") + "]; cannot void");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
         Map<String, Object> reply = voidTransaction(authTransaction, context, delegator);
         if (ServiceUtil.isError(reply)) {
@@ -240,6 +254,7 @@ public class AIMPaymentServices {
     }
 
     private static Map<String, Object> voidTransaction(GenericValue authTransaction, Map<String, Object> context, Delegator delegator) {
+        Locale locale = (Locale) context.get("locale");
         context.put("authTransaction", authTransaction);
         Map<String, Object> results = ServiceUtil.returnSuccess();
         Map<String, Object> request = FastMap.newInstance();
@@ -255,7 +270,7 @@ public class AIMPaymentServices {
             results.put(ModelService.ERROR_MESSAGE, "Validation Failed - invalid values");
             return results;
         }
-        return processCard(request, props);
+        return processCard(request, props, locale);
     }
 
     public static Map<String, Object> ccCredit(DispatchContext ctx, Map<String, Object> context) {
@@ -267,6 +282,7 @@ public class AIMPaymentServices {
 
     public static Map<String, Object> ccAuthCapture(DispatchContext ctx, Map<String, Object> context) {
         Delegator delegator = ctx.getDelegator();
+        Locale locale = (Locale) context.get("locale");
         Map<String, Object> results = ServiceUtil.returnSuccess();
         Map<String, Object> request = FastMap.newInstance();
         Properties props = buildAIMProperties(context, delegator);
@@ -283,7 +299,7 @@ public class AIMPaymentServices {
             results.put(ModelService.ERROR_MESSAGE, "Validation Failed - invalid values");
             return results;
         }
-        Map<String, Object> reply = processCard(request, props);
+        Map<String, Object> reply = processCard(request, props, locale);
         //now we need to process the result
         processAuthCaptureTransResult(reply, results);
         // if there is no captureRefNum, then the capture failed
@@ -293,11 +309,12 @@ public class AIMPaymentServices {
         return results;
     }
 
-    private static Map<String, Object> processCard(Map<String, Object> request, Properties props) {
+    private static Map<String, Object> processCard(Map<String, Object> request, Properties props, Locale locale) {
         Map<String, Object> result = FastMap.newInstance();
         String url = props.getProperty("url");
         if (UtilValidate.isEmpty(url)) {
-            return ServiceUtil.returnFailure("No payment.authorizedotnet.url found.");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingAuthorizeNetTransactionUrlNotFound", locale));
         }
         if (isTestMode()) {
             Debug.logInfo("TEST Authorize.net using url [" + url + "]", module);

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java?rev=1060070&r1=1060069&r2=1060070&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java Mon Jan 17 20:10:56 2011
@@ -25,6 +25,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -57,7 +58,7 @@ public class CCPaymentServices {
     public final static String module = CCPaymentServices.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
     private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
-
+    public final static String resource = "AccountingUiLabels";
 
     public static Map<String, Object> ccAuth(DispatchContext dctx, Map<String, Object> context) {
         String ccAction = (String) context.get("ccAction");
@@ -118,11 +119,12 @@ public class CCPaymentServices {
     }
 
     public static Map<String, Object> ccCapture(DispatchContext dctx, Map<String, Object> context) {
-
+        Locale locale = (Locale) context.get("locale");
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found; cannot capture");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
         }
 
         Document captureRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
@@ -151,11 +153,12 @@ public class CCPaymentServices {
     }
 
     public static Map<String, Object> ccRelease(DispatchContext dctx, Map<String, Object> context) {
-
+        Locale locale = (Locale) context.get("locale");
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found; cannot release");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
 
         Document releaseRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"), "Void", null);
@@ -183,11 +186,12 @@ public class CCPaymentServices {
     }
 
     public static Map<String, Object> ccReleaseNoop(DispatchContext dctx, Map<String, Object> context) {
-
+        Locale locale = (Locale) context.get("locale");
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found; cannot release");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
 
         Map<String, Object> result = ServiceUtil.returnSuccess();
@@ -202,11 +206,12 @@ public class CCPaymentServices {
     }
 
     public static Map<String, Object> ccRefund(DispatchContext dctx, Map<String, Object> context) {
-
+        Locale locale = (Locale) context.get("locale");
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found; cannot refund");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
         }
 
         // Although refunds are applied to captured transactions, using the auth reference number is ok here
@@ -237,11 +242,12 @@ public class CCPaymentServices {
     }
 
     public static Map<String, Object> ccReAuth(DispatchContext dctx, Map<String, Object> context) {
-
+        Locale locale = (Locale) context.get("locale");
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError("No authorization transaction found; cannot re-auth.");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotReauth", locale));
         }
 
         Document reauthRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
@@ -271,7 +277,8 @@ public class CCPaymentServices {
     }
 
     public static Map<String, Object> ccReport(DispatchContext dctx, Map<String, Object> context) {
-
+        Locale locale = (Locale) context.get("locale");
+        
         // configuration file
         String paymentConfig = (String) context.get("paymentConfig");
         if (UtilValidate.isEmpty(paymentConfig)) {
@@ -281,7 +288,8 @@ public class CCPaymentServices {
         // orderId
         String orderId = (String) context.get("orderId");
         if (UtilValidate.isEmpty(orderId)) {
-            return ServiceUtil.returnError("orderId is required......");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingClearCommerceCannotExecuteReport", locale));
         }
 
 

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java?rev=1060070&r1=1060069&r2=1060070&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java Mon Jan 17 20:10:56 2011
@@ -19,6 +19,7 @@
 package org.ofbiz.accounting.thirdparty.eway;
 
 import java.math.BigDecimal;
+import java.util.Locale;
 import java.util.Map;
 
 import org.ofbiz.accounting.payment.PaymentGatewayServices;
@@ -35,6 +36,7 @@ import org.ofbiz.service.ServiceUtil;
 public class EwayServices {
     
     public static final String module = EwayServices.class.getName();
+    public final static String resource = "AccountingUiLabels";
     
     // eway charge (auth w/ capture)
     public static Map<String, Object> ewayCharge(DispatchContext dctx, Map<String, Object> context) {        
@@ -112,11 +114,13 @@ public class EwayServices {
         Delegator delegator = dctx.getDelegator();
         GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
         BigDecimal refundAmount = (BigDecimal) context.get("refundAmount");
+        Locale locale = (Locale) context.get("locale");
         
         // original charge transaction
         GenericValue chargeTrans = PaymentGatewayServices.getCaptureTransaction(paymentPref);
         if (chargeTrans == null) {
-            return ServiceUtil.returnError("No charge transaction found for the OrderPaymentPreference; cannot refund");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
         }
         
         // credit card used for transaction
@@ -125,7 +129,8 @@ public class EwayServices {
             cc = delegator.getRelatedOne("CreditCard", paymentPref);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
-            return ServiceUtil.returnError("Unable to obtain credit card information from payment preference; cannot refund");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentUnableToGetCCInfo", locale));
         }
         
         // orig ref number
@@ -170,6 +175,7 @@ public class EwayServices {
         Delegator delegator = dctx.getDelegator();
         GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");        
         BigDecimal releaseAmount = (BigDecimal) context.get("releaseAmount");
+        Locale locale = (Locale) context.get("locale");
         
         // original charge transaction
         GenericValue chargeTrans = (GenericValue) context.get("authTrans");
@@ -178,7 +184,8 @@ public class EwayServices {
         }
 
         if (chargeTrans == null) {
-            return ServiceUtil.returnError("No charge transaction found for the OrderPaymentPreference; cannot refund (release)");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
         
         // credit card used for transaction
@@ -187,7 +194,8 @@ public class EwayServices {
             cc = delegator.getRelatedOne("CreditCard", paymentPref);
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
-            return ServiceUtil.returnError("Unable to obtain credit card information from payment preference; cannot refund");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentUnableToGetCCInfo", locale));
         }
         
         // orig ref number

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java?rev=1060070&r1=1060069&r2=1060070&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java Mon Jan 17 20:10:56 2011
@@ -23,6 +23,7 @@ import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.Calendar;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javolution.util.FastMap;
@@ -32,6 +33,7 @@ import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
@@ -45,6 +47,7 @@ import org.ofbiz.service.ServiceUtil;
 public class SagePayPaymentServices {
 
     public static final String module = SagePayPaymentServices.class.getName();
+    public final static String resource = "AccountingUiLabels";
 
     private static Map<String, String> buildCustomerBillingInfo(Map<String, Object> context) {
 
@@ -295,12 +298,13 @@ public class SagePayPaymentServices {
     public static Map<String, Object> ccRefund(DispatchContext ctx, Map<String, Object> context) {
         Debug.logInfo("SagePay - Entered ccRefund", module);
         Debug.logInfo("SagePay ccRefund context : " + context, module);
-
+        Locale locale = (Locale) context.get("locale");
         Delegator delegator = ctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue captureTransaction = PaymentGatewayServices.getCaptureTransaction(orderPaymentPreference);
         if (captureTransaction == null) {
-            return ServiceUtil.returnError("No captured transaction found for the OrderPaymentPreference; cannot Refund");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
         }
         Debug.logInfo("SagePay ccRefund captureTransaction : " + captureTransaction, module);
         GenericValue creditCard = null;
@@ -308,7 +312,8 @@ public class SagePayPaymentServices {
             creditCard = delegator.getRelatedOne("CreditCard", orderPaymentPreference);
         } catch (GenericEntityException e) {
             Debug.logError(e, "Error getting CreditCard for OrderPaymentPreference : " + orderPaymentPreference, module);
-            return ServiceUtil.returnError("Unable to obtain cc information from payment preference");
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+                    "AccountingPaymentUnableToGetCCInfo", locale) + " " + orderPaymentPreference);
         }
         context.put("creditCard",creditCard);
         context.put("captureTransaction", captureTransaction);