Skip to content

Commit 55c5e8e

Browse files
committed
Testing Modified LogUtility
1 parent 4357c7d commit 55c5e8e

File tree

3 files changed

+107
-5
lines changed

3 files changed

+107
-5
lines changed

NLog.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<target name="file"
1616
xsi:type="File"
1717
layout="[${longdate:universalTime=true}] [${level:uppercase=true}] [${logger:shortName=true}] : ${message}"
18-
fileName="${basedir}\logs\application.log"
18+
fileName="${basedir}..\..\..\logs\application.log"
1919
keepFileOpen="false"
2020
archiveAboveSize="5242880"
2121
archiveNumbering="Date"
@@ -24,9 +24,9 @@
2424
layout="[${longdate:universalTime=true}] [${level:uppercase=true}] [${logger:shortName=true}] : ${message}" />
2525
</targets>
2626
<rules>
27-
<logger name="Cybersource_rest_samples_dotnet.Samples.*" minlevel="Trace" writeTo="file" />
28-
<logger name="Cybersource_rest_samples_dotnet.Samples.*" minlevel="Trace" writeTo="logconsole" />
29-
<!--<logger name="*" minlevel="Trace" writeTo="file" />
30-
<logger name="*" minlevel="Trace" writeTo="logconsole" />-->
27+
<!--<logger name="Cybersource_rest_samples_dotnet.Samples.*" minlevel="Trace" writeTo="file" />
28+
<logger name="Cybersource_rest_samples_dotnet.Samples.*" minlevel="Trace" writeTo="logconsole" />-->
29+
<logger name="*" minlevel="Trace" writeTo="file" />
30+
<logger name="*" minlevel="Trace" writeTo="logconsole" />
3131
</rules>
3232
</nlog>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using CyberSource.Api;
2+
using CyberSource.Client;
3+
using CyberSource.Model;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Cybersource_rest_samples_dotnet.Samples.Payments
11+
{
12+
public class ParallelAuth
13+
{
14+
public static async Task Run()
15+
{
16+
var task1 = Task.Run(() => AuthPayment());
17+
var task2 = Task.Run(() => AuthPayment());
18+
var task3 = Task.Run(() => AuthPayment());
19+
var task4 = Task.Run(() => AuthPayment());
20+
var task5 = Task.Run(() => AuthPayment());
21+
var task6 = Task.Run(() => AuthPayment());
22+
23+
await task1;
24+
await task2;
25+
await task3;
26+
await task4;
27+
await task5;
28+
await task6;
29+
30+
Console.WriteLine("COMPLETE");
31+
}
32+
33+
public static PtsV2PaymentsPost201Response AuthPayment()
34+
{
35+
string clientReferenceInformationCode = "TC50171_3";
36+
Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
37+
Code: clientReferenceInformationCode
38+
);
39+
40+
bool processingInformationCapture = false;
41+
42+
Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation(
43+
Capture: processingInformationCapture
44+
);
45+
46+
string paymentInformationCardNumber = "4111111111111111";
47+
string paymentInformationCardExpirationMonth = "12";
48+
string paymentInformationCardExpirationYear = "2031";
49+
Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard(
50+
Number: paymentInformationCardNumber,
51+
ExpirationMonth: paymentInformationCardExpirationMonth,
52+
ExpirationYear: paymentInformationCardExpirationYear
53+
);
54+
55+
Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation(
56+
Card: paymentInformationCard
57+
);
58+
59+
string orderInformationAmountDetailsTotalAmount = new Random().Next(100, 1000).ToString();
60+
string orderInformationAmountDetailsCurrency = "USD";
61+
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails(
62+
TotalAmount: orderInformationAmountDetailsTotalAmount,
63+
Currency: orderInformationAmountDetailsCurrency
64+
);
65+
66+
Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation(
67+
AmountDetails: orderInformationAmountDetails
68+
);
69+
70+
var requestObj = new CreatePaymentRequest(
71+
ClientReferenceInformation: clientReferenceInformation,
72+
ProcessingInformation: processingInformation,
73+
PaymentInformation: paymentInformation,
74+
OrderInformation: orderInformation
75+
);
76+
77+
try
78+
{
79+
var configDictionary = new Configuration().GetConfiguration();
80+
var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
81+
82+
var apiInstance = new PaymentsApi(clientConfig);
83+
PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj);
84+
Console.WriteLine(result);
85+
return result;
86+
}
87+
catch (ApiException err)
88+
{
89+
Console.WriteLine("Error Code: " + err.ErrorCode);
90+
Console.WriteLine("Error Message: " + err.Message);
91+
return null;
92+
}
93+
catch (Exception e)
94+
{
95+
Console.WriteLine("Exception on calling the API : " + e.Message);
96+
return null;
97+
}
98+
}
99+
}
100+
}

cybersource-rest-samples-csharp.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
<Compile Include="Source\Samples\Payments\Payments\IncrementalAuthorization.cs" />
171171
<Compile Include="Source\Samples\Payments\Payments\LevelIIData.cs" />
172172
<Compile Include="Source\Samples\Payments\Payments\LevelIIIData.cs" />
173+
<Compile Include="Source\Samples\Payments\Payments\ParallelAuth.cs" />
173174
<Compile Include="Source\Samples\Payments\Payments\PartialAuthorization.cs" />
174175
<Compile Include="Source\Samples\Payments\Payments\PaymentNetworkTokenization.cs" />
175176
<Compile Include="Source\Samples\Payments\Payments\PaymentWithFlexToken.cs" />
@@ -304,6 +305,7 @@
304305
</None>
305306
<None Include="NLog.xsd">
306307
<SubType>Designer</SubType>
308+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
307309
</None>
308310
<None Include="packages.config">
309311
<SubType>Designer</SubType>

0 commit comments

Comments
 (0)