You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2017/12/18 11:56:05 UTC

svn commit: r1818555 - in /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce: CCPaymentServices.java CCServicesTest.java

Author: mbrohl
Date: Mon Dec 18 11:56:05 2017
New Revision: 1818555

URL: http://svn.apache.org/viewvc?rev=1818555&view=rev
Log:
Improved: General refactoring and code improvements, package 
org.apache.ofbiz.accounting.thirdparty.clearcommerce.
(OFBIZ-9879)

Thanks Julian Leichert for reporting and providing the patches.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java?rev=1818555&r1=1818554&r2=1818555&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java Mon Dec 18 11:56:05 2017
@@ -22,7 +22,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -48,7 +47,6 @@ import org.apache.ofbiz.service.ServiceU
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-
 /**
  * ClearCommerce Payment Services (CCE 5.4)
  */
@@ -62,7 +60,9 @@ public class CCPaymentServices {
     public static Map<String, Object> ccAuth(DispatchContext dctx, Map<String, Object> context) {
         String ccAction = (String) context.get("ccAction");
         Delegator delegator = dctx.getDelegator();
-        if (ccAction == null) ccAction = "PreAuth";
+        if (ccAction == null) {
+            ccAction = "PreAuth";
+        }
         Document authRequestDoc = buildPrimaryTxRequest(context, ccAction, (BigDecimal) context.get("processAmount"),
                 (String) context.get("orderId"));
 
@@ -73,7 +73,7 @@ public class CCPaymentServices {
             return ServiceUtil.returnError(cce.getMessage());
         }
 
-        if (getMessageListMaxSev(authResponseDoc) > 4) {  // 5 and higher, process error from HSBC
+        if (getMessageListMaxSev(authResponseDoc) > 4) { // 5 and higher, process error from HSBC
             Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("authResult", Boolean.FALSE);
             result.put("processAmount", BigDecimal.ZERO);
@@ -92,7 +92,7 @@ public class CCPaymentServices {
         String action = "Credit";
         Delegator delegator = dctx.getDelegator();
         if (context.get("pbOrder") != null) {
-            action = "Auth";  // required for periodic billing....
+            action = "Auth"; // required for periodic billing....
         }
 
         Document creditRequestDoc = buildPrimaryTxRequest(context, action, (BigDecimal) context.get("creditAmount"),
@@ -125,7 +125,7 @@ public class CCPaymentServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
         }
 
@@ -160,11 +160,12 @@ public class CCPaymentServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
 
-        Document releaseRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"), "Void", null, delegator);
+        Document releaseRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"), "Void",
+                null, delegator);
 
         Document releaseResponseDoc = null;
         try {
@@ -193,7 +194,7 @@ public class CCPaymentServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
         }
 
@@ -214,7 +215,7 @@ public class CCPaymentServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
         }
 
@@ -251,7 +252,7 @@ public class CCPaymentServices {
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingPaymentTransactionAuthorizationNotFoundCannotReauth", locale));
         }
 
@@ -293,11 +294,10 @@ public class CCPaymentServices {
         // orderId
         String orderId = (String) context.get("orderId");
         if (UtilValidate.isEmpty(orderId)) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingClearCommerceCannotExecuteReport", locale));
         }
 
-
         // EngineDocList
         Document requestDocument = UtilXml.makeEmptyXmlDocument("EngineDocList");
         Element engineDocListElement = requestDocument.getDocumentElement();
@@ -315,10 +315,9 @@ public class CCPaymentServices {
         String groupId = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.groupId", delegator);
         if (UtilValidate.isNotEmpty(groupId)) {
             UtilXml.addChildElementValue(engineDocElement, "GroupId", groupId, requestDocument);
-        }
-        else
+        } else {
             UtilXml.addChildElementValue(engineDocElement, "GroupId", orderId, requestDocument);
-
+        }
 
         // EngineDocList.EngineDoc.User
         Element userElement = UtilXml.addChildElement(engineDocElement, "User", requestDocument);
@@ -338,33 +337,33 @@ public class CCPaymentServices {
         Element instructionsElement = UtilXml.addChildElement(engineDocElement, "Instructions", requestDocument);
         Element routingListDocElement = UtilXml.addChildElement(instructionsElement, "RoutingList", requestDocument);
         Element routingDocElement = UtilXml.addChildElement(routingListDocElement, "Routing", requestDocument);
-        UtilXml.addChildElementValue(routingDocElement,"name","CcxReports", requestDocument);
+        UtilXml.addChildElementValue(routingDocElement, "name", "CcxReports", requestDocument);
 
         // EngineDocList.EngineDoc.ReportDoc
-        Element reportDocElement = UtilXml.addChildElement(engineDocElement, "ReportDoc",requestDocument);
-        Element compList = UtilXml.addChildElement(reportDocElement, "CompList",requestDocument);
-        Element comp = UtilXml.addChildElement(compList, "Comp",requestDocument);
-        UtilXml.addChildElementValue(comp,"Name","CcxReports",requestDocument);
+        Element reportDocElement = UtilXml.addChildElement(engineDocElement, "ReportDoc", requestDocument);
+        Element compList = UtilXml.addChildElement(reportDocElement, "CompList", requestDocument);
+        Element comp = UtilXml.addChildElement(compList, "Comp", requestDocument);
+        UtilXml.addChildElementValue(comp, "Name", "CcxReports", requestDocument);
         // EngineDocList.EngineDoc.ReportDoc.ReportActionList
-        Element actionList = UtilXml.addChildElement(comp, "ReportActionList",requestDocument);
-        Element action = UtilXml.addChildElement(actionList, "ReportAction",requestDocument);
-        UtilXml.addChildElementValue(action,"ReportName","CCE_OrderDetail",requestDocument);
-        Element start = UtilXml.addChildElementValue(action,"Start","1",requestDocument);
+        Element actionList = UtilXml.addChildElement(comp, "ReportActionList", requestDocument);
+        Element action = UtilXml.addChildElement(actionList, "ReportAction", requestDocument);
+        UtilXml.addChildElementValue(action, "ReportName", "CCE_OrderDetail", requestDocument);
+        Element start = UtilXml.addChildElementValue(action, "Start", "1", requestDocument);
         start.setAttribute("DataType", "S32");
-        Element count = UtilXml.addChildElementValue(action,"Count","10",requestDocument);
+        Element count = UtilXml.addChildElementValue(action, "Count", "10", requestDocument);
         count.setAttribute("DataType", "S32");
         // EngineDocList.EngineDoc.ReportDoc.ReportActionList.ReportAction.ValueList
-        Element valueList = UtilXml.addChildElement(action, "ValueList",requestDocument);
-        Element value = UtilXml.addChildElement(valueList, "Value",requestDocument);
+        Element valueList = UtilXml.addChildElement(action, "ValueList", requestDocument);
+        Element value = UtilXml.addChildElement(valueList, "Value", requestDocument);
         String clientIdConfig = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.clientId", delegator);
         if (UtilValidate.isNotEmpty(clientIdConfig)) {
-            Element clientId = UtilXml.addChildElementValue(value,"ClientId", clientIdConfig, requestDocument);
+            Element clientId = UtilXml.addChildElementValue(value, "ClientId", clientIdConfig, requestDocument);
             clientId.setAttribute("DataType", "S32");
         }
-        UtilXml.addChildElementValue(value,"OrderId", orderId, requestDocument);
+        UtilXml.addChildElementValue(value, "OrderId", orderId, requestDocument);
 
         Debug.set(Debug.VERBOSE, true);
-        //Document reportResponseDoc = null;
+        // Document reportResponseDoc = null;
         try {
             sendRequest(requestDocument, (String) context.get("paymentConfig"), delegator);
         } catch (ClearCommerceException cce) {
@@ -377,7 +376,6 @@ public class CCPaymentServices {
         return result;
     }
 
-
     private static Map<String, Object> processAuthResponse(Document responseDocument) {
 
         Element engineDocElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "EngineDoc");
@@ -596,14 +594,13 @@ public class CCPaymentServices {
 
     private static List<String> getMessageList(Document responseDocument) {
 
-        List<String> messageList = new ArrayList<String>();
+        List<String> messageList = new ArrayList<>();
 
         Element engineDocElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "EngineDoc");
         Element messageListElement = UtilXml.firstChildElement(engineDocElement, "MessageList");
         List<? extends Element> messageElementList = UtilXml.childElementList(messageListElement, "Message");
         if (UtilValidate.isNotEmpty(messageElementList)) {
-            for (Iterator<? extends Element> i = messageElementList.iterator(); i.hasNext();) {
-                Element messageElement = i.next();
+            for (Element messageElement : messageElementList) {
                 int severity = 0;
                 try {
                     severity = Integer.parseInt(UtilXml.childElementValue(messageElement, "Sev"));
@@ -611,8 +608,8 @@ public class CCPaymentServices {
                     Debug.logError("Error parsing message severity: " + nfe.getMessage(), module);
                     severity = 9;
                 }
-                String message = "[" + UtilXml.childElementValue(messageElement, "Audience") + "] " +
-                        UtilXml.childElementValue(messageElement, "Text") + " (" + severity + ")";
+                String message = "[" + UtilXml.childElementValue(messageElement, "Audience") + "] " + UtilXml
+                        .childElementValue(messageElement, "Text") + " (" + severity + ")";
                 messageList.add(message);
             }
         }
@@ -709,20 +706,28 @@ public class CCPaymentServices {
 
         Map<String, Object> pbOrder = UtilGenerics.checkMap(context.get("pbOrder"));
         if (pbOrder != null) {
-            if (Debug.verboseOn()) Debug.logVerbose("pbOrder Map not empty:" + pbOrder.toString(),module);
-            Element pbOrderElement =  UtilXml.addChildElement(orderFormDocElement, "PbOrder", requestDocument); // periodic billing order
-            UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyCycle", (String) pbOrder.get("OrderFrequencyCycle"), requestDocument);
-            Element interval = UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyInterval", (String) pbOrder.get("OrderFrequencyInterval"), requestDocument);
+            if (Debug.verboseOn()) {
+                Debug.logVerbose("pbOrder Map not empty:" + pbOrder.toString(), module);
+            }
+            Element pbOrderElement = UtilXml.addChildElement(orderFormDocElement, "PbOrder", requestDocument); // periodic billing order
+            UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyCycle", (String) pbOrder.get(
+                    "OrderFrequencyCycle"), requestDocument);
+            Element interval = UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyInterval", (String) pbOrder
+                    .get("OrderFrequencyInterval"), requestDocument);
             interval.setAttribute("DataType", "S32");
-            Element total = UtilXml.addChildElementValue(pbOrderElement, "TotalNumberPayments", (String) pbOrder.get("TotalNumberPayments"), requestDocument);
+            Element total = UtilXml.addChildElementValue(pbOrderElement, "TotalNumberPayments", (String) pbOrder.get(
+                    "TotalNumberPayments"), requestDocument);
             total.setAttribute("DataType", "S32");
-        }
-        else if  (context.get("OrderFrequencyCycle") != null && context.get("OrderFrequencyInterval") != null && context.get("TotalNumberPayments") != null) {
-            Element pbOrderElement =  UtilXml.addChildElement(orderFormDocElement, "PbOrder", requestDocument); // periodic billing order
-            UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyCycle", (String) context.get("OrderFrequencyCycle"), requestDocument);
-            Element interval = UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyInterval", (String) context.get("OrderFrequencyInterval"), requestDocument);
+        } else if (context.get("OrderFrequencyCycle") != null && context.get("OrderFrequencyInterval") != null
+                && context.get("TotalNumberPayments") != null) {
+            Element pbOrderElement = UtilXml.addChildElement(orderFormDocElement, "PbOrder", requestDocument); // periodic billing order
+            UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyCycle", (String) context.get(
+                    "OrderFrequencyCycle"), requestDocument);
+            Element interval = UtilXml.addChildElementValue(pbOrderElement, "OrderFrequencyInterval", (String) context
+                    .get("OrderFrequencyInterval"), requestDocument);
             interval.setAttribute("DataType", "S32");
-            Element total = UtilXml.addChildElementValue(pbOrderElement, "TotalNumberPayments", (String) context.get("TotalNumberPayments"), requestDocument);
+            Element total = UtilXml.addChildElementValue(pbOrderElement, "TotalNumberPayments", (String) context.get(
+                    "TotalNumberPayments"), requestDocument);
             total.setAttribute("DataType", "S32");
         }
 
@@ -761,8 +766,8 @@ public class CCPaymentServices {
         UtilXml.addChildElementValue(creditCardElement, "Number", creditCard.getString("cardNumber"), document);
 
         String expDate = creditCard.getString("expireDate");
-        Element expiresElement = UtilXml.addChildElementValue(creditCardElement, "Expires",
-                expDate.substring(0, 3) + expDate.substring(5), document);
+        Element expiresElement = UtilXml.addChildElementValue(creditCardElement, "Expires", expDate.substring(0, 3)
+                + expDate.substring(5), document);
         expiresElement.setAttribute("DataType", "ExpirationDate");
         expiresElement.setAttribute("Locale", localeCode);
 
@@ -771,7 +776,7 @@ public class CCPaymentServices {
             if (cardSecurityCode.length() < securityCodeLength) {
                 // space padding on right side of cardSecurityCode
                 cardSecurityCode = String.format("%-" + securityCodeLength + "s", cardSecurityCode);
-               
+
             } else if (cardSecurityCode.length() > securityCodeLength) {
                 cardSecurityCode = cardSecurityCode.substring(0, securityCodeLength);
             }
@@ -849,14 +854,15 @@ public class CCPaymentServices {
 
         // EngineDocList.EngineDoc.User
         Element userElement = UtilXml.addChildElement(engineDocElement, "User", requestDocument);
-        UtilXml.addChildElementValue(userElement, "Name",
-                EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.username", "", delegator), requestDocument);
-        UtilXml.addChildElementValue(userElement, "Password",
-                EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.password", "", delegator), requestDocument);
-        UtilXml.addChildElementValue(userElement, "Alias",
-                EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.alias", "", delegator), requestDocument);
+        UtilXml.addChildElementValue(userElement, "Name", EntityUtilProperties.getPropertyValue(paymentConfig,
+                "payment.clearcommerce.username", "", delegator), requestDocument);
+        UtilXml.addChildElementValue(userElement, "Password", EntityUtilProperties.getPropertyValue(paymentConfig,
+                "payment.clearcommerce.password", "", delegator), requestDocument);
+        UtilXml.addChildElementValue(userElement, "Alias", EntityUtilProperties.getPropertyValue(paymentConfig,
+                "payment.clearcommerce.alias", "", delegator), requestDocument);
 
-        String effectiveAlias = EntityUtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.effectiveAlias", delegator);
+        String effectiveAlias = EntityUtilProperties.getPropertyValue(paymentConfig,
+                "payment.clearcommerce.effectiveAlias", delegator);
         if (UtilValidate.isNotEmpty(effectiveAlias)) {
             UtilXml.addChildElementValue(userElement, "EffectiveAlias", effectiveAlias, requestDocument);
         }
@@ -899,7 +905,7 @@ public class CCPaymentServices {
         } catch (TransformerException e) {
             throw new ClearCommerceException("Error serializing requestDocument: " + e.getMessage());
         }
-       
+
         String xmlString = os.toString();
 
         if (Debug.verboseOn()) {
@@ -923,9 +929,12 @@ public class CCPaymentServices {
         } catch (Exception e) {
             throw new ClearCommerceException("Error reading response Document from a String: " + e.getMessage());
         }
-        if (Debug.verboseOn()) Debug.logVerbose("Result severity from clearCommerce:" + getMessageListMaxSev(responseDocument), module);
-        if (Debug.verboseOn() && getMessageListMaxSev(responseDocument) > 4)
-                if (Debug.verboseOn()) Debug.logVerbose("Returned messages:" + getMessageList(responseDocument),module);
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("Result severity from clearCommerce:" + getMessageListMaxSev(responseDocument), module);
+        }
+        if (Debug.verboseOn() && getMessageListMaxSev(responseDocument) > 4) {
+            Debug.logVerbose("Returned messages:" + getMessageList(responseDocument), module);
+        }
         return responseDocument;
     }
 
@@ -938,19 +947,15 @@ class ClearCommerceException extends Gen
         super();
     }
 
-
     ClearCommerceException(String msg) {
         super(msg);
     }
 
-
     ClearCommerceException(Throwable t) {
         super(t);
     }
 
-
     ClearCommerceException(String msg, Throwable t) {
         super(msg, t);
     }
 }
-

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java?rev=1818555&r1=1818554&r2=1818555&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java Mon Dec 18 11:56:05 2017
@@ -54,22 +54,22 @@ public class CCServicesTest extends OFBi
         // populate test data
         configFile = "paymentTest.properties";
         creditAmount = new BigDecimal("234.00");
-        emailAddr = delegator.makeValue("ContactMech", UtilMisc.toMap("infoString","test@hansbakker.com"));
+        emailAddr = delegator.makeValue("ContactMech", UtilMisc.toMap("infoString", "test@hansbakker.com"));
         orderId = "testOrder1000";
-        creditCard = delegator.makeValue("CreditCard", UtilMisc.toMap("cardType","CCT_VISA",
-                "expireDate","12/2008",  // mm/yyyy, gets converted to mm/yy
-                "cardNumber","4111111111111111"));
-        billingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap("toName","The customer Name",
-                "address1","The customer billingAddress1",
-                "address2","The customer billingAddress2",
-                "city","The customer city",
+        creditCard = delegator.makeValue("CreditCard", UtilMisc.toMap("cardType", "CCT_VISA",
+                "expireDate", "12/2008", // mm/yyyy, gets converted to mm/yy
+                "cardNumber", "4111111111111111"));
+        billingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap("toName", "The customer Name",
+                "address1", "The customer billingAddress1",
+                "address2", "The customer billingAddress2",
+                "city", "The customer city",
                 "stateProvinceGeoId", "NLD"));
-        shippingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap("toName","The customer Name",
-                "address1","The customer shippingStreet1",
-                "address2","The customer shippingStreet2",
-                "city","The customer city",
+        shippingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap("toName", "The customer Name",
+                "address1", "The customer shippingStreet1",
+                "address2", "The customer shippingStreet2",
+                "city", "The customer city",
                 "stateProvinceGeoId", "NLD",
-                "postalCode","12345"));
+                "postalCode", "12345"));
         pbOrder = UtilMisc.<String, Object>toMap("OrderFrequencyCycle", "M",
                 "OrderFrequencyInterval", "3",
                 "TotalNumberPayments", "4");
@@ -78,7 +78,7 @@ public class CCServicesTest extends OFBi
     /*
      * Check the authorisation
      */
-    public void testAuth() throws Exception{
+    public void testAuth() throws Exception {
         Debug.logInfo("=====[testAuth] starting....", module);
         try {
             Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap("paymentConfig", configFile,
@@ -86,12 +86,11 @@ public class CCServicesTest extends OFBi
                     "creditCard", creditCard,
                     "billingAddress", billingAddress,
                     "shippingAddress", shippingAddress,
-                    "orderId", orderId
-           );
+                    "orderId", orderId);
             serviceInput.put("processAmount", new BigDecimal("200.00"));
 
             // run the service (make sure in payment
-            Map<String, Object> result = dispatcher.runSync("clearCommerceCCAuth",serviceInput);
+            Map<String, Object> result = dispatcher.runSync("clearCommerceCCAuth", serviceInput);
 
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
@@ -99,7 +98,7 @@ public class CCServicesTest extends OFBi
             TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
             TestCase.assertNotNull("Service returned null for parameter authResult.", result.get("authResult"));
 
-            if ((Boolean.TRUE).equals((Boolean) result.get("authResult"))) { // returnCode ok?
+            if ((Boolean.TRUE).equals(result.get("authResult"))) { // returnCode ok?
                 Debug.logInfo("[testAuth] Error Messages from ClearCommerce:" + result.get("internalRespMsgs"), module);
                 TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
             }
@@ -109,10 +108,11 @@ public class CCServicesTest extends OFBi
         }
 
     }
+
     /*
      * Check the credit action: to deduct a certain amount of a credit card.
      */
-    public void testCredit() throws Exception{
+    public void testCredit() throws Exception {
         Debug.logInfo("=====[testCCredit] starting....", module);
         try {
             Map<String, Object> serviceMap = UtilMisc.<String, Object>toMap("paymentConfig", configFile,
@@ -122,7 +122,7 @@ public class CCServicesTest extends OFBi
                     "creditCard", creditCard,
                     "creditAmount", new BigDecimal("200.00"));
             // run the service
-            Map<String, Object> result = dispatcher.runSync("clearCommerceCCCredit",serviceMap);
+            Map<String, Object> result = dispatcher.runSync("clearCommerceCCCredit", serviceMap);
 
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
@@ -130,7 +130,7 @@ public class CCServicesTest extends OFBi
             TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
             TestCase.assertNotNull("Service returned null for parameter creditResult.", result.get("creditResult"));
 
-            if ((Boolean.FALSE).equals((Boolean) result.get("creditResult"))) {          // returnCode ok?
+            if ((Boolean.FALSE).equals(result.get("creditResult"))) { // returnCode ok?
                 Debug.logInfo("[testCCCredit] Error Messages from ClearCommerce: " + result.get("internalRespMsgs"), module);
                 TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
             }
@@ -139,6 +139,7 @@ public class CCServicesTest extends OFBi
         }
 
     }
+
     /*
      * Test Purchase subscription
      */
@@ -150,8 +151,8 @@ public class CCServicesTest extends OFBi
                     "creditAmount", creditAmount,
                     "billToEmail", emailAddr,
                     "creditCard", creditCard,
-                    "pbOrder", pbOrder);  // if supplied, the crediting is for a subscription and credit by period is managed by ClearCommerce
-                       
+                    "pbOrder", pbOrder); // if supplied, the crediting is for a subscription and credit by period is managed by ClearCommerce
+
             serviceMap.put("creditAmount", new BigDecimal("200.00"));
 
             // run the service
@@ -160,10 +161,10 @@ public class CCServicesTest extends OFBi
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
             Debug.logInfo("[testPurchaseDescription] responseMessage: " + responseMessage, module);
-            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);  // service completed ok?
+            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage); // service completed ok?
             TestCase.assertNotNull("Service returned null for parameter creditResult.", result.get("creditResult"));
 
-            if ((Boolean.FALSE).equals((Boolean) result.get("creditResult"))) {          // returnCode ok?
+            if ((Boolean.FALSE).equals(result.get("creditResult"))) { // returnCode ok?
                 Debug.logInfo("[testPurchaseSubscription] Error Messages from ClearCommerce: " + result.get("internalRespMsgs"), module);
                 TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
             }
@@ -177,42 +178,46 @@ public class CCServicesTest extends OFBi
      */
     public void testFreeSubscription() throws Exception {
 
-            // not communicate with CC.
+        // not communicate with CC.
     }
+
     /*
      * Test cancel subscription
      */
     public void testCancelSubscription() throws Exception {
-       /* from the API doc:
-       After the Engine receives and processes an internally-managed periodic billing order, the
-order cannot be modified. An order can only be cancelled. If, for example, the credit card
-associated with a recurring order expires and a payment is rejected, the order must be
-cancelled. If the order is to be resumed, a new recurring order must be submitted.
---> Orders are cancelled by using the Store Administrator Tool.
-
-    So cannot by program.
-       */
+        /*
+         * from the API doc: After the Engine receives and processes an
+         * internally-managed periodic billing order, the order cannot be modified. An
+         * order can only be cancelled. If, for example, the credit card associated with
+         * a recurring order expires and a payment is rejected, the order must be
+         * cancelled. If the order is to be resumed, a new recurring order must be
+         * submitted. --> Orders are cancelled by using the Store Administrator Tool.
+         * 
+         * So cannot by program.
+         */
     }
+
     /*
      * Test Query subscription transaction status
      */
-    public void testCCReport() throws Exception{
+    public void testCCReport() throws Exception {
         Debug.logInfo("=====[testReport] starting....", module);
         try {
 
-            Map<String, Object> serviceMap = UtilMisc.<String, Object>toMap("orderId", "4488668f-2db0-3002-002b-0003ba1d84d5",
+            Map<String, Object> serviceMap = UtilMisc.<String, Object>toMap("orderId",
+                    "4488668f-2db0-3002-002b-0003ba1d84d5",
                     "paymentConfig", configFile);
 
             // run the service
-            Map<String, Object> result = dispatcher.runSync("clearCommerceCCReport",serviceMap);
+            Map<String, Object> result = dispatcher.runSync("clearCommerceCCReport", serviceMap);
 
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
             Debug.logInfo("[testPurchaseDescription] responseMessage: " + responseMessage, module);
-            TestCase.assertEquals("Reporting service", ModelService.RESPOND_SUCCESS, responseMessage);  // service completed ok?
+            TestCase.assertEquals("Reporting service", ModelService.RESPOND_SUCCESS, responseMessage); // service completed ok?
             TestCase.assertNotNull("Service returned null for parameter creditResult.", result.get("creditResult"));
 
-            if ((Boolean.FALSE).equals((Boolean) result.get("creditResult"))) {          // returnCode ok?
+            if ((Boolean.FALSE).equals(result.get("creditResult"))) { // returnCode ok?
                 Debug.logInfo("[testReport] Error Messages from ClearCommerce: " + result.get("internalRespMsgs"), module);
                 TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
             }