From 002e289a3df993971160626930076fe0d4be9b91 Mon Sep 17 00:00:00 2001 From: sudhirkumar2018 <36911383+sudhirkumar2018@users.noreply.github.com> Date: Fri, 26 Oct 2018 16:38:00 +0530 Subject: [PATCH 1/5] PR1992_getaujobdetails_sample code_modifications 1.Added new class GetAccountUpdaterJobDetails. 2. Added code for fetching the new and old card details for updated profiles. 3. Added code for fetching the card details for deleted profile. 4. Added code for fetching subscription id in both updated and deleted profile, 5. Added new test method for the new class created in the test runner. 6. Added case statement for new class in samplecode.java file. --- .../java/net/authorize/sample/SampleCode.java | 21 ++- .../GetAccountUpdaterJobDetails.java | 178 ++++++++++++++++++ .../sample/SampleCodeTest/TestRunner.java | 26 ++- 3 files changed, 209 insertions(+), 16 deletions(-) create mode 100644 src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 3e66e7e9..7b59c39c 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -18,7 +18,7 @@ */ public class SampleCode { - public static void main( String[] args ) + public static void main( String[] args ) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { if (args.length == 0) @@ -97,6 +97,7 @@ private static void ShowMethods() System.out.println(" CancelSubscription"); System.out.println(" UpdateSubscription"); System.out.println(" GetListOfSubscriptions"); + System.out.println(" GetAccountUpdaterJobDetails"); System.out.println(" GetBatchStatistics"); System.out.println(" GetSettledBatchList"); System.out.println(" GetTransactionList"); @@ -134,19 +135,20 @@ private static void ShowMethods() System.out.println(" GetAnAcceptPaymentPage"); } - private static void RunMethod(String methodName) + private static void RunMethod(String methodName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { // These are default transaction keys. // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ - String apiLoginId = "5KP3u95bQpv"; - String transactionKey = "346HZ32z3fP4hTG2"; + String apiLoginId = "mbld_api_%63ty4Rq"; + + String transactionKey = "123abc"; //Update the payedId with which you want to run the sample code String payerId = "6ZSCSYG33VP8Q"; //Update the transactionId with which you want to run the sample code String transactionId = "123456"; - String customerProfileId = "37905546"; - String customerPaymentProfileId = "34461178"; + String customerProfileId = "40204235"; + String customerPaymentProfileId = "1000041617"; String customerAddressId = "1871959249"; String emailId = "test@test.com"; @@ -163,7 +165,8 @@ private static void RunMethod(String methodName) // System.setProperty("https.proxyPort", "portNumber"); // System.setProperty("https.proxyUserName", "exampleUsername"); // System.setProperty("https.proxyPassword", "examplePassword"); - + + switch (methodName) { case "DecryptVisaCheckoutData": DecryptVisaCheckoutData.run(apiLoginId, transactionKey); @@ -342,6 +345,10 @@ private static void RunMethod(String methodName) case "GetAnAcceptPaymentPage": GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, amount); break; + case "GetAccountUpdaterJobDetails": + GetAccountUpdaterJobDetails.run(apiLoginId, transactionKey); + break; + default: ShowUsage(); break; diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java new file mode 100644 index 00000000..f813bb33 --- /dev/null +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java @@ -0,0 +1,178 @@ +package net.authorize.sample.TransactionReporting; + +import java.util.ArrayList; +import net.authorize.Environment; +import net.authorize.api.contract.v1.ANetApiResponse; +import net.authorize.api.contract.v1.AUJobTypeEnum; +import net.authorize.api.contract.v1.AuDeleteType; +import net.authorize.api.contract.v1.AuDetailsType; +import net.authorize.api.contract.v1.AuUpdateType; +import net.authorize.api.contract.v1.CreditCardMaskedType; +import net.authorize.api.contract.v1.GetAUJobDetailsRequest; +import net.authorize.api.contract.v1.GetAUJobDetailsResponse; +import net.authorize.api.contract.v1.MerchantAuthenticationType; +import net.authorize.api.contract.v1.MessageTypeEnum; +import net.authorize.api.contract.v1.Paging; +import net.authorize.api.controller.GetAUJobDetailsController; +import net.authorize.api.controller.base.ApiOperationBase; + +public class GetAccountUpdaterJobDetails { + + public static ANetApiResponse run(String apiLoginId, String transactionKey) + throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + + // Set the request to operate in either the sandbox or production environment + ApiOperationBase.setEnvironment(Environment.SANDBOX); + + // Create object with merchant authentication details + MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType(); + merchantAuthenticationType.setName(apiLoginId); + merchantAuthenticationType.setTransactionKey(transactionKey); + + String month = "2018-08"; + String reFid = "123456"; + Paging paging = new Paging(); + paging.setLimit(100); + paging.setOffset(2); + + // Create the API request and set the parameters for this specific request + GetAUJobDetailsRequest apiRequest = new GetAUJobDetailsRequest(); + apiRequest.setMerchantAuthentication(merchantAuthenticationType); + apiRequest.setPaging(paging); + apiRequest.setRefId(reFid); + apiRequest.setMonth(month); + apiRequest.setModifiedTypeFilter(AUJobTypeEnum.ALL); + + // Call the controller + GetAUJobDetailsController controller = new GetAUJobDetailsController(apiRequest); + controller.execute(); + + GetAUJobDetailsResponse response = new GetAUJobDetailsResponse(); + response = controller.getApiResponse(); + + // If API Response is OK, go ahead and check the transaction response + if (response != null && response.getMessages().getResultCode() == MessageTypeEnum.OK) { + + System.out.println("SUCCESS: Get Account Updater job details for Month and year : " + month); + + if (response.getAuDetails() == null) { + System.out.println("No GetAccountUpdaterjobdetails for this month and year."); + return response; + } + + ArrayList updateTypeList = new ArrayList(); + ArrayList deleteTypeList = new ArrayList(); + + for (AuDetailsType details : response.getAuDetails().getAuUpdateOrAuDelete()) { + + System.out.println("---Customer profile details Start---"); + System.out.println("customerProfileID:" + details.getCustomerProfileID()); + System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); + System.out.println("customerFirstname:" + details.getFirstName()); + System.out.println("customerLastname:" + details.getLastName()); + System.out.println("updateTimeUTC:" + details.getUpdateTimeUTC()); + System.out.println("reasonCode:" + details.getAuReasonCode()); + System.out.println("reasonDescription:" + details.getReasonDescription()); + + if (details.getClass().getTypeName().toString().contains("AuUpdateType")) { + + updateTypeList.add((AuUpdateType) details); + + } else if (details.getClass().getTypeName().toString().contains("AuDeleteType")) { + + deleteTypeList.add((AuDeleteType) details); + + } + + if (!(updateTypeList.isEmpty())) { + for (int i = 0; i < updateTypeList.size(); i++) { + + System.out.println("---AU Update Start---"); + System.out.println("customerProfileID:" + details.getCustomerProfileID()); + System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); + System.out.println("customerFirstname:" + details.getFirstName()); + System.out.println("customerLastname:" + details.getLastName()); + System.out.println("updateTimeUTC:" + details.getUpdateTimeUTC()); + System.out.println("reasonCode:" + details.getAuReasonCode()); + System.out.println("reasonDescription:" + details.getReasonDescription()); + + if ((updateTypeList.get(i).getSubscriptionIdList() != null) + && (updateTypeList.get(i).getSubscriptionIdList().getSubscriptionId() != null) + && (!updateTypeList.get(i).getSubscriptionIdList().getSubscriptionId().isEmpty())) { + System.out.println("SubscriptionIdlist"); + for (String subscriptionid : updateTypeList.get(i).getSubscriptionIdList() + .getSubscriptionId()) + System.out.println("SubscriptionId:" + subscriptionid); + + } + + if (updateTypeList.get(i).getNewCreditCard() != null) { + CreditCardMaskedType newCreditCard = updateTypeList.get(i).getNewCreditCard(); + System.out.println("---Fetching New Card Details---"); + System.out.println("cardNumber:" + newCreditCard.getCardNumber()); + System.out.println("expirationDate:" + newCreditCard.getExpirationDate()); + System.out.println("cardType:" + newCreditCard.getCardType()); + + } + + if (updateTypeList.get(i).getOldCreditCard() != null) { + CreditCardMaskedType oldCreditCard = updateTypeList.get(i).getOldCreditCard(); + System.out.println("---Fetching Old Card Details---"); + System.out.println("cardNumber:" + oldCreditCard.getCardNumber()); + System.out.println("expirationDate:" + oldCreditCard.getExpirationDate()); + System.out.println("cardType:" + oldCreditCard.getCardType()); + + } + } + } + + if (!(deleteTypeList.isEmpty())) { + for (int i = 0; i < deleteTypeList.size(); i++) { + + System.out.println("---AU Delete Start---"); + System.out.println("customerProfileID:" + details.getCustomerProfileID()); + System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); + System.out.println("customerFirstname:" + details.getFirstName()); + System.out.println("customerLastname:" + details.getLastName()); + System.out.println("updateTimeUTC:" + details.getUpdateTimeUTC()); + System.out.println("reasonCode:" + details.getAuReasonCode()); + System.out.println("reasonDescription:" + details.getReasonDescription()); + + + if ((deleteTypeList.get(i).getSubscriptionIdList() != null) + && (deleteTypeList.get(i).getSubscriptionIdList().getSubscriptionId() != null) + && (!deleteTypeList.get(i).getSubscriptionIdList().getSubscriptionId().isEmpty())) { + System.out.println("SubscriptionIdlist"); + for (String subscriptionid : deleteTypeList.get(i).getSubscriptionIdList() + .getSubscriptionId()) + System.out.println("SubscriptionId:" + subscriptionid); + + } + + if (deleteTypeList.get(i).getCreditCard() != null) { + + CreditCardMaskedType creditCard = deleteTypeList.get(i).getCreditCard(); + System.out.println("cardNumber:" + creditCard.getCardNumber()); + System.out.println("expirationDate:" + creditCard.getExpirationDate()); + System.out.println("cardType:" + creditCard.getCardType()); + } + + } + } + + } + } + + else { + // Display the error code and message when response is null + ANetApiResponse errorResponse = controller.getErrorResponse(); + System.out.println("Failed to get response"); + if (!errorResponse.getMessages().getMessage().isEmpty()) { + System.out.println("Error: " + errorResponse.getMessages().getMessage().get(0).getCode() + " \n" + + errorResponse.getMessages().getMessage().get(0).getText()); + } + } + + return response; + } +} diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index c8a30c8a..ddb06e9b 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -39,14 +39,21 @@ import net.authorize.sample.CustomerProfiles.DeleteCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.DeleteCustomerProfile; import net.authorize.sample.CustomerProfiles.DeleteCustomerShippingAddress; +import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage; import net.authorize.sample.CustomerProfiles.GetCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.GetCustomerProfile; import net.authorize.sample.CustomerProfiles.GetCustomerShippingAddress; -import net.authorize.sample.CustomerProfiles.GetAcceptCustomerProfilePage; import net.authorize.sample.CustomerProfiles.UpdateCustomerPaymentProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerProfile; import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress; import net.authorize.sample.CustomerProfiles.ValidateCustomerPaymentProfile; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCapture; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCaptureContinued; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnly; +import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnlyContinued; +import net.authorize.sample.PayPalExpressCheckout.Credit; +import net.authorize.sample.PayPalExpressCheckout.GetDetails; +import net.authorize.sample.PayPalExpressCheckout.PriorAuthorizationCapture; import net.authorize.sample.PaymentTransactions.AuthorizeCreditCard; import net.authorize.sample.PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel; import net.authorize.sample.PaymentTransactions.CapturePreviouslyAuthorizedAmount; @@ -55,23 +62,18 @@ import net.authorize.sample.PaymentTransactions.ChargeTokenizedCreditCard; import net.authorize.sample.PaymentTransactions.CreditBankAccount; import net.authorize.sample.PaymentTransactions.DebitBankAccount; +import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage; import net.authorize.sample.PaymentTransactions.RefundTransaction; import net.authorize.sample.PaymentTransactions.VoidTransaction; -import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCapture; -import net.authorize.sample.PayPalExpressCheckout.AuthorizationAndCaptureContinued; -import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnly; -import net.authorize.sample.PayPalExpressCheckout.AuthorizationOnlyContinued; -import net.authorize.sample.PayPalExpressCheckout.Credit; -import net.authorize.sample.PayPalExpressCheckout.GetDetails; -import net.authorize.sample.PayPalExpressCheckout.PriorAuthorizationCapture; import net.authorize.sample.RecurringBilling.CancelSubscription; import net.authorize.sample.RecurringBilling.CreateSubscription; import net.authorize.sample.RecurringBilling.CreateSubscriptionFromCustomerProfile; import net.authorize.sample.RecurringBilling.GetSubscription; import net.authorize.sample.RecurringBilling.GetSubscriptionStatus; import net.authorize.sample.RecurringBilling.UpdateSubscription; +import net.authorize.sample.TransactionReporting.GetAccountUpdaterJobDetails; import net.authorize.sample.TransactionReporting.GetTransactionDetails; -import net.authorize.sample.PaymentTransactions.GetAnAcceptPaymentPage; + public class TestRunner { @@ -539,4 +541,10 @@ public ANetApiResponse TestGetAnAcceptPaymentPage() { return GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, getAmount()); } + /*---Added for GetAccountUpdaterJobDetails---*/ + public ANetApiResponse TestGetAccountUpdaterJobDetails() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException + { + return GetAccountUpdaterJobDetails.run(apiLoginId, transactionKey); + } + /*---End---*/ } From 59dd17ebf2a5f5c6745ddf68386db50905c89b9d Mon Sep 17 00:00:00 2001 From: JeevapriyaC <30900716+JeevapriyaC@users.noreply.github.com> Date: Wed, 7 Nov 2018 16:29:12 +0530 Subject: [PATCH 2/5] GetAccountUpdaterJobDetails review comment changes GetAccountUpdaterJobDetails review comment changes --- .../java/net/authorize/sample/SampleCode.java | 47 ++++++++++--------- .../GetAccountUpdaterJobDetails.java | 3 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index 7b59c39c..f588569b 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -1,7 +1,6 @@ package net.authorize.sample; import java.io.BufferedReader; -import java.io.IOException; import java.io.InputStreamReader; import net.authorize.sample.VisaCheckout.*; @@ -18,30 +17,30 @@ */ public class SampleCode { - public static void main( String[] args ) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException + public static void main( String[] args ) { - if (args.length == 0) - { - SelectMethod(); - } - else if (args.length == 1) - { - RunMethod(args[0]); - return; - } - else - { - ShowUsage(); - } + if (args.length == 0) + { + SelectMethod(); + } + else if (args.length == 1) + { + RunMethod(args[0]); + return; + } + else + { + ShowUsage(); + } - System.out.println(""); - System.out.print("Press to finish ..."); - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - try{ - int i = Integer.parseInt(br.readLine()); - }catch(Exception ex) { - } + System.out.println(""); + System.out.print("Press to finish ..."); + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + try{ + int i = Integer.parseInt(br.readLine()); + }catch(Exception ex) { + } } @@ -135,7 +134,7 @@ private static void ShowMethods() System.out.println(" GetAnAcceptPaymentPage"); } - private static void RunMethod(String methodName) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException + private static void RunMethod(String methodName) { // These are default transaction keys. // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ @@ -166,6 +165,7 @@ private static void RunMethod(String methodName) throws IllegalArgumentException // System.setProperty("https.proxyUserName", "exampleUsername"); // System.setProperty("https.proxyPassword", "examplePassword"); + switch (methodName) { case "DecryptVisaCheckoutData": @@ -353,5 +353,6 @@ private static void RunMethod(String methodName) throws IllegalArgumentException ShowUsage(); break; } + } } diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java index f813bb33..e42794d8 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java @@ -18,8 +18,7 @@ public class GetAccountUpdaterJobDetails { - public static ANetApiResponse run(String apiLoginId, String transactionKey) - throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + public static ANetApiResponse run(String apiLoginId, String transactionKey) { // Set the request to operate in either the sandbox or production environment ApiOperationBase.setEnvironment(Environment.SANDBOX); From 85aba41b4215c599f31e4b91f63688663fac8234 Mon Sep 17 00:00:00 2001 From: JeevapriyaC <30900716+JeevapriyaC@users.noreply.github.com> Date: Wed, 7 Nov 2018 17:00:24 +0530 Subject: [PATCH 3/5] GetAccountUpdaterJobDetails review comment changes GetAccountUpdaterJobDetails review comment changes --- .../java/net/authorize/sample/SampleCode.java | 32 +++++-------------- .../GetAccountUpdaterJobDetails.java | 19 +---------- 2 files changed, 9 insertions(+), 42 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index f588569b..a380d88a 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -1,8 +1,6 @@ package net.authorize.sample; - import java.io.BufferedReader; import java.io.InputStreamReader; - import net.authorize.sample.VisaCheckout.*; import net.authorize.sample.PaymentTransactions.*; import net.authorize.sample.PayPalExpressCheckout.*; @@ -19,7 +17,6 @@ public class SampleCode { public static void main( String[] args ) { - if (args.length == 0) { SelectMethod(); @@ -33,7 +30,6 @@ else if (args.length == 1) { ShowUsage(); } - System.out.println(""); System.out.print("Press to finish ..."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); @@ -41,7 +37,6 @@ else if (args.length == 1) int i = Integer.parseInt(br.readLine()); }catch(Exception ex) { } - } private static void ShowUsage() @@ -52,8 +47,6 @@ private static void ShowUsage() System.out.println(""); System.out.println("Code Sample Names: "); ShowMethods(); - - } private static void SelectMethod() @@ -138,35 +131,27 @@ private static void RunMethod(String methodName) { // These are default transaction keys. // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ - String apiLoginId = "mbld_api_%63ty4Rq"; - + String apiLoginId = "mbld_api_%63ty4Rq"; String transactionKey = "123abc"; //Update the payedId with which you want to run the sample code String payerId = "6ZSCSYG33VP8Q"; //Update the transactionId with which you want to run the sample code - String transactionId = "123456"; - + String transactionId = "123456"; String customerProfileId = "40204235"; String customerPaymentProfileId = "1000041617"; - String customerAddressId = "1871959249"; - - String emailId = "test@test.com"; - - String subscriptionId = "2925606"; - + String customerAddressId = "1871959249"; + String emailId = "test@test.com"; + String subscriptionId = "2925606"; Double amount = 123.45; // Proxy server settings. -// Enable these lines for using Sample Codes behind a proxy server - +// Enable these lines for using Sample Codes behind a proxy server // System.setProperty("https.proxyUse", "true"); // System.setProperty("https.proxyHost", "example.proxy.server"); // System.setProperty("https.proxyPort", "portNumber"); // System.setProperty("https.proxyUserName", "exampleUsername"); // System.setProperty("https.proxyPassword", "examplePassword"); - - - + switch (methodName) { case "DecryptVisaCheckoutData": DecryptVisaCheckoutData.run(apiLoginId, transactionKey); @@ -352,7 +337,6 @@ private static void RunMethod(String methodName) default: ShowUsage(); break; - } - + } } } diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java index e42794d8..6cc77994 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java @@ -63,7 +63,6 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { ArrayList deleteTypeList = new ArrayList(); for (AuDetailsType details : response.getAuDetails().getAuUpdateOrAuDelete()) { - System.out.println("---Customer profile details Start---"); System.out.println("customerProfileID:" + details.getCustomerProfileID()); System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); @@ -74,18 +73,13 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { System.out.println("reasonDescription:" + details.getReasonDescription()); if (details.getClass().getTypeName().toString().contains("AuUpdateType")) { - updateTypeList.add((AuUpdateType) details); - } else if (details.getClass().getTypeName().toString().contains("AuDeleteType")) { - deleteTypeList.add((AuDeleteType) details); - } if (!(updateTypeList.isEmpty())) { for (int i = 0; i < updateTypeList.size(); i++) { - System.out.println("---AU Update Start---"); System.out.println("customerProfileID:" + details.getCustomerProfileID()); System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); @@ -102,7 +96,6 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { for (String subscriptionid : updateTypeList.get(i).getSubscriptionIdList() .getSubscriptionId()) System.out.println("SubscriptionId:" + subscriptionid); - } if (updateTypeList.get(i).getNewCreditCard() != null) { @@ -111,7 +104,6 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { System.out.println("cardNumber:" + newCreditCard.getCardNumber()); System.out.println("expirationDate:" + newCreditCard.getExpirationDate()); System.out.println("cardType:" + newCreditCard.getCardType()); - } if (updateTypeList.get(i).getOldCreditCard() != null) { @@ -120,14 +112,12 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { System.out.println("cardNumber:" + oldCreditCard.getCardNumber()); System.out.println("expirationDate:" + oldCreditCard.getExpirationDate()); System.out.println("cardType:" + oldCreditCard.getCardType()); - } } } if (!(deleteTypeList.isEmpty())) { - for (int i = 0; i < deleteTypeList.size(); i++) { - + for (int i = 0; i < deleteTypeList.size(); i++) { System.out.println("---AU Delete Start---"); System.out.println("customerProfileID:" + details.getCustomerProfileID()); System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); @@ -136,7 +126,6 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { System.out.println("updateTimeUTC:" + details.getUpdateTimeUTC()); System.out.println("reasonCode:" + details.getAuReasonCode()); System.out.println("reasonDescription:" + details.getReasonDescription()); - if ((deleteTypeList.get(i).getSubscriptionIdList() != null) && (deleteTypeList.get(i).getSubscriptionIdList().getSubscriptionId() != null) @@ -145,23 +134,18 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { for (String subscriptionid : deleteTypeList.get(i).getSubscriptionIdList() .getSubscriptionId()) System.out.println("SubscriptionId:" + subscriptionid); - } if (deleteTypeList.get(i).getCreditCard() != null) { - CreditCardMaskedType creditCard = deleteTypeList.get(i).getCreditCard(); System.out.println("cardNumber:" + creditCard.getCardNumber()); System.out.println("expirationDate:" + creditCard.getExpirationDate()); System.out.println("cardType:" + creditCard.getCardType()); } - } } - } } - else { // Display the error code and message when response is null ANetApiResponse errorResponse = controller.getErrorResponse(); @@ -171,7 +155,6 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { + errorResponse.getMessages().getMessage().get(0).getText()); } } - return response; } } From ba06a5cd1e1b5804cf5ef75041642e06a630a118 Mon Sep 17 00:00:00 2001 From: JeevapriyaC <30900716+JeevapriyaC@users.noreply.github.com> Date: Wed, 7 Nov 2018 17:09:57 +0530 Subject: [PATCH 4/5] GetAccountUpdateJobDetails review comment chnges(Default credentials added) GetAccountUpdateJobDetails review comment chnges(Default credentials added) --- src/main/java/net/authorize/sample/SampleCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index a380d88a..a6f81dde 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -131,8 +131,8 @@ private static void RunMethod(String methodName) { // These are default transaction keys. // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ - String apiLoginId = "mbld_api_%63ty4Rq"; - String transactionKey = "123abc"; + String apiLoginId = "5KP3u95bQpv"; + String transactionKey = "346HZ32z3fP4hTG2"; //Update the payedId with which you want to run the sample code String payerId = "6ZSCSYG33VP8Q"; //Update the transactionId with which you want to run the sample code From 3f630710fa13006bc842073f69f0eb5685288c83 Mon Sep 17 00:00:00 2001 From: JeevapriyaC <30900716+JeevapriyaC@users.noreply.github.com> Date: Wed, 7 Nov 2018 18:42:05 +0530 Subject: [PATCH 5/5] GetAccountUpdaterJobDetails review comments change GetAccountUpdaterJobDetails review comments change. --- .../java/net/authorize/sample/SampleCode.java | 25 +++--- .../GetAccountUpdaterJobDetails.java | 81 +++++++++++-------- .../sample/SampleCodeTest/TestRunner.java | 2 +- 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/main/java/net/authorize/sample/SampleCode.java b/src/main/java/net/authorize/sample/SampleCode.java index a6f81dde..60400f47 100644 --- a/src/main/java/net/authorize/sample/SampleCode.java +++ b/src/main/java/net/authorize/sample/SampleCode.java @@ -1,4 +1,5 @@ package net.authorize.sample; + import java.io.BufferedReader; import java.io.InputStreamReader; import net.authorize.sample.VisaCheckout.*; @@ -17,6 +18,7 @@ public class SampleCode { public static void main( String[] args ) { + if (args.length == 0) { SelectMethod(); @@ -30,6 +32,7 @@ else if (args.length == 1) { ShowUsage(); } + System.out.println(""); System.out.print("Press to finish ..."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); @@ -37,6 +40,7 @@ else if (args.length == 1) int i = Integer.parseInt(br.readLine()); }catch(Exception ex) { } + } private static void ShowUsage() @@ -131,27 +135,30 @@ private static void RunMethod(String methodName) { // These are default transaction keys. // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ - String apiLoginId = "5KP3u95bQpv"; + String apiLoginId = "5KP3u95bQpv"; String transactionKey = "346HZ32z3fP4hTG2"; //Update the payedId with which you want to run the sample code String payerId = "6ZSCSYG33VP8Q"; //Update the transactionId with which you want to run the sample code - String transactionId = "123456"; + String transactionId = "123456"; String customerProfileId = "40204235"; String customerPaymentProfileId = "1000041617"; - String customerAddressId = "1871959249"; - String emailId = "test@test.com"; - String subscriptionId = "2925606"; + String customerAddressId = "1871959249"; + + String emailId = "test@test.com"; + + String subscriptionId = "2925606"; + Double amount = 123.45; // Proxy server settings. -// Enable these lines for using Sample Codes behind a proxy server +// Enable these lines for using Sample Codes behind a proxy server // System.setProperty("https.proxyUse", "true"); // System.setProperty("https.proxyHost", "example.proxy.server"); // System.setProperty("https.proxyPort", "portNumber"); // System.setProperty("https.proxyUserName", "exampleUsername"); // System.setProperty("https.proxyPassword", "examplePassword"); - + switch (methodName) { case "DecryptVisaCheckoutData": DecryptVisaCheckoutData.run(apiLoginId, transactionKey); @@ -333,10 +340,10 @@ private static void RunMethod(String methodName) case "GetAccountUpdaterJobDetails": GetAccountUpdaterJobDetails.run(apiLoginId, transactionKey); break; - default: ShowUsage(); break; - } + } + } } diff --git a/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java index 6cc77994..4da256b4 100644 --- a/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java +++ b/src/main/java/net/authorize/sample/TransactionReporting/GetAccountUpdaterJobDetails.java @@ -52,10 +52,10 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { // If API Response is OK, go ahead and check the transaction response if (response != null && response.getMessages().getResultCode() == MessageTypeEnum.OK) { - System.out.println("SUCCESS: Get Account Updater job details for Month and year : " + month); + System.out.println("SUCCESS: Get Account Updater job details for Month: " + month); if (response.getAuDetails() == null) { - System.out.println("No GetAccountUpdaterjobdetails for this month and year."); + System.out.println("No GetAccountUpdaterjobdetails for Month."); return response; } @@ -63,31 +63,37 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { ArrayList deleteTypeList = new ArrayList(); for (AuDetailsType details : response.getAuDetails().getAuUpdateOrAuDelete()) { - System.out.println("---Customer profile details Start---"); - System.out.println("customerProfileID:" + details.getCustomerProfileID()); - System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); - System.out.println("customerFirstname:" + details.getFirstName()); - System.out.println("customerLastname:" + details.getLastName()); - System.out.println("updateTimeUTC:" + details.getUpdateTimeUTC()); - System.out.println("reasonCode:" + details.getAuReasonCode()); - System.out.println("reasonDescription:" + details.getReasonDescription()); + + System.out.println("---Customer Profile Details Start---"); + System.out.println("Profile ID:" + details.getCustomerProfileID()); + System.out.println("Payment Profile ID:" + details.getCustomerPaymentProfileID()); + System.out.println("First Name:" + details.getFirstName()); + System.out.println("Last Name:" + details.getLastName()); + System.out.println("Update Time UTC:" + details.getUpdateTimeUTC()); + System.out.println("Reason Code:" + details.getAuReasonCode()); + System.out.println("Reason Description:" + details.getReasonDescription()); if (details.getClass().getTypeName().toString().contains("AuUpdateType")) { + updateTypeList.add((AuUpdateType) details); + } else if (details.getClass().getTypeName().toString().contains("AuDeleteType")) { + deleteTypeList.add((AuDeleteType) details); + } if (!(updateTypeList.isEmpty())) { for (int i = 0; i < updateTypeList.size(); i++) { + System.out.println("---AU Update Start---"); - System.out.println("customerProfileID:" + details.getCustomerProfileID()); - System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); - System.out.println("customerFirstname:" + details.getFirstName()); - System.out.println("customerLastname:" + details.getLastName()); - System.out.println("updateTimeUTC:" + details.getUpdateTimeUTC()); - System.out.println("reasonCode:" + details.getAuReasonCode()); - System.out.println("reasonDescription:" + details.getReasonDescription()); + System.out.println("Profile ID:" + details.getCustomerProfileID()); + System.out.println("Payment Profile ID:" + details.getCustomerPaymentProfileID()); + System.out.println("First Name:" + details.getFirstName()); + System.out.println("Last Name:" + details.getLastName()); + System.out.println("Update Time UTC:" + details.getUpdateTimeUTC()); + System.out.println("Reason Code:" + details.getAuReasonCode()); + System.out.println("Reason Description:" + details.getReasonDescription()); if ((updateTypeList.get(i).getSubscriptionIdList() != null) && (updateTypeList.get(i).getSubscriptionIdList().getSubscriptionId() != null) @@ -101,32 +107,33 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { if (updateTypeList.get(i).getNewCreditCard() != null) { CreditCardMaskedType newCreditCard = updateTypeList.get(i).getNewCreditCard(); System.out.println("---Fetching New Card Details---"); - System.out.println("cardNumber:" + newCreditCard.getCardNumber()); - System.out.println("expirationDate:" + newCreditCard.getExpirationDate()); - System.out.println("cardType:" + newCreditCard.getCardType()); + System.out.println("Card Number:" + newCreditCard.getCardNumber()); + System.out.println("Expiration Date:" + newCreditCard.getExpirationDate()); + System.out.println("Card Type:" + newCreditCard.getCardType()); } if (updateTypeList.get(i).getOldCreditCard() != null) { CreditCardMaskedType oldCreditCard = updateTypeList.get(i).getOldCreditCard(); System.out.println("---Fetching Old Card Details---"); - System.out.println("cardNumber:" + oldCreditCard.getCardNumber()); - System.out.println("expirationDate:" + oldCreditCard.getExpirationDate()); - System.out.println("cardType:" + oldCreditCard.getCardType()); + System.out.println("Card Number:" + oldCreditCard.getCardNumber()); + System.out.println("Expiration Date:" + oldCreditCard.getExpirationDate()); + System.out.println("Card Type:" + oldCreditCard.getCardType()); } } } if (!(deleteTypeList.isEmpty())) { - for (int i = 0; i < deleteTypeList.size(); i++) { - System.out.println("---AU Delete Start---"); - System.out.println("customerProfileID:" + details.getCustomerProfileID()); - System.out.println("customerPaymentProfileID:" + details.getCustomerPaymentProfileID()); - System.out.println("customerFirstname:" + details.getFirstName()); - System.out.println("customerLastname:" + details.getLastName()); - System.out.println("updateTimeUTC:" + details.getUpdateTimeUTC()); - System.out.println("reasonCode:" + details.getAuReasonCode()); - System.out.println("reasonDescription:" + details.getReasonDescription()); + for (int i = 0; i < deleteTypeList.size(); i++) { + System.out.println("---AU Delete Start---"); + System.out.println("Profile ID:" + details.getCustomerProfileID()); + System.out.println("Payment Profile ID:" + details.getCustomerPaymentProfileID()); + System.out.println("First Name:" + details.getFirstName()); + System.out.println("Last Name:" + details.getLastName()); + System.out.println("Update Time UTC:" + details.getUpdateTimeUTC()); + System.out.println("Reason Code:" + details.getAuReasonCode()); + System.out.println("Reason Description:" + details.getReasonDescription()); + if ((deleteTypeList.get(i).getSubscriptionIdList() != null) && (deleteTypeList.get(i).getSubscriptionIdList().getSubscriptionId() != null) && (!deleteTypeList.get(i).getSubscriptionIdList().getSubscriptionId().isEmpty())) { @@ -137,15 +144,18 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { } if (deleteTypeList.get(i).getCreditCard() != null) { + CreditCardMaskedType creditCard = deleteTypeList.get(i).getCreditCard(); - System.out.println("cardNumber:" + creditCard.getCardNumber()); - System.out.println("expirationDate:" + creditCard.getExpirationDate()); - System.out.println("cardType:" + creditCard.getCardType()); + System.out.println("Card Number:" + creditCard.getCardNumber()); + System.out.println("Expiration Date:" + creditCard.getExpirationDate()); + System.out.println("Card Type:" + creditCard.getCardType()); } + } } } } + else { // Display the error code and message when response is null ANetApiResponse errorResponse = controller.getErrorResponse(); @@ -155,6 +165,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) { + errorResponse.getMessages().getMessage().get(0).getText()); } } + return response; } } diff --git a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java index ddb06e9b..bacac66b 100644 --- a/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java +++ b/src/test/java/net/authorize/sample/SampleCodeTest/TestRunner.java @@ -542,7 +542,7 @@ public ANetApiResponse TestGetAnAcceptPaymentPage() return GetAnAcceptPaymentPage.run(apiLoginId, transactionKey, getAmount()); } /*---Added for GetAccountUpdaterJobDetails---*/ - public ANetApiResponse TestGetAccountUpdaterJobDetails() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException + public ANetApiResponse TestGetAccountUpdaterJobDetails() { return GetAccountUpdaterJobDetails.run(apiLoginId, transactionKey); }