-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathGetAccountUpdaterJobDetails.cs
More file actions
129 lines (111 loc) · 5.78 KB
/
GetAccountUpdaterJobDetails.cs
File metadata and controls
129 lines (111 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Controllers.Bases;
using System.Collections;
namespace net.authorize.sample
{
public class GetAccountUpdaterJobDetails
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Get Account Updater job details sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
// parameters for request
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,
offset = 1
};
// instantiate the controller that will call the service
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 : " + month);
if (response.auDetails == null)
{
Console.WriteLine("No GetAccountUpdaterjobdetails for this month");
return response;
}
// Displaying the Audetails of each response in the list
foreach (var details in response.auDetails)
{
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);
}
else if (response == null)
{
var errResponse = controller.GetErrorResponse();
Console.WriteLine("Error: " + errResponse.messages.message[0].code + " " +
response.messages.message[0].text);
}
return response;
}
}
}