-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathSaleUsingEMVTechnologyWithContactless.cs
More file actions
90 lines (79 loc) · 4.12 KB
/
Copy pathSaleUsingEMVTechnologyWithContactless.cs
File metadata and controls
90 lines (79 loc) · 4.12 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
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 SaleUsingEMVTechnologyWithContactless
{
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 = "123456";
Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
Code: clientReferenceInformationCode
);
bool processingInformationCapture = false;
string processingInformationCommerceIndicator = "retail";
Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation(
Capture: processingInformationCapture,
CommerceIndicator: processingInformationCommerceIndicator
);
string orderInformationAmountDetailsTotalAmount = "100.00";
string orderInformationAmountDetailsCurrency = "USD";
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails(
TotalAmount: orderInformationAmountDetailsTotalAmount,
Currency: orderInformationAmountDetailsCurrency
);
Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation(
AmountDetails: orderInformationAmountDetails
);
int pointOfSaleInformationCatLevel = 2;
string pointOfSaleInformationEntryMode = "contactless";
int pointOfSaleInformationTerminalCapability = 2;
string pointOfSaleInformationEmvCardSequenceNumber = "999";
bool pointOfSaleInformationEmvFallback = false;
Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv(
CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber,
Fallback: pointOfSaleInformationEmvFallback
);
string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?";
Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation(
CatLevel: pointOfSaleInformationCatLevel,
EntryMode: pointOfSaleInformationEntryMode,
TerminalCapability: pointOfSaleInformationTerminalCapability,
Emv: pointOfSaleInformationEmv,
TrackData: pointOfSaleInformationTrackData
);
var requestObj = new CreatePaymentRequest(
ClientReferenceInformation: clientReferenceInformation,
ProcessingInformation: processingInformation,
OrderInformation: orderInformation,
PointOfSaleInformation: pointOfSaleInformation
);
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;
}
}
}
}