1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Globalization ;
4
+
5
+ using CyberSource . Api ;
6
+ using CyberSource . Model ;
7
+
8
+ namespace Cybersource_rest_samples_dotnet . Samples . Payments
9
+ {
10
+ public class CITInitiatingInstalmentSubscriptionUK
11
+ {
12
+ public static PtsV2PaymentsPost201Response Run ( )
13
+ {
14
+ string clientReferenceInformationCode = "TC50171_3" ;
15
+ Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation (
16
+ Code : clientReferenceInformationCode
17
+ ) ;
18
+
19
+ bool processingInformationCapture = false ;
20
+ string processingInformationCommerceIndicator = "vbv" ;
21
+ bool processingInformationAuthorizationOptionsIgnoreAvsResult = false ;
22
+ bool processingInformationAuthorizationOptionsIgnoreCvResult = false ;
23
+ bool processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile = true ;
24
+ Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator (
25
+ CredentialStoredOnFile : processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile
26
+ ) ;
27
+
28
+ Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions (
29
+ IgnoreAvsResult : processingInformationAuthorizationOptionsIgnoreAvsResult ,
30
+ IgnoreCvResult : processingInformationAuthorizationOptionsIgnoreCvResult ,
31
+ Initiator : processingInformationAuthorizationOptionsInitiator
32
+ ) ;
33
+
34
+ bool processingInformationRecurringOptionsLoanPayment = false ;
35
+ bool processingInformationRecurringOptionsFirstRecurringPayment = true ;
36
+ Ptsv2paymentsProcessingInformationRecurringOptions processingInformationRecurringOptions = new Ptsv2paymentsProcessingInformationRecurringOptions (
37
+ LoanPayment : processingInformationRecurringOptionsLoanPayment ,
38
+ FirstRecurringPayment : processingInformationRecurringOptionsFirstRecurringPayment
39
+ ) ;
40
+
41
+ Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation (
42
+ Capture : processingInformationCapture ,
43
+ CommerceIndicator : processingInformationCommerceIndicator ,
44
+ AuthorizationOptions : processingInformationAuthorizationOptions ,
45
+ RecurringOptions : processingInformationRecurringOptions
46
+ ) ;
47
+
48
+ string paymentInformationCardNumber = "4111111111111111" ;
49
+ string paymentInformationCardExpirationMonth = "12" ;
50
+ string paymentInformationCardExpirationYear = "2031" ;
51
+ Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard (
52
+ Number : paymentInformationCardNumber ,
53
+ ExpirationMonth : paymentInformationCardExpirationMonth ,
54
+ ExpirationYear : paymentInformationCardExpirationYear
55
+ ) ;
56
+
57
+ Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation (
58
+ Card : paymentInformationCard
59
+ ) ;
60
+
61
+ string orderInformationAmountDetailsTotalAmount = "102.21" ;
62
+ string orderInformationAmountDetailsCurrency = "GBP" ;
63
+ Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails (
64
+ TotalAmount : orderInformationAmountDetailsTotalAmount ,
65
+ Currency : orderInformationAmountDetailsCurrency
66
+ ) ;
67
+
68
+ string orderInformationBillToFirstName = "John" ;
69
+ string orderInformationBillToLastName = "Doe" ;
70
+ string orderInformationBillToAddress1 = "1 Market St" ;
71
+ string orderInformationBillToLocality = "san francisco" ;
72
+ string orderInformationBillToAdministrativeArea = "CA" ;
73
+ string orderInformationBillToPostalCode = "94105" ;
74
+ string orderInformationBillToCountry = "US" ;
75
+ string orderInformationBillToEmail = "[email protected] " ;
76
+ string orderInformationBillToPhoneNumber = "4158880000" ;
77
+ Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo (
78
+ FirstName : orderInformationBillToFirstName ,
79
+ LastName : orderInformationBillToLastName ,
80
+ Address1 : orderInformationBillToAddress1 ,
81
+ Locality : orderInformationBillToLocality ,
82
+ AdministrativeArea : orderInformationBillToAdministrativeArea ,
83
+ PostalCode : orderInformationBillToPostalCode ,
84
+ Country : orderInformationBillToCountry ,
85
+ Email : orderInformationBillToEmail ,
86
+ PhoneNumber : orderInformationBillToPhoneNumber
87
+ ) ;
88
+
89
+ Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation (
90
+ AmountDetails : orderInformationAmountDetails ,
91
+ BillTo : orderInformationBillTo
92
+ ) ;
93
+
94
+ string consumerAuthenticationInformationCavv = "EHuWW9PiBkWvqE5juRwDzAUFBAk=" ;
95
+ Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation (
96
+ Cavv : consumerAuthenticationInformationCavv
97
+ ) ;
98
+
99
+ var requestObj = new CreatePaymentRequest (
100
+ ClientReferenceInformation : clientReferenceInformation ,
101
+ ProcessingInformation : processingInformation ,
102
+ PaymentInformation : paymentInformation ,
103
+ OrderInformation : orderInformation ,
104
+ ConsumerAuthenticationInformation : consumerAuthenticationInformation
105
+ ) ;
106
+
107
+ try
108
+ {
109
+ var configDictionary = new Configuration ( ) . GetConfiguration ( ) ;
110
+ var clientConfig = new CyberSource . Client . Configuration ( merchConfigDictObj : configDictionary ) ;
111
+
112
+ var apiInstance = new PaymentsApi ( clientConfig ) ;
113
+ PtsV2PaymentsPost201Response result = apiInstance . CreatePayment ( requestObj ) ;
114
+ Console . WriteLine ( result ) ;
115
+ return result ;
116
+ }
117
+ catch ( Exception e )
118
+ {
119
+ Console . WriteLine ( "Exception on calling the API : " + e . Message ) ;
120
+ return null ;
121
+ }
122
+ }
123
+ }
124
+ }
0 commit comments