Skip to content

Commit 075a41e

Browse files
committed
Updates for December 2020 Release
Updates for MetaKey support
1 parent c43354d commit 075a41e

17 files changed

+2115
-38
lines changed

cybersource-rest-auth-netstandard/ApiSdk/ApiSdk/ApiSdk.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.1</TargetFramework>
@@ -24,7 +24,7 @@
2424

2525
<ItemGroup>
2626
<Reference Include="Cybersource.Authentication.NetStandard">
27-
<HintPath>..\..\AuthenticationSdk\AuthenticationSdk\bin\Debug\netstandard2.1\Cybersource.Authentication.NetStandard.dll</HintPath>
27+
<HintPath>..\..\AuthenticationSdk\AuthenticationSdk\bin\Release\netstandard2.1\Cybersource.Authentication.NetStandard.dll</HintPath>
2828
</Reference>
2929
</ItemGroup>
3030

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/authentication/http/HttpToken.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ public HttpToken(MerchantConfig merchantConfig)
1919
MerchantSecretKey = merchantConfig.MerchantSecretKey;
2020
MerchantKeyId = merchantConfig.MerchantKeyId;
2121
HttpSignRequestTarget = merchantConfig.RequestType.ToLower() + " " + merchantConfig.RequestTarget;
22+
23+
bool.TryParse(merchantConfig.UseMetaKey, out bool tempUseMetaKey);
24+
25+
UseMetaKey = tempUseMetaKey;
26+
27+
if (UseMetaKey)
28+
{
29+
PortfolioId = merchantConfig.PortfolioId;
30+
}
2231
}
2332

2433
public string SignatureAlgorithm { get; set; }
@@ -27,6 +36,10 @@ public HttpToken(MerchantConfig merchantConfig)
2736

2837
public string MerchantId { get; set; }
2938

39+
public string PortfolioId { get; set; }
40+
41+
public bool UseMetaKey { get; set; }
42+
3043
public string MerchantSecretKey { get; set; }
3144

3245
public string RequestJsonData { get; }

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/authentication/http/HttpTokenGenerator.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ private string SignatureForCategory1()
6161
signatureString.Append('\n');
6262
signatureString.Append("v-c-merchant-id");
6363
signatureString.Append(": ");
64-
signatureString.Append(_httpToken.MerchantId);
64+
if(_httpToken.UseMetaKey == true)
65+
signatureString.Append(_httpToken.PortfolioId);
66+
else
67+
signatureString.Append(_httpToken.MerchantId);
6568
signatureString.Remove(0, 1);
6669

6770
var signatureByteString = Encoding.UTF8.GetBytes(signatureString.ToString());
@@ -104,7 +107,10 @@ private string SignatureForCategory2()
104107
signatureString.Append('\n');
105108
signatureString.Append("v-c-merchant-id");
106109
signatureString.Append(": ");
107-
signatureString.Append(_httpToken.MerchantId);
110+
if (_httpToken.UseMetaKey == true)
111+
signatureString.Append(_httpToken.PortfolioId);
112+
else
113+
signatureString.Append(_httpToken.MerchantId);
108114
signatureString.Remove(0, 1);
109115

110116
var signatureByteString = Encoding.UTF8.GetBytes(signatureString.ToString());

cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/core/MerchantConfig.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ If a dictionary object has been passed use that object
6868

6969
public string MerchantId { get; set; }
7070

71+
public string PortfolioId { get; set; }
72+
7173
public string MerchantSecretKey { get; set; }
7274

7375
public string MerchantKeyId { get; set; }
7476

77+
public string UseMetaKey { get; set; }
78+
7579
public string AuthenticationType { get; set; }
7680

7781
public string KeyDirectory { get; set; }
@@ -158,8 +162,10 @@ private void SetValuesFromAppConfig(NameValueCollection merchantConfigSection)
158162
_propertiesSetUsing = "App.Config File";
159163

160164
MerchantId = merchantConfigSection["merchantID"];
165+
PortfolioId = merchantConfigSection["portfolioID"];
161166
MerchantSecretKey = merchantConfigSection["merchantsecretKey"];
162167
MerchantKeyId = merchantConfigSection["merchantKeyId"];
168+
UseMetaKey = merchantConfigSection["useMetaKey"];
163169
AuthenticationType = merchantConfigSection["authenticationType"];
164170
KeyDirectory = merchantConfigSection["keysDirectory"];
165171
KeyfileName = merchantConfigSection["keyFilename"];
@@ -195,6 +201,12 @@ private void SetValuesUsingDictObj(IReadOnlyDictionary<string, string> merchantC
195201
RunEnvironment = merchantConfigDictionary[key];
196202
key = "authenticationType";
197203
AuthenticationType = merchantConfigDictionary[key];
204+
key = "useMetaKey";
205+
UseMetaKey = merchantConfigDictionary[key];
206+
if(string.IsNullOrEmpty(UseMetaKey))
207+
{
208+
UseMetaKey = "false";
209+
}
198210

199211
Enumerations.AuthenticationType authTypeInput;
200212
Enum.TryParse(AuthenticationType.ToUpper(), out authTypeInput);
@@ -207,6 +219,16 @@ private void SetValuesUsingDictObj(IReadOnlyDictionary<string, string> merchantC
207219
MerchantKeyId = merchantConfigDictionary[key];
208220
}
209221

222+
if (Equals(bool.Parse(UseMetaKey.ToString()), true))
223+
{
224+
key = "portfolioID";
225+
PortfolioId = merchantConfigDictionary[key];
226+
if(Equals(PortfolioId, string.Empty))
227+
{
228+
throw new KeyNotFoundException();
229+
}
230+
}
231+
210232
// OPTIONAL KEYS
211233
// only if the key is passed read the value, otherwise use default / null values
212234
if (Equals(authTypeInput, Enumerations.AuthenticationType.JWT))

cybersource-rest-client-netstandard/cybersource-rest-client-netstandard.Test/Api/InstrumentIdentifierApiTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,20 @@ public void PostInstrumentIdentifierTest()
133133
//Assert.IsInstanceOf<Tmsv2customersEmbeddedDefaultPaymentInstrumentEmbeddedInstrumentIdentifier> (response, "response is Tmsv2customersEmbeddedDefaultPaymentInstrumentEmbeddedInstrumentIdentifier");
134134
}
135135

136+
/// <summary>
137+
/// Test PostInstrumentIdentifierEnrollment
138+
/// </summary>
139+
[Test]
140+
public void PostInstrumentIdentifierEnrollmentTest()
141+
{
142+
// TODO uncomment below to test the method and replace null with proper value
143+
//string instrumentIdentifierTokenId = null;
144+
//PostInstrumentIdentifierEnrollmentRequest postInstrumentIdentifierEnrollmentRequest = null;
145+
//string profileId = null;
146+
//instance.PostInstrumentIdentifierEnrollment(instrumentIdentifierTokenId, postInstrumentIdentifierEnrollmentRequest, profileId);
147+
148+
}
149+
136150
}
137151

138152
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/*
2+
* CyberSource Merged Spec
3+
*
4+
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
5+
*
6+
* OpenAPI spec version: 0.0.1
7+
*
8+
* Generated by: https://github.com/swagger-api/swagger-codegen.git
9+
*/
10+
11+
12+
using NUnit.Framework;
13+
14+
using System;
15+
using System.Linq;
16+
using System.IO;
17+
using System.Collections.Generic;
18+
using CyberSource.Api;
19+
using CyberSource.Model;
20+
using CyberSource.Client;
21+
using System.Reflection;
22+
23+
namespace CyberSource.Test
24+
{
25+
/// <summary>
26+
/// Class for testing PostInstrumentIdentifierEnrollmentRequest
27+
/// </summary>
28+
/// <remarks>
29+
/// This file is automatically generated by Swagger Codegen.
30+
/// Please update the test case below to test the model.
31+
/// </remarks>
32+
[TestFixture]
33+
public class PostInstrumentIdentifierEnrollmentRequestTests
34+
{
35+
// TODO uncomment below to declare an instance variable for PostInstrumentIdentifierEnrollmentRequest
36+
//private PostInstrumentIdentifierEnrollmentRequest instance;
37+
38+
/// <summary>
39+
/// Setup before each test
40+
/// </summary>
41+
[SetUp]
42+
public void Init()
43+
{
44+
// TODO uncomment below to create an instance of PostInstrumentIdentifierEnrollmentRequest
45+
//instance = new PostInstrumentIdentifierEnrollmentRequest();
46+
}
47+
48+
/// <summary>
49+
/// Clean up after each test
50+
/// </summary>
51+
[TearDown]
52+
public void Cleanup()
53+
{
54+
55+
}
56+
57+
/// <summary>
58+
/// Test an instance of PostInstrumentIdentifierEnrollmentRequest
59+
/// </summary>
60+
[Test]
61+
public void PostInstrumentIdentifierEnrollmentRequestInstanceTest()
62+
{
63+
// TODO uncomment below to test "IsInstanceOfType" PostInstrumentIdentifierEnrollmentRequest
64+
//Assert.IsInstanceOfType<PostInstrumentIdentifierEnrollmentRequest> (instance, "variable 'instance' is a PostInstrumentIdentifierEnrollmentRequest");
65+
}
66+
67+
/// <summary>
68+
/// Test the property 'Links'
69+
/// </summary>
70+
[Test]
71+
public void LinksTest()
72+
{
73+
// TODO unit test for the property 'Links'
74+
}
75+
/// <summary>
76+
/// Test the property 'Id'
77+
/// </summary>
78+
[Test]
79+
public void IdTest()
80+
{
81+
// TODO unit test for the property 'Id'
82+
}
83+
/// <summary>
84+
/// Test the property '_Object'
85+
/// </summary>
86+
[Test]
87+
public void _ObjectTest()
88+
{
89+
// TODO unit test for the property '_Object'
90+
}
91+
/// <summary>
92+
/// Test the property 'State'
93+
/// </summary>
94+
[Test]
95+
public void StateTest()
96+
{
97+
// TODO unit test for the property 'State'
98+
}
99+
/// <summary>
100+
/// Test the property 'Type'
101+
/// </summary>
102+
[Test]
103+
public void TypeTest()
104+
{
105+
// TODO unit test for the property 'Type'
106+
}
107+
/// <summary>
108+
/// Test the property 'Card'
109+
/// </summary>
110+
[Test]
111+
public void CardTest()
112+
{
113+
// TODO unit test for the property 'Card'
114+
}
115+
/// <summary>
116+
/// Test the property 'BankAccount'
117+
/// </summary>
118+
[Test]
119+
public void BankAccountTest()
120+
{
121+
// TODO unit test for the property 'BankAccount'
122+
}
123+
/// <summary>
124+
/// Test the property 'TokenizedCard'
125+
/// </summary>
126+
[Test]
127+
public void TokenizedCardTest()
128+
{
129+
// TODO unit test for the property 'TokenizedCard'
130+
}
131+
/// <summary>
132+
/// Test the property 'Issuer'
133+
/// </summary>
134+
[Test]
135+
public void IssuerTest()
136+
{
137+
// TODO unit test for the property 'Issuer'
138+
}
139+
/// <summary>
140+
/// Test the property 'ProcessingInformation'
141+
/// </summary>
142+
[Test]
143+
public void ProcessingInformationTest()
144+
{
145+
// TODO unit test for the property 'ProcessingInformation'
146+
}
147+
/// <summary>
148+
/// Test the property 'BillTo'
149+
/// </summary>
150+
[Test]
151+
public void BillToTest()
152+
{
153+
// TODO unit test for the property 'BillTo'
154+
}
155+
/// <summary>
156+
/// Test the property 'Metadata'
157+
/// </summary>
158+
[Test]
159+
public void MetadataTest()
160+
{
161+
// TODO unit test for the property 'Metadata'
162+
}
163+
164+
}
165+
166+
}

0 commit comments

Comments
 (0)