Skip to content

Commit 582d11f

Browse files
committed
PR1992_getaujobdetails_sample code_modifications_ java
Added new class GetAccountUpdaterJobDetails.
1 parent 79f28c7 commit 582d11f

3 files changed

Lines changed: 201 additions & 41 deletions

File tree

src/main/java/net/authorize/sample/SampleCode.java

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package net.authorize.sample;
22

33
import java.io.BufferedReader;
4-
import java.io.IOException;
54
import java.io.InputStreamReader;
6-
75
import net.authorize.sample.VisaCheckout.*;
86
import net.authorize.sample.PaymentTransactions.*;
97
import net.authorize.sample.PayPalExpressCheckout.*;
@@ -18,30 +16,30 @@
1816
*/
1917
public class SampleCode {
2018

21-
public static void main( String[] args )
19+
public static void main( String[] args )
2220
{
2321

24-
if (args.length == 0)
25-
{
26-
SelectMethod();
27-
}
28-
else if (args.length == 1)
29-
{
30-
RunMethod(args[0]);
31-
return;
32-
}
33-
else
34-
{
35-
ShowUsage();
36-
}
22+
if (args.length == 0)
23+
{
24+
SelectMethod();
25+
}
26+
else if (args.length == 1)
27+
{
28+
RunMethod(args[0]);
29+
return;
30+
}
31+
else
32+
{
33+
ShowUsage();
34+
}
3735

38-
System.out.println("");
39-
System.out.print("Press <Return> to finish ...");
40-
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
41-
try{
42-
int i = Integer.parseInt(br.readLine());
43-
}catch(Exception ex) {
44-
}
36+
System.out.println("");
37+
System.out.print("Press <Return> to finish ...");
38+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
39+
try{
40+
int i = Integer.parseInt(br.readLine());
41+
}catch(Exception ex) {
42+
}
4543

4644
}
4745

@@ -53,8 +51,6 @@ private static void ShowUsage()
5351
System.out.println("");
5452
System.out.println("Code Sample Names: ");
5553
ShowMethods();
56-
57-
5854
}
5955

6056
private static void SelectMethod()
@@ -97,6 +93,7 @@ private static void ShowMethods()
9793
System.out.println(" CancelSubscription");
9894
System.out.println(" UpdateSubscription");
9995
System.out.println(" GetListOfSubscriptions");
96+
System.out.println(" GetAccountUpdaterJobDetails");
10097
System.out.println(" GetBatchStatistics");
10198
System.out.println(" GetSettledBatchList");
10299
System.out.println(" GetTransactionList");
@@ -138,15 +135,14 @@ private static void RunMethod(String methodName)
138135
{
139136
// These are default transaction keys.
140137
// You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/
141-
String apiLoginId = "5KP3u95bQpv";
138+
String apiLoginId = "5KP3u95bQpv";
142139
String transactionKey = "346HZ32z3fP4hTG2";
143140
//Update the payedId with which you want to run the sample code
144141
String payerId = "6ZSCSYG33VP8Q";
145142
//Update the transactionId with which you want to run the sample code
146143
String transactionId = "123456";
147-
148-
String customerProfileId = "37905546";
149-
String customerPaymentProfileId = "34461178";
144+
String customerProfileId = "40204235";
145+
String customerPaymentProfileId = "1000041617";
150146
String customerAddressId = "1871959249";
151147

152148
String emailId = "test@test.com";
@@ -156,14 +152,13 @@ private static void RunMethod(String methodName)
156152
Double amount = 123.45;
157153

158154
// Proxy server settings.
159-
// Enable these lines for using Sample Codes behind a proxy server
160-
155+
// Enable these lines for using Sample Codes behind a proxy server
161156
// System.setProperty("https.proxyUse", "true");
162157
// System.setProperty("https.proxyHost", "example.proxy.server");
163158
// System.setProperty("https.proxyPort", "portNumber");
164159
// System.setProperty("https.proxyUserName", "exampleUsername");
165160
// System.setProperty("https.proxyPassword", "examplePassword");
166-
161+
167162
switch (methodName) {
168163
case "DecryptVisaCheckoutData":
169164
DecryptVisaCheckoutData.run(apiLoginId, transactionKey);
@@ -342,9 +337,13 @@ private static void RunMethod(String methodName)
342337
case "GetAnAcceptPaymentPage":
343338
GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, amount);
344339
break;
340+
case "GetAccountUpdaterJobDetails":
341+
GetAccountUpdaterJobDetails.run(apiLoginId, transactionKey);
342+
break;
345343
default:
346344
ShowUsage();
347345
break;
348346
}
347+
349348
}
350349
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package net.authorize.sample.TransactionReporting;
2+
3+
import java.util.ArrayList;
4+
import net.authorize.Environment;
5+
import net.authorize.api.contract.v1.ANetApiResponse;
6+
import net.authorize.api.contract.v1.AUJobTypeEnum;
7+
import net.authorize.api.contract.v1.AuDeleteType;
8+
import net.authorize.api.contract.v1.AuDetailsType;
9+
import net.authorize.api.contract.v1.AuUpdateType;
10+
import net.authorize.api.contract.v1.CreditCardMaskedType;
11+
import net.authorize.api.contract.v1.GetAUJobDetailsRequest;
12+
import net.authorize.api.contract.v1.GetAUJobDetailsResponse;
13+
import net.authorize.api.contract.v1.MerchantAuthenticationType;
14+
import net.authorize.api.contract.v1.MessageTypeEnum;
15+
import net.authorize.api.contract.v1.Paging;
16+
import net.authorize.api.controller.GetAUJobDetailsController;
17+
import net.authorize.api.controller.base.ApiOperationBase;
18+
19+
public class GetAccountUpdaterJobDetails {
20+
21+
public static ANetApiResponse run(String apiLoginId, String transactionKey) {
22+
23+
// Set the request to operate in either the sandbox or production environment
24+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
25+
26+
// Create object with merchant authentication details
27+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType();
28+
merchantAuthenticationType.setName(apiLoginId);
29+
merchantAuthenticationType.setTransactionKey(transactionKey);
30+
31+
String month = "2018-08";
32+
String reFid = "123456";
33+
Paging paging = new Paging();
34+
paging.setLimit(100);
35+
paging.setOffset(2);
36+
37+
// Create the API request and set the parameters for this specific request
38+
GetAUJobDetailsRequest apiRequest = new GetAUJobDetailsRequest();
39+
apiRequest.setMerchantAuthentication(merchantAuthenticationType);
40+
apiRequest.setPaging(paging);
41+
apiRequest.setRefId(reFid);
42+
apiRequest.setMonth(month);
43+
apiRequest.setModifiedTypeFilter(AUJobTypeEnum.ALL);
44+
45+
// Call the controller
46+
GetAUJobDetailsController controller = new GetAUJobDetailsController(apiRequest);
47+
controller.execute();
48+
49+
GetAUJobDetailsResponse response = new GetAUJobDetailsResponse();
50+
response = controller.getApiResponse();
51+
52+
// If API Response is OK, go ahead and check the transaction response
53+
if (response != null && response.getMessages().getResultCode() == MessageTypeEnum.OK) {
54+
55+
System.out.println("SUCCESS: Get Account Updater job details for Month: " + month);
56+
57+
if (response.getAuDetails() == null) {
58+
System.out.println("No GetAccountUpdaterjobdetails for Month.");
59+
return response;
60+
}
61+
62+
ArrayList<AuUpdateType> updateTypeList = new ArrayList<AuUpdateType>();
63+
ArrayList<AuDeleteType> deleteTypeList = new ArrayList<AuDeleteType>();
64+
65+
for (AuDetailsType details : response.getAuDetails().getAuUpdateOrAuDelete()) {
66+
67+
System.out.println("---Customer Profile Details Start---");
68+
System.out.println("Profile ID:" + details.getCustomerProfileID());
69+
System.out.println("Payment Profile ID:" + details.getCustomerPaymentProfileID());
70+
System.out.println("First Name:" + details.getFirstName());
71+
System.out.println("Last Name:" + details.getLastName());
72+
System.out.println("Update Time UTC:" + details.getUpdateTimeUTC());
73+
System.out.println("Reason Code:" + details.getAuReasonCode());
74+
System.out.println("Reason Description:" + details.getReasonDescription());
75+
76+
if (details.getClass().getTypeName().toString().contains("AuUpdateType")) {
77+
78+
updateTypeList.add((AuUpdateType) details);
79+
80+
} else if (details.getClass().getTypeName().toString().contains("AuDeleteType")) {
81+
82+
deleteTypeList.add((AuDeleteType) details);
83+
84+
}
85+
86+
if (!(updateTypeList.isEmpty())) {
87+
for (int i = 0; i < updateTypeList.size(); i++) {
88+
89+
System.out.println("---AU Update Start---");
90+
System.out.println("Profile ID:" + details.getCustomerProfileID());
91+
System.out.println("Payment Profile ID:" + details.getCustomerPaymentProfileID());
92+
System.out.println("First Name:" + details.getFirstName());
93+
System.out.println("Last Name:" + details.getLastName());
94+
System.out.println("Update Time UTC:" + details.getUpdateTimeUTC());
95+
System.out.println("Reason Code:" + details.getAuReasonCode());
96+
System.out.println("Reason Description:" + details.getReasonDescription());
97+
98+
if (updateTypeList.get(i).getNewCreditCard() != null) {
99+
CreditCardMaskedType newCreditCard = updateTypeList.get(i).getNewCreditCard();
100+
System.out.println("---Fetching New Card Details---");
101+
System.out.println("Card Number:" + newCreditCard.getCardNumber());
102+
System.out.println("Expiration Date:" + newCreditCard.getExpirationDate());
103+
System.out.println("Card Type:" + newCreditCard.getCardType());
104+
}
105+
106+
if (updateTypeList.get(i).getOldCreditCard() != null) {
107+
CreditCardMaskedType oldCreditCard = updateTypeList.get(i).getOldCreditCard();
108+
System.out.println("---Fetching Old Card Details---");
109+
System.out.println("Card Number:" + oldCreditCard.getCardNumber());
110+
System.out.println("Expiration Date:" + oldCreditCard.getExpirationDate());
111+
System.out.println("Card Type:" + oldCreditCard.getCardType());
112+
}
113+
}
114+
}
115+
116+
if (!(deleteTypeList.isEmpty())) {
117+
for (int i = 0; i < deleteTypeList.size(); i++) {
118+
119+
System.out.println("---AU Delete Start---");
120+
System.out.println("Profile ID:" + details.getCustomerProfileID());
121+
System.out.println("Payment Profile ID:" + details.getCustomerPaymentProfileID());
122+
System.out.println("First Name:" + details.getFirstName());
123+
System.out.println("Last Name:" + details.getLastName());
124+
System.out.println("Update Time UTC:" + details.getUpdateTimeUTC());
125+
System.out.println("Reason Code:" + details.getAuReasonCode());
126+
System.out.println("Reason Description:" + details.getReasonDescription());
127+
128+
if (deleteTypeList.get(i).getCreditCard() != null) {
129+
130+
CreditCardMaskedType creditCard = deleteTypeList.get(i).getCreditCard();
131+
System.out.println("Card Number:" + creditCard.getCardNumber());
132+
System.out.println("Expiration Date:" + creditCard.getExpirationDate());
133+
System.out.println("Card Type:" + creditCard.getCardType());
134+
}
135+
136+
}
137+
}
138+
}
139+
}
140+
141+
else {
142+
// Display the error code and message when response is null
143+
ANetApiResponse errorResponse = controller.getErrorResponse();
144+
System.out.println("Failed to get response");
145+
if (!errorResponse.getMessages().getMessage().isEmpty()) {
146+
System.out.println("Error: " + errorResponse.getMessages().getMessage().get(0).getCode() + " \n"
147+
+ errorResponse.getMessages().getMessage().get(0).getText());
148+
}
149+
}
150+
151+
return response;
152+
}
153+
}

src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,21 @@
3939
import net.authorize.sample.CustomerProfiles.DeleteCustomerPaymentProfile;
4040
import net.authorize.sample.CustomerProfiles.DeleteCustomerProfile;
4141
import net.authorize.sample.CustomerProfiles.DeleteCustomerShippingAddress;
42+
import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage;
4243
import net.authorize.sample.CustomerProfiles.GetCustomerPaymentProfile;
4344
import net.authorize.sample.CustomerProfiles.GetCustomerProfile;
4445
import net.authorize.sample.CustomerProfiles.GetCustomerShippingAddress;
45-
import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage;
4646
import net.authorize.sample.CustomerProfiles.UpdateCustomerPaymentProfile;
4747
import net.authorize.sample.CustomerProfiles.UpdateCustomerProfile;
4848
import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress;
4949
import net.authorize.sample.CustomerProfiles.ValidateCustomerPaymentProfile;
50+
import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCapture;
51+
import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCaptureContinued;
52+
import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnly;
53+
import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnlyContinued;
54+
import net.authorize.sample.PayPalExpressCheckout.Credit;
55+
import net.authorize.sample.PayPalExpressCheckout.GetDetails;
56+
import net.authorize.sample.PayPalExpressCheckout.PriorAuthorizationCapture;
5057
import net.authorize.sample.PaymentTransactions.AuthorizeCreditCard;
5158
import net.authorize.sample.PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel;
5259
import net.authorize.sample.PaymentTransactions.CapturePreviouslyAuthorizedAmount;
@@ -55,23 +62,18 @@
5562
import net.authorize.sample.PaymentTransactions.ChargeTokenizedCreditCard;
5663
import net.authorize.sample.PaymentTransactions.CreditBankAccount;
5764
import net.authorize.sample.PaymentTransactions.DebitBankAccount;
65+
import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage;
5866
import net.authorize.sample.PaymentTransactions.RefundTransaction;
5967
import net.authorize.sample.PaymentTransactions.VoidTransaction;
60-
import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCapture;
61-
import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCaptureContinued;
62-
import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnly;
63-
import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnlyContinued;
64-
import net.authorize.sample.PayPalExpressCheckout.Credit;
65-
import net.authorize.sample.PayPalExpressCheckout.GetDetails;
66-
import net.authorize.sample.PayPalExpressCheckout.PriorAuthorizationCapture;
6768
import net.authorize.sample.RecurringBilling.CancelSubscription;
6869
import net.authorize.sample.RecurringBilling.CreateSubscription;
6970
import net.authorize.sample.RecurringBilling.CreateSubscriptionFromCustomerProfile;
7071
import net.authorize.sample.RecurringBilling.GetSubscription;
7172
import net.authorize.sample.RecurringBilling.GetSubscriptionStatus;
7273
import net.authorize.sample.RecurringBilling.UpdateSubscription;
74+
import net.authorize.sample.TransactionReporting.GetAccountUpdaterJobDetails;
7375
import net.authorize.sample.TransactionReporting.GetTransactionDetails;
74-
import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage;
76+
7577

7678
public class TestRunner {
7779

@@ -539,4 +541,10 @@ public ANetApiResponse TestGetAnAcceptPaymentPage()
539541
{
540542
return GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, getAmount());
541543
}
544+
/*---Added for GetAccountUpdaterJobDetails---*/
545+
public ANetApiResponse TestGetAccountUpdaterJobDetails()
546+
{
547+
return GetAccountUpdaterJobDetails.run(apiLoginId, transactionKey);
548+
}
549+
/*---End---*/
542550
}

0 commit comments

Comments
 (0)