-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathGetBatchStatistics.cs
72 lines (63 loc) · 2.93 KB
/
GetBatchStatistics.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AuthorizeNet;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers.Bases;
namespace net.authorize.sample
{
public class GetBatchStatistics
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Get batch statistics 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,
};
// unique batch id
string batchId = "12345";
var request = new getBatchStatisticsRequest();
request.batchId = batchId;
// instantiate the controller that will call the service
var controller = new getBatchStatisticsController(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)
{
if (response.batch == null)
return response;
Console.WriteLine("Batch Id: {0}", response.batch.batchId);
Console.WriteLine("Batch settled on (UTC): {0}", response.batch.settlementTimeUTC);
Console.WriteLine("Batch settled on (Local): {0}", response.batch.settlementTimeLocal);
Console.WriteLine("Batch settlement state: {0}", response.batch.settlementState);
Console.WriteLine("Batch payment method: {0}", response.batch.paymentMethod);
foreach (var item in response.batch.statistics)
{
Console.WriteLine(
"Account type: {0} Charge amount: {1} Charge count: {2} Refund amount: {3} Refund count: {4} Void count: {5} Decline count: {6} Error amount: {7}",
item.accountType, item.chargeAmount, item.chargeCount, item.refundAmount, item.refundCount,
item.voidCount, item.declineCount, item.errorCount);
}
}
else if (response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
else
{
Console.WriteLine("Null response");
}
return response;
}
}
}