svn commit: r759247 [2/2] - in /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting: ./ agreement/ finaccount/ invoice/ payment/ period/ tax/ thirdparty/authorizedotnet/ thirdparty/clearcommerce/ thirdparty/paypal/ thirdparty/valuelink/ thirdp...

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

svn commit: r759247 [2/2] - in /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting: ./ agreement/ finaccount/ invoice/ payment/ period/ tax/ thirdparty/authorizedotnet/ thirdparty/clearcommerce/ thirdparty/paypal/ thirdparty/valuelink/ thirdp...

doogie-3
Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java Fri Mar 27 16:59:58 2009
@@ -40,7 +40,7 @@
  * Services for Payment maintenance
  */
 public class PaymentMethodServices {
-
+
     public final static String module = PaymentMethodServices.class.getName();
 
     /**
@@ -91,12 +91,12 @@
         result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
         return result;
     }
-
+
     public static Map makeExpireDate(DispatchContext ctx, Map context) {
         Map result = new HashMap();
         String expMonth = (String) context.get("expMonth");
         String expYear = (String) context.get("expYear");
-
+
         StringBuffer expDate = new StringBuffer();
         expDate.append(expMonth);
         expDate.append("/");
@@ -265,10 +265,10 @@
         if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin)) {
             return ServiceUtil.returnError("Party Id [" + partyId + "] is not the owner of payment method [" + paymentMethodId + "] and does not have permission to change it.");
         }
-
+
         // do some more complicated/critical validation...
         List messages = new LinkedList();
-
+
         // first remove all spaces from the credit card number
         String updatedCardNumber = StringUtil.removeSpaces((String) context.get("cardNumber"));
         if (updatedCardNumber.startsWith("*")) {
@@ -282,14 +282,14 @@
             }
             origMaskedNumber = origMaskedNumber + origCardNumber.substring(cardLength);
             Debug.log(origMaskedNumber);
-
+
             // compare the two masked numbers
             if (updatedCardNumber.equals(origMaskedNumber)) {
                 updatedCardNumber = origCardNumber;
             }
         }
         context.put("cardNumber", updatedCardNumber);
-
+
         if (!UtilValidate.isCardMatch((String) context.get("cardType"), (String) context.get("cardNumber")))
             messages.add((String) context.get("cardNumber")
                     + UtilValidate.isCreditCardPrefixMsg + (String) context.get("cardType") + UtilValidate.isCreditCardSuffixMsg
@@ -310,7 +310,7 @@
             newPmId = delegator.getNextSeqId("PaymentMethod");
         } catch (IllegalArgumentException e) {
             return ServiceUtil.returnError("ERROR: Could not update credit card info (id generation failure)");
-
+
         }
 
         newPm.set("partyId", partyId);
@@ -534,8 +534,8 @@
         if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin)) {
             return ServiceUtil.returnError("Party Id [" + partyId + "] is not the owner of payment method [" + paymentMethodId + "] and does not have permission to change it.");
         }
-
-
+
+
         // card number (masked)
         String cardNumber = StringUtil.removeSpaces((String) context.get("cardNumber"));
         if (cardNumber.startsWith("*")) {
@@ -752,7 +752,7 @@
         if (!paymentMethod.getString("partyId").equals(partyId) && !security.hasEntityPermission("PAY_INFO", "_UPDATE", userLogin)) {
             return ServiceUtil.returnError("Party Id [" + partyId + "] is not the owner of payment method [" + paymentMethodId + "] and does not have permission to change it.");
         }
-
+
         newPm = GenericValue.create(paymentMethod);
         toBeStored.add(newPm);
         newEa = GenericValue.create(eftAccount);

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java Fri Mar 27 16:59:58 2009
@@ -48,11 +48,11 @@
  * Worker methods for Payments
  */
 public class PaymentWorker {
-
+
     public static final String module = PaymentWorker.class.getName();
     private static int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
     private static int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
-
+
     /** @deprecated */
     public static void getPartyPaymentMethodValueMaps(PageContext pageContext, String partyId, Boolean showOld, String paymentMethodValueMapsAttr) {
         GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
@@ -64,7 +64,7 @@
     public static List getPartyPaymentMethodValueMaps(GenericDelegator delegator, String partyId) {
         return(getPartyPaymentMethodValueMaps(delegator, partyId, false));
     }
-
+
     public static List getPartyPaymentMethodValueMaps(GenericDelegator delegator, String partyId, Boolean showOld) {
         List paymentMethodValueMaps = new LinkedList();
         try {
@@ -104,7 +104,7 @@
 
         ServletRequest request = pageContext.getRequest();
         Map results = getPaymentMethodAndRelated(request, partyId);
-
+
         if (results.get("paymentMethod") != null) pageContext.setAttribute(paymentMethodAttr, results.get("paymentMethod"));
         if (results.get("creditCard") != null) pageContext.setAttribute(creditCardAttr, results.get("creditCard"));
         if (results.get("eftAccount") != null) pageContext.setAttribute(eftAccountAttr, results.get("eftAccount"));
@@ -113,11 +113,11 @@
         if (results.get("donePage") != null) pageContext.setAttribute(donePageAttr, results.get("donePage"));
         if (results.get("tryEntity") != null) pageContext.setAttribute(tryEntityAttr, results.get("tryEntity"));
     }
-
+
     public static Map getPaymentMethodAndRelated(ServletRequest request, String partyId) {
         GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
         Map results = new HashMap();
-
+
         Boolean tryEntity = Boolean.TRUE;
         if (request.getAttribute("_ERROR_MESSAGE_") != null) tryEntity = false;
 
@@ -180,10 +180,10 @@
         }
 
         results.put("tryEntity", new Boolean(tryEntity));
-
+
         return results;
     }
-
+
     public static GenericValue getPaymentAddress(GenericDelegator delegator, String partyId) {
         List paymentAddresses = null;
         try {
@@ -194,7 +194,7 @@
         } catch (GenericEntityException e) {
             Debug.logError(e, "Trouble getting PartyContactMechPurpose entity list", module);
         }
-
+
         // get the address for the primary contact mech
         GenericValue purpose = EntityUtil.getFirst(paymentAddresses);
         GenericValue postalAddress = null;
@@ -205,10 +205,10 @@
                 Debug.logError(e, "Trouble getting PostalAddress record for contactMechId: " + purpose.getString("contactMechId"), module);
             }
         }
-
+
         return postalAddress;
     }
-
+
     /**
      * Returns the total from a list of Payment entities
      *
@@ -238,23 +238,23 @@
     public static BigDecimal getPaymentApplied(GenericDelegator delegator, String paymentId) {
         return getPaymentApplied(delegator, paymentId, false);
     }
-
+
     public static BigDecimal getPaymentApplied(GenericDelegator delegator, String paymentId, Boolean actual) {
         if (delegator == null) {
             throw new IllegalArgumentException("Null delegator is not allowed in this method");
         }
-
+
         GenericValue payment = null;
         try {
             payment = delegator.findByPrimaryKey("Payment", UtilMisc.toMap("paymentId", paymentId));
         } catch (GenericEntityException e) {
             Debug.logError(e, "Problem getting Payment", module);
         }
-
+
         if (payment == null) {
             throw new IllegalArgumentException("The paymentId passed does not match an existing payment");
         }
-
+
         return getPaymentApplied(payment, actual);
     }
     /**
@@ -291,7 +291,7 @@
     public static BigDecimal getPaymentApplied(GenericValue payment) {
         return getPaymentApplied(payment, false);
     }
-
+
     /**
      * Method to return the total amount of an payment which is applied to a payment
      * @param payment GenericValue object of the Payment
@@ -345,14 +345,14 @@
         if (delegator == null) {
             throw new IllegalArgumentException("Null delegator is not allowed in this method");
         }
-
+
         GenericValue payment = null;
         try {
             payment = delegator.findByPrimaryKey("Payment", UtilMisc.toMap("paymentId", paymentId));
         } catch (GenericEntityException e) {
             Debug.logError(e, "Problem getting Payment", module);
         }
-
+
         if (payment == null) {
             throw new IllegalArgumentException("The paymentId passed does not match an existing payment");
         }

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java Fri Mar 27 16:59:58 2009
@@ -36,7 +36,7 @@
 
 public class PeriodServices {
     public static String module = PeriodServices.class.getName();
-
+
     /* find the date of the last closed CustomTimePeriod, or, if none available, the earliest date available of any
      * CustomTimePeriod
      */
@@ -45,16 +45,16 @@
         String organizationPartyId = (String) context.get("organizationPartyId"); // input parameters
         String periodTypeId = (String) context.get("periodTypeId");
         Timestamp findDate = (Timestamp) context.get("findDate");
-
+
         // default findDate to now
         if (findDate == null) {
             findDate = UtilDateTime.nowTimestamp();
         }
-
+
         Timestamp lastClosedDate = null;          // return parameters
         GenericValue lastClosedTimePeriod = null;
         Map<String, Object> result = ServiceUtil.returnSuccess();
-
+
         try {
             // try to get the ending date of the most recent accounting time period before findDate which has been closed
             List<EntityCondition> findClosedConditions = UtilMisc.toList(EntityCondition.makeConditionMap("organizationPartyId", organizationPartyId),
@@ -85,7 +85,7 @@
                     return ServiceUtil.returnError("Cannot get a starting date for net income");
                 }
             }
-
+
             result.put("lastClosedTimePeriod", lastClosedTimePeriod);  // ok if this is null - no time periods have been closed
             result.put("lastClosedDate", lastClosedDate);  // should have a value - not null
             return result;

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java Fri Mar 27 16:59:58 2009
@@ -72,7 +72,7 @@
 
         if (quantity == null) quantity = ONE_BASE;
         BigDecimal amount = basePrice.multiply(quantity);
-
+
         BigDecimal taxTotal = ZERO_BASE;
         BigDecimal taxPercentage = ZERO_BASE;
         BigDecimal priceWithTax = basePrice;
@@ -84,7 +84,7 @@
             if (productStore == null) {
                 throw new IllegalArgumentException("Could not find ProductStore with ID [" + productStoreId + "] for tax calculation");
             }
-
+
             if ("Y".equals(productStore.getString("showPricesWithVatTax"))) {
                 Set taxAuthoritySet = FastSet.newInstance();
                 if (productStore.get("vatTaxAuthPartyId") == null) {
@@ -94,11 +94,11 @@
                     GenericValue taxAuthority = delegator.findByPrimaryKeyCache("TaxAuthority", UtilMisc.toMap("taxAuthGeoId", productStore.get("vatTaxAuthGeoId"), "taxAuthPartyId", productStore.get("vatTaxAuthPartyId")));
                     taxAuthoritySet.add(taxAuthority);
                 }
-
+
                 if (taxAuthoritySet.size() == 0) {
                     throw new IllegalArgumentException("Could not find any Tax Authories for store with ID [" + productStoreId + "] for tax calculation; the store settings may need to be corrected.");
                 }
-
+
                 List taxAdustmentList = getTaxAdjustments(delegator, product, productStore, null, billToPartyId, taxAuthoritySet, basePrice, amount, shippingPrice, ZERO_BASE);
                 if (taxAdustmentList.size() == 0) {
                     // this is something that happens every so often for different products and such, so don't blow up on it...
@@ -121,11 +121,11 @@
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
         }
-
+
         // round to 2 decimal places for display/etc
         taxTotal = taxTotal.setScale(salestaxFinalDecimals, salestaxRounding);
         priceWithTax = priceWithTax.setScale(salestaxFinalDecimals, salestaxRounding);
-
+
         Map result = ServiceUtil.returnSuccess();
         result.put("taxTotal", taxTotal);
         result.put("taxPercentage", taxPercentage);
@@ -162,11 +162,11 @@
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
         }
-
+
         if (productStore == null && payToPartyId == null) {
             throw new IllegalArgumentException("Could not find payToPartyId [" + payToPartyId + "] or ProductStore [" + productStoreId + "] for tax calculation");
         }
-
+
         // Setup the return lists.
         List orderAdjustments = FastList.newInstance();
         List itemAdjustments = FastList.newInstance();
@@ -219,7 +219,7 @@
         } else {
             Debug.logWarning("shippingAddress was null, adding nothing to taxAuthoritySet", module);
         }
-
+
         //Debug.logInfo("Tax calc geoIdSet before expand:" + geoIdSet + "; this is for shippingAddress=" + shippingAddress, module);
         // get the most granular, or all available, geoIds and then find parents by GeoAssoc with geoAssocTypeId="REGIONS" and geoIdTo=<granular geoId> and find the GeoAssoc.geoId
         geoIdSet = GeoWorker.expandGeoRegionDeep(geoIdSet, delegator);
@@ -258,7 +258,7 @@
                 EntityCondition.makeCondition("taxAuthPartyId", EntityOperator.EQUALS, "_NA_"),
                 EntityOperator.AND,
                 EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.EQUALS, "_NA_")));
-
+
         Iterator taxAuthorityIter = taxAuthoritySet.iterator();
         while (taxAuthorityIter.hasNext()) {
             GenericValue taxAuthority = (GenericValue) taxAuthorityIter.next();
@@ -283,7 +283,7 @@
                     GenericValue pcm = (GenericValue) pcmIter.next();
                     productCategoryIdSet.add(pcm.get("productCategoryId"));
                 }
-
+
                 if (productCategoryIdSet.size() == 0) {
                     productCategoryCond = EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, null);
                 } else {
@@ -331,7 +331,7 @@
                 if (orderPromotionsAmount != null && taxAuthorityRateProduct != null && (taxAuthorityRateProduct.get("taxPromotions") == null || (taxAuthorityRateProduct.get("taxPromotions") != null && taxAuthorityRateProduct.getBoolean("taxPromotions").booleanValue()))) {
                     taxable = taxable.add(orderPromotionsAmount);
                 }
-
+
                 if (taxable.compareTo(BigDecimal.ZERO) == 0) {
                     // this should make it less confusing if the taxable flag on the product is not Y/true, and there is no shipping and such
                     continue;
@@ -391,7 +391,7 @@
 
         return adjustments;
     }
-
+
     private static void handlePartyTaxExempt(GenericValue adjValue, Set billToPartyIdSet, String taxAuthGeoId, String taxAuthPartyId, BigDecimal taxAmount, Timestamp nowTimestamp, GenericDelegator delegator) throws GenericEntityException {
         Debug.logInfo("Checking for tax exemption : " + taxAuthGeoId + " / " + taxAuthPartyId, module);
         List ptiConditionList = UtilMisc.toList(

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=759247&r1=759246&r2=759247&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 Mar 27 16:59:58 2009
@@ -145,7 +145,7 @@
     public static Map ccRefund(DispatchContext ctx, Map context) {
         GenericDelegator delegator = ctx.getDelegator();
         GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
-
+
         GenericValue creditCard = null;
         try {
             creditCard = delegator.getRelatedOne("CreditCard",orderPaymentPreference);
@@ -153,12 +153,12 @@
             Debug.logError(e, module);
             return ServiceUtil.returnError("Unable to obtain cc information from payment preference");
         }
-
+
         GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
         if (authTransaction == null) {
             return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot Refund");
         }
-
+
         context.put("creditCard",creditCard);
         context.put("authTransaction",authTransaction);
         Map results = ServiceUtil.returnSuccess();
@@ -224,7 +224,7 @@
                     if (ServiceUtil.isError(reply)) {
                         return reply;
                     }
-
+
                     results = ServiceUtil.returnSuccess();
                     results.putAll( processRefundTransResult(reply) );
                     return results;
@@ -508,7 +508,7 @@
                 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;

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=759247&r1=759246&r2=759247&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 Fri Mar 27 16:59:58 2009
@@ -263,22 +263,22 @@
         return processReAuthResponse(reauthResponseDoc);
 
     }
-
+
     public static Map ccReport(DispatchContext dctx, Map context) {
-
+
         // configuration file
         String paymentConfig = (String) context.get("paymentConfig");
         if (UtilValidate.isEmpty(paymentConfig)) {
             paymentConfig = "payment.properties";
         }
-
+
         // orderId
         String orderId = (String) context.get("orderId");
         if (UtilValidate.isEmpty(orderId)) {
             return ServiceUtil.returnError("orderId is required......");
         }
-
-
+
+
         // EngineDocList
         Document requestDocument = UtilXml.makeEmptyXmlDocument("EngineDocList");
         Element engineDocListElement = requestDocument.getDocumentElement();
@@ -299,7 +299,7 @@
         }
         else
             UtilXml.addChildElementValue(engineDocElement, "GroupId", orderId, requestDocument);
-
+
 
         // EngineDocList.EngineDoc.User
         Element userElement = UtilXml.addChildElement(engineDocElement, "User", requestDocument);
@@ -343,7 +343,7 @@
             clientId.setAttribute("DataType", "S32");
         }
         UtilXml.addChildElementValue(value,"OrderId", orderId, requestDocument);
-
+
         Debug.set(Debug.VERBOSE, true);
         Document reportResponseDoc = null;
         try {
@@ -352,9 +352,9 @@
             return ServiceUtil.returnError(cce.getMessage());
         }
         Debug.set(Debug.VERBOSE, true);
-
+
         Map result = ServiceUtil.returnSuccess();
-
+
         return result;
     }
 
@@ -707,7 +707,7 @@
             Element total = UtilXml.addChildElementValue(pbOrderElement, "TotalNumberPayments", (String) pbOrder.get("TotalNumberPayments"), requestDocument);
             total.setAttribute("DataType", "S32");
         }
-
+
         return requestDocument;
     }
 

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java Fri Mar 27 16:59:58 2009
@@ -50,7 +50,7 @@
     public GenericDelegator delegator = null;
     public static final String DISPATCHER_NAME = "test-dispatcher";
     public LocalDispatcher dispatcher = null;
-
+
     // test data
     protected GenericValue emailAddr = null;
     protected String orderId = null;
@@ -60,7 +60,7 @@
     protected Map pbOrder = null;
     protected BigDecimal creditAmount = null;
     protected String configFile = null;
-
+
     public CCServicesTest(String name) {
         super(name);
     }
@@ -97,7 +97,7 @@
                 "OrderFrequencyInterval", "3",
                 "TotalNumberPayments", "4");
     }
-
+
     protected void tearDown() throws Exception {
         dispatcher.deregister();
     }
@@ -117,15 +117,15 @@
                     "orderId", orderId
             );
             serviceInput.put("processAmount", new BigDecimal("200.00"));
-
+
             // run the service (make sure in payment
             Map result = dispatcher.runSync("clearCommerceCCAuth",serviceInput);
-
+
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
             Debug.logInfo("[testCCAuth] responseMessage: " + responseMessage, module);
             TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
-
+
             if (((Boolean) result.get("authResult")).equals(new Boolean(false))) {          // returnCode ok?
                 Debug.logInfo("[testAuth] Error Messages from ClearCommerce: " + result.get("internalRespMsgs"), module);
                 TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
@@ -134,7 +134,7 @@
         } catch (GenericServiceException ex) {
             TestCase.fail(ex.getMessage());
         }
-
+
     }
     /*
      * Check the credit action: to deduct a certain amount of a credit card.
@@ -152,12 +152,12 @@
             );
             // run the service
             Map result = dispatcher.runSync("clearCommerceCCCredit",serviceMap);
-
+
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
             Debug.logInfo("[testCCCredit] responseMessage: " + responseMessage, module);
             TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
-
+
             if (((Boolean) result.get("creditResult")).equals(new Boolean(false))) {          // returnCode ok?
                 Debug.logInfo("[testCCCredit] Error Messages from ClearCommerce: " + result.get("internalRespMsgs"), module);
                 TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
@@ -165,7 +165,7 @@
         } catch (GenericServiceException ex) {
             TestCase.fail(ex.getMessage());
         }
-
+
     }
     /*
      * Test Purchase subscription
@@ -173,7 +173,7 @@
     public void testPurchaseSubscription() throws Exception {
         Debug.logInfo("=====[testPurchaseSubscription] starting....", module);
         try {
-
+
             Map serviceMap = UtilMisc.toMap(
                     "paymentConfig", configFile,
                     "orderId", orderId,
@@ -186,7 +186,7 @@
 
             // run the service
             Map result = dispatcher.runSync("clearCommerceCCCredit",serviceMap);
-
+
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
             Debug.logInfo("[testPurchaseDescription] responseMessage: " + responseMessage, module);
@@ -199,12 +199,12 @@
             TestCase.fail(ex.getMessage());
         }
     }
-
+
     /*
      * Test Free subscription
      */
     public void testFreeSubscription() throws Exception {
-
+
             // not communicate with CC.
     }
     /*
@@ -227,15 +227,15 @@
     public void testCCReport() throws Exception{
         Debug.logInfo("=====[testReport] starting....", module);
         try {
-
+
             Map serviceMap = UtilMisc.toMap(
                     "orderId", "4488668f-2db0-3002-002b-0003ba1d84d5",
                     "paymentConfig", configFile
             );
-
+
             // run the service
             Map result = dispatcher.runSync("clearCommerceCCReport",serviceMap);
-
+
             // verify the results
             String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
             Debug.logInfo("[testPurchaseDescription] responseMessage: " + responseMessage, module);

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java Fri Mar 27 16:59:58 2009
@@ -57,21 +57,21 @@
 
 
 public class PayPalEvents {
-
+
     public static final String resource = "AccountingUiLabels";
     public static final String resourceErr = "AccountingErrorUiLabels";
     public static final String commonResource = "CommonUiLabels";
     public static final String module = PayPalEvents.class.getName();
-
+
     /** Initiate PayPal Request */
     public static String callPayPal(HttpServletRequest request, HttpServletResponse response) {
         Locale locale = UtilHttp.getLocale(request);
         GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
-
+
         // get the orderId
         String orderId = (String) request.getAttribute("orderId");
-
+
         // get the order header
         GenericValue orderHeader = null;
         try {
@@ -81,10 +81,10 @@
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingOrderHeader", locale));
             return "error";
         }
-
+
         // get the order total
         String orderTotal = orderHeader.getBigDecimal("grandTotal").toPlainString();
-
+
         // get the product store
         GenericValue productStore = ProductStoreWorker.getProductStore(request);
 
@@ -93,44 +93,44 @@
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingMerchantConfiguration", locale));
             return "error";
         }
-
+
         // get the payment properties file
         GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_PAYPAL", null, true);
         String configString = null;
         if (paymentConfig != null) {
             configString = paymentConfig.getString("paymentPropertiesPath");
         }
-
+
         if (configString == null) {
             configString = "payment.properties";
         }
-
+
         // get the company name
         String company = UtilFormatOut.checkEmpty(productStore.getString("companyName"), "");
-
+
         // create the item name
         String itemName = UtilProperties.getMessage(resource, "AccountingOrderNr", locale) + orderId + " " +
                                  (company != null ? UtilProperties.getMessage(commonResource, "CommonFrom", locale) + " "+ company : "");
         String itemNumber = "0";
-
+
         // get the redirect url
         String redirectUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.redirect");
-
+
         // get the notify url
         String notifyUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.notify");
-
+
         // get the return urls
         String returnUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.return");
-
+
         // get the cancel return urls
         String cancelReturnUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.cancelReturn");
-
+
         // get the image url
         String imageUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.image");
-
+
         // get the paypal account
         String payPalAccount = UtilProperties.getPropertyValue(configString, "payment.paypal.business");
-
+
         if (UtilValidate.isEmpty(redirectUrl)
             || UtilValidate.isEmpty(notifyUrl)
             || UtilValidate.isEmpty(returnUrl)
@@ -141,7 +141,7 @@
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingMerchantConfiguration", locale));
             return "error";
         }
-
+
         // create the redirect string
         Map <String, Object> parameters = new LinkedHashMap <String, Object>();
         parameters.put("cmd", "_xclick");
@@ -157,13 +157,13 @@
         parameters.put("image_url", imageUrl);
         parameters.put("no_note", "1");        // no notes allowed in paypal (not passed back)
         parameters.put("no_shipping", "1");    // no shipping address required (local shipping used)
-
+
         String encodedParameters = UtilHttp.urlEncodeArgs(parameters, false);
         String redirectString = redirectUrl + "?" + encodedParameters;
-
+
         // set the order in the session for cancelled orders
         request.getSession().setAttribute("PAYPAL_ORDER", orderId);
-
+
         // redirect to paypal
         try {
             response.sendRedirect(redirectString);
@@ -172,16 +172,16 @@
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsConnectingWithPayPal", locale));
             return "error";
         }
-
+
         return "success";
     }
-
+
     /** PayPal Call-Back Event */
     public static String payPalIPN(HttpServletRequest request, HttpServletResponse response) {
         Locale locale = UtilHttp.getLocale(request);
         GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
-
+
         // get the product store
         GenericValue productStore = ProductStoreWorker.getProductStore(request);
         if (productStore == null) {
@@ -189,10 +189,10 @@
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingMerchantConfiguration", locale));
             return "error";
         }
-
+
         // get the payment properties file
         GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_PAYPAL", null, true);
-
+
         String configString = null;
         if (paymentConfig != null) {
             configString = paymentConfig.getString("paymentPropertiesPath");
@@ -201,23 +201,23 @@
         if (configString == null) {
             configString = "payment.properties";
         }
-
+
         // get the confirm URL
         String confirmUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.confirm");
-
+
         // get the redirect URL
         String redirectUrl = UtilProperties.getPropertyValue(configString, "payment.paypal.redirect");
-
+
         if (confirmUrl == null || redirectUrl == null) {
             Debug.logError("Payment properties is not configured properly, no confirm URL defined!", module);
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingMerchantConfiguration", locale));
             return "error";
         }
-
+
         // first verify this is valid from PayPal
         Map <String, Object> parametersMap = UtilHttp.getParameterMap(request);
         parametersMap.put("cmd", "_notify-validate");
-
+
         // send off the confirm request
         String confirmResp = null;
 
@@ -252,7 +252,7 @@
                 Debug.logError("### Param: " + name + " => " + value, module);
             }
         }
-
+
         // get the user
         GenericValue userLogin = null;
         String userLoginId = request.getParameter("custom");
@@ -265,7 +265,7 @@
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingAuthenticationUser", locale));
             return "error";
         }
-
+
         // get the orderId
         String orderId = request.getParameter("invoice");
 
@@ -357,16 +357,16 @@
 
         return "success";
     }
-
+
     /** Event called when customer cancels a paypal order */
     public static String cancelPayPalOrder(HttpServletRequest request, HttpServletResponse response) {
         Locale locale = UtilHttp.getLocale(request);
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
-
+
         // get the stored order id from the session
         String orderId = (String) request.getSession().getAttribute("PAYPAL_ORDER");
-
+
         // attempt to start a transaction
         boolean beganTransaction = false;
         try {
@@ -374,10 +374,10 @@
         } catch (GenericTransactionException gte) {
             Debug.logError(gte, "Unable to begin transaction", module);
         }
-
+
         // cancel the order
         boolean okay = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId);
-
+
         if (okay) {
             try {
                 TransactionUtil.commit(beganTransaction);
@@ -391,15 +391,15 @@
                 Debug.logError(gte, "Unable to rollback transaction", module);
             }
         }
-
+
         // attempt to release the offline hold on the order (workflow)
         if (okay)
             OrderChangeHelper.releaseInitialOrderHold(dispatcher, orderId);
-
+
         request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.previousPayPalOrderHasBeenCancelled", locale));
         return "success";
     }
-
+
     private static boolean setPaymentPreferences(GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, String orderId, HttpServletRequest request) {
         Debug.logVerbose("Setting payment prefrences..", module);
         List <GenericValue> paymentPrefs = null;
@@ -421,7 +421,7 @@
         }
         return true;
     }
-
+
     private static boolean setPaymentPreference(LocalDispatcher dispatcher, GenericValue userLogin, GenericValue paymentPreference, HttpServletRequest request) {
         Locale locale = UtilHttp.getLocale(request);
         String paymentDate = request.getParameter("payment_date");
@@ -483,7 +483,7 @@
             Debug.logError(e, "Cannot set payment preference/payment info", module);
             return false;
         }
-
+
         // create a payment record too
         Map <String, Object> results = null;
         try {

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java Fri Mar 27 16:59:58 2009
@@ -687,7 +687,7 @@
         BigDecimal amountBd = new BigDecimal(amount);
         return amountBd.movePointLeft(2);
     }
-
+
     public String getCurrency(String currency) {
         return "840"; // todo make this multi-currency
     }

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java Fri Mar 27 16:59:58 2009
@@ -1449,7 +1449,7 @@
             uiLabelMap.addBottomResourceBundle("CommonUiLabels");
             answerMap.put("uiLabelMap", uiLabelMap);
             answerMap.put("locale", locale);
-
+
             String bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
             if (UtilValidate.isEmpty(bodyScreenLocation)) {
                 bodyScreenLocation = ProductStoreWorker.getDefaultProductStoreEmailScreenLocation(emailType);

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java Fri Mar 27 16:59:58 2009
@@ -414,7 +414,7 @@
             // other error
             Debug.logWarning("In PayflowPro failing authorization; respCode/RESULT=" + respCode + ", avsCheckOkay=" + avsCheckOkay + ", cvv2CheckOkay=" + cvv2CheckOkay + "; AUTHCODE=" + parameters.get("AUTHCODE"), module);
             result.put("authResult", Boolean.FALSE);
-
+
             // now check certain special conditions and report back through the generic params
             if ("12".equals(respCode)) {
                 result.put("resultDeclined", Boolean.TRUE);
@@ -797,7 +797,7 @@
 already validated for a previous Validate Authentication transaction
 
  */
-
+
 /* RESULT for communication errors (less than 0)
  *
 -1 Failed to connect to host

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/SelectRespServlet.java Fri Mar 27 16:59:58 2009
@@ -59,20 +59,20 @@
  * WorldPay Select Pro Response Servlet
  */
 public class SelectRespServlet extends SelectServlet implements SelectDefs {
-
+
     public static final String module = SelectRespServlet.class.getName();
     protected JPublishWrapper jp = null;
 
     protected void doRequest(SelectServletRequest request, SelectServletResponse response) throws ServletException, IOException {
         Debug.logInfo("Response received from worldpay..", module);
-
+
         String localLocaleStr = request.getParameter("M_localLocale");
         String webSiteId = request.getParameter("M_webSiteId");
         String delegatorName = request.getParameter("M_delegatorName");
         String dispatchName = request.getParameter("M_dispatchName");
         String userLoginId = request.getParameter("M_userLoginId");
         String confirmTemplate = request.getParameter("M_confirmTemplate");
-
+
         // get the ServletContext
         ServletContext context = (ServletContext) request.getAttribute("servletContext");
         if (this.jp == null) {
@@ -81,15 +81,15 @@
                 this.jp = new JPublishWrapper(context);
             }
         }
-
+
         // get the delegator
         GenericDelegator delegator = GenericDelegator.getGenericDelegator(delegatorName);
-
+
         // get the dispatcher
         ServiceDispatcher serviceDisp = ServiceDispatcher.getInstance(dispatchName, delegator);
         DispatchContext dctx = serviceDisp.getLocalContext(dispatchName);
         LocalDispatcher dispatcher = dctx.getDispatcher();
-
+
         // get the userLogin
         GenericValue userLogin = null;
         try {
@@ -98,11 +98,11 @@
             Debug.logError(e, "Cannot get admin UserLogin entity", module);
             callError(request);
         }
-
+
         // get the client locale
         List localeSplit = StringUtil.split(localLocaleStr, "_");
         Locale localLocale = new Locale((String) localeSplit.get(0), (String) localeSplit.get(1));
-
+
         // get the properties file
         String configString = null;
         try {
@@ -115,11 +115,11 @@
         if (configString == null)
         configString = "payment.properties";
         Debug.logInfo("Got the payment configuration", module);
-
+
         String orderId = request.getParameter(SelectDefs.SEL_cartId);
         String authAmount = request.getParameter(SelectDefs.SEL_authAmount);
         String transStatus = request.getParameter(SelectDefs.SEL_transStatus);
-
+
         // get the order header
         GenericValue orderHeader = null;
         try {
@@ -128,7 +128,7 @@
             Debug.logError(e, "Cannot get the order header for the returned orderId", module);
             callError(request);
         }
-
+
         // the order total MUST match the auth amount or we do not process
         BigDecimal wpTotal = new BigDecimal(authAmount);
         BigDecimal orderTotal = orderHeader.getBigDecimal("grandTotal");
@@ -138,18 +138,18 @@
                 callError(request);
             }
         }
-
+
         // store some stuff for calling existing events
         HttpSession session = request.getSession(true);
         session.setAttribute("userLogin", userLogin);
-
+
         request.setAttribute("delegator", delegator);
         request.setAttribute("dispatcher", dispatcher);
         request.setAttribute("orderId", orderId);
         request.setAttribute("notifyEmail", request.getParameter("M_notifyEmail"));
         request.setAttribute("confirmEmail", request.getParameter("M_confirmEmail"));
         request.setAttribute("_CONTROL_PATH_", request.getParameter("M_controlPath"));
-
+
         // attempt to start a transaction
         boolean beganTransaction = false;
         try {
@@ -157,7 +157,7 @@
         } catch (GenericTransactionException gte) {
             Debug.logError(gte, "Unable to begin transaction", module);
         }
-
+
         boolean okay = false;
         if (transStatus.equalsIgnoreCase("Y")) {
             // order was approved
@@ -168,12 +168,12 @@
             Debug.logInfo("Order #" + orderId + " cancelled", module);
             okay = OrderChangeHelper.cancelOrder(dispatcher, userLogin, orderId);
         }
-
+
         if (okay) {
             // set the payment preference
             okay = setPaymentPreferences(delegator, userLogin, orderId, request);
         }
-
+
         if (okay) {
             try {
                 TransactionUtil.commit(beganTransaction);
@@ -187,10 +187,10 @@
                 Debug.logError(gte, "Unable to rollback transaction", module);
             }
         }
-
+
         // attempt to release the offline hold on the order (workflow)
         OrderChangeHelper.releaseInitialOrderHold(dispatcher, orderId);
-
+
         // call the email confirm service
         Map emailContext = UtilMisc.toMap("orderId", orderId);
         try {
@@ -198,7 +198,7 @@
         } catch (GenericServiceException e) {
             Debug.logError(e, "Problems sending email confirmation", module);
         }
-
+
         // set up the output stream for the response
         response.setContentType("text/html");
         ServletOutputStream out = response.getOutputStream();
@@ -214,7 +214,7 @@
         out.println(content);
         out.flush();
     }
-
+
     private boolean setPaymentPreferences(GenericDelegator delegator, GenericValue userLogin, String orderId, ServletRequest request) {
         List paymentPrefs = null;
         boolean okay = true;
@@ -233,7 +233,7 @@
         }
         return okay;
     }
-
+
     private boolean setPaymentPreference(GenericValue paymentPreference, GenericValue userLogin, ServletRequest request) {
         String transId = request.getParameter(SelectDefs.SEL_transId);
         String transTime = request.getParameter(SelectDefs.SEL_transTime);
@@ -242,10 +242,10 @@
         String authCode = request.getParameter(SelectDefs.SEL_authCode);
         String authAmount = request.getParameter(SelectDefs.SEL_authAmount);
         String rawAuthMessage = request.getParameter(SelectDefs.SEL_rawAuthMessage);
-
+
         // Need these for create payment service
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
-
+
         if (transStatus.equalsIgnoreCase("Y")) {
             paymentPreference.set("authCode", authCode);
             paymentPreference.set("statusId", "PAYMENT_RECEIVED");
@@ -254,14 +254,14 @@
         }
         Long transTimeLong = new Long(transTime);
         java.sql.Timestamp authDate = new java.sql.Timestamp(transTimeLong.longValue());
-
+
         paymentPreference.set("avsCode", avsCode);
         paymentPreference.set("authRefNum", transId);
         paymentPreference.set("authDate", authDate);
         paymentPreference.set("authFlag", transStatus);
         paymentPreference.set("authMessage", rawAuthMessage);
         paymentPreference.set("maxAmount", new BigDecimal(authAmount));
-
+
         // create a payment record too -- this method does not store the object so we must here
         Map results = null;
         try {
@@ -278,7 +278,7 @@
             request.setAttribute("_ERROR_MESSAGE_", (String) results.get(ModelService.ERROR_MESSAGE));
             return false;
         }
-
+
         try {
             paymentPreference.store();
             paymentPreference.getDelegator().create(paymentPreference);
@@ -288,7 +288,7 @@
         }
         return true;
     }
-
+
     private void callError(ServletRequest request) throws ServletException {
         Enumeration e = request.getParameterNames();
         Debug.logError("###### SelectRespServlet Error:", module);

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java?rev=759247&r1=759246&r2=759247&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java Fri Mar 27 16:59:58 2009
@@ -53,27 +53,27 @@
  * WorldPay Select Pro Events/Services
  */
 public class WorldPayEvents {
-
+
     public static final String module = WorldPayEvents.class.getName();
-
+
     public static String worldPayRequest(HttpServletRequest request, HttpServletResponse response) {
         ServletContext application = ((ServletContext) request.getAttribute("servletContext"));
         GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
-
+
         // we need the websiteId for the correct properties file
         String webSiteId = CatalogWorker.getWebSiteId(request);
-
+
         // get the orderId from the request, stored by previous event(s)
         String orderId = (String) request.getAttribute("orderId");
-
+
         if (orderId == null) {
             Debug.logError("Problems getting orderId, was not found in request", module);
             request.setAttribute("_ERROR_MESSAGE_", "<li>OrderID not found, please contact customer service.");
             return "error";
         }
-
+
         // get the order header for total and other information
         GenericValue orderHeader = null;
         try {
@@ -83,7 +83,7 @@
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting order information, please contact customer service.");
             return "error";
         }
-
+
         // get the contact address to pass over
         GenericValue contactAddress = null;
         try {
@@ -95,7 +95,7 @@
         } catch (GenericEntityException e) {
             Debug.logWarning(e, "Problems getting order contact information", module);
         }
-
+
         // get the country geoID
         GenericValue countryGeo = null;
         if (contactAddress != null) {
@@ -105,7 +105,7 @@
                 Debug.logWarning(e, "Problems getting country geo entity", module);
             }
         }
-
+
         // string of customer's name
         String name = null;
         if (contactAddress != null) {
@@ -114,7 +114,7 @@
             else if (contactAddress.get("toName") != null && contactAddress.getString("toName").length() > 0)
                 name = contactAddress.getString("toName");
         }
-
+
         // build an address string
         StringBuffer address = null;
         if (contactAddress != null) {
@@ -138,11 +138,11 @@
                 address.append(contactAddress.getString("stateProvinceGeoId").trim());
             }
         }
-
+
         // get the telephone number to pass over
         String phoneNumber = null;
         GenericValue phoneContact = null;
-
+
         // get the email address to pass over
         String emailAddress = null;
         GenericValue emailContact = null;
@@ -154,32 +154,32 @@
         } catch (GenericEntityException e) {
             Debug.logWarning(e, "Problems getting order email address", module);
         }
-
+
         // get the product store
         GenericValue productStore = null;
         try {
             productStore = orderHeader.getRelatedOne("ProductStore");
         } catch (GenericEntityException e) {
             Debug.logError(e, "Unable to get ProductStore from OrderHeader", module);
-
+
         }
         if (productStore == null) {
             Debug.logError("ProductStore is null", module);
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service.");
             return "error";
         }
-
+
         // get the payment properties file
         GenericValue paymentConfig = ProductStoreWorker.getProductStorePaymentSetting(delegator, productStore.getString("productStoreId"), "EXT_WORLDPAY", null, true);
         String configString = null;
         if (paymentConfig != null) {
             configString = paymentConfig.getString("paymentPropertiesPath");
         }
-
+
         if (configString == null) {
             configString = "payment.properties";
         }
-
+
         String instId = UtilProperties.getPropertyValue(configString, "payment.worldpay.instId", "NONE");
         String authMode = UtilProperties.getPropertyValue(configString, "payment.worldpay.authMode", "A");
         String testMode = UtilProperties.getPropertyValue(configString, "payment.worldpay.testMode", "100");
@@ -189,19 +189,19 @@
         String timeout = UtilProperties.getPropertyValue(configString, "payment.worldpay.timeout", "0");
         String company = UtilFormatOut.checkEmpty(productStore.getString("companyName"), "");
         String defCur = UtilFormatOut.checkEmpty(productStore.getString("defaultCurrencyUomId"), "USD");
-
+
         // order description
         String description = "Order #" + orderId;
         if (company != null && company.length() > 0)
         description = description + " from " + company;
-
+
         // check the instId - very important
         if (instId == null || instId.equals("NONE")) {
             Debug.logError("Worldpay InstId not found, cannot continue", module);
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service.");
             return "error";
         }
-
+
         int instIdInt = 0;
         try {
             instIdInt = Integer.parseInt(instId);
@@ -210,7 +210,7 @@
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting merchant configuration, please contact customer service.");
             return "error";
         }
-
+
         // check the testMode
         int testModeInt = -1;
         if (testMode != null) {
@@ -221,7 +221,7 @@
                 testModeInt = 0;
             }
         }
-
+
         // create the purchase link
         String purchaseURL = null;
         HTTPURL link = null;
@@ -239,7 +239,7 @@
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service.");
             return "error";
         }
-
+
         // create the currency amount
         double orderTotal = orderHeader.getDouble("grandTotal").doubleValue();
         CurrencyAmount currencyAmount = null;
@@ -251,7 +251,7 @@
             request.setAttribute("_ERROR_MESSAGE_", "<li>Merchant Configuration Error, please contact customer service.");
             return "error";
         }
-
+
         // create a purchase token
         PurchaseToken token = null;
         try {
@@ -265,7 +265,7 @@
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problems creating a purchase token, please contact customer service.");
             return "error";
         }
-
+
         // set the auth/test modes
         try {
             token.setAuthorisationMode(authMode);
@@ -273,7 +273,7 @@
             Debug.logWarning(e, "Problems setting the authorization mode", module);
         }
         token.setTestMode(testModeInt);
-
+
         // set the token to the purchase link
         try {
             linkParms.setValue(SelectDefs.SEL_purchase, token.produce());
@@ -282,7 +282,7 @@
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problems producing purchase token, please contact customer service.");
             return "error";
         }
-
+
         // set the customer data in the link
         linkParms.setValue(SelectDefs.SEL_desc, description);
         linkParms.setValue(SelectDefs.SEL_name, name != null ? name : "");
@@ -291,7 +291,7 @@
         linkParms.setValue(SelectDefs.SEL_country, countryGeo.getString("geoCode"));
         linkParms.setValue(SelectDefs.SEL_tel, phoneNumber != null ? phoneNumber : "");
         linkParms.setValue(SelectDefs.SEL_email, emailAddress != null ? emailAddress : "");
-
+
         // set some optional data
         if (fixContact != null && fixContact.toUpperCase().startsWith("Y")) {
             linkParms.setValue(SelectDefs.SEL_fixContact, "Y");
@@ -299,7 +299,7 @@
         if (hideContact != null && hideContact.toUpperCase().startsWith("Y")) {
             linkParms.setValue("hideContact", "Y"); // why is this not in SelectDefs??
         }
-
+
         // now set some send-back parameters
         linkParms.setValue("M_controlPath", (String)request.getAttribute("_CONTROL_PATH_"));
         linkParms.setValue("M_userLoginId", userLogin.getString("userLoginId"));
@@ -308,7 +308,7 @@
         linkParms.setValue("M_webSiteId", webSiteId);
         linkParms.setValue("M_localLocale", UtilHttp.getLocale(request).toString());
         linkParms.setValue("M_confirmTemplate", confirmTemplate != null ? confirmTemplate : "");
-
+
         // redirect to worldpay
         try {
             response.sendRedirect(link.produce());
@@ -317,7 +317,7 @@
             request.setAttribute("_ERROR_MESSAGE_", "<li>Problems connecting with WorldPay, please contact customer service.");
             return "error";
         }
-
+
         return "success";
     }