-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathAuthorizationWithPAEnrollAuthenticationNeeded.cs
118 lines (104 loc) · 5.62 KB
/
AuthorizationWithPAEnrollAuthenticationNeeded.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
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
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 AuthorizationWithPAEnrollAuthenticationNeeded
{
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 PtsV2PaymentsPost201Response Run()
{
string clientReferenceInformationCode = "TC50171_3";
Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
Code: clientReferenceInformationCode
);
List<string> processingInformationActionList = new List<string>();
processingInformationActionList.Add("CONSUMER_AUTHENTICATION");
bool processingInformationCapture = false;
Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation(
ActionList: processingInformationActionList,
Capture: processingInformationCapture
);
string paymentInformationCardNumber = "4000000000001091";
string paymentInformationCardExpirationMonth = "12";
string paymentInformationCardExpirationYear = "2023";
Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard(
Number: paymentInformationCardNumber,
ExpirationMonth: paymentInformationCardExpirationMonth,
ExpirationYear: paymentInformationCardExpirationYear
);
Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation(
Card: paymentInformationCard
);
string orderInformationAmountDetailsTotalAmount = "100.00";
string orderInformationAmountDetailsCurrency = "usd";
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails(
TotalAmount: orderInformationAmountDetailsTotalAmount,
Currency: orderInformationAmountDetailsCurrency
);
string orderInformationBillToFirstName = "John";
string orderInformationBillToLastName = "Smith";
string orderInformationBillToAddress1 = "201 S. Division St._1";
string orderInformationBillToAddress2 = "Suite 500";
string orderInformationBillToLocality = "Foster City";
string orderInformationBillToAdministrativeArea = "CA";
string orderInformationBillToPostalCode = "94404";
string orderInformationBillToCountry = "US";
string orderInformationBillToEmail = "accept@cybersource.com";
string orderInformationBillToPhoneNumber = "6504327113";
Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo(
FirstName: orderInformationBillToFirstName,
LastName: orderInformationBillToLastName,
Address1: orderInformationBillToAddress1,
Address2: orderInformationBillToAddress2,
Locality: orderInformationBillToLocality,
AdministrativeArea: orderInformationBillToAdministrativeArea,
PostalCode: orderInformationBillToPostalCode,
Country: orderInformationBillToCountry,
Email: orderInformationBillToEmail,
PhoneNumber: orderInformationBillToPhoneNumber
);
Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation(
AmountDetails: orderInformationAmountDetails,
BillTo: orderInformationBillTo
);
string consumerAuthenticationInformationRequestorId = "123123197675";
string consumerAuthenticationInformationReferenceId = "CybsCruiseTester-8ac0b02f";
Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation(
RequestorId: consumerAuthenticationInformationRequestorId,
ReferenceId: consumerAuthenticationInformationReferenceId
);
var requestObj = new CreatePaymentRequest(
ClientReferenceInformation: clientReferenceInformation,
ProcessingInformation: processingInformation,
PaymentInformation: paymentInformation,
OrderInformation: orderInformation,
ConsumerAuthenticationInformation: consumerAuthenticationInformation
);
try
{
var configDictionary = new Configuration().GetConfiguration();
var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
var apiInstance = new PaymentsApi(clientConfig);
PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(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;
}
}
}
}