Skip to content

Commit

Permalink
Merge pull request #67 from Vantiv/US268420-Add-Timeout-Setting-8.0
Browse files Browse the repository at this point in the history
Us268420 add timeout setting 8.0
  • Loading branch information
VantivSDK authored Oct 25, 2019
2 parents 5ff070f + bc6049c commit ad2f9da
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
= LitleOnline CHANGELOG

== Version 8.31.5 (Oct 22, 2019)
* BugFix: Fixed custom timeout not being used

== Version 8.31.4 (Dec 14, 2018)
* the default value of processingType is replaced from accountFunding to undefined.

Expand Down
13 changes: 13 additions & 0 deletions LitleSdkForNet/LitleSdkForNet/Communications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ public virtual string HttpPost(string xmlRequest, Dictionary<string, string> con
req.ServicePoint.MaxIdleTime = 8000;
req.ServicePoint.Expect100Continue = false;
req.KeepAlive = false;

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))
{
var myproxy = new WebProxy(config["proxyHost"], int.Parse(config["proxyPort"]))
Expand Down
2 changes: 1 addition & 1 deletion LitleSdkForNet/LitleSdkForNet/LitleBatchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ public string generateXmlHeader()
{
xmlHeader += "numBalanceInquirys=\"" + numBalanceInquiries + "\"\r\n";
}
xmlHeader += "merchantSdk=\"DotNet;8.31.4\"\r\n";
xmlHeader += "merchantSdk=\"DotNet;8.31.5\"\r\n";

xmlHeader += "merchantId=\"" + config["merchantId"] + "\">\r\n";
return xmlHeader;
Expand Down
2 changes: 1 addition & 1 deletion LitleSdkForNet/LitleSdkForNet/LitleOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private litleOnlineRequest createLitleOnlineRequest()
{
litleOnlineRequest request = new litleOnlineRequest();
request.merchantId = config["merchantId"];
request.merchantSdk = "DotNet;8.31.4";
request.merchantSdk = "DotNet;8.31.5";
authentication authentication = new authentication();
authentication.password = config["password"];
authentication.user = config["username"];
Expand Down
4 changes: 2 additions & 2 deletions LitleSdkForNet/LitleSdkForNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("8.31.4")]
[assembly: AssemblyFileVersion("8.31.4")]
[assembly: AssemblyVersion("8.31.5")]
[assembly: AssemblyFileVersion("8.31.5")]

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

2 changes: 1 addition & 1 deletion LitleSdkForNet/LitleSdkForNet/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Value Profile="(Default)">true</Value>
</Setting>
<Setting Name="timeout" Type="System.String" Scope="User">
<Value Profile="(Default)">500</Value>
<Value Profile="(Default)">5000</Value>
</Setting>
<Setting Name="proxyHost" Type="System.String" Scope="User">
<Value Profile="(Default)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void SetUp()
{ "reportGroup", "Default Report Group" },
{ "username", Properties.Settings.Default.username },
{ "version", "8.31" },
{ "timeout", "500" },
{ "timeout", "20000" },
{ "merchantId", Properties.Settings.Default.merchantId },
{ "password", Properties.Settings.Default.password },
{ "printxml", "true" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void setUp()
config.Add("reportGroup", "Default Report Group");
config.Add("username", Properties.Settings.Default.username);
config.Add("version", "8.31");
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void setUp()
config.Add("reportGroup", "Default Report Group");
config.Add("username", Properties.Settings.Default.username);
config.Add("version", "8.31");
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void setUp()
config.Add("reportGroup", "Default Report Group");
config.Add("username", Properties.Settings.Default.username);
config.Add("version", "8.31");
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void setUp()
config.Add("reportGroup", "Default Report Group");
config.Add("username", Properties.Settings.Default.username);
config.Add("version", "8.31");
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");
Expand Down
106 changes: 106 additions & 0 deletions LitleSdkForNet/LitleSdkForNetTest/Functional/TestTimeout.cs
Original file line number Diff line number Diff line change
@@ -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<string, string> _config;

[Test]
public void TestTimeoutNotDefined()
{
_config = new Dictionary<string, string>
{
{"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<string, string>
{
{"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<string, string> {
{"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<WebException>(() => { _cnp.RegisterToken(registerTokenRequest); });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<Compile Include="Functional\TestForceCapture.cs" />
<Compile Include="Functional\TestEcheckRedeposit.cs" />
<Compile Include="Functional\TestSale.cs" />
<Compile Include="Functional\TestTimeout.cs" />
<Compile Include="Functional\TestToken.cs" />
<Compile Include="Functional\TestAuth.cs" />
<Compile Include="Program.cs" />
Expand Down
2 changes: 1 addition & 1 deletion LitleSdkForNet/LitleSdkForNetTest/Unit/TestBatchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testBatchRequestContainsMerchantSdkAttribute()
String actual = batchRequest.generateXmlHeader();
String expected = @"
<batchRequest id=""""
merchantSdk=""DotNet;8.31.4""
merchantSdk=""DotNet;8.31.5""
merchantId=""01234"">
";
Assert.AreEqual(expected, actual);
Expand Down

0 comments on commit ad2f9da

Please sign in to comment.