Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions SampleCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions SampleCode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<Compile Include="RecurringBilling\GetSubscriptionStatus.cs" />
<Compile Include="RecurringBilling\UpdateSubscription.cs" />
<Compile Include="SampleCode.cs" />
<Compile Include="TransactionReporting\GetAccountUpdaterJobDetails.cs" />
<Compile Include="TransactionReporting\GetBatchStatistics.cs" />
<Compile Include="TransactionReporting\GetMerchantDetails.cs" />
<Compile Include="TransactionReporting\GetSettledBatchList.cs" />
Expand Down
91 changes: 55 additions & 36 deletions SampleCodeTest/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -435,5 +450,9 @@ public ANetApiResponse TestGetAnAcceptPaymentPage()
//{
// return GetAccountUpdaterJobSummary.Run(apiLoginId, transactionKey);
//}
public ANetApiResponse TestGetAccountUpdaterJobDetails()
{
return GetAccountUpdaterJobDetails.Run(apiLoginId, transactionKey);
}
}
}
91 changes: 71 additions & 20 deletions TransactionReporting/GetAccountUpdaterJobDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -25,52 +26,102 @@ 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)
var response = controller.GetApiResponse();

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;
}
}
Expand Down