Skip to content

Commit 6b149c9

Browse files
Sdk 12 40 2 (#76)
* Promoting changes for 12.40.2 * Promoting changeLog. * testCase to validate unsafe directory access. --------- Co-authored-by: e5651806 <[email protected]>
1 parent 9a862cf commit 6b149c9

File tree

6 files changed

+87
-10
lines changed

6 files changed

+87
-10
lines changed

CHANGELOG

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

22
= Worldpay CNP CHANGELOG
3+
4+
==Change Log for 12.40.2(November 19,2024)
5+
* Change: [cnpAPI v12.40.2] Changed bydefault value of payloadTobeEncrypted as false.
6+
* Change: [cnpAPI v12.40.2] Removed unsafe access for payloadTobeEncrypted and oltpEncryptionKeySequence.
7+
38
==Change Log for 12.40.1(November 08,2024)
49
* Change: [cnpAPI v12.40.1] Changing Renci.SshNet library version from 2016.1.0 to 2020.0.2
510

CnpSdkForNet/CnpSdkForNet/CnpOnline.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,13 +1259,11 @@ private cnpOnlineResponse SendToCnp(cnpOnlineRequest request)
12591259
{
12601260
var xmlRequest = request.Serialize();
12611261
var xmlResponse="";
1262-
1263-
if (_config["encryptOltpPayload"] == "true")
1262+
if (_config.ContainsKey("encryptOltpPayload") && Convert.ToBoolean(_config["encryptOltpPayload"]) && _config["encryptOltpPayload"] == "true")
12641263
{
1264+
String payloadTobeEncrypted = ReplaceXMLTxnWithEncryptedPayload(xmlRequest);
12651265

1266-
String payloadTobeEncrypted = ReplaceXMLTxnWithEncryptedPayload(xmlRequest);
1267-
1268-
xmlResponse = _communication.HttpPost(payloadTobeEncrypted);
1266+
xmlResponse = _communication.HttpPost(payloadTobeEncrypted);
12691267
}
12701268
else
12711269
{
@@ -1450,8 +1448,8 @@ private String ReplaceXMLTxnWithEncryptedPayload(String xmlRequest)
14501448
XmlElement encryptedPayloadElement = doc.CreateElement("encryptedPayload");
14511449
// Create and append the encryptionKeySequence element
14521450
XmlElement encryptionKeySequenceElement = doc.CreateElement("encryptionKeySequence");
1453-
if (_config["oltpEncryptionKeySequence"] != null)
1454-
{
1451+
if (_config.ContainsKey("oltpEncryptionKeySequence") && _config["oltpEncryptionKeySequence"] != null)
1452+
{
14551453
encryptionKeySequence = _config["oltpEncryptionKeySequence"];
14561454
}
14571455
else

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.40.1</PackageVersion>
6+
<PackageVersion>12.40.2</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.40";
12-
public const String CurrentCNPSDKVersion = "12.40.1";
12+
public const String CurrentCNPSDKVersion = "12.40.2";
1313
}
1414
}

CnpSdkForNet/CnpSdkForNet/Properties/Settings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using NUnit.Framework;
4+
using System.Threading;
5+
6+
namespace Cnp.Sdk.Test.Functional
7+
{
8+
[TestFixture]
9+
internal class TestAuthWithConfig
10+
{
11+
private CnpOnline _cnp;
12+
private Dictionary<string, string> _config;
13+
14+
[OneTimeSetUp]
15+
public void SetUpCnp()
16+
{
17+
_config = GetCnpConfig(); ;
18+
_cnp = new CnpOnline(_config);
19+
}
20+
21+
[Test]
22+
public void SimpleUnsafeConfig()
23+
{
24+
var authorization = new authorization
25+
{
26+
id = "1",
27+
reportGroup = "Planets",
28+
orderId = "12344",
29+
amount = 106,
30+
orderSource = orderSourceType.ecommerce,
31+
card = new cardType
32+
{
33+
type = methodOfPaymentTypeEnum.VI,
34+
number = "414100000000000000",
35+
expDate = "1210"
36+
},
37+
customBilling = new customBilling { phone = "1112223333" }
38+
};
39+
var response = _cnp.Authorize(authorization);
40+
41+
42+
Assert.AreEqual("000", response.response);
43+
}
44+
45+
static Dictionary<string, string> GetCnpConfig()
46+
{
47+
Dictionary<string, string> _cnpConfig = new Dictionary<string, string>();
48+
_cnpConfig.Add("url", "https://www.testvantivcnp.com/sandbox/communicator/online");
49+
_cnpConfig.Add("merchantId", "128");
50+
_cnpConfig.Add("reportGroup", "Default Report Group");
51+
_cnpConfig.Add("username", "asd");
52+
_cnpConfig.Add("password", "sdf");
53+
_cnpConfig.Add("printxml", "true");
54+
_cnpConfig.Add("timeout", "900000");
55+
_cnpConfig.Add("proxyHost", "");
56+
_cnpConfig.Add("proxyPort", "");
57+
_cnpConfig.Add("logFile", "cnpLogFile.log");
58+
_cnpConfig.Add("neuterAccountNums", "");
59+
_cnpConfig.Add("sftpUrl", "");
60+
_cnpConfig.Add("sftpUsername", "");
61+
_cnpConfig.Add("sftpPassword", "");
62+
_cnpConfig.Add("onlineBatchUrl", "");
63+
_cnpConfig.Add("onlineBatchPort", "");
64+
_cnpConfig.Add("requestDirectory", "");
65+
_cnpConfig.Add("responseDirectory", "");
66+
_cnpConfig.Add("useEncryption", "");
67+
_cnpConfig.Add("vantivPublicKeyId", "");
68+
_cnpConfig.Add("pgpPassphrase", "");
69+
_cnpConfig.Add("neuterUserCredentials", "");
70+
_cnpConfig.Add("maxConnections", "");
71+
return _cnpConfig;
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)