Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7257173

Browse filesBrowse files
authored
Merge pull request AuthorizeNet#75 from gnongsie/master
Moving files to AcceptSuite
2 parents e991670 + 8dd55fb commit 7257173
Copy full SHA for 7257173
Expand file treeCollapse file tree

10 files changed

+203
-147
lines changed
Open diff view settings
Collapse file

‎…ns/CreateAnAcceptPaymentTransaction.java‎ ‎…te/CreateAnAcceptPaymentTransaction.java‎src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java renamed to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java src/main/java/net/authorize/sample/PaymentTransactions/CreateAnAcceptPaymentTransaction.java renamed to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptPaymentTransaction.java

Copy file name to clipboard
File renamed without changes.
Collapse file

‎…nsactions/CreateAnAcceptTransaction.java‎ ‎…ceptSuite/CreateAnAcceptTransaction.java‎src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java renamed to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java src/main/java/net/authorize/sample/MobileInAppTransactions/CreateAnAcceptTransaction.java renamed to src/main/java/net/authorize/sample/AcceptSuite/CreateAnAcceptTransaction.java

Copy file name to clipboard
File renamed without changes.
Collapse file

‎…ofiles/GetAcceptCustomerProfilePage.java‎ ‎…tSuite/GetAcceptCustomerProfilePage.java‎src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java renamed to src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java src/main/java/net/authorize/sample/CustomerProfiles/GetAcceptCustomerProfilePage.java renamed to src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java

Copy file name to clipboardExpand all lines: src/main/java/net/authorize/sample/AcceptSuite/GetAcceptCustomerProfilePage.java
+21-19Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
import net.authorize.Environment;
44
import net.authorize.api.contract.v1.*;
5-
6-
import net.authorize.api.contract.v1.MerchantAuthenticationType;
75
import net.authorize.api.controller.base.ApiOperationBase;
86
import net.authorize.api.controller.GetHostedProfilePageController;
9-
import net.authorize.api.controller.base.ApiOperationBase;
107

118
public class GetAcceptCustomerProfilePage {
129

@@ -32,24 +29,29 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
3229

3330
GetHostedProfilePageController controller = new GetHostedProfilePageController(apiRequest);
3431
controller.execute();
35-
36-
GetHostedProfilePageResponse response = new GetHostedProfilePageResponse();
37-
response = controller.getApiResponse();
38-
39-
if (response!=null) {
40-
41-
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
42-
43-
System.out.println(response.getMessages().getMessage().get(0).getCode());
44-
System.out.println(response.getMessages().getMessage().get(0).getText());
45-
46-
System.out.println(response.getToken());
32+
33+
ANetApiResponse apiResponse = controller.getApiResponse();
34+
if (apiResponse != null) {
35+
if (apiResponse instanceof GetHostedProfilePageResponse) {
36+
GetHostedProfilePageResponse response = (GetHostedProfilePageResponse) apiResponse;
37+
38+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
39+
System.out.println(response.getToken());
40+
System.out.println(response.getMessages().getMessage().get(0).getCode());
41+
System.out.println(response.getMessages().getMessage().get(0).getText());
42+
}
43+
else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) {
44+
System.out.println(response.getMessages().getMessage().get(0).getCode());
45+
System.out.println(response.getMessages().getMessage().get(0).getText());
46+
}
4747
}
48-
else
49-
{
50-
System.out.println("Failed to get hosted profile page: " + response.getMessages().getResultCode());
48+
else if (apiResponse instanceof ErrorResponse) {
49+
System.out.println(apiResponse.getMessages().getMessage().get(0).getCode());
50+
System.out.println(apiResponse.getMessages().getMessage().get(0).getText());
51+
System.out.println("Failed to get hosted profile page: " + apiResponse.getMessages().getResultCode());
5152
}
5253
}
53-
return response;
54+
55+
return apiResponse;
5456
}
5557
}
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerPaymentProfile.java
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
import net.authorize.api.contract.v1.MerchantAuthenticationType;
77
import net.authorize.api.controller.base.ApiOperationBase;
88

9-
import net.authorize.Transaction;
10-
import net.authorize.api.controller.CreateCustomerProfileController;
11-
import net.authorize.api.controller.CreateCustomerProfileFromTransactionController;
129
import net.authorize.api.controller.CreateCustomerPaymentProfileController;
13-
import net.authorize.api.controller.base.ApiOperationBase;
14-
import net.authorize.cim.Result;
15-
import net.authorize.cim.TransactionType;
16-
import net.authorize.cim.ValidationModeType;
1710

1811
//author @krgupta
1912
public class CreateCustomerPaymentProfile {
@@ -61,23 +54,30 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
6154
CreateCustomerPaymentProfileController controller = new CreateCustomerPaymentProfileController(apiRequest);
6255
controller.execute();
6356

64-
CreateCustomerPaymentProfileResponse response = new CreateCustomerPaymentProfileResponse();
65-
response = controller.getApiResponse();
66-
if (response!=null) {
67-
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
68-
69-
System.out.println(response.getCustomerPaymentProfileId());
70-
System.out.println(response.getMessages().getMessage().get(0).getCode());
71-
System.out.println(response.getMessages().getMessage().get(0).getText());
72-
if (response.getValidationDirectResponse() != null)
73-
System.out.println(response.getValidationDirectResponse());
57+
ANetApiResponse apiResponse = controller.getApiResponse();
58+
if (apiResponse != null) {
59+
if (apiResponse instanceof CreateCustomerPaymentProfileResponse) {
60+
CreateCustomerPaymentProfileResponse response = (CreateCustomerPaymentProfileResponse) apiResponse;
61+
62+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
63+
System.out.println(response.getCustomerPaymentProfileId());
64+
System.out.println(response.getMessages().getMessage().get(0).getCode());
65+
System.out.println(response.getMessages().getMessage().get(0).getText());
66+
if (response.getValidationDirectResponse() != null)
67+
System.out.println(response.getValidationDirectResponse());
68+
}
69+
else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) {
70+
System.out.println(response.getMessages().getMessage().get(0).getCode());
71+
System.out.println(response.getMessages().getMessage().get(0).getText());
72+
}
7473
}
75-
else
76-
{
77-
System.out.println("Failed to create customer payment profile: " + response.getMessages().getResultCode());
74+
else if (apiResponse instanceof ErrorResponse) {
75+
System.out.println(apiResponse.getMessages().getMessage().get(0).getCode());
76+
System.out.println(apiResponse.getMessages().getMessage().get(0).getText());
77+
System.out.println("Failed to create customer payment profile: " + apiResponse.getMessages().getResultCode());
7878
}
7979
}
8080

81-
return response;
81+
return apiResponse;
8282
}
8383
}
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfile.java
+27-28Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import net.authorize.Environment;
44
import net.authorize.api.contract.v1.*;
5-
import java.math.BigDecimal;
65
import net.authorize.api.controller.CreateCustomerProfileController;
76
import net.authorize.api.controller.base.ApiOperationBase;
87

@@ -47,37 +46,37 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
4746
controller.execute();
4847

4948
// Get the response
50-
CreateCustomerProfileResponse response = new CreateCustomerProfileResponse();
51-
response = controller.getApiResponse();
49+
ANetApiResponse apiResponse = controller.getApiResponse();
5250

5351
// Parse the response to determine results
54-
if (response!=null) {
52+
if (apiResponse != null) {
53+
if (apiResponse instanceof CreateCustomerProfileResponse) {
5554
// If API Response is OK, go ahead and check the transaction response
56-
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
57-
System.out.println(response.getCustomerProfileId());
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-
}
55+
CreateCustomerProfileResponse response = (CreateCustomerProfileResponse) apiResponse;
56+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
57+
System.out.println(response.getCustomerProfileId());
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+
}
67+
}
68+
else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) {
69+
System.out.println(response.getMessages().getMessage().get(0).getCode());
70+
System.out.println(response.getMessages().getMessage().get(0).getText());
71+
}
72+
}
73+
else if (apiResponse instanceof ErrorResponse) {
74+
System.out.println(apiResponse.getMessages().getMessage().get(0).getCode());
75+
System.out.println(apiResponse.getMessages().getMessage().get(0).getText());
76+
System.out.println("Failed to create customer profile: " + apiResponse.getMessages().getResultCode());
6777
}
68-
else
69-
{
70-
System.out.println("Failed to create customer profile: " + response.getMessages().getResultCode());
71-
}
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-
}
79-
}
80-
return response;
78+
}
79+
return apiResponse;
8180

8281
}
8382
}
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerProfileFromTransaction.java
+53-13Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
import net.authorize.api.contract.v1.CreditCardType;
1313
import net.authorize.api.contract.v1.CustomerDataType;
1414
import net.authorize.api.contract.v1.CustomerProfileBaseType;
15+
import net.authorize.api.contract.v1.ErrorResponse;
1516
import net.authorize.api.contract.v1.MerchantAuthenticationType;
17+
import net.authorize.api.contract.v1.MessageTypeEnum;
1618
import net.authorize.api.contract.v1.PaymentType;
1719
import net.authorize.api.contract.v1.TransactionRequestType;
1820
import net.authorize.api.controller.CreateCustomerProfileFromTransactionController;
@@ -46,34 +48,72 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Doub
4648
customer.setEmail(email);
4749
requestInternal.setCustomer(customer);
4850

49-
CreateTransactionRequest request = new CreateTransactionRequest();
50-
request.setTransactionRequest(requestInternal);
51+
CreateTransactionRequest transactionRequest = new CreateTransactionRequest();
52+
transactionRequest.setTransactionRequest(requestInternal);
5153

52-
CreateTransactionController controller = new CreateTransactionController(request);
54+
CreateTransactionController controller = new CreateTransactionController(transactionRequest);
5355
controller.execute();
5456

55-
CreateTransactionResponse response = controller.getApiResponse();
57+
ANetApiResponse apiResponseForTransaction = controller.getApiResponse();
58+
59+
if (apiResponseForTransaction != null) {
60+
if (!(apiResponseForTransaction instanceof CreateTransactionResponse) && !(apiResponseForTransaction instanceof ErrorResponse)) {
61+
System.out.println(apiResponseForTransaction.getMessages().getMessage().get(0).getCode());
62+
System.out.println(apiResponseForTransaction.getMessages().getMessage().get(0).getText());
63+
System.out.println("Failed to create transaction: " + apiResponseForTransaction.getMessages().getResultCode());
64+
65+
return apiResponseForTransaction;
66+
}
67+
}
68+
69+
CreateTransactionResponse transactionResponse = (CreateTransactionResponse) apiResponseForTransaction;
5670

5771
CustomerProfileBaseType customerProfile = new CustomerProfileBaseType();
5872
customerProfile.setMerchantCustomerId("123213");
5973
customerProfile.setEmail("johnsnow@castleblack.com");
6074
customerProfile.setDescription("This is a sample customer profile");
6175

62-
CreateCustomerProfileFromTransactionRequest transaction_request = new CreateCustomerProfileFromTransactionRequest();
63-
transaction_request.setTransId(response.getTransactionResponse().getTransId());
76+
CreateCustomerProfileFromTransactionRequest request = new CreateCustomerProfileFromTransactionRequest();
77+
request.setTransId(transactionResponse.getTransactionResponse().getTransId());
6478
// You can either specify the customer information in form of customerProfileBaseType object
65-
transaction_request.setCustomer(customerProfile);
79+
request.setCustomer(customerProfile);
6680
// OR
6781
// You can just provide the customer Profile ID
6882
// transaction_request.setCustomerProfileId("1232132");
6983

70-
CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(transaction_request);
84+
CreateCustomerProfileFromTransactionController createProfileController = new CreateCustomerProfileFromTransactionController(request);
7185
createProfileController.execute();
72-
CreateCustomerProfileResponse customer_response = createProfileController.getApiResponse();
86+
ANetApiResponse apiResponse = createProfileController.getApiResponse();
7387

74-
if (customer_response != null) {
75-
System.out.println(transaction_request.getTransId());
76-
}
77-
return customer_response;
88+
if (apiResponse != null) {
89+
if (apiResponse instanceof CreateCustomerProfileResponse) {
90+
CreateCustomerProfileResponse response = (CreateCustomerProfileResponse) apiResponse;
91+
92+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
93+
System.out.println("Transaction ID : " + transactionResponse.getTransactionResponse().getTransId());
94+
System.out.println("Customer Profile Created : " + response.getCustomerProfileId());
95+
if (!response.getCustomerPaymentProfileIdList().getNumericString().isEmpty()) {
96+
System.out.println(response.getCustomerPaymentProfileIdList().getNumericString().get(0));
97+
}
98+
if (!response.getCustomerShippingAddressIdList().getNumericString().isEmpty()) {
99+
System.out.println(response.getCustomerShippingAddressIdList().getNumericString().get(0));
100+
}
101+
if (!response.getValidationDirectResponseList().getString().isEmpty()) {
102+
System.out.println(response.getValidationDirectResponseList().getString().get(0));
103+
}
104+
}
105+
else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) {
106+
System.out.println(response.getMessages().getMessage().get(0).getCode());
107+
System.out.println(response.getMessages().getMessage().get(0).getText());
108+
}
109+
}
110+
else if (apiResponse instanceof ErrorResponse) {
111+
System.out.println(apiResponse.getMessages().getMessage().get(0).getCode());
112+
System.out.println(apiResponse.getMessages().getMessage().get(0).getText());
113+
System.out.println("Failed to create customer payment profile: " + apiResponse.getMessages().getResultCode());
114+
}
115+
}
116+
117+
return apiResponse;
78118
}
79119
}
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/net/authorize/sample/CustomerProfiles/CreateCustomerShippingAddress.java
+20-14Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import net.authorize.Environment;
44
import net.authorize.api.contract.v1.*;
5-
import java.math.BigDecimal;
65
import net.authorize.api.controller.CreateCustomerShippingAddressController;
76
import net.authorize.api.controller.base.ApiOperationBase;
87

@@ -34,21 +33,28 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
3433
CreateCustomerShippingAddressController controller = new CreateCustomerShippingAddressController(apiRequest);
3534
controller.execute();
3635

37-
CreateCustomerShippingAddressResponse response = controller.getApiResponse();
38-
if (response!=null) {
39-
40-
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
41-
42-
System.out.println(response.getCustomerAddressId());
43-
System.out.println(response.getMessages().getMessage().get(0).getCode());
44-
System.out.println(response.getMessages().getMessage().get(0).getText());
45-
}
46-
else
47-
{
48-
System.out.println("Failed to create customer shipping address: " + response.getMessages().getResultCode());
36+
ANetApiResponse apiResponse = controller.getApiResponse();
37+
if (apiResponse != null) {
38+
if (apiResponse instanceof CreateCustomerShippingAddressResponse) {
39+
CreateCustomerShippingAddressResponse response = (CreateCustomerShippingAddressResponse) apiResponse;
40+
41+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
42+
System.out.println(response.getCustomerAddressId());
43+
System.out.println(response.getMessages().getMessage().get(0).getCode());
44+
System.out.println(response.getMessages().getMessage().get(0).getText());
45+
}
46+
else if (response.getMessages().getResultCode() == MessageTypeEnum.ERROR) {
47+
System.out.println(response.getMessages().getMessage().get(0).getCode());
48+
System.out.println(response.getMessages().getMessage().get(0).getText());
49+
}
50+
}
51+
else if (apiResponse instanceof ErrorResponse) {
52+
System.out.println(apiResponse.getMessages().getMessage().get(0).getCode());
53+
System.out.println(apiResponse.getMessages().getMessage().get(0).getText());
54+
System.out.println("Failed to create customer shipping address: " + apiResponse.getMessages().getResultCode());
4955
}
5056
}
51-
return response;
57+
return apiResponse;
5258

5359
}
5460
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.