Skip to content

Commit

Permalink
Merge pull request #68 from Vantiv/US268420-Add-Timeout-Setting-10.1
Browse files Browse the repository at this point in the history
Us268420 add timeout setting 10.1
  • Loading branch information
VantivSDK authored Oct 28, 2019
2 parents 4ee75ae + ae9db3e commit 342ec1f
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 13 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 10.8.4 (Oct 28, 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

Expand Down
13 changes: 13 additions & 0 deletions LitleSdkForNet/LitleSdkForNet/Communications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ virtual public string HttpPost(string xmlRequest, Dictionary<String, String> con
req.Method = "POST";
req.ServicePoint.MaxIdleTime = 10000;
req.ServicePoint.Expect100Continue = 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))
{
WebProxy 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 @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion LitleSdkForNet/LitleSdkForNet/LitleOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
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("10.8.3")]
[assembly: AssemblyFileVersion("10.8.3")]
[assembly: AssemblyVersion("10.8.4")]
[assembly: AssemblyFileVersion("10.8.4")]

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 @@ -9,7 +9,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="sftpUrl" Type="System.String" Scope="User">
<Value Profile="(Default)">prelive.litle.com</Value>
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", "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");
Expand Down Expand Up @@ -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);
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", "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");
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", "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");
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", "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");
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", "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");
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 @@ -123,6 +123,7 @@
<Compile Include="Functional\TestEcheckRedeposit.cs" />
<Compile Include="Functional\TestFraudCheck.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;10.8""
merchantSdk=""DotNet;10.8.4""
merchantId=""01234"">
";
Assert.AreEqual(expected, actual);
Expand Down

0 comments on commit 342ec1f

Please sign in to comment.