[OFBiz] SVN: r7804 - in trunk/applications/accounting: . config servicedef src/org/ofbiz/accounting/thirdparty/clearcommerce
hansbak@svn.ofbiz.org
hansbak at svn.ofbiz.org
Thu Jun 15 23:38:05 CDT 2006
Author: hansbak
Date: 2006-06-15 23:37:21 -0500 (Thu, 15 Jun 2006)
New Revision: 7804
Added:
trunk/applications/accounting/config/paymentTest.properties
trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java
Modified:
trunk/applications/accounting/config/AccountingUiLabels.properties
trunk/applications/accounting/config/AccountingUiLabels_nl.properties
trunk/applications/accounting/config/payment.properties
trunk/applications/accounting/ofbiz-component.xml
trunk/applications/accounting/servicedef/services_clearcommerce.xml
trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
Log:
test extension to the clearCommerce payment interface. Added subscription and reporting Reporting is returning normally but does not yet return a report. Question outstanding with HSBC
Modified: trunk/applications/accounting/config/AccountingUiLabels.properties
===================================================================
--- trunk/applications/accounting/config/AccountingUiLabels.properties 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/config/AccountingUiLabels.properties 2006-06-16 04:37:21 UTC (rev 7804)
@@ -20,15 +20,6 @@
de=German
nl=Dutch
-# items to be moved to the common uiLabels
-CommonNoPostalAddress=No postal address defined
-CommonTelephoneAbbr=Tel
-CommonWebsite=Website
-CommonFinBankName=Bank
-CommonRouting=Routing
-CommonBankAccntNrAbbr=AccntNr
-CommonQty=Qty
-
AccountingPermissionError=Security Error\: to run ${methodShortDescription} you must have the ACCOUNTING${securityAction} or ACCOUNTING_ADMIN permission
AcctgGlPartyLabel=GL Party :
Modified: trunk/applications/accounting/config/AccountingUiLabels_nl.properties
===================================================================
--- trunk/applications/accounting/config/AccountingUiLabels_nl.properties 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/config/AccountingUiLabels_nl.properties 2006-06-16 04:37:21 UTC (rev 7804)
@@ -20,16 +20,6 @@
de=Duits
nl=Nederlands
-
-# items to be moved to the common uiLabels
-CommonNoPostalAddress=Geen postadres gedefinieerd
-CommonTelephoneAbbr=Tel
-CommonWebsite=Website
-CommonFinBankName=Bank
-CommonRouting=Routing
-CommonBankAccntNrAbbr=Rek.Nr
-CommonQty=Aan- tal
-
AccountingPermissionError=Toegangs fout\: Om ${methodShortDescription} te gebruiken moet u de ACCOUNTING${securityAction} of ACCOUNTING_ADMIN permissie bezitten
AcctgGlPartyLabel=GL Partij :
Modified: trunk/applications/accounting/config/payment.properties
===================================================================
--- trunk/applications/accounting/config/payment.properties 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/config/payment.properties 2006-06-16 04:37:21 UTC (rev 7804)
@@ -106,6 +106,7 @@
payment.clearcommerce.groupId=myGroup
# Account information
+payment.clearcommerce.clientId=[ClearCommerce clientId]
payment.clearcommerce.username=[ClearCommerce username]
payment.clearcommerce.password=[ClearCommerce password]
payment.clearcommerce.alias=[ClearCommerce alias]
Added: trunk/applications/accounting/config/paymentTest.properties
===================================================================
--- trunk/applications/accounting/config/paymentTest.properties 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/config/paymentTest.properties 2006-06-16 04:37:21 UTC (rev 7804)
@@ -0,0 +1,51 @@
+#####################################################################
+# $Id: $
+#
+# Copyright 2001-2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#####################################################################
+
+################################
+# this configuration file only used for jUnit tests
+################################
+
+
+############################################
+# ClearCommerce Test Configuration
+############################################
+
+# Useful for tagging/grouping transactions
+payment.clearcommerce.sourceId=
+payment.clearcommerce.groupId=
+
+# Account information
+payment.clearcommerce.clientId=372
+payment.clearcommerce.username=testuser
+payment.clearcommerce.password=XXXXXXXX
+payment.clearcommerce.alias=UK11113322GBP
+payment.clearcommerce.effectiveAlias=
+
+# Process mode (Y: approve / N: decline / R: random / P: production) // Y,N,R = test mode Y approve always
+payment.clearcommerce.processMode=P
+
+# Server URL of the payment processor
+payment.clearcommerce.serverURL=https://www.uat.apixml.netq.hsbc.com
+
+# Enable Card Verification Methods (CID, CVC, CVV2)
+payment.clearcommerce.enableCVM=N
+
+# currency code 826 is UK
+payment.clearcommerce.currencyCode=826
+
+
Property changes on: trunk/applications/accounting/config/paymentTest.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ "Date Rev Author URL Id"
Name: svn:eol-style
+ native
Modified: trunk/applications/accounting/ofbiz-component.xml
===================================================================
--- trunk/applications/accounting/ofbiz-component.xml 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/ofbiz-component.xml 2006-06-16 04:37:21 UTC (rev 7804)
@@ -40,7 +40,7 @@
<entity-resource type="data" reader-name="seed" loader="main" location="data/AccountingTypeData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/UsTaxAccountGroups.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/AccountingSecurityData.xml"/>
- <entity-resource type="data" reader-name="demo" loader="main" location="data/DemoGeneralChartOfAccounts.xml"/>
+ <entity-resource type="data" reader-name="seed" loader="main" location="data/DemoGeneralChartOfAccounts.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/DemoOrganizationData.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/PaymentsInvoices.xml"/>
Modified: trunk/applications/accounting/servicedef/services_clearcommerce.xml
===================================================================
--- trunk/applications/accounting/servicedef/services_clearcommerce.xml 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/servicedef/services_clearcommerce.xml 2006-06-16 04:37:21 UTC (rev 7804)
@@ -1,29 +1,25 @@
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
- * Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+$Id$
+
+Copyright 2001-2006 The Apache Software Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations
+under the License.
-->
-
+
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/services.xsd">
- <description>Accounting Services</description>
+ <description>Clear Commerce Services</description>
<vendor>OFBiz</vendor>
<version>1.0</version>
@@ -49,8 +45,19 @@
<implements service="paymentRefundInterface"/>
</service>
<service name="clearCommerceCCCredit" engine="java"
- location="org.ofbiz.accounting.thirdparty.clearcommerce.CCPaymentServices" invoke="ccCredit">
+ location="org.ofbiz.accounting.thirdparty.clearcommerce.CCPaymentServices" invoke="ccCredit">
<description>ClearCommerce Credit Card Credit</description>
<implements service="ccCreditInterface"/>
+ <attribute name="orderId" type="String" mode="IN" optional="false"/>
+ <attribute name="pbOrder" type="Map" mode="IN" optional="true"/> <!-- map of the 3 values below -->
+ <attribute name="OrderFrequencyCycle" type="String" mode="IN" optional="true"/>
+ <attribute name="OrderFrequencyInterval" type="String" mode="IN" optional="true"/>
+ <attribute name="TotalNumberPayments" type="String" mode="IN" optional="true"/>
+
</service>
+ <service name="clearCommerceCCReport" engine="java"
+ location="org.ofbiz.accounting.thirdparty.clearcommerce.CCPaymentServices" invoke="ccReport">
+ <description>Reporting facility</description>
+ <implements service="ccAuthInterface"/>
+ </service>
</services>
Modified: trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java
===================================================================
--- trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java 2006-06-16 04:37:21 UTC (rev 7804)
@@ -60,7 +60,6 @@
public static Map ccAuth(DispatchContext dctx, Map context) {
-
Document authRequestDoc = buildPrimaryTxRequest(context, "PreAuth", (Double) context.get("processAmount"),
(String) context.get("orderId"));
@@ -71,7 +70,7 @@
return ServiceUtil.returnError(cce.getMessage());
}
- if (getMessageListMaxSev(authResponseDoc) > 4) {
+ if (getMessageListMaxSev(authResponseDoc) > 4) { // 5 and higher, process error from HSBC
Map result = ServiceUtil.returnSuccess();
result.put("authResult", new Boolean(false));
result.put("processAmount", new Double(0.00));
@@ -87,10 +86,13 @@
}
public static Map ccCredit(DispatchContext dctx, Map context) {
+ String action = new String("Credit");
+ if (context.get("pbOrder") != null) {
+ action = new String("Auth"); // required for periodic billing....
+ }
- Document creditRequestDoc = buildPrimaryTxRequest(context, "Credit", (Double) context.get("creditAmount"),
+ Document creditRequestDoc = buildPrimaryTxRequest(context, action, (Double) context.get("creditAmount"),
(String) context.get("referenceCode"));
-
Document creditResponseDoc = null;
try {
creditResponseDoc = sendRequest(creditRequestDoc, (String) context.get("paymentConfig"));
@@ -265,7 +267,102 @@
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();
+ UtilXml.addChildElementValue(engineDocListElement, "DocVersion", "1.0", requestDocument);
+ // EngineDocList.EngineDoc
+ Element engineDocElement = UtilXml.addChildElement(engineDocListElement, "EngineDoc", requestDocument);
+ UtilXml.addChildElementValue(engineDocElement, "ContentType", "ReportDoc", requestDocument);
+
+ String sourceId = UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.sourceId");
+ if (UtilValidate.isNotEmpty(sourceId)) {
+ UtilXml.addChildElementValue(engineDocElement, "SourceId", sourceId, requestDocument);
+ }
+
+ String groupId = UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.groupId");
+ if (UtilValidate.isNotEmpty(groupId)) {
+ UtilXml.addChildElementValue(engineDocElement, "GroupId", groupId, requestDocument);
+ }
+ else
+ UtilXml.addChildElementValue(engineDocElement, "GroupId", orderId, requestDocument);
+
+
+ // EngineDocList.EngineDoc.User
+ Element userElement = UtilXml.addChildElement(engineDocElement, "User", requestDocument);
+ UtilXml.addChildElementValue(userElement, "Name",
+ UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.username", ""), requestDocument);
+ UtilXml.addChildElementValue(userElement, "Password",
+ UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.password", ""), requestDocument);
+ UtilXml.addChildElementValue(userElement, "Alias",
+ UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.alias", ""), requestDocument);
+
+ String effectiveAlias = UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.effectiveAlias");
+ if (UtilValidate.isNotEmpty(effectiveAlias)) {
+ UtilXml.addChildElementValue(userElement, "EffectiveAlias", effectiveAlias, requestDocument);
+ }
+
+ // EngineDocList.EngineDoc.Instructions
+ 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);
+
+ // 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);
+ // 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);
+ start.setAttribute("DataType", "S32");
+ 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);
+ String clientIdConfig = UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.clientId");
+ if (UtilValidate.isNotEmpty(clientIdConfig)) {
+ Element clientId = UtilXml.addChildElementValue(value,"ClientId", clientIdConfig, requestDocument);
+ clientId.setAttribute("DataType", "S32");
+ }
+ UtilXml.addChildElementValue(value,"OrderId", orderId, requestDocument);
+
+ Debug.set(Debug.VERBOSE, true);
+ Document reportResponseDoc = null;
+ try {
+ reportResponseDoc = sendRequest(requestDocument, (String) context.get("paymentConfig"));
+ } catch (ClearCommerceException cce) {
+ return ServiceUtil.returnError(cce.getMessage());
+ }
+ Debug.set(Debug.VERBOSE, true);
+
+ Map result = ServiceUtil.returnSuccess();
+
+ return result;
+ }
+
+
private static Map processAuthResponse(Document responseDocument) {
Element engineDocElement = UtilXml.firstChildElement(responseDocument.getDocumentElement(), "EngineDoc");
@@ -596,6 +693,25 @@
// TODO: determine if adding OrderItemList is worthwhile - JFE 2004.02.14
+ Map pbOrder = (Map) context.get("pbOrder");
+ if (pbOrder != null) {
+ if (Debug.verboseOn()) Debug.logInfo("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);
+ 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) pbOrder.get("OrderFrequencyInterval"), requestDocument);
+ interval.setAttribute("DataType", "S32");
+ Element total = UtilXml.addChildElementValue(pbOrderElement, "TotalNumberPayments", (String) pbOrder.get("TotalNumberPayments"), requestDocument);
+ total.setAttribute("DataType", "S32");
+ }
+
return requestDocument;
}
@@ -750,11 +866,9 @@
}
private static Document sendRequest(Document requestDocument, String paymentConfig) throws ClearCommerceException {
-
if (UtilValidate.isEmpty(paymentConfig)) {
paymentConfig = "payment.properties";
}
-
String serverURL = UtilProperties.getPropertyValue(paymentConfig, "payment.clearcommerce.serverURL");
if (UtilValidate.isEmpty(serverURL)) {
throw new ClearCommerceException("Missing server URL; check your ClearCommerce configuration");
@@ -795,10 +909,10 @@
throw new ClearCommerceException("ClearCommerce connection problem", hce);
}
- // Note: if Debug.verboseOn(), HttpClient will log this...
- //if (Debug.verboseOn()) {
- // Debug.logVerbose("ClearCommerce response: " + response, module);
- //}
+ // Note: if Debug.verboseOn(), HttpClient will log this...set on with: Debug.set(Debug.VERBOSE, true);
+ // if (Debug.verboseOn()) {
+ // Debug.logVerbose("ClearCommerce response: " + response, module);
+ // }
Document responseDocument = null;
try {
@@ -810,7 +924,9 @@
} catch (IOException ioe) {
throw new ClearCommerceException("Error reading response Document from a String: " + ioe.getMessage());
}
-
+ 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;
}
Added: trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java
===================================================================
--- trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java 2006-06-16 01:04:20 UTC (rev 7803)
+++ trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java 2006-06-16 04:37:21 UTC (rev 7804)
@@ -0,0 +1,249 @@
+/*
+ * $Id: $
+ *
+ * Copyright 2001-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.ofbiz.accounting.thirdparty.clearcommerce;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.lang.Thread;
+
+import junit.framework.TestCase;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilXml;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.GenericDispatcher;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ModelService;
+
+public class CCServicesTest extends TestCase {
+
+ public static final String module = CCServicesTest.class.getName();
+ public static final String DELEGATOR_NAME = "test";
+ 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;
+ protected GenericValue creditCard = null;
+ protected GenericValue billingAddress = null;
+ protected GenericValue shippingAddress = null;
+ protected Map pbOrder = null;
+ protected Double creditAmount = null;
+ protected String configFile = null;
+
+ public CCServicesTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ this.delegator = GenericDelegator.getGenericDelegator(DELEGATOR_NAME);
+ dispatcher = new GenericDispatcher(DISPATCHER_NAME, delegator);
+
+ // populate test data
+ configFile = new String("paymentTest.properties");
+ creditAmount = new Double(234.00);
+ emailAddr = delegator.makeValue("ContactMech", UtilMisc.toMap(
+ "infoString","test at hansbakker.com"));
+ orderId = new String("testOrder1000");
+ creditCard = delegator.makeValue("CreditCard", UtilMisc.toMap(
+ "cardType","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",
+ "stateProvinceGeoId", "NLD",
+ "postalCode","12345"));
+ pbOrder = UtilMisc.toMap(
+ "OrderFrequencyCycle", "M",
+ "OrderFrequencyInterval", "3",
+ "TotalNumberPayments", "4");
+ }
+
+ protected void tearDown() throws Exception {
+ dispatcher.deregister();
+ }
+
+ /*
+ * Check the authorisation
+ */
+ public void qtestAuth() throws Exception{
+ Debug.logInfo("=====[testAuth] starting....", module);
+ try {
+ Map serviceInput = UtilMisc.toMap(
+ "paymentConfig", configFile,
+ "billToEmail", emailAddr,
+ "creditCard", creditCard,
+ "billingAddress", billingAddress,
+ "shippingAddress", shippingAddress,
+ "orderId", orderId
+ );
+ serviceInput.put("processAmount", new Double(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"));
+ }
+
+ } catch (GenericServiceException ex) {
+ TestCase.fail(ex.getMessage());
+ }
+
+ }
+ /*
+ * Check the credit action: to deduct a certain amount of a credit card.
+ */
+ public void qtestCredit() throws Exception{
+ Debug.logInfo("=====[testCCredit] starting....", module);
+ try {
+ Map serviceMap = UtilMisc.toMap(
+ "paymentConfig", configFile,
+ "orderId", orderId,
+ "creditAmount", creditAmount,
+ "billToEmail", emailAddr,
+ "creditCard", creditCard,
+ "creditAmount", new Double(200.00)
+ );
+ // 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"));
+ }
+ } catch (GenericServiceException ex) {
+ TestCase.fail(ex.getMessage());
+ }
+
+ }
+ /*
+ * Test Purchase subscription
+ */
+ public void qtestPurchaseSubscription() throws Exception {
+ Debug.logInfo("=====[testPurchaseSubscription] starting....", module);
+ try {
+
+ Map serviceMap = UtilMisc.toMap(
+ "paymentConfig", configFile,
+ "orderId", orderId,
+ "creditAmount", creditAmount,
+ "billToEmail", emailAddr,
+ "creditCard", creditCard,
+ "pbOrder", pbOrder // if supplied, the crediting is for a subscription and credit by period is managed by ClearCommerce
+ );
+ serviceMap.put("creditAmount", new Double(200.00));
+
+ // 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);
+ TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage); // service completed ok?
+ if (((Boolean) result.get("creditResult")).equals(new Boolean(false))) { // returnCode ok?
+ Debug.logInfo("[testPurchaseSubscription] Error Messages from ClearCommerce: " + result.get("internalRespMsgs"), module);
+ TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
+ }
+ } catch (GenericServiceException ex) {
+ TestCase.fail(ex.getMessage());
+ }
+ }
+
+ /*
+ * Test Free subscription
+ */
+ public void qtestFreeSubscription() throws Exception {
+
+ // 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.
+ */
+ }
+ /*
+ * Test Query subscription transaction status
+ */
+ 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);
+ TestCase.assertEquals("Reporting service", ModelService.RESPOND_SUCCESS, responseMessage); // service completed ok?
+ if (((Boolean) result.get("creditResult")).equals(new Boolean(false))) { // returnCode ok?
+ Debug.logInfo("[testReport] Error Messages from ClearCommerce: " + result.get("internalRespMsgs"), module);
+ TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
+ }
+ } catch (GenericServiceException ex) {
+ TestCase.fail(ex.getMessage());
+ }
+ }
+}
Property changes on: trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ "Date Rev Author URL Id"
Name: svn:eol-style
+ native
More information about the Svn
mailing list