-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathElectronicCheckDebits.cs
More file actions
107 lines (93 loc) · 4.82 KB
/
Copy pathElectronicCheckDebits.cs
File metadata and controls
107 lines (93 loc) · 4.82 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
using System;
using System.Collections.Generic;
using System.Globalization;
using CyberSource.Api;
using CyberSource.Client;
using CyberSource.Model;
namespace Cybersource_rest_samples_dotnet.Samples.Payments
{
public class ElectronicCheckDebits
{
public static void WriteLogAudit(int status)
{
var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.');
var filename = filePath[filePath.Length - 1];
Console.WriteLine($"[Sample Code Testing] [{filename}] {status}");
}
public static async System.Threading.Tasks.Task<PtsV2PaymentsPost201Response> RunAsync()
{
string clientReferenceInformationCode = "TC50171_3";
Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
Code: clientReferenceInformationCode
);
string paymentInformationBankAccountType = "C";
string paymentInformationBankAccountNumber = "4100";
Ptsv2paymentsPaymentInformationBankAccount paymentInformationBankAccount = new Ptsv2paymentsPaymentInformationBankAccount(
Type: paymentInformationBankAccountType,
Number: paymentInformationBankAccountNumber
);
string paymentInformationBankRoutingNumber = "071923284";
Ptsv2paymentsPaymentInformationBank paymentInformationBank = new Ptsv2paymentsPaymentInformationBank(
Account: paymentInformationBankAccount,
RoutingNumber: paymentInformationBankRoutingNumber
);
string paymentInformationPaymentTypeName = "CHECK";
Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType(
Name: paymentInformationPaymentTypeName
);
Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation(
Bank: paymentInformationBank,
PaymentType: paymentInformationPaymentType
);
string orderInformationAmountDetailsTotalAmount = "100";
string orderInformationAmountDetailsCurrency = "USD";
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails(
TotalAmount: orderInformationAmountDetailsTotalAmount,
Currency: orderInformationAmountDetailsCurrency
);
string orderInformationBillToFirstName = "John";
string orderInformationBillToLastName = "Doe";
string orderInformationBillToAddress1 = "1 Market St";
string orderInformationBillToLocality = "san francisco";
string orderInformationBillToAdministrativeArea = "CA";
string orderInformationBillToPostalCode = "94105";
string orderInformationBillToCountry = "US";
string orderInformationBillToEmail = "test@cybs.com";
Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo(
FirstName: orderInformationBillToFirstName,
LastName: orderInformationBillToLastName,
Address1: orderInformationBillToAddress1,
Locality: orderInformationBillToLocality,
AdministrativeArea: orderInformationBillToAdministrativeArea,
PostalCode: orderInformationBillToPostalCode,
Country: orderInformationBillToCountry,
Email: orderInformationBillToEmail
);
Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation(
AmountDetails: orderInformationAmountDetails,
BillTo: orderInformationBillTo
);
var requestObj = new CreatePaymentRequest(
ClientReferenceInformation: clientReferenceInformation,
PaymentInformation: paymentInformation,
OrderInformation: orderInformation
);
try
{
var configDictionary = new Configuration().GetConfiguration();
var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
var apiInstance = new PaymentsApi(clientConfig);
PtsV2PaymentsPost201Response result = await apiInstance.CreatePaymentAsync(requestObj);
Console.WriteLine(result);
WriteLogAudit(apiInstance.GetStatusCode());
return result;
}
catch (ApiException e)
{
Console.WriteLine("Exception on calling the API : " + e.Message);
WriteLogAudit(e.ErrorCode);
return null;
}
}
}
}