Repository navigation
Expand file tree
/
Copy pathIncrementalAuthorization.cs
More file actions
89 lines (76 loc) · 4.17 KB
/
Copy pathIncrementalAuthorization.cs
File metadata and controls
89 lines (76 loc) · 4.17 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
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 IncrementalAuthorization
{
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<PtsV2IncrementalAuthorizationPatch201Response> RunAsync()
{
string id = (await AuthorizationForIncrementalAuthorizationFlow.RunAsync()).Id;
string clientReferenceInformationCode = "TC50171_3";
Ptsv2paymentsidClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidClientReferenceInformation(
Code: clientReferenceInformationCode
);
bool processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed = true;
Ptsv2paymentsidProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsidProcessingInformationAuthorizationOptionsInitiator(
StoredCredentialUsed: processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed
);
Ptsv2paymentsidProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsidProcessingInformationAuthorizationOptions(
Initiator: processingInformationAuthorizationOptionsInitiator
);
Ptsv2paymentsidProcessingInformation processingInformation = new Ptsv2paymentsidProcessingInformation(
AuthorizationOptions: processingInformationAuthorizationOptions
);
string orderInformationAmountDetailsAdditionalAmount = "22.49";
string orderInformationAmountDetailsCurrency = "USD";
Ptsv2paymentsidOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidOrderInformationAmountDetails(
AdditionalAmount: orderInformationAmountDetailsAdditionalAmount,
Currency: orderInformationAmountDetailsCurrency
);
Ptsv2paymentsidOrderInformation orderInformation = new Ptsv2paymentsidOrderInformation(
AmountDetails: orderInformationAmountDetails
);
string merchantInformationTransactionLocalDateTime = "20191002080000";
Ptsv2paymentsidMerchantInformation merchantInformation = new Ptsv2paymentsidMerchantInformation(
TransactionLocalDateTime: merchantInformationTransactionLocalDateTime
);
string travelInformationDuration = "4";
Ptsv2paymentsidTravelInformation travelInformation = new Ptsv2paymentsidTravelInformation(
Duration: travelInformationDuration
);
var requestObj = new IncrementAuthRequest(
ClientReferenceInformation: clientReferenceInformation,
ProcessingInformation: processingInformation,
OrderInformation: orderInformation,
MerchantInformation: merchantInformation,
TravelInformation: travelInformation
);
try
{
var configDictionary = new Configuration().GetAlternativeConfiguration();
var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
var apiInstance = new PaymentsApi(clientConfig);
PtsV2IncrementalAuthorizationPatch201Response result = await apiInstance.IncrementAuthAsync(id, 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;
}
}
}
}