Skip to content

Commit 6c20e20

Browse files
committed
formatting changes to try to make formatting more consistent
1 parent 4509302 commit 6c20e20

38 files changed

+344
-337
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
6969
System.out.println(response.getCustomerPaymentProfileId());
7070
System.out.println(response.getMessages().getMessage().get(0).getCode());
7171
System.out.println(response.getMessages().getMessage().get(0).getText());
72-
if(response.getValidationDirectResponse() != null)
72+
if (response.getValidationDirectResponse() != null)
7373
System.out.println(response.getValidationDirectResponse());
7474
}
7575
else

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

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,77 @@
77
import net.authorize.api.controller.base.ApiOperationBase;
88

99
public class CreateCustomerProfile {
10+
public static ANetApiResponse run(String apiLoginId, String transactionKey, String eMail) {
1011

11-
public static ANetApiResponse run(String apiLoginId, String transactionKey, String eMail) {
12-
13-
ApiOperationBase.setEnvironment(Environment.SANDBOX);
14-
12+
// Set the request to operate in either the sandbox or production environment
13+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
14+
15+
// Create object with merchant authentication details
1516
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
1617
merchantAuthenticationType.setName(apiLoginId);
1718
merchantAuthenticationType.setTransactionKey(transactionKey);
18-
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
1919

20+
// Populate the payment data
2021
CreditCardType creditCard = new CreditCardType();
21-
creditCard.setCardNumber("4111111111111111");
22-
creditCard.setExpirationDate("1220");
23-
24-
PaymentType paymentType = new PaymentType();
25-
paymentType.setCreditCard(creditCard);
22+
creditCard.setCardNumber("4111111111111111");
23+
creditCard.setExpirationDate("1220");
24+
PaymentType paymentType = new PaymentType();
25+
paymentType.setCreditCard(creditCard);
2626

27-
CustomerPaymentProfileType customerPaymentProfileType = new CustomerPaymentProfileType();
28-
customerPaymentProfileType.setCustomerType(CustomerTypeEnum.INDIVIDUAL);
29-
customerPaymentProfileType.setPayment(paymentType);
27+
// Set payment profile data
28+
CustomerPaymentProfileType customerPaymentProfileType = new CustomerPaymentProfileType();
29+
customerPaymentProfileType.setCustomerType(CustomerTypeEnum.INDIVIDUAL);
30+
customerPaymentProfileType.setPayment(paymentType);
3031

32+
// Set customer profile data
3133
CustomerProfileType customerProfileType = new CustomerProfileType();
3234
customerProfileType.setMerchantCustomerId("M_" + eMail);
3335
customerProfileType.setDescription("Profile description for " + eMail);
3436
customerProfileType.setEmail(eMail);
3537
customerProfileType.getPaymentProfiles().add(customerPaymentProfileType);
3638

39+
// Create the API request and set the parameters for this specific request
3740
CreateCustomerProfileRequest apiRequest = new CreateCustomerProfileRequest();
41+
apiRequest.setMerchantAuthentication(merchantAuthenticationType);
3842
apiRequest.setProfile(customerProfileType);
3943
apiRequest.setValidationMode(ValidationModeEnum.TEST_MODE);
44+
45+
// Call the controller
4046
CreateCustomerProfileController controller = new CreateCustomerProfileController(apiRequest);
4147
controller.execute();
42-
CreateCustomerProfileResponse response = controller.getApiResponse();
43-
if (response!=null) {
44-
45-
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
4648

49+
// Get the response
50+
CreateCustomerProfileResponse response = new CreateCustomerProfileResponse();
51+
response = controller.getApiResponse();
52+
53+
// Parse the response to determine results
54+
if (response!=null) {
55+
// If API Response is OK, go ahead and check the transaction response
56+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
4757
System.out.println(response.getCustomerProfileId());
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));
58+
if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) {
59+
System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0));
60+
}
61+
if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) {
62+
System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0));
63+
}
64+
if (!response.getValidationDirectResponseList().getString().isEmpty()) {
65+
System.out.println(response.getValidationDirectResponseList().getString().get(0));
66+
}
5467
}
5568
else
5669
{
5770
System.out.println("Failed to create customer profile: " + response.getMessages().getResultCode());
5871
}
72+
} else {
73+
// Display the error code and message when response is null
74+
ANetApiResponse errorResponse = controller.getErrorResponse();
75+
System.out.println("Failed to get response");
76+
if (!errorResponse.getMessages().getMessage().isEmpty()) {
77+
System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText());
78+
}
5979
}
60-
return response;
80+
return response;
6181

6282
}
6383
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub
7171
createProfileController.execute();
7272
CreateCustomerProfileResponse customer_response = createProfileController.getApiResponse();
7373

74-
if(customer_response != null) {
74+
if (customer_response != null) {
7575
System.out.println(transaction_request.getTransId());
7676
}
7777
return customer_response;

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
5353
System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getCardNumber());
5454
System.out.println(response.getPaymentProfile().getPayment().getCreditCard().getExpirationDate());
5555

56-
if((response.getPaymentProfile().getSubscriptionIds() != null) && (response.getPaymentProfile().getSubscriptionIds().getSubscriptionId() != null) &&
57-
(!response.getPaymentProfile().getSubscriptionIds().getSubscriptionId().isEmpty())){
56+
if ((response.getPaymentProfile().getSubscriptionIds() != null) && (response.getPaymentProfile().getSubscriptionIds().getSubscriptionId() != null) &&
57+
(!response.getPaymentProfile().getSubscriptionIds().getSubscriptionId().isEmpty())) {
5858
System.out.println("List of subscriptions:");
59-
for(String subscriptionid : response.getPaymentProfile().getSubscriptionIds().getSubscriptionId())
59+
for (String subscriptionid : response.getPaymentProfile().getSubscriptionIds().getSubscriptionId())
6060
System.out.println(subscriptionid);
6161
}
62-
}
63-
else
64-
{
62+
} else {
6563
System.out.println("Failed to get customer payment profile: " + response.getMessages().getResultCode());
6664
}
6765
}

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@
77
import net.authorize.api.controller.base.ApiOperationBase;
88
import net.authorize.api.controller.*;
99

10-
public class GetCustomerPaymentProfileList
11-
{
12-
public static ANetApiResponse run(String apiLoginId,String transactionKey)
13-
{
10+
public class GetCustomerPaymentProfileList {
11+
public static ANetApiResponse run(String apiLoginId,String transactionKey) {
12+
13+
// Set the request to operate in either the sandbox or production environment
1414
ApiOperationBase.setEnvironment(Environment.SANDBOX);
1515

16-
// Giving the merchant authentication information
16+
// Create object with merchant authentication details
1717
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
1818
merchantAuthenticationType.setName(apiLoginId);
1919
merchantAuthenticationType.setTransactionKey(transactionKey);
20-
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2120

22-
//Setting the paging
21+
// Setting the paging
2322
Paging paging = new Paging();
2423
paging.setLimit(100);
2524
paging.setOffset(1);
@@ -33,56 +32,57 @@ public static ANetApiResponse run(String apiLoginId,String transactionKey)
3332
// Setting the searchType
3433
CustomerPaymentProfileSearchTypeEnum searchType = CustomerPaymentProfileSearchTypeEnum.CARDS_EXPIRING_IN_MONTH;
3534

36-
// Making the API request
35+
// Create the API request and set the parameters for this specific request
3736
GetCustomerPaymentProfileListRequest apiRequest = new GetCustomerPaymentProfileListRequest();
37+
apiRequest.setMerchantAuthentication(merchantAuthenticationType);
3838
apiRequest.setPaging(paging);
3939
apiRequest.setSearchType(searchType);
4040
apiRequest.setSorting(sorting);
4141
apiRequest.setMonth("2020-12");
4242

43-
// Calling the controller
43+
// Call the controller
4444
GetCustomerPaymentProfileListController controller = new GetCustomerPaymentProfileListController(apiRequest);
4545
controller.execute();
46-
// Getting the response
46+
47+
// Get the response
4748
GetCustomerPaymentProfileListResponse response = new GetCustomerPaymentProfileListResponse();
4849
response = controller.getApiResponse();
49-
// Checking id the response is not null then printing the details
50-
if(response != null)
51-
{
52-
if(response.getMessages().getResultCode() == MessageTypeEnum.OK)
53-
{
50+
51+
// Parse the response to determine results
52+
if (response != null) {
53+
// If API Response is OK, go ahead and check the transaction response
54+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
5455
System.out.println("Successfully got customer payment profile list");
5556
System.out.println("Message Code:" + response.getMessages().getMessage().get(0).getCode());
5657
System.out.println("Message Text:" + response.getMessages().getMessage().get(0).getText());
5758
System.out.println("Total Number of Results in the Results Set:" + response.getTotalNumInResultSet());
5859
List <CustomerPaymentProfileListItemType> arr = response.getPaymentProfiles().getPaymentProfile();
5960

60-
for(CustomerPaymentProfileListItemType element : arr)
61-
{
61+
for (CustomerPaymentProfileListItemType element : arr) {
6262
System.out.println();
63-
if(element.getBillTo()!=null)
63+
if (element.getBillTo()!=null) {
6464
System.out.println("Customer name : "+element.getBillTo().getFirstName()+" "+element.getBillTo().getLastName());
65+
}
6566
System.out.println("Credit card number: "+element.getPayment().getCreditCard().getCardNumber());
6667
System.out.println("Customer Profile ID : "+element.getCustomerProfileId());
6768
System.out.println("Customer Payment Profile ID : "+element.getCustomerPaymentProfileId());
6869
}
69-
}
70-
else
71-
{
72-
// When the error occurs
70+
} else {
71+
// Displaying the error code and message when error occurs
7372
System.out.println("Failed to get customer payment profile list");
74-
if(!response.getMessages().getMessage().isEmpty())
73+
if (!response.getMessages().getMessage().isEmpty()) {
7574
System.out.println("Error: "+response.getMessages().getMessage().get(0).getCode()+" "+ response.getMessages().getMessage().get(0).getText());
75+
}
7676
}
77-
}
78-
else
79-
{
80-
// Displaying the error code and message when response is null
77+
} else {
78+
// Display the error code and message when response is null
8179
ANetApiResponse errorResponse = controller.getErrorResponse();
8280
System.out.println("Failed to get response");
83-
if(!errorResponse.getMessages().getMessage().isEmpty())
81+
if (!errorResponse.getMessages().getMessage().isEmpty()) {
8482
System.out.println("Error: "+errorResponse.getMessages().getMessage().get(0).getCode()+" \n"+ errorResponse.getMessages().getMessage().get(0).getText());
83+
}
8584
}
86-
return response;
85+
86+
return response;
8787
}
8888
}

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
3030

3131
if (response!=null) {
3232

33-
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
33+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
3434

3535
System.out.println(response.getMessages().getMessage().get(0).getCode());
3636
System.out.println(response.getMessages().getMessage().get(0).getText());
@@ -40,8 +40,8 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
4040
System.out.println(response.getProfile().getEmail());
4141
System.out.println(response.getProfile().getCustomerProfileId());
4242

43-
if((!response.getProfile().getPaymentProfiles().isEmpty()) &&
44-
(response.getProfile().getPaymentProfiles().get(0).getBillTo() != null)){
43+
if ((!response.getProfile().getPaymentProfiles().isEmpty()) &&
44+
(response.getProfile().getPaymentProfiles().get(0).getBillTo() != null)) {
4545
System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getFirstName());
4646
System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getLastName());
4747
System.out.println(response.getProfile().getPaymentProfiles().get(0).getBillTo().getCompany());
@@ -59,7 +59,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
5959
System.out.println(response.getProfile().getPaymentProfiles().get(0).getPayment().getCreditCard().getExpirationDate());
6060
}
6161

62-
if(!response.getProfile().getShipToList().isEmpty()){
62+
if (!response.getProfile().getShipToList().isEmpty()) {
6363
System.out.println(response.getProfile().getShipToList().get(0).getFirstName());
6464
System.out.println(response.getProfile().getShipToList().get(0).getLastName());
6565
System.out.println(response.getProfile().getShipToList().get(0).getCompany());
@@ -72,16 +72,14 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
7272
System.out.println(response.getProfile().getShipToList().get(0).getFaxNumber());
7373
}
7474

75-
if((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) &&
76-
(!response.getSubscriptionIds().getSubscriptionId().isEmpty())){
75+
if ((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) &&
76+
(!response.getSubscriptionIds().getSubscriptionId().isEmpty())) {
7777
System.out.println("List of subscriptions:");
78-
for(String subscriptionid : response.getSubscriptionIds().getSubscriptionId())
78+
for (String subscriptionid : response.getSubscriptionIds().getSubscriptionId())
7979
System.out.println(subscriptionid);
8080
}
8181

82-
}
83-
else
84-
{
82+
} else {
8583
System.out.println("Failed to get customer profile: " + response.getMessages().getResultCode());
8684
}
8785
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) {
3434
System.out.println(response.getMessages().getMessage().get(0).getCode());
3535
System.out.println(response.getMessages().getMessage().get(0).getText());
3636

37-
for(int i =0; i < response.getIds().getNumericString().size(); i++) {
37+
for (int i =0; i < response.getIds().getNumericString().size(); i++) {
3838

3939
System.out.println(response.getIds().getNumericString().get(i));
4040
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
5050

5151
System.out.println(response.getAddress().getCustomerAddressId());
5252

53-
if((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) &&
54-
(!response.getSubscriptionIds().getSubscriptionId().isEmpty())){
53+
if ((response.getSubscriptionIds() != null) && (response.getSubscriptionIds().getSubscriptionId() != null) &&
54+
(!response.getSubscriptionIds().getSubscriptionId().isEmpty())) {
5555
System.out.println("List of subscriptions:");
56-
for(String subscriptionid : response.getSubscriptionIds().getSubscriptionId())
56+
for (String subscriptionid : response.getSubscriptionIds().getSubscriptionId())
5757
System.out.println(subscriptionid);
5858
}
59-
}
60-
else
61-
{
59+
} else {
6260
System.out.println("Failed to get customer shipping address: " + response.getMessages().getResultCode());
6361
}
6462
}

0 commit comments

Comments
 (0)