Skip to content

Commit 38f57c5

Browse files
authored
Merge pull request #55 from rahul8agarwal8/US941241_12.24.1
deprecating threatMetrixSessionId
2 parents f4dde3b + f0b9f11 commit 38f57c5

File tree

6 files changed

+79
-2
lines changed

6 files changed

+79
-2
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
= Worldpay CNP CHANGELOG
33

4+
==Version 12.24.1 (April 21, 2022)
5+
* BugFix: Starting with CNP API v12.3, threatMetrixSessionId is deprecated. Use webSessionId instead. The use and structure is identical.
6+
7+
48
==Version 12.24.0 (April 18, 2022)
59
Note: It contains changes from cnpAPI v12.23. In case you need any feature supported by cnpAPI v12.23, please use SDK version 12.24.0
610

CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<SignAssembly>true</SignAssembly>
55
<AssemblyOriginatorKeyFile>dotNetSDKKey.snk</AssemblyOriginatorKeyFile>
6-
<PackageVersion>12.24.0</PackageVersion>
6+
<PackageVersion>12.24.1</PackageVersion>
77
<Title>Vantiv.CnpSdkForNet</Title>
88
<Authors>FIS</Authors>
99
<Copyright>Copyright © FIS 2020</Copyright>

CnpSdkForNet/CnpSdkForNet/CnpVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ namespace Cnp.Sdk
99
public class CnpVersion
1010
{
1111
public const String CurrentCNPXMLVersion = "12.24";
12-
public const String CurrentCNPSDKVersion = "12.24.0";
12+
public const String CurrentCNPSDKVersion = "12.24.1";
1313
}
1414
}

CnpSdkForNet/CnpSdkForNet/XmlRequestFields.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5331,7 +5331,9 @@ public string Serialize()
53315331

53325332
public partial class advancedFraudChecksType
53335333
{
5334+
[Obsolete("threatMetrixSessionId is deprecated, please use webSessionId instead.")]
53345335
public string threatMetrixSessionId;
5336+
public string webSessionId;
53355337
private string customAttribute1Field;
53365338
private bool customAttribute1Set;
53375339
public string customAttribute1
@@ -5372,6 +5374,7 @@ public string Serialize()
53725374
{
53735375
var xml = "";
53745376
if (threatMetrixSessionId != null) xml += "\r\n<threatMetrixSessionId>" + SecurityElement.Escape(threatMetrixSessionId) + "</threatMetrixSessionId>";
5377+
else if (webSessionId != null) xml += "\r\n<webSessionId>" + SecurityElement.Escape(webSessionId) + "</webSessionId>";
53755378
if (customAttribute1Set) xml += "\r\n<customAttribute1>" + SecurityElement.Escape(customAttribute1Field) + "</customAttribute1>";
53765379
if (customAttribute2Set) xml += "\r\n<customAttribute2>" + SecurityElement.Escape(customAttribute2Field) + "</customAttribute2>";
53775380
if (customAttribute3Set) xml += "\r\n<customAttribute3>" + SecurityElement.Escape(customAttribute3Field) + "</customAttribute3>";

CnpSdkForNet/CnpSdkForNetTest/Functional/TestFraudCheck.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,50 @@ public void TestCustomAttribute7TriggeredRules()
4949
Assert.AreEqual("triggered_rule_7", fraudCheckResponse.advancedFraudResults.triggeredRule[6]);
5050
}
5151

52+
[Test]
53+
public void TestFraudCheckWithWebSessionId()
54+
{
55+
var fraudCheck = new fraudCheck
56+
{
57+
id = "1",
58+
reportGroup = "Planets",
59+
advancedFraudChecks = new advancedFraudChecksType
60+
{
61+
customAttribute1 = "fail",
62+
customAttribute2 = "60",
63+
customAttribute3 = "7",
64+
customAttribute4 = "jkl",
65+
customAttribute5 = "mno",
66+
webSessionId = "abc123"
67+
},
68+
billToAddress = new contact
69+
{
70+
firstName = "Bob",
71+
lastName = "Bagels",
72+
addressLine1 = "37 Main Street",
73+
city = "Augusta",
74+
state = "Wisconsin",
75+
zip = "28209"
76+
},
77+
shipToAddress = new contact
78+
{
79+
firstName = "P",
80+
lastName = "Sherman",
81+
addressLine1 = "42 Wallaby Way",
82+
city = "Sydney",
83+
state = "New South Wales",
84+
zip = "2127"
85+
},
86+
amount = 51699
87+
};
88+
89+
var fraudCheckResponse = _cnp.FraudCheck(fraudCheck);
90+
Assert.NotNull(fraudCheckResponse);
91+
Assert.AreEqual("sandbox", fraudCheckResponse.location);
92+
Assert.AreEqual("Approved", fraudCheckResponse.message);
93+
Assert.AreEqual("fail", fraudCheckResponse.advancedFraudResults.deviceReviewStatus);
94+
}
95+
5296
[Test]
5397
public void TestFraudCheckWithAddressAndAmount()
5498
{

CnpSdkForNet/CnpSdkForNetTest/Unit/TestAdvancedFraudCheck.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,31 @@ public void TestCustomAttribute5()
159159
Assert.AreEqual(742802348034313000, fraudCheckResponse.cnpTxnId);
160160
}
161161

162+
[Test]
163+
public void TestAdvancedFraudChecksTypeWebSessionId()
164+
{
165+
fraudCheck fraudCheck = new fraudCheck();
166+
advancedFraudChecksType advancedFraudCheck = new advancedFraudChecksType();
167+
fraudCheck.advancedFraudChecks = advancedFraudCheck;
168+
advancedFraudCheck.webSessionId = "ajhgsdjh";
169+
advancedFraudCheck.customAttribute1 = "abc";
170+
advancedFraudCheck.customAttribute2 = "def";
171+
advancedFraudCheck.customAttribute3 = "ghi";
172+
advancedFraudCheck.customAttribute4 = "jkl";
173+
advancedFraudCheck.customAttribute5 = "mno";
174+
175+
var mock = new Mock<Communications>();
176+
177+
mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*<webSessionId>ajhgsdjh</webSessionId>\r\n<customAttribute1>abc</customAttribute1>\r\n<customAttribute2>def</customAttribute2>\r\n<customAttribute3>ghi</customAttribute3>\r\n<customAttribute4>jkl</customAttribute4>\r\n<customAttribute5>mno</customAttribute5>\r\n.*", RegexOptions.Singleline)))
178+
.Returns("<cnpOnlineResponse version='10.1' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><fraudCheckResponse id='127' reportGroup='Planets' customerId=''><cnpTxnId>742802348034313000</cnpTxnId><response>000</response><message>Approved</message><advancedFraudResults><deviceReviewStatus>pass</deviceReviewStatus><deviceReputationScore>42</deviceReputationScore><triggeredRule>triggered_rule_default</triggeredRule></advancedFraudResults></fraudCheckResponse></cnpOnlineResponse >");
179+
180+
Communications mockedCommunication = mock.Object;
181+
cnp.SetCommunication(mockedCommunication);
182+
fraudCheckResponse fraudCheckResponse = cnp.FraudCheck(fraudCheck);
183+
184+
Assert.NotNull(fraudCheckResponse);
185+
Assert.AreEqual(742802348034313000, fraudCheckResponse.cnpTxnId);
186+
}
187+
162188
}
163189
}

0 commit comments

Comments
 (0)