Skip to content

Commit 1219f87

Browse files
committed
Upgrade to latest version of SDK
1 parent 0877a8e commit 1219f87

13 files changed

+365
-11
lines changed

src/SampleCode.csproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</Reference>
4646
<Reference Include="cybersource-rest-client-dotnet, Version=0.0.1.5, Culture=neutral, processorArchitecture=MSIL">
4747
<SpecificVersion>False</SpecificVersion>
48-
<HintPath>..\packages\CyberSource.Rest.Client.0.0.1.5\lib\cybersource-rest-client-dotnet.dll</HintPath>
48+
<HintPath>..\packages\CyberSource.Rest.Client.0.0.1.6\lib\cybersource-rest-client-dotnet.dll</HintPath>
4949
</Reference>
5050
<Reference Include="jose-jwt">
5151
<HintPath>..\packages\jose-jwt.2.4.0\lib\net461\jose-jwt.dll</HintPath>
@@ -95,7 +95,9 @@
9595
<Compile Include="Samples\Authentication\GenerateHttpRequestHeaders\PutGenerateHeaders.cs" />
9696
<Compile Include="Samples\Authentication\StandAloneHttpSignature.cs" />
9797
<Compile Include="Samples\Authentication\StandAloneJWT.cs" />
98+
<Compile Include="Samples\FlexMicroform\FlexTokenizeCard.cs" />
9899
<Compile Include="Samples\FlexMicroform\GenerateKey.cs" />
100+
<Compile Include="Samples\FlexMicroform\GenerateKeyLegacyTokenFormat.cs" />
99101
<Compile Include="Samples\Invoicing\InvoiceSettings\GetInvoiceSettings.cs" />
100102
<Compile Include="Samples\Invoicing\InvoiceSettings\UpdateInvoiceSettings.cs" />
101103
<Compile Include="Samples\Invoicing\Invoices\CreateAndSendInvoiceImmediately.cs" />
@@ -134,6 +136,7 @@
134136
<Compile Include="Samples\Payments\Payments\AuthorizationForIncrementalAuthorizationFlow.cs" />
135137
<Compile Include="Samples\Payments\Payments\AuthorizationForTimeoutReversalFlow.cs" />
136138
<Compile Include="Samples\Payments\Payments\AuthorizationSkipDecisionManagerForSingleTransaction.cs" />
139+
<Compile Include="Samples\Payments\Payments\AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer.cs" />
137140
<Compile Include="Samples\Payments\Payments\AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect.cs" />
138141
<Compile Include="Samples\Payments\Payments\AuthorizationUsingSwipedTrackData.cs" />
139142
<Compile Include="Samples\Payments\Payments\AuthorizationWithCaptureSale.cs" />
@@ -163,6 +166,7 @@
163166
<Compile Include="Samples\Payments\Payments\PartialAuthorization.cs" />
164167
<Compile Include="Samples\Payments\Payments\PaymentNetworkTokenization.cs" />
165168
<Compile Include="Samples\Payments\Payments\PaymentWithFlexToken.cs" />
169+
<Compile Include="Samples\Payments\Payments\PaymentWithFlexTokenCreatePermanentTMSToken.cs" />
166170
<Compile Include="Samples\Payments\Payments\RestaurantAuthorization.cs" />
167171
<Compile Include="Samples\Payments\Payments\SaleUsingEMVTechnologyWithContactless.cs" />
168172
<Compile Include="Samples\Payments\Payments\SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
5+
using CyberSource.Api;
6+
using CyberSource.Model;
7+
using CyberSource.Utilities.Flex.Model;
8+
using CyberSource.Utilities.Flex.TokenVerification;
9+
10+
namespace Cybersource_rest_samples_dotnet.Samples.FlexMicroform
11+
{
12+
public class FlexTokenizeCard
13+
{
14+
public static FlexV1TokensPost200Response Run()
15+
{
16+
var generateKeyResult = GenerateKeyLegacyTokenFormat.Run();
17+
string keyId = generateKeyResult.KeyId;
18+
var derFormat = generateKeyResult.Der.Format;
19+
var derAlgo = generateKeyResult.Der.Algorithm;
20+
var derPublicKey = generateKeyResult.Der.PublicKey;
21+
22+
string cardInfoCardNumber = "4111111111111111";
23+
string cardInfoCardExpirationMonth = "12";
24+
string cardInfoCardExpirationYear = "2031";
25+
string cardInfoCardType = "001";
26+
Flexv1tokensCardInfo cardInfo = new Flexv1tokensCardInfo(
27+
CardNumber: cardInfoCardNumber,
28+
CardExpirationMonth: cardInfoCardExpirationMonth,
29+
CardExpirationYear: cardInfoCardExpirationYear,
30+
CardType: cardInfoCardType
31+
);
32+
33+
var requestObj = new TokenizeRequest(
34+
KeyId: keyId,
35+
CardInfo: cardInfo
36+
);
37+
38+
try
39+
{
40+
var configDictionary = new Configuration().GetConfiguration();
41+
var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
42+
43+
var apiInstance = new TokenizationApi(clientConfig);
44+
FlexV1TokensPost200Response result = apiInstance.Tokenize(requestObj);
45+
Console.WriteLine(result);
46+
47+
TokenVerificationUtility tokenVerifier = new TokenVerificationUtility();
48+
49+
var flexPublicKey = new FlexPublicKey(keyId, new FlexDerPublicKey(derFormat, derAlgo, derPublicKey), null);
50+
var flexToken = new FlexToken()
51+
{
52+
keyId = result.KeyId,
53+
token = result.Token,
54+
maskedPan = result.MaskedPan,
55+
cardType = result.CardType,
56+
timestamp = (long)result.Timestamp,
57+
signedFields = result.SignedFields,
58+
signature = result.Signature,
59+
discoverableServices = result.DiscoverableServices
60+
};
61+
62+
IDictionary<string, string> postParameters = new Dictionary<string, string>();
63+
postParameters["signedFields"] = flexToken.signedFields;
64+
postParameters["signature"] = flexToken.signature;
65+
postParameters["cardType"] = flexToken.cardType;
66+
postParameters["keyId"] = flexToken.keyId;
67+
postParameters["maskedPan"] = flexToken.maskedPan;
68+
postParameters["token"] = flexToken.token;
69+
postParameters["timestamp"] = Convert.ToString(flexToken.timestamp);
70+
71+
var tokenVerificationResult = tokenVerifier.Verify(flexPublicKey, postParameters);
72+
Console.WriteLine("TOKEN VERIFICATION : " + tokenVerificationResult);
73+
74+
return result;
75+
}
76+
catch (Exception e)
77+
{
78+
Console.WriteLine("Exception on calling the API : " + e.Message);
79+
return null;
80+
}
81+
}
82+
}
83+
}

src/Samples/FlexMicroform/GenerateKey.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using CyberSource.Api;
66
using CyberSource.Model;
77

8-
namespace Cybersource_rest_samples_dotnet.Samples.Flex
8+
namespace Cybersource_rest_samples_dotnet.Samples.FlexMicroform
99
{
1010
public class GenerateKey
1111
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.FlexMicroform
9+
{
10+
public class GenerateKeyLegacyTokenFormat
11+
{
12+
public static FlexV1KeysPost200Response Run()
13+
{
14+
string encryptionType = "None";
15+
string targetOrigin = "https://www.test.com";
16+
var requestObj = new GeneratePublicKeyRequest(
17+
EncryptionType: encryptionType,
18+
TargetOrigin: targetOrigin
19+
);
20+
21+
string format = "legacy";
22+
try
23+
{
24+
var configDictionary = new Configuration().GetConfiguration();
25+
var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
26+
27+
var apiInstance = new KeyGenerationApi(clientConfig);
28+
FlexV1KeysPost200Response result = apiInstance.GeneratePublicKey(format, requestObj);
29+
Console.WriteLine(result);
30+
return result;
31+
}
32+
catch (Exception e)
33+
{
34+
Console.WriteLine("Exception on calling the API : " + e.Message);
35+
return null;
36+
}
37+
}
38+
}
39+
}

src/Samples/PayerAuthentication/EnrollWithPendingAuthentication.cs

-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ public static RiskV1AuthenticationsPost201Response Run()
7171
MobilePhone: buyerInformationMobilePhone
7272
);
7373

74-
string consumerAuthenticationInformationReturnUrl = "http://localhost:8189/cart/enterprise/collect-term";
7574
string consumerAuthenticationInformationTransactionMode = "MOTO";
7675
Riskv1decisionsConsumerAuthenticationInformation consumerAuthenticationInformation = new Riskv1decisionsConsumerAuthenticationInformation(
77-
ReturnUrl: consumerAuthenticationInformationReturnUrl,
7876
TransactionMode: consumerAuthenticationInformationTransactionMode
7977
);
8078

src/Samples/PayerAuthentication/SetupCompletionWithCardNumber.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static RiskV1AuthenticationSetupsPost201Response Run()
1919
string paymentInformationCardType = "001";
2020
string paymentInformationCardExpirationMonth = "12";
2121
string paymentInformationCardExpirationYear = "2025";
22-
string paymentInformationCardNumber = "4111111111111111";
22+
string paymentInformationCardNumber = "4000000000000101";
2323
Riskv1authenticationsetupsPaymentInformationCard paymentInformationCard = new Riskv1authenticationsetupsPaymentInformationCard(
2424
Type: paymentInformationCardType,
2525
ExpirationMonth: paymentInformationCardExpirationMonth,

src/Samples/PayerAuthentication/ValidateAuthenticationResults.cs

-2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ public static RiskV1AuthenticationResultsPost201Response Run()
5555
);
5656

5757
string consumerAuthenticationInformationAuthenticationTransactionId = "PYffv9G3sa1e0CQr5fV0";
58-
string consumerAuthenticationInformationResponseAccessToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5YTAwYTYzMC0zNzFhLTExZTYtYTU5Ni1kZjQwZjUwMjAwNmMiLCJpYXQiOjE0NjY0NDk4MDcsImlzcyI6Ik1pZGFzLU5vRFYtS2V5IiwiUGF5bG9hZCI6eyJPcmRlckRldGFpbHMiOnsiT3JkZXJOdW1iZXIiOjE1NTc4MjAyMzY3LCJBbW91bnQiOiIxNTAwIiwiQ3VycmVudENvZGUiOiI4NDAiLCJUcmFuc2FjdGlvbklkIjoiOVVzaGVoRFFUcWh1SFk5SElqZTAifX0sIk9yZ1VuaXRJZCI6IjU2NGNkY2JjYjlmNjNmMGM0OGQ2Mzg3ZiIsIk9iamVjdGlmeVBheWxvYWQiOnRydWV9.eaU8LZJnMtY3mPl4vBXVCVUuyeSeAp8zoNaEOmKS4XY";
5958
string consumerAuthenticationInformationSignedPares = "eNqdmFmT4jgSgN+J4D90zD4yMz45PEFVhHzgA2zwjXnzhQ984Nvw61dAV1";
6059
Riskv1authenticationresultsConsumerAuthenticationInformation consumerAuthenticationInformation = new Riskv1authenticationresultsConsumerAuthenticationInformation(
6160
AuthenticationTransactionId: consumerAuthenticationInformationAuthenticationTransactionId,
62-
ResponseAccessToken: consumerAuthenticationInformationResponseAccessToken,
6361
SignedPares: consumerAuthenticationInformationSignedPares
6462
);
6563

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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 AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer
11+
{
12+
public static PtsV2PaymentsPost201Response Run()
13+
{
14+
string clientReferenceInformationCode = "demomerchant";
15+
Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation(
16+
Code: clientReferenceInformationCode
17+
);
18+
19+
bool processingInformationCapture = false;
20+
string processingInformationCommerceIndicator = "retail";
21+
Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation(
22+
Capture: processingInformationCapture,
23+
CommerceIndicator: processingInformationCommerceIndicator
24+
);
25+
26+
string paymentInformationCardExpirationMonth = "12";
27+
string paymentInformationCardExpirationYear = "2050";
28+
Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard(
29+
ExpirationMonth: paymentInformationCardExpirationMonth,
30+
ExpirationYear: paymentInformationCardExpirationYear
31+
);
32+
33+
string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg==";
34+
string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003";
35+
Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData(
36+
Descriptor: paymentInformationFluidDataDescriptor,
37+
Value: paymentInformationFluidDataValue
38+
);
39+
40+
Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation(
41+
Card: paymentInformationCard,
42+
FluidData: paymentInformationFluidData
43+
);
44+
45+
string orderInformationAmountDetailsTotalAmount = "100.00";
46+
string orderInformationAmountDetailsCurrency = "USD";
47+
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails(
48+
TotalAmount: orderInformationAmountDetailsTotalAmount,
49+
Currency: orderInformationAmountDetailsCurrency
50+
);
51+
52+
string orderInformationBillToFirstName = "John";
53+
string orderInformationBillToLastName = "Deo";
54+
string orderInformationBillToAddress1 = "201 S. Division St.";
55+
string orderInformationBillToLocality = "Ann Arbor";
56+
string orderInformationBillToAdministrativeArea = "MI";
57+
string orderInformationBillToPostalCode = "48104-2201";
58+
string orderInformationBillToCountry = "US";
59+
string orderInformationBillToDistrict = "MI";
60+
string orderInformationBillToEmail = "[email protected]";
61+
string orderInformationBillToPhoneNumber = "999999999";
62+
Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo(
63+
FirstName: orderInformationBillToFirstName,
64+
LastName: orderInformationBillToLastName,
65+
Address1: orderInformationBillToAddress1,
66+
Locality: orderInformationBillToLocality,
67+
AdministrativeArea: orderInformationBillToAdministrativeArea,
68+
PostalCode: orderInformationBillToPostalCode,
69+
Country: orderInformationBillToCountry,
70+
District: orderInformationBillToDistrict,
71+
Email: orderInformationBillToEmail,
72+
PhoneNumber: orderInformationBillToPhoneNumber
73+
);
74+
75+
Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation(
76+
AmountDetails: orderInformationAmountDetails,
77+
BillTo: orderInformationBillTo
78+
);
79+
80+
int pointOfSaleInformationCatLevel = 1;
81+
string pointOfSaleInformationEntryMode = "keyed";
82+
int pointOfSaleInformationTerminalCapability = 2;
83+
Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation(
84+
CatLevel: pointOfSaleInformationCatLevel,
85+
EntryMode: pointOfSaleInformationEntryMode,
86+
TerminalCapability: pointOfSaleInformationTerminalCapability
87+
);
88+
89+
var requestObj = new CreatePaymentRequest(
90+
ClientReferenceInformation: clientReferenceInformation,
91+
ProcessingInformation: processingInformation,
92+
PaymentInformation: paymentInformation,
93+
OrderInformation: orderInformation,
94+
PointOfSaleInformation: pointOfSaleInformation
95+
);
96+
97+
try
98+
{
99+
var configDictionary = new Configuration().GetConfiguration();
100+
var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
101+
102+
var apiInstance = new PaymentsApi(clientConfig);
103+
PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj);
104+
Console.WriteLine(result);
105+
return result;
106+
}
107+
catch (Exception e)
108+
{
109+
Console.WriteLine("Exception on calling the API : " + e.Message);
110+
return null;
111+
}
112+
}
113+
}
114+
}

0 commit comments

Comments
 (0)