Skip to content

Commit

Permalink
Sdk 12 40 2 (#76)
Browse files Browse the repository at this point in the history
* Promoting changes for 12.40.2

* Promoting changeLog.

* testCase to validate unsafe directory access.

---------

Co-authored-by: e5651806 <sushamaghadage38@gmail.com>
  • Loading branch information
SushamaGhadage0310 and Sushamaghadage123 authored Nov 19, 2024
1 parent 9a862cf commit 6b149c9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

= Worldpay CNP CHANGELOG

==Change Log for 12.40.2(November 19,2024)
* Change: [cnpAPI v12.40.2] Changed bydefault value of payloadTobeEncrypted as false.
* Change: [cnpAPI v12.40.2] Removed unsafe access for payloadTobeEncrypted and oltpEncryptionKeySequence.

==Change Log for 12.40.1(November 08,2024)
* Change: [cnpAPI v12.40.1] Changing Renci.SshNet library version from 2016.1.0 to 2020.0.2

Expand Down
12 changes: 5 additions & 7 deletions CnpSdkForNet/CnpSdkForNet/CnpOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,13 +1259,11 @@ private cnpOnlineResponse SendToCnp(cnpOnlineRequest request)
{
var xmlRequest = request.Serialize();
var xmlResponse="";

if (_config["encryptOltpPayload"] == "true")
if (_config.ContainsKey("encryptOltpPayload") && Convert.ToBoolean(_config["encryptOltpPayload"]) && _config["encryptOltpPayload"] == "true")
{
String payloadTobeEncrypted = ReplaceXMLTxnWithEncryptedPayload(xmlRequest);

String payloadTobeEncrypted = ReplaceXMLTxnWithEncryptedPayload(xmlRequest);

xmlResponse = _communication.HttpPost(payloadTobeEncrypted);
xmlResponse = _communication.HttpPost(payloadTobeEncrypted);
}
else
{
Expand Down Expand Up @@ -1450,8 +1448,8 @@ private String ReplaceXMLTxnWithEncryptedPayload(String xmlRequest)
XmlElement encryptedPayloadElement = doc.CreateElement("encryptedPayload");
// Create and append the encryptionKeySequence element
XmlElement encryptionKeySequenceElement = doc.CreateElement("encryptionKeySequence");
if (_config["oltpEncryptionKeySequence"] != null)
{
if (_config.ContainsKey("oltpEncryptionKeySequence") && _config["oltpEncryptionKeySequence"] != null)
{
encryptionKeySequence = _config["oltpEncryptionKeySequence"];
}
else
Expand Down
2 changes: 1 addition & 1 deletion CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>dotNetSDKKey.snk</AssemblyOriginatorKeyFile>
<PackageVersion>12.40.1</PackageVersion>
<PackageVersion>12.40.2</PackageVersion>
<Title>Vantiv.CnpSdkForNet</Title>
<Authors>FIS</Authors>
<Copyright>Copyright © FIS 2020</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion CnpSdkForNet/CnpSdkForNet/CnpVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ namespace Cnp.Sdk
public class CnpVersion
{
public const String CurrentCNPXMLVersion = "12.40";
public const String CurrentCNPSDKVersion = "12.40.1";
public const String CurrentCNPSDKVersion = "12.40.2";
}
}
2 changes: 1 addition & 1 deletion CnpSdkForNet/CnpSdkForNet/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuthWithConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using System.Threading;

namespace Cnp.Sdk.Test.Functional
{
[TestFixture]
internal class TestAuthWithConfig
{
private CnpOnline _cnp;
private Dictionary<string, string> _config;

[OneTimeSetUp]
public void SetUpCnp()
{
_config = GetCnpConfig(); ;
_cnp = new CnpOnline(_config);
}

[Test]
public void SimpleUnsafeConfig()
{
var authorization = new authorization
{
id = "1",
reportGroup = "Planets",
orderId = "12344",
amount = 106,
orderSource = orderSourceType.ecommerce,
card = new cardType
{
type = methodOfPaymentTypeEnum.VI,
number = "414100000000000000",
expDate = "1210"
},
customBilling = new customBilling { phone = "1112223333" }
};
var response = _cnp.Authorize(authorization);


Assert.AreEqual("000", response.response);
}

static Dictionary<string, string> GetCnpConfig()
{
Dictionary<string, string> _cnpConfig = new Dictionary<string, string>();
_cnpConfig.Add("url", "https://www.testvantivcnp.com/sandbox/communicator/online");
_cnpConfig.Add("merchantId", "128");
_cnpConfig.Add("reportGroup", "Default Report Group");
_cnpConfig.Add("username", "asd");
_cnpConfig.Add("password", "sdf");
_cnpConfig.Add("printxml", "true");
_cnpConfig.Add("timeout", "900000");
_cnpConfig.Add("proxyHost", "");
_cnpConfig.Add("proxyPort", "");
_cnpConfig.Add("logFile", "cnpLogFile.log");
_cnpConfig.Add("neuterAccountNums", "");
_cnpConfig.Add("sftpUrl", "");
_cnpConfig.Add("sftpUsername", "");
_cnpConfig.Add("sftpPassword", "");
_cnpConfig.Add("onlineBatchUrl", "");
_cnpConfig.Add("onlineBatchPort", "");
_cnpConfig.Add("requestDirectory", "");
_cnpConfig.Add("responseDirectory", "");
_cnpConfig.Add("useEncryption", "");
_cnpConfig.Add("vantivPublicKeyId", "");
_cnpConfig.Add("pgpPassphrase", "");
_cnpConfig.Add("neuterUserCredentials", "");
_cnpConfig.Add("maxConnections", "");
return _cnpConfig;
}
}
}

0 comments on commit 6b149c9

Please sign in to comment.