From 3a58293daba9ce3f73394ea8940e8bbe7459d0d3 Mon Sep 17 00:00:00 2001 From: kapilkumar99 <36911550+kapilkumar99@users.noreply.github.com> Date: Wed, 24 Oct 2018 13:47:36 +0530 Subject: [PATCH 1/5] PR1992#Modified files 1)GetAccountUpdaterJobDetails.cs 2)TestRunner.cs --- SampleCodeTest/TestRunner.cs | 91 +++++++++++-------- .../GetAccountUpdaterJobDetails.cs | 91 +++++++++++++++---- 2 files changed, 126 insertions(+), 56 deletions(-) diff --git a/SampleCodeTest/TestRunner.cs b/SampleCodeTest/TestRunner.cs index 79fa80e..dfe2dab 100644 --- a/SampleCodeTest/TestRunner.cs +++ b/SampleCodeTest/TestRunner.cs @@ -42,51 +42,66 @@ private static short GetMonth() [Test] public void TestAllSampleCodes() { - string fileName = Constants.CONFIG_FILE; - StreamReader reader = File.OpenText(fileName); - TestRunner tr = new TestRunner(); - var numRetries = 3; - string line; - while ((line = reader.ReadLine()) != null) + try { - string[] items = line.Split('\t'); - - string apiName = items[0]; - string isDependent = items[1]; - string shouldApiRun = items[2]; - - if (!shouldApiRun.Equals("1")) - continue; - - Console.WriteLine(new String('-', 20)); - Console.WriteLine("Running test case for :: " + apiName); - Console.WriteLine(new String('-', 20)); - ANetApiResponse response = null; - for (int i = 0; i < numRetries; ++i) + string fileName = Constants.CONFIG_FILE; + using (StreamReader reader = File.OpenText(fileName)) { - try + TestRunner tr = new TestRunner(); + var numRetries = 3; + + string line; + while ((line = reader.ReadLine()) != null) { - if (isDependent.Equals("0")) - { - response = InvokeRunMethod(apiName); - } - else + string[] items = line.Split('\t'); + + string apiName = items[0]; + string isDependent = items[1]; + string shouldApiRun = items[2]; + + if (!shouldApiRun.Equals("1")) + continue; + + Console.WriteLine(new String('-', 20)); + Console.WriteLine("Running test case for :: " + apiName); + Console.WriteLine(new String('-', 20)); + ANetApiResponse response = null; + for (int i = 0; i < numRetries; ++i) { - response = (ANetApiResponse)typeof(TestRunner).GetMethod("Test" + apiName).Invoke(tr, new Object[] { }); + try + { + if (isDependent.Equals("0")) + { + response = InvokeRunMethod(apiName); + } + else + { + response = (ANetApiResponse)typeof(TestRunner).GetMethod("Test" + apiName).Invoke(tr, new Object[] { }); + } + + if ((response != null) && (response.messages.resultCode == messageTypeEnum.Ok)) + break; + + } + catch (Exception ex) + + { + Console.WriteLine(ex.ToString()); + } } - if ((response != null) && (response.messages.resultCode == messageTypeEnum.Ok)) - break; - } - catch (Exception e) - { - Console.WriteLine(apiName); - Console.WriteLine(e.ToString()); + Assert.IsNotNull(response); + Assert.AreEqual(response.messages.resultCode, messageTypeEnum.Ok); } + } - Assert.IsNotNull(response); - Assert.AreEqual(response.messages.resultCode, messageTypeEnum.Ok); + + } + catch (Exception ex) + { + + throw ex; } } @@ -435,5 +450,9 @@ public ANetApiResponse TestGetAnAcceptPaymentPage() //{ // return GetAccountUpdaterJobSummary.Run(apiLoginId, transactionKey); //} + public ANetApiResponse TestGetAccountUpdaterJobDetails() + { + return GetAccountUpdaterJobDetails.Run(apiLoginId, transactionKey); + } } } diff --git a/TransactionReporting/GetAccountUpdaterJobDetails.cs b/TransactionReporting/GetAccountUpdaterJobDetails.cs index f74f4a0..47a511e 100644 --- a/TransactionReporting/GetAccountUpdaterJobDetails.cs +++ b/TransactionReporting/GetAccountUpdaterJobDetails.cs @@ -6,6 +6,7 @@ using AuthorizeNet.Api.Contracts.V1; using AuthorizeNet.Api.Controllers; using AuthorizeNet.Api.Controllers.Bases; +using System.Collections; namespace net.authorize.sample { @@ -25,20 +26,20 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey) }; // parameters for request - string month = "2017-06"; - string modifiedTypeFilter = "all" + string month = "2018-08"; //"2017-06"; + string modifiedTypeFilter = "all"; - var request = new getAccountUpdaterJobDetailsRequest(); + var request = new getAUJobDetailsRequest(); request.month = month; - request.modifiedTypeFilter = modifiedTypeFilter; + request.modifiedTypeFilter = AUJobTypeEnum.all; request.paging = new Paging { - limit = 1000, + limit = 100, offset = 1 }; // instantiate the controller that will call the service - var controller = new getAccountUpdaterJobDetailsController(request); + var controller = new getAUJobDetailsController(request); controller.Execute(); // get the response from the service (errors contained if any) @@ -46,31 +47,81 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey) if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { + Console.WriteLine("SUCCESS: Get Account Updater job details for Month and year : " + month); if (response.auDetails == null) - return response; - - foreach (var update in response.auDetails.auUpdate) { - Console.WriteLine("Profile ID / Payment Profile ID: {0} / {1}", update.customerProfileID, update.customerPaymentProfileID); - Console.WriteLine("Update Time (UTC): {0}", update.updateTimeUTC); - Console.WriteLine("Reason Code: {0}", update.auReasonCode); - Console.WriteLine("Reason Description: {0}", update.reasonDescription); + Console.WriteLine("No GetAccountUpdaterjobdetails for this month and year."); + return response; } - foreach (var delete in response.auDetails.auDelete) + // Displaying the Audetails of each response in the list + foreach (var details in response.auDetails) { - Console.WriteLine("Profile ID / Payment Profile ID: {0} / {1}", delete.customerProfileID, update.customerPaymentProfileID); - Console.WriteLine("Update Time (UTC): {0}", delete.updateTimeUTC); - Console.WriteLine("Reason Code: {0}", delete.auReasonCode); - Console.WriteLine("Reason Description: {0}", delete.reasonDescription); + + + Console.WriteLine(" **** Customer profile details Start ****"); + Console.WriteLine("Profile ID / Payment Profile ID: {0} / {1}", details.customerProfileID, details.customerPaymentProfileID); + Console.WriteLine("Firstname lastname : {0} / {1}", details.firstName, details.lastName); + Console.WriteLine("Update Time (UTC): {0}", details.updateTimeUTC); + Console.WriteLine("Reason Code: {0}", details.auReasonCode); + Console.WriteLine("Reason Description: {0}", details.reasonDescription); + + + if (details is auUpdateType) + { + for (int i = 0; i < ((auUpdateType)details).subscriptionIdList.Length; i++) + { + Console.WriteLine("SubscriptionIdList: {0}", ((auUpdateType)details).subscriptionIdList[i]); + } + } + else if (details is auDeleteType) + { + for (int i = 0; i < ((auDeleteType)details).subscriptionIdList.Length; i++) + { + Console.WriteLine("SubscriptionIdList: {0}", ((auDeleteType)details).subscriptionIdList[i]); + } + } + + + if (details.GetType().GetField("newCreditCard") != null) + { + Console.WriteLine("Fetching New Card Details"); + // Fetching New Card Details + var newCreditCard = details.GetType().GetField("newCreditCard").GetValue(details); + creditCardMaskedType newCreditCardMaskedType = (creditCardMaskedType)newCreditCard; + Console.WriteLine("Card Number: {0}", newCreditCardMaskedType.cardNumber); + Console.WriteLine("New Expiration Date: {0}", newCreditCardMaskedType.expirationDate); + Console.WriteLine("New Card Type: {0}", newCreditCardMaskedType.cardType); + + } + + if (details.GetType().GetField("oldCreditCard") != null) + { + Console.WriteLine("Fetching Old Card Details"); + // Fetching Old Card Details + var oldCreditCard = details.GetType().GetField("oldCreditCard").GetValue(details); + creditCardMaskedType oldCreditCardMaskedType = (creditCardMaskedType)oldCreditCard; + Console.WriteLine("Old Card Number: {0}", oldCreditCardMaskedType.cardNumber); + Console.WriteLine("Old Expiration Date: {0}", oldCreditCardMaskedType.expirationDate); + Console.WriteLine("Old Card Type: {0}", oldCreditCardMaskedType.cardType); + + Console.WriteLine("**** Customer profile details End ****"); + } } + } + else if (response != null) { Console.WriteLine("Error: " + response.messages.message[0].code + " " + - response.messages.message[0].text); + response.messages.message[0].text); + } + else if (response == null) + { + var errResponse = controller.GetErrorResponse(); + Console.WriteLine("Error: " + errResponse.messages.message[0].code + " " + + response.messages.message[0].text); } - return response; } } From 27a119b21fdf266478fa5d511e7ab8076d47e588 Mon Sep 17 00:00:00 2001 From: kapilkumar99 <36911550+kapilkumar99@users.noreply.github.com> Date: Fri, 26 Oct 2018 12:34:33 +0530 Subject: [PATCH 2/5] PR#1992 Modified Sample.cs class --- SampleCode.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SampleCode.cs b/SampleCode.cs index db546ce..9a38b98 100644 --- a/SampleCode.cs +++ b/SampleCode.cs @@ -127,14 +127,15 @@ private static void ShowMethods() Console.WriteLine(" GetAnAcceptPaymentPage"); Console.WriteLine(" GetCustomerProfileTransactionList"); Console.WriteLine(" GetAccountUpdaterJobSummary"); + Console.WriteLine(" GetAccountUpdaterJobDetails"); } 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/ - const string apiLoginId = "5KP3u95bQpv"; - const string transactionKey = "346HZ32z3fP4hTG2"; + const string apiLoginId = "mbld_api_-Bgb1Oig"; + const string transactionKey = "123abc"; //Update TransactionID for which you want to run the sample code const string transactionId = "2249735976"; @@ -335,6 +336,9 @@ private static void RunMethod(String methodName) //case "GetAccountUpdaterJobSummary": // GetAccountUpdaterJobSummary.Run(apiLoginId, transactionKey); // break; + case "GetAccountUpdaterJobDetails": + GetAccountUpdaterJobDetails.Run(apiLoginId, transactionKey); + break; default: ShowUsage(); break; From 740910f3cb69ed56f1fbb1cf7347af9fba2da407 Mon Sep 17 00:00:00 2001 From: kapilkumar99 <36911550+kapilkumar99@users.noreply.github.com> Date: Thu, 1 Nov 2018 16:38:47 +0530 Subject: [PATCH 3/5] Added SampleCode.csproj file --- SampleCode.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/SampleCode.csproj b/SampleCode.csproj index 96585c5..657802d 100644 --- a/SampleCode.csproj +++ b/SampleCode.csproj @@ -100,6 +100,7 @@ + From 7562b54b88fa7ec3f5bc2cf0edb3b0f3fa3d3afb Mon Sep 17 00:00:00 2001 From: kapilkumar99 <36911550+kapilkumar99@users.noreply.github.com> Date: Tue, 6 Nov 2018 15:27:10 +0530 Subject: [PATCH 4/5] Reverted exception handling code --- SampleCodeTest/TestRunner.cs | 87 +++++++++++++++--------------------- 1 file changed, 36 insertions(+), 51 deletions(-) diff --git a/SampleCodeTest/TestRunner.cs b/SampleCodeTest/TestRunner.cs index dfe2dab..a81c377 100644 --- a/SampleCodeTest/TestRunner.cs +++ b/SampleCodeTest/TestRunner.cs @@ -42,66 +42,51 @@ private static short GetMonth() [Test] public void TestAllSampleCodes() { + string fileName = Constants.CONFIG_FILE; + StreamReader reader = File.OpenText(fileName); + TestRunner tr = new TestRunner(); + var numRetries = 3; - try + string line; + while ((line = reader.ReadLine()) != null) { - string fileName = Constants.CONFIG_FILE; - using (StreamReader reader = File.OpenText(fileName)) + string[] items = line.Split('\t'); + + string apiName = items[0]; + string isDependent = items[1]; + string shouldApiRun = items[2]; + + if (!shouldApiRun.Equals("1")) + continue; + + Console.WriteLine(new String('-', 20)); + Console.WriteLine("Running test case for :: " + apiName); + Console.WriteLine(new String('-', 20)); + ANetApiResponse response = null; + for (int i = 0; i < numRetries; ++i) { - TestRunner tr = new TestRunner(); - var numRetries = 3; - - string line; - while ((line = reader.ReadLine()) != null) + try { - string[] items = line.Split('\t'); - - string apiName = items[0]; - string isDependent = items[1]; - string shouldApiRun = items[2]; - - if (!shouldApiRun.Equals("1")) - continue; - - Console.WriteLine(new String('-', 20)); - Console.WriteLine("Running test case for :: " + apiName); - Console.WriteLine(new String('-', 20)); - ANetApiResponse response = null; - for (int i = 0; i < numRetries; ++i) + if (isDependent.Equals("0")) { - try - { - if (isDependent.Equals("0")) - { - response = InvokeRunMethod(apiName); - } - else - { - response = (ANetApiResponse)typeof(TestRunner).GetMethod("Test" + apiName).Invoke(tr, new Object[] { }); - } - - if ((response != null) && (response.messages.resultCode == messageTypeEnum.Ok)) - break; - - } - catch (Exception ex) - - { - Console.WriteLine(ex.ToString()); - } + response = InvokeRunMethod(apiName); + } + else + { + response = (ANetApiResponse)typeof(TestRunner).GetMethod("Test" + apiName).Invoke(tr, new Object[] { }); } - Assert.IsNotNull(response); - Assert.AreEqual(response.messages.resultCode, messageTypeEnum.Ok); + if ((response != null) && (response.messages.resultCode == messageTypeEnum.Ok)) + break; + } + catch (Exception e) + { + Console.WriteLine(apiName); + Console.WriteLine(e.ToString()); } - } - - } - catch (Exception ex) - { - - throw ex; + Assert.IsNotNull(response); + Assert.AreEqual(response.messages.resultCode, messageTypeEnum.Ok); } } From 4420f7faeb6470c8a672b795240d12aecc700cfb Mon Sep 17 00:00:00 2001 From: kapilkumar99 <36911550+kapilkumar99@users.noreply.github.com> Date: Tue, 6 Nov 2018 16:46:49 +0530 Subject: [PATCH 5/5] Done necessary changes to resolve the comments --- SampleCode.cs | 4 ++-- TransactionReporting/GetAccountUpdaterJobDetails.cs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/SampleCode.cs b/SampleCode.cs index 9a38b98..98adf68 100644 --- a/SampleCode.cs +++ b/SampleCode.cs @@ -134,8 +134,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/ - const string apiLoginId = "mbld_api_-Bgb1Oig"; - const string transactionKey = "123abc"; + const string apiLoginId = "5KP3u95bQpv"; + const string transactionKey = "346HZ32z3fP4hTG2"; //Update TransactionID for which you want to run the sample code const string transactionId = "2249735976"; diff --git a/TransactionReporting/GetAccountUpdaterJobDetails.cs b/TransactionReporting/GetAccountUpdaterJobDetails.cs index 47a511e..ee5c939 100644 --- a/TransactionReporting/GetAccountUpdaterJobDetails.cs +++ b/TransactionReporting/GetAccountUpdaterJobDetails.cs @@ -26,12 +26,13 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey) }; // parameters for request - string month = "2018-08"; //"2017-06"; + string month = "2017-06"; string modifiedTypeFilter = "all"; - + string refId = "123456"; var request = new getAUJobDetailsRequest(); request.month = month; request.modifiedTypeFilter = AUJobTypeEnum.all; + request.refId = refId; request.paging = new Paging { limit = 100, @@ -47,10 +48,10 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey) if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { - Console.WriteLine("SUCCESS: Get Account Updater job details for Month and year : " + month); + Console.WriteLine("SUCCESS: Get Account Updater job details for Month : " + month); if (response.auDetails == null) { - Console.WriteLine("No GetAccountUpdaterjobdetails for this month and year."); + Console.WriteLine("No GetAccountUpdaterjobdetails for this month"); return response; } @@ -61,7 +62,7 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey) Console.WriteLine(" **** Customer profile details Start ****"); Console.WriteLine("Profile ID / Payment Profile ID: {0} / {1}", details.customerProfileID, details.customerPaymentProfileID); - Console.WriteLine("Firstname lastname : {0} / {1}", details.firstName, details.lastName); + Console.WriteLine("FirstName LastName : {0} / {1}", details.firstName, details.lastName); Console.WriteLine("Update Time (UTC): {0}", details.updateTimeUTC); Console.WriteLine("Reason Code: {0}", details.auReasonCode); Console.WriteLine("Reason Description: {0}", details.reasonDescription); @@ -105,7 +106,7 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey) Console.WriteLine("Old Expiration Date: {0}", oldCreditCardMaskedType.expirationDate); Console.WriteLine("Old Card Type: {0}", oldCreditCardMaskedType.cardType); - Console.WriteLine("**** Customer profile details End ****"); + Console.WriteLine("**** Customer Profile Details End ****"); } }