From 292bfc20dd0cb13fb5b7ab429205765c8b067019 Mon Sep 17 00:00:00 2001 From: zxc8027 Date: Thu, 3 Oct 2019 14:19:45 -0400 Subject: [PATCH 1/6] Back-ported timeout fix from version 11 --- CHANGELOG | 3 +++ LitleSdkForNet/LitleSdkForNet/Communications.cs | 10 ++++++++++ .../LitleSdkForNet/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4bc52853..07a48bf2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ = LitleOnline CHANGELOG +== Version 10.8.4 (Oct 3, 2019) +* BugFix: Fixed custom timeout not being used + == Version 10.8.3 (December 14 2018) * the default value of processingType is replaced from accountFunding to undefined diff --git a/LitleSdkForNet/LitleSdkForNet/Communications.cs b/LitleSdkForNet/LitleSdkForNet/Communications.cs index 19d30cdc..a47f7042 100644 --- a/LitleSdkForNet/LitleSdkForNet/Communications.cs +++ b/LitleSdkForNet/LitleSdkForNet/Communications.cs @@ -109,6 +109,16 @@ virtual public string HttpPost(string xmlRequest, Dictionary con req.Method = "POST"; req.ServicePoint.MaxIdleTime = 10000; req.ServicePoint.Expect100Continue = false; + + //set timeout for request if available. #Issue 58 + //connection timeout is increased 3 times on successful establishment. + if(config.ContainsKey("timeout") && config["timeout"] != null && int.Parse(config["timeout"]) > 0) + { + var timeOut = int.Parse(config["timeout"]); + req.Timeout = timeOut; + req.ReadWriteTimeout = 3*timeOut; + } + if (isProxyOn(config)) { WebProxy myproxy = new WebProxy(config["proxyHost"], int.Parse(config["proxyPort"])); diff --git a/LitleSdkForNet/LitleSdkForNet/Properties/AssemblyInfo.cs b/LitleSdkForNet/LitleSdkForNet/Properties/AssemblyInfo.cs index acc19279..a9ffe59d 100644 --- a/LitleSdkForNet/LitleSdkForNet/Properties/AssemblyInfo.cs +++ b/LitleSdkForNet/LitleSdkForNet/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("10.8.3")] -[assembly: AssemblyFileVersion("10.8.3")] +[assembly: AssemblyVersion("10.8.4")] +[assembly: AssemblyFileVersion("10.8.4")] From 8d60d4f1a4ccfc26498b917852add7380323b0f9 Mon Sep 17 00:00:00 2001 From: zxc8027 Date: Mon, 7 Oct 2019 14:58:09 -0400 Subject: [PATCH 2/6] Fixed timeout not being used in non-async methods --- CHANGELOG | 2 +- .../LitleSdkForNet/Communications.cs | 17 +-- .../Functional/TestTimeout.cs | 106 ++++++++++++++++++ .../LitleSdkForNetTest.csproj | 1 + 4 files changed, 118 insertions(+), 8 deletions(-) create mode 100644 LitleSdkForNet/LitleSdkForNetTest/Functional/TestTimeout.cs diff --git a/CHANGELOG b/CHANGELOG index 07a48bf2..156a6e33 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ = LitleOnline CHANGELOG -== Version 10.8.4 (Oct 3, 2019) +== Version 10.8.4 (Oct 7, 2019) * BugFix: Fixed custom timeout not being used == Version 10.8.3 (December 14 2018) diff --git a/LitleSdkForNet/LitleSdkForNet/Communications.cs b/LitleSdkForNet/LitleSdkForNet/Communications.cs index a47f7042..4edc724b 100644 --- a/LitleSdkForNet/LitleSdkForNet/Communications.cs +++ b/LitleSdkForNet/LitleSdkForNet/Communications.cs @@ -110,13 +110,16 @@ virtual public string HttpPost(string xmlRequest, Dictionary con req.ServicePoint.MaxIdleTime = 10000; req.ServicePoint.Expect100Continue = false; - //set timeout for request if available. #Issue 58 - //connection timeout is increased 3 times on successful establishment. - if(config.ContainsKey("timeout") && config["timeout"] != null && int.Parse(config["timeout"]) > 0) - { - var timeOut = int.Parse(config["timeout"]); - req.Timeout = timeOut; - req.ReadWriteTimeout = 3*timeOut; + if (config.ContainsKey("timeout")) { + try { + req.Timeout = Convert.ToInt32(config["timeout"]); + } + catch (FormatException e) { + // If timeout setting contains non-numeric + // characters, we will fall back to 1 minute + // default timeout. + req.Timeout = 60000; + } } if (isProxyOn(config)) diff --git a/LitleSdkForNet/LitleSdkForNetTest/Functional/TestTimeout.cs b/LitleSdkForNet/LitleSdkForNetTest/Functional/TestTimeout.cs new file mode 100644 index 00000000..a06c4456 --- /dev/null +++ b/LitleSdkForNet/LitleSdkForNetTest/Functional/TestTimeout.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using System.Net; +using NUnit.Framework; + +namespace Litle.Sdk.Test.Functional { + [TestFixture] + internal class TestTimeout + { + private LitleOnline _cnp; + private Dictionary _config; + + [Test] + public void TestTimeoutNotDefined() + { + _config = new Dictionary + { + {"url", Properties.Settings.Default.url}, + {"reportGroup", "Default Report Group"}, + {"username", "DOTNET"}, + {"version", "11.0"}, + {"merchantId", "101"}, + {"password", "TESTCASE"}, + {"printxml", "true"}, + {"proxyHost", Properties.Settings.Default.proxyHost}, + {"proxyPort", Properties.Settings.Default.proxyPort}, + {"logFile", Properties.Settings.Default.logFile}, + {"neuterAccountNums", "true"} + }; + + _cnp = new LitleOnline(_config); + + var registerTokenRequest = new registerTokenRequestType + { + id = "1", + reportGroup = "Planets", + orderId = "12344", + accountNumber = "1233456789103801", + }; + + var rtokenResponse = _cnp.RegisterToken(registerTokenRequest); + StringAssert.AreEqualIgnoringCase("Account number was successfully registered", rtokenResponse.message); + } + + [Test] + public void TestTimeoutNotParsable() + { + _config = new Dictionary + { + {"url", Properties.Settings.Default.url}, + {"reportGroup", "Default Report Group"}, + {"username", "DOTNET"}, + {"version", "11.0"}, + {"timeout", "notparsableasint"}, + {"merchantId", "101"}, + {"password", "TESTCASE"}, + {"printxml", "true"}, + {"proxyHost", Properties.Settings.Default.proxyHost}, + {"proxyPort", Properties.Settings.Default.proxyPort}, + {"logFile", Properties.Settings.Default.logFile}, + {"neuterAccountNums", "true"} + }; + + _cnp = new LitleOnline(_config); + + var registerTokenRequest = new registerTokenRequestType + { + id = "1", + reportGroup = "Planets", + orderId = "12344", + accountNumber = "1233456789103801", + }; + + var rtokenResponse = _cnp.RegisterToken(registerTokenRequest); + StringAssert.AreEqualIgnoringCase("Account number was successfully registered", rtokenResponse.message); + } + + [Test] + public void TestTimeoutReached() { + _config = new Dictionary { + {"url", Properties.Settings.Default.url}, + {"reportGroup", "Default Report Group"}, + {"username", "DOTNET"}, + {"version", "11.0"}, + {"timeout", "0"}, + {"merchantId", "101"}, + {"password", "TESTCASE"}, + {"printxml", "true"}, + {"proxyHost", Properties.Settings.Default.proxyHost}, + {"proxyPort", Properties.Settings.Default.proxyPort}, + {"logFile", Properties.Settings.Default.logFile}, + {"neuterAccountNums", "true"} + }; + + _cnp = new LitleOnline(_config); + + var registerTokenRequest = new registerTokenRequestType { + id = "1", + reportGroup = "Planets", + orderId = "12344", + accountNumber = "1233456789103801", + }; + + Assert.Throws(() => { _cnp.RegisterToken(registerTokenRequest); }); + } + } +} \ No newline at end of file diff --git a/LitleSdkForNet/LitleSdkForNetTest/LitleSdkForNetTest.csproj b/LitleSdkForNet/LitleSdkForNetTest/LitleSdkForNetTest.csproj index d7239c42..24e10da7 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/LitleSdkForNetTest.csproj +++ b/LitleSdkForNet/LitleSdkForNetTest/LitleSdkForNetTest.csproj @@ -123,6 +123,7 @@ + From 9487fa3ca0cade3ae56a50696e22e94e63abccde Mon Sep 17 00:00:00 2001 From: zxc8027 Date: Mon, 7 Oct 2019 15:18:45 -0400 Subject: [PATCH 3/6] Increased default timeout --- LitleSdkForNet/LitleSdkForNet/Properties/Settings.Designer.cs | 2 +- LitleSdkForNet/LitleSdkForNet/Properties/Settings.settings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LitleSdkForNet/LitleSdkForNet/Properties/Settings.Designer.cs b/LitleSdkForNet/LitleSdkForNet/Properties/Settings.Designer.cs index fd26a4c5..8c0c7faf 100644 --- a/LitleSdkForNet/LitleSdkForNet/Properties/Settings.Designer.cs +++ b/LitleSdkForNet/LitleSdkForNet/Properties/Settings.Designer.cs @@ -50,7 +50,7 @@ public string printxml { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("500")] + [global::System.Configuration.DefaultSettingValueAttribute("5000")] public string timeout { get { return ((string)(this["timeout"])); diff --git a/LitleSdkForNet/LitleSdkForNet/Properties/Settings.settings b/LitleSdkForNet/LitleSdkForNet/Properties/Settings.settings index 48c4d837..38d24577 100644 --- a/LitleSdkForNet/LitleSdkForNet/Properties/Settings.settings +++ b/LitleSdkForNet/LitleSdkForNet/Properties/Settings.settings @@ -9,7 +9,7 @@ true - 500 + 5000 prelive.litle.com From b8a00085ea5de3fd1829b36ce4c2e16b68588985 Mon Sep 17 00:00:00 2001 From: zxc8027 Date: Mon, 28 Oct 2019 08:36:53 -0400 Subject: [PATCH 4/6] Increased timeout for tests --- .../LitleSdkForNetTest/Certification/TestCert1Base.cs | 2 +- .../LitleSdkForNetTest/Certification/TestCert2AuthEnhanced.cs | 2 +- .../LitleSdkForNetTest/Certification/TestCert3AuthReversal.cs | 2 +- .../LitleSdkForNetTest/Certification/TestCert4Echeck.cs | 2 +- .../LitleSdkForNetTest/Certification/TestCert5Token.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs index 76dde892..2687e0c5 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs +++ b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs @@ -19,7 +19,7 @@ public void setUp() config.Add("reportGroup", "Default Report Group"); config.Add("username", Properties.Settings.Default.username); config.Add("version", "10.8"); - config.Add("timeout", "500"); + config.Add("timeout", "20000"); config.Add("merchantId", Properties.Settings.Default.merchantId); config.Add("password", Properties.Settings.Default.password); config.Add("printxml", "true"); diff --git a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert2AuthEnhanced.cs b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert2AuthEnhanced.cs index a72e3bb1..5c1c8e4c 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert2AuthEnhanced.cs +++ b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert2AuthEnhanced.cs @@ -20,7 +20,7 @@ public void setUp() config.Add("reportGroup", "Default Report Group"); config.Add("username", Properties.Settings.Default.username); config.Add("version", "10.8"); - config.Add("timeout", "500"); + config.Add("timeout", "20000"); config.Add("merchantId", Properties.Settings.Default.merchantId); config.Add("password", Properties.Settings.Default.password); config.Add("printxml", "true"); diff --git a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert3AuthReversal.cs b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert3AuthReversal.cs index 2025b0af..db5badc9 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert3AuthReversal.cs +++ b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert3AuthReversal.cs @@ -19,7 +19,7 @@ public void setUp() config.Add("reportGroup", "Default Report Group"); config.Add("username", Properties.Settings.Default.username); config.Add("version", "10.8"); - config.Add("timeout", "500"); + config.Add("timeout", "20000"); config.Add("merchantId", Properties.Settings.Default.merchantId); config.Add("password", Properties.Settings.Default.password); config.Add("printxml", "true"); diff --git a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert4Echeck.cs b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert4Echeck.cs index e0bea031..36012317 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert4Echeck.cs +++ b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert4Echeck.cs @@ -19,7 +19,7 @@ public void setUp() config.Add("reportGroup", "Default Report Group"); config.Add("username", Properties.Settings.Default.username); config.Add("version", "10.8"); - config.Add("timeout", "500"); + config.Add("timeout", "20000"); config.Add("merchantId", Properties.Settings.Default.merchantId); config.Add("password", Properties.Settings.Default.password); config.Add("printxml", "true"); diff --git a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert5Token.cs b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert5Token.cs index 0dbec831..9fdc3a7a 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert5Token.cs +++ b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert5Token.cs @@ -19,7 +19,7 @@ public void setUp() config.Add("reportGroup", "Default Report Group"); config.Add("username", Properties.Settings.Default.username); config.Add("version", "10.8"); - config.Add("timeout", "500"); + config.Add("timeout", "20000"); config.Add("merchantId", Properties.Settings.Default.merchantId); config.Add("password", Properties.Settings.Default.password); config.Add("printxml", "true"); From cc8286e68be2819da6098390ec33fe4b5951b626 Mon Sep 17 00:00:00 2001 From: zxc8027 Date: Mon, 28 Oct 2019 08:44:37 -0400 Subject: [PATCH 5/6] Updated version number --- CHANGELOG | 2 +- LitleSdkForNet/LitleSdkForNet/LitleBatchRequest.cs | 2 +- LitleSdkForNet/LitleSdkForNet/LitleOnline.cs | 2 +- LitleSdkForNet/LitleSdkForNetTest/Unit/TestBatchRequest.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 156a6e33..a527bab3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ = LitleOnline CHANGELOG -== Version 10.8.4 (Oct 7, 2019) +== Version 10.8.4 (Oct 28, 2019) * BugFix: Fixed custom timeout not being used == Version 10.8.3 (December 14 2018) diff --git a/LitleSdkForNet/LitleSdkForNet/LitleBatchRequest.cs b/LitleSdkForNet/LitleSdkForNet/LitleBatchRequest.cs index c8079603..5a3b6c02 100644 --- a/LitleSdkForNet/LitleSdkForNet/LitleBatchRequest.cs +++ b/LitleSdkForNet/LitleSdkForNet/LitleBatchRequest.cs @@ -1254,7 +1254,7 @@ public string generateXmlHeader() xmlHeader += "physicalCheckDebitAmount=\"" + physicalCheckDebitAmount + "\"\r\n"; } - xmlHeader += "merchantSdk=\"DotNet;10.8\"\r\n"; + xmlHeader += "merchantSdk=\"DotNet;10.8.4\"\r\n"; xmlHeader += "merchantId=\"" + config["merchantId"] + "\">\r\n"; return xmlHeader; diff --git a/LitleSdkForNet/LitleSdkForNet/LitleOnline.cs b/LitleSdkForNet/LitleSdkForNet/LitleOnline.cs index 12b15b9b..cc62aab0 100644 --- a/LitleSdkForNet/LitleSdkForNet/LitleOnline.cs +++ b/LitleSdkForNet/LitleSdkForNet/LitleOnline.cs @@ -407,7 +407,7 @@ private litleOnlineRequest createLitleOnlineRequest() { litleOnlineRequest request = new litleOnlineRequest(); request.merchantId = config["merchantId"]; - request.merchantSdk = "DotNet;10.8"; + request.merchantSdk = "DotNet;10.8.4"; authentication authentication = new authentication(); authentication.password = config["password"]; authentication.user = config["username"]; diff --git a/LitleSdkForNet/LitleSdkForNetTest/Unit/TestBatchRequest.cs b/LitleSdkForNet/LitleSdkForNetTest/Unit/TestBatchRequest.cs index e5ecac12..764e786f 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/Unit/TestBatchRequest.cs +++ b/LitleSdkForNet/LitleSdkForNetTest/Unit/TestBatchRequest.cs @@ -55,7 +55,7 @@ public void testBatchRequestContainsMerchantSdkAttribute() String actual = batchRequest.generateXmlHeader(); String expected = @" "; Assert.AreEqual(expected, actual); From ae9db3e70c902007098886d604b2b399a28c9b2c Mon Sep 17 00:00:00 2001 From: zxc8027 Date: Mon, 28 Oct 2019 09:42:09 -0400 Subject: [PATCH 6/6] Removed cardValidationNum from test --- LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs index 2687e0c5..efe99bfe 100644 --- a/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs +++ b/LitleSdkForNet/LitleSdkForNetTest/Certification/TestCert1Base.cs @@ -502,7 +502,6 @@ public void test4AVS() card.type = methodOfPaymentTypeEnum.AX; card.number = "375001000000005"; card.expDate = "0412"; - card.cardValidationNum = "758"; authorization.card = card; authorizationResponse response = litle.Authorize(authorization);