Skip to content

Commit e39c176

Browse files
author
srathod
committed
- Implemented testrunner for java.
- Updated sample codes to return ANetApiResponse so that output can be validated by TestRunner.
1 parent f773cc4 commit e39c176

File tree

55 files changed

+781
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+781
-184
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ hs_err_pid*
1414
/logs/
1515

1616
/target/
17+
/bin/

src/main/java/net/authorize/sample/ApplePayTransactions/CreateAnApplePayTransaction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class CreateAnApplePayTransaction
1111
{
12-
public static void run(String apiLoginId, String transactionKey)
12+
public static ANetApiResponse run(String apiLoginId, String transactionKey)
1313
{
1414
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1515

@@ -61,5 +61,6 @@ public static void run(String apiLoginId, String transactionKey)
6161
System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText());
6262
}
6363
}
64+
return response;
6465
}
6566
}

src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//author @krgupta
1919
public class CreateCustomerPaymentProfile {
2020

21-
public static void run(String apiLoginId, String transactionKey) {
21+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) {
2222

2323
ApiOperationBase.setEnvironment(Environment.SANDBOX);
2424

@@ -27,13 +27,10 @@ public static void run(String apiLoginId, String transactionKey) {
2727
merchantAuthenticationType.setTransactionKey(transactionKey);
2828
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2929

30-
String customerprofileId = "36374423" ;
31-
32-
3330
//private String getPaymentDetails(MerchantAuthenticationType merchantAuthentication, String customerprofileId, ValidationModeEnum validationMode) {
3431
CreateCustomerPaymentProfileRequest apiRequest = new CreateCustomerPaymentProfileRequest();
3532
apiRequest.setMerchantAuthentication(merchantAuthenticationType);
36-
apiRequest.setCustomerProfileId(customerprofileId);
33+
apiRequest.setCustomerProfileId(customerProfileId);
3734

3835
//customer address
3936
CustomerAddressType customerAddress = new CustomerAddressType();
@@ -50,7 +47,7 @@ public static void run(String apiLoginId, String transactionKey) {
5047
CreditCardType creditCard = new CreditCardType();
5148
creditCard.setCardNumber("4111111111111111");
5249
creditCard.setExpirationDate("2023-12");
53-
creditCard.setCardCode("");
50+
creditCard.setCardCode("122");
5451

5552
CustomerPaymentProfileType profile = new CustomerPaymentProfileType();
5653
profile.setBillTo(customerAddress);
@@ -60,26 +57,27 @@ public static void run(String apiLoginId, String transactionKey) {
6057
profile.setPayment(payment);
6158

6259
apiRequest.setPaymentProfile(profile);
63-
64-
CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest);
65-
controller.execute();
60+
61+
CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest);
62+
controller.execute();
6663

6764
CreateCustomerPaymentProfileResponse response = new CreateCustomerPaymentProfileResponse();
6865
response = controller.getApiResponse();
69-
7066
if (response!=null) {
71-
7267
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
73-
68+
7469
System.out.println(response.getCustomerPaymentProfileId());
7570
System.out.println(response.getMessages().getMessage().get(0).getCode());
7671
System.out.println(response.getMessages().getMessage().get(0).getText());
77-
System.out.println(response.getValidationDirectResponse());
72+
if(response.getValidationDirectResponse() != null)
73+
System.out.println(response.getValidationDirectResponse());
7874
}
7975
else
8076
{
8177
System.out.println("Failed to create customer payment profile: " + response.getMessages().getResultCode());
8278
}
8379
}
80+
81+
return response;
8482
}
8583
}

src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class CreateCustomerProfile {
1010

11-
public static void run(String apiLoginId, String transactionKey) {
11+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String eMail) {
1212

1313
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1414

@@ -31,7 +31,7 @@ public static void run(String apiLoginId, String transactionKey) {
3131
CustomerProfileType customerProfileType = new CustomerProfileType();
3232
customerProfileType.setMerchantCustomerId("Merchant_Customer_ID");
3333
customerProfileType.setDescription("Profile description here");
34-
customerProfileType.setEmail("[email protected]");
34+
customerProfileType.setEmail(eMail);
3535
customerProfileType.getPaymentProfiles().add(customerPaymentProfileType);
3636

3737
CreateCustomerProfileRequest apiRequest = new CreateCustomerProfileRequest();
@@ -45,15 +45,19 @@ public static void run(String apiLoginId, String transactionKey) {
4545
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
4646

4747
System.out.println(response.getCustomerProfileId());
48-
System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0));
49-
System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0));
50-
System.out.println(response.getValidationDirectResponseList().getString().get(0));
48+
if(!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty())
49+
System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0));
50+
if(!response.getCustomerShippingAddressIdList().getNumericString().isEmpty())
51+
System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0));
52+
if(!response.getValidationDirectResponseList().getString().isEmpty())
53+
System.out.println(response.getValidationDirectResponseList().getString().get(0));
5154
}
5255
else
5356
{
5457
System.out.println("Failed to create customer profile: " + response.getMessages().getResultCode());
5558
}
5659
}
60+
return response;
5761

5862
}
5963
}

src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class CreateCustomerProfileFromTransaction {
1212

13-
public static void run(String apiLoginId, String transactionKey) {
13+
public static ANetApiResponse run(String apiLoginId, String transactionKey) {
1414

1515
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1616

@@ -19,8 +19,6 @@ public static void run(String apiLoginId, String transactionKey) {
1919
merchantAuthenticationType.setTransactionKey(transactionKey);
2020
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2121

22-
String customerprofileId = "36374423" ;
23-
2422
CreditCardType creditCard = new CreditCardType();
2523
creditCard.setCardNumber("4111111111111111");
2624
creditCard.setExpirationDate("0616");
@@ -54,5 +52,6 @@ public static void run(String apiLoginId, String transactionKey) {
5452
if(customer_response != null) {
5553
System.out.println(transaction_request.getTransId());
5654
}
55+
return customer_response;
5756
}
5857
}

src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class CreateCustomerShippingAddress {
1010

11-
public static void run(String apiLoginId, String transactionKey) {
11+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) {
1212

1313
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1414

@@ -28,7 +28,7 @@ public static void run(String apiLoginId, String transactionKey) {
2828
customerAddressType.setPhoneNumber("000-000-0000");
2929

3030
CreateCustomerShippingAddressRequest apiRequest = new CreateCustomerShippingAddressRequest();
31-
apiRequest.setCustomerProfileId("10000");
31+
apiRequest.setCustomerProfileId(customerProfileId);
3232
apiRequest.setAddress(customerAddressType);
3333

3434
CreateCustomerShippingAddressController controller = new CreateCustomerShippingAddressController(apiRequest);
@@ -48,6 +48,7 @@ public static void run(String apiLoginId, String transactionKey) {
4848
System.out.println("Failed to create customer shipping address: " + response.getMessages().getResultCode());
4949
}
5050
}
51+
return response;
5152

5253
}
5354
}

src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerPaymentProfile.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
public class DeleteCustomerPaymentProfile {
1212

13-
public static void run(String apiLoginId, String transactionKey) {
13+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId,
14+
String customerPaymentProfileId) {
1415

1516
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1617

@@ -20,8 +21,8 @@ public static void run(String apiLoginId, String transactionKey) {
2021
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2122

2223
DeleteCustomerPaymentProfileRequest apiRequest = new DeleteCustomerPaymentProfileRequest();
23-
apiRequest.setCustomerProfileId("10000");
24-
apiRequest.setCustomerPaymentProfileId("20000");
24+
apiRequest.setCustomerProfileId(customerProfileId);
25+
apiRequest.setCustomerPaymentProfileId(customerPaymentProfileId);
2526

2627
DeleteCustomerPaymentProfileController controller = new DeleteCustomerPaymentProfileController(apiRequest);
2728
controller.execute();
@@ -41,5 +42,6 @@ public static void run(String apiLoginId, String transactionKey) {
4142
System.out.println("Failed to delete customer payment profile: " + response.getMessages().getResultCode());
4243
}
4344
}
45+
return response;
4446
}
4547
}

src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerProfile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class DeleteCustomerProfile {
1212

13-
public static void run(String apiLoginId, String transactionKey) {
13+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId) {
1414

1515
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1616

@@ -20,7 +20,7 @@ public static void run(String apiLoginId, String transactionKey) {
2020
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2121

2222
DeleteCustomerProfileRequest apiRequest = new DeleteCustomerProfileRequest();
23-
apiRequest.setCustomerProfileId("10000");
23+
apiRequest.setCustomerProfileId(customerProfileId);
2424

2525
DeleteCustomerProfileController controller = new DeleteCustomerProfileController(apiRequest);
2626
controller.execute();
@@ -40,5 +40,6 @@ public static void run(String apiLoginId, String transactionKey) {
4040
System.out.println("Failed to delete customer profile: " + response.getMessages().getResultCode());
4141
}
4242
}
43+
return response;
4344
}
4445
}

src/main/java/net/authorize/sample/CustomerProfiles/DeleteCustomerShippingAddress.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
public class DeleteCustomerShippingAddress {
1212

13-
public static void run(String apiLoginId, String transactionKey) {
13+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId,
14+
String customerAddressId) {
1415

1516
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1617

@@ -20,8 +21,8 @@ public static void run(String apiLoginId, String transactionKey) {
2021
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2122

2223
DeleteCustomerShippingAddressRequest apiRequest = new DeleteCustomerShippingAddressRequest();
23-
apiRequest.setCustomerProfileId("10000");
24-
apiRequest.setCustomerAddressId("30000");
24+
apiRequest.setCustomerProfileId(customerProfileId);
25+
apiRequest.setCustomerAddressId(customerAddressId);
2526

2627
DeleteCustomerShippingAddressController controller = new DeleteCustomerShippingAddressController(apiRequest);
2728
controller.execute();
@@ -41,5 +42,6 @@ public static void run(String apiLoginId, String transactionKey) {
4142
System.out.println("Failed to delete customer shipping address: " + response.getMessages().getResultCode());
4243
}
4344
}
45+
return response;
4446
}
4547
}

src/main/java/net/authorize/sample/CustomerProfiles/GetCustomerPaymentProfile.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
public class GetCustomerPaymentProfile {
1212

13-
public static void run(String apiLoginId, String transactionKey) {
13+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId,
14+
String customerPaymentProfileId) {
1415

1516
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1617

@@ -20,8 +21,8 @@ public static void run(String apiLoginId, String transactionKey) {
2021
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2122

2223
GetCustomerPaymentProfileRequest apiRequest = new GetCustomerPaymentProfileRequest();
23-
apiRequest.setCustomerProfileId("10000");
24-
apiRequest.setCustomerPaymentProfileId("20000");
24+
apiRequest.setCustomerProfileId(customerProfileId);
25+
apiRequest.setCustomerPaymentProfileId(customerPaymentProfileId);
2526

2627
GetCustomerPaymentProfileController controller = new GetCustomerPaymentProfileController(apiRequest);
2728
controller.execute();
@@ -57,5 +58,6 @@ public static void run(String apiLoginId, String transactionKey) {
5758
System.out.println("Failed to get customer payment profile: " + response.getMessages().getResultCode());
5859
}
5960
}
61+
return response;
6062
}
6163
}

0 commit comments

Comments
 (0)