Skip to content

Commit 21dc88b

Browse files
committed
Merge pull request AuthorizeNet#32 from arktseytlin/master
Removing CP/CNP reference and fixing unit tests
2 parents eb30b86 + a37f195 commit 21dc88b

15 files changed

+98
-237
lines changed

anet_java_sdk.properties

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# populate this file and put it into your home directory either named as
22
# anet_java_sdk.properties or build.properties
3-
api.login.id=API_LOGIN_ID
4-
transaction.key=TRANSACTION_KEY
5-
# card present transactions currently require different credentials.
6-
cp.api.login.id=CP_API_LOGIN_ID
7-
cp.transaction.key=CP_TRANSACTION_KEY
8-
md5.hash.key=HASH_KEY
9-
http.proxyHost=HOST
10-
http.proxyPort=PORT
11-
http.ProxyUse=false
12-
https.proxyHost=HOST
13-
https.proxyPort=PORT
14-
https.proxyUse=false
3+
api.login.id=ANET_API_LOGIN
4+
transaction.key=ANET_API_KEY
5+
md5.hash.key=ANET_API_HASH_KEY
6+
http.proxyHost=internet.visa.com
7+
http.proxyPort=80
8+
http.ProxyUse=true
9+
https.proxyHost=internet.visa.com
10+
https.proxyPort=443
11+
https.proxyUse=true

src/main/java/net/authorize/util/Constants.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ public final class Constants {
1313

1414
public static final String ENV_API_LOGINID = "API_LOGIN_ID";
1515
public static final String ENV_TRANSACTION_KEY = "TRANSACTION_KEY";
16-
public static final String ENV_CP_API_LOGINID = "CP_API_LOGIN_ID";
17-
public static final String ENV_CP_TRANSACTION_KEY = "CP_TRANSACTION_KEY";
1816
public static final String ENV_MD5_HASHKEY = "MD5_HASH_KEY";
1917

2018
public static final String PROP_API_LOGINID = "api.login.id";
2119
public static final String PROP_TRANSACTION_KEY = "transaction.key";
22-
public static final String PROP_CP_API_LOGINID = "cp.api.login.id";
23-
public static final String PROP_CP_TRANSACTION_KEY = "cp.transaction.key";
2420
public static final String PROP_MD5_HASHKEY = "md5.hash.key";
2521
}

src/test/java/net/authorize/MerchantTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public void createMerchant() {
1414

1515
@Test
1616
public void setMerchantPartialAuth() {
17-
Assert.assertFalse(merchant.isAllowPartialAuth());
18-
merchant.setAllowPartialAuth(true);
19-
Assert.assertTrue(merchant.isAllowPartialAuth());
17+
boolean currentValue = merchant.isAllowPartialAuth();
18+
merchant.setAllowPartialAuth(!currentValue);
19+
Assert.assertTrue(merchant.isAllowPartialAuth()!=currentValue);
2020
}
2121

2222
}

src/test/java/net/authorize/UnitTestData.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
public abstract class UnitTestData {
2626
protected static String apiLoginID ;
2727
protected static String transactionKey ;
28-
protected static String cp_apiLoginID ;
29-
protected static String cp_transactionKey ;
3028
protected static String merchantMD5Key ;
3129
protected static Merchant merchant = null;
3230

@@ -164,22 +162,18 @@ public abstract class UnitTestData {
164162
//getPropertyFromNames get the value from properties file or environment
165163
apiLoginID = getPropertyFromNames(Constants.ENV_API_LOGINID, Constants.PROP_API_LOGINID);
166164
transactionKey = getPropertyFromNames(Constants.ENV_TRANSACTION_KEY, Constants.PROP_TRANSACTION_KEY);
167-
cp_apiLoginID = getPropertyFromNames(Constants.ENV_CP_API_LOGINID, Constants.PROP_CP_API_LOGINID);
168-
cp_transactionKey = getPropertyFromNames(Constants.ENV_CP_TRANSACTION_KEY, Constants.PROP_CP_TRANSACTION_KEY);
169165
merchantMD5Key = getPropertyFromNames(Constants.ENV_MD5_HASHKEY, Constants.PROP_MD5_HASHKEY);
170166

171167
if ((null == apiLoginID) ||
172-
(null == transactionKey) ||
173-
(null == cp_apiLoginID) ||
174-
(null == cp_transactionKey))
168+
(null == transactionKey) )
175169
{
176170
throw new IllegalArgumentException("LoginId and/or TransactionKey have not been set.");
177171
}
178172
else
179173
{
180174
net.authorize.util.LogHelper.info( logger,
181-
"PropertyValues: ApiLoginId:'%s', TransactionKey:'%s', CPApiLoginId:'%s', CPTransactionKey:'%s', MD5Key:'%s' ",
182-
apiLoginID, transactionKey, cp_apiLoginID, cp_transactionKey, merchantMD5Key);
175+
"PropertyValues: ApiLoginId:'%s', TransactionKey:'%s', MD5Key:'%s' ",
176+
apiLoginID, transactionKey, merchantMD5Key);
183177
merchant = Merchant.createMerchant( Environment.SANDBOX, apiLoginID, transactionKey);
184178
}
185179
if ( !internetAccessible()) {

src/test/java/net/authorize/aim/cardpresent/functional_test/SimpleAuthCaptureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void setUp() {
5151
creditCard.setTrack1("%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?");
5252
creditCard.setTrack2(";4111111111111111=1803101000020000831?");
5353

54-
merchant = Merchant.createMerchant(Environment.SANDBOX, cp_apiLoginID, cp_transactionKey);
54+
merchant = Merchant.createMerchant(Environment.SANDBOX, apiLoginID, transactionKey);
5555
merchant.setDeviceType(DeviceType.VIRTUAL_TERMINAL);
5656
merchant.setMarketType(MarketType.RETAIL);
5757
merchant.setMD5Value(merchantMD5Key);

src/test/java/net/authorize/api/controller/sampletest/ArbSubscriptionSampleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void subscriptionSamples() {
5757

5858
//Common code to set for all requests
5959
ApiOperationBase.setEnvironment(environment);
60-
ApiOperationBase.setMerchantAuthentication(cnpMerchantAuthenticationType);
60+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
6161

6262
//create
6363
ARBCreateSubscriptionRequest createRequest = new ARBCreateSubscriptionRequest();
@@ -104,7 +104,7 @@ public void subscriptionSamples() {
104104

105105
//cancel
106106
ARBCancelSubscriptionRequest cancelRequest = new ARBCancelSubscriptionRequest();
107-
cancelRequest.setMerchantAuthentication(cnpMerchantAuthenticationType);
107+
cancelRequest.setMerchantAuthentication(merchantAuthenticationType);
108108
cancelRequest.setRefId(refId);
109109
cancelRequest.setSubscriptionId(subscriptionId);
110110
//explicitly setting up the merchant id and environment

src/test/java/net/authorize/api/controller/sampletest/CreateCustomerProfileFromTransactionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void createCustomerProfileFromTransactionSample()
5050
{
5151
//Common code to set for all requests
5252
ApiOperationBase.setEnvironment(environment);
53-
ApiOperationBase.setMerchantAuthentication(cnpMerchantAuthenticationType);
53+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
5454

5555
CreateCustomerProfileFromTransactionRequest request = new CreateCustomerProfileFromTransactionRequest();
5656
request.setTransId(createTransactionAndReturnId());

src/test/java/net/authorize/api/controller/sampletest/CreateTransactionTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@
99
import org.junit.BeforeClass;
1010
import org.junit.Test;
1111

12+
import net.authorize.api.contract.v1.BankAccountType;
1213
import net.authorize.api.contract.v1.CreateCustomerProfileFromTransactionRequest;
1314
import net.authorize.api.contract.v1.CreateCustomerProfileResponse;
1415
import net.authorize.api.contract.v1.CreateTransactionRequest;
1516
import net.authorize.api.contract.v1.CreateTransactionResponse;
17+
import net.authorize.api.contract.v1.CreditCardTrackType;
1618
import net.authorize.api.contract.v1.CreditCardType;
1719
import net.authorize.api.contract.v1.CustomerDataType;
20+
import net.authorize.api.contract.v1.EncodingType;
21+
import net.authorize.api.contract.v1.EncryptedTrackDataType;
22+
import net.authorize.api.contract.v1.EncryptionAlgorithmType;
23+
import net.authorize.api.contract.v1.KeyBlock;
24+
import net.authorize.api.contract.v1.KeyManagementScheme;
25+
import net.authorize.api.contract.v1.KeyManagementScheme.DUKPT;
26+
import net.authorize.api.contract.v1.KeyValue;
1827
import net.authorize.api.contract.v1.MessageTypeEnum;
1928
import net.authorize.api.contract.v1.MessagesType;
2029
import net.authorize.api.contract.v1.OpaqueDataType;
@@ -26,6 +35,7 @@
2635
import net.authorize.api.controller.base.ApiOperationBase;
2736
import net.authorize.api.controller.test.ApiCoreTestBase;
2837
import net.authorize.data.Customer;
38+
import net.authorize.data.xml.BankAccount;
2939

3040
public class CreateTransactionTest extends ApiCoreTestBase {
3141

@@ -98,12 +108,12 @@ public void createTransactionWithPayPal()
98108
Assert.assertNotNull(response.getTransactionResponse().getSecureAcceptance());
99109
Assert.assertFalse(response.getTransactionResponse().getSecureAcceptance().getSecureAcceptanceUrl().isEmpty());
100110
}
101-
111+
102112
private CreateTransactionResponse createAndValidate(String transactionType, PaymentType paymentType)
103113
{
104114
//Common code to set for all requests
105115
ApiOperationBase.setEnvironment(environment);
106-
ApiOperationBase.setMerchantAuthentication(cnpMerchantAuthenticationType);
116+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
107117

108118
TransactionRequestType requestInternal = new TransactionRequestType();
109119
requestInternal.setTransactionType(transactionType);

src/test/java/net/authorize/api/controller/test/ApiCoreTestBase.java

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,10 @@ public abstract class ApiCoreTestBase {
7575
//protected static Environment environment = Environment.HOSTED_VM;
7676
protected static Environment environment = Environment.SANDBOX;
7777

78-
static Merchant cnpMerchant = null;
79-
static Merchant cpMerchant = null;
80-
static String CnpApiLoginIdKey = null;
81-
static String CnpTransactionKey = null;
82-
static String CnpMd5HashKey = null;
83-
static String CpApiLoginIdKey = null;
84-
static String CpTransactionKey = null;
85-
static String CpMd5HashKey = null;
78+
static Merchant merchant = null;
79+
static String apiLoginIdKey = null;
80+
static String transactionKey = null;
81+
static String md5HashKey = null;
8682

8783
DatatypeFactory datatypeFactory = null;
8884
GregorianCalendar pastDate = null;
@@ -95,8 +91,7 @@ public abstract class ApiCoreTestBase {
9591
protected int counter = 0;
9692
protected String counterStr = null;
9793

98-
protected MerchantAuthenticationType cnpMerchantAuthenticationType = null;
99-
protected MerchantAuthenticationType cpMerchantAuthenticationType = null;
94+
protected MerchantAuthenticationType merchantAuthenticationType = null;
10095

10196
protected ARBSubscriptionType arbSubscriptionOne = null;
10297
protected ARBSubscriptionType arbSubscriptionTwo = null;
@@ -124,37 +119,29 @@ public abstract class ApiCoreTestBase {
124119

125120
static {
126121
//getPropertyFromNames get the value from properties file or environment
127-
CnpApiLoginIdKey = UnitTestData.getPropertyFromNames(Constants.ENV_API_LOGINID, Constants.PROP_API_LOGINID);
128-
CnpTransactionKey = UnitTestData.getPropertyFromNames(Constants.ENV_TRANSACTION_KEY, Constants.PROP_TRANSACTION_KEY);
129-
CnpMd5HashKey = null;
130-
CpApiLoginIdKey = UnitTestData.getPropertyFromNames(Constants.ENV_CP_API_LOGINID, Constants.PROP_CP_API_LOGINID);
131-
CpTransactionKey = UnitTestData.getPropertyFromNames(Constants.ENV_CP_TRANSACTION_KEY, Constants.PROP_CP_TRANSACTION_KEY);
132-
CpMd5HashKey = UnitTestData.getPropertyFromNames(Constants.ENV_MD5_HASHKEY, Constants.PROP_MD5_HASHKEY);
122+
apiLoginIdKey = UnitTestData.getPropertyFromNames(Constants.ENV_API_LOGINID, Constants.PROP_API_LOGINID);
123+
transactionKey = UnitTestData.getPropertyFromNames(Constants.ENV_TRANSACTION_KEY, Constants.PROP_TRANSACTION_KEY);
124+
md5HashKey = UnitTestData.getPropertyFromNames(Constants.ENV_MD5_HASHKEY, Constants.PROP_MD5_HASHKEY);
133125

134126
//require only one cnp or cp merchant keys
135-
if ((null != CnpApiLoginIdKey && null != CnpTransactionKey) ||
136-
(null != CpApiLoginIdKey && null != CpTransactionKey))
127+
if ((null != apiLoginIdKey && null != transactionKey) )
137128
{
138-
logger.debug("At least one of CardPresent or CardNotPresent merchant keys are present.");
129+
logger.debug("Merchant keys are present.");
139130
}
140131
else
141132
{
142133
throw new IllegalArgumentException(
143134
"LoginId and/or TransactionKey have not been set. " +
144-
"At least one of CardPresent or CardNotPresent merchant keys are required.");
135+
"Merchant keys are required.");
145136
}
146137

147-
if (null != CnpApiLoginIdKey && null != CnpTransactionKey)
138+
if (null != apiLoginIdKey && null != transactionKey)
148139
{
149-
cnpMerchant = Merchant.createMerchant( environment, CnpApiLoginIdKey, CnpTransactionKey);
140+
merchant = Merchant.createMerchant( environment, apiLoginIdKey, transactionKey);
150141
}
151-
if (null != CpApiLoginIdKey && null != CpTransactionKey)
142+
if ( null == merchant )
152143
{
153-
cpMerchant = Merchant.createMerchant( environment, CpApiLoginIdKey, CpTransactionKey);
154-
}
155-
if ( null == cnpMerchant && null == cpMerchant)
156-
{
157-
Assert.fail("None of the cardPresent or cardNotPresent merchant logins have been set");
144+
Assert.fail("Merchant login is not set");
158145
}
159146

160147
errorMessages = new HashMap<String, String>();
@@ -194,14 +181,10 @@ public void setUp() throws Exception {
194181
nowDate = new GregorianCalendar();
195182
futureDate = new GregorianCalendar(2020, 12, 31);
196183

197-
cnpMerchantAuthenticationType = new MerchantAuthenticationType() ;
198-
cnpMerchantAuthenticationType.setName(CnpApiLoginIdKey);
199-
cnpMerchantAuthenticationType.setTransactionKey(CnpTransactionKey);
184+
merchantAuthenticationType = new MerchantAuthenticationType() ;
185+
merchantAuthenticationType.setName(apiLoginIdKey);
186+
merchantAuthenticationType.setTransactionKey(transactionKey);
200187

201-
cpMerchantAuthenticationType = new MerchantAuthenticationType() ;
202-
cpMerchantAuthenticationType.setName(CpApiLoginIdKey);
203-
cpMerchantAuthenticationType.setTransactionKey(CpTransactionKey);
204-
205188
// merchantAuthenticationType.setSessionToken(getRandomString("SessionToken"));
206189
// merchantAuthenticationType.setPassword(getRandomString("Password"));
207190
// merchantAuthenticationType.setMobileDeviceId(getRandomString("MobileDevice"));

src/test/java/net/authorize/api/controller/test/ArbSubscriptionTest.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,13 @@ public void tearDown() throws Exception {
5555

5656
@Test
5757
public void testGetSubscriptionList() throws DatatypeConfigurationException {
58-
59-
//String subscriptionId = "42";
60-
61-
String subscriptionId = createSubscription(cnpMerchantAuthenticationType);
62-
ARBSubscriptionStatusEnum newStatus = getSubscription(cnpMerchantAuthenticationType, subscriptionId);
58+
String subscriptionId = createSubscription(merchantAuthenticationType);
59+
ARBSubscriptionStatusEnum newStatus = getSubscription(merchantAuthenticationType, subscriptionId);
6360
Assert.assertEquals(ARBSubscriptionStatusEnum.ACTIVE, newStatus);
6461

6562
LogHelper.info(logger, "Getting Subscription List for SubscriptionId: %s", subscriptionId);
6663

67-
ARBGetSubscriptionListRequest listRequest = setupSubscriptionListRequest(cnpMerchantAuthenticationType);
64+
ARBGetSubscriptionListRequest listRequest = setupSubscriptionListRequest(merchantAuthenticationType);
6865
ARBGetSubscriptionListResponse listResponse = executeTestRequestWithSuccess(listRequest, ARBGetSubscriptionListController.class, environment);
6966

7067
LogHelper.info( logger, "Subscription Count: %d", listResponse.getTotalNumInResultSet());
@@ -82,19 +79,19 @@ public void testGetSubscriptionList() throws DatatypeConfigurationException {
8279
if ( subsId == aSubscription.getId()) { found = true;}
8380
}
8481

85-
cancelSubscription(cnpMerchantAuthenticationType, subscriptionId);
82+
cancelSubscription(merchantAuthenticationType, subscriptionId);
8683
Assert.assertTrue(found);
8784
//validate the status of subscription to make sure it is in-activated
88-
ARBSubscriptionStatusEnum cancelStatus = getSubscription(cnpMerchantAuthenticationType, subscriptionId);
85+
ARBSubscriptionStatusEnum cancelStatus = getSubscription(merchantAuthenticationType, subscriptionId);
8986
Assert.assertEquals(ARBSubscriptionStatusEnum.CANCELED, cancelStatus);
9087
}
9188

9289
@Test
9390
public void testSubscription() throws Exception {
9491
//cache the result
95-
String subscriptionId = createSubscription(cnpMerchantAuthenticationType);
96-
getSubscription(cnpMerchantAuthenticationType, subscriptionId);
97-
cancelSubscription(cnpMerchantAuthenticationType, subscriptionId);
92+
String subscriptionId = createSubscription(merchantAuthenticationType);
93+
getSubscription(merchantAuthenticationType, subscriptionId);
94+
cancelSubscription(merchantAuthenticationType, subscriptionId);
9895
}
9996

10097
private ARBGetSubscriptionListRequest setupSubscriptionListRequest(MerchantAuthenticationType merchantAuthentication) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy