Skip to content

Commit

Permalink
Merge pull request #153 from AuthorizeNet/future
Browse files Browse the repository at this point in the history
Merging Future for Q3 updates.
  • Loading branch information
Sunny Raj Rathod authored Aug 12, 2016
2 parents c6d24f7 + f75129d commit 6d99225
Show file tree
Hide file tree
Showing 38 changed files with 3,922 additions and 2,555 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ install:
- sudo apt-get install nunit-console

before_script:
- git submodule update --recursive
- git submodule update --remote --recursive

script:
- xbuild ./Authorize.NET/AuthorizeNET.csproj
Expand Down
30 changes: 24 additions & 6 deletions Authorize.NET/AIM/Gateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class Gateway : AuthorizeNet.IGateway {

public const string TEST_URL = "https://test.authorize.net/gateway/transact.dll";
public const string LIVE_URL = "https://secure2.authorize.net/gateway/transact.dll";

//Max response size allowed: 64 MB
private const int MaxResponseLength = 67108864;

public string ApiLogin { get; set;}
public string TransactionKey { get; set;}
Expand All @@ -49,7 +50,7 @@ protected void LoadAuthorization(IGatewayRequest request) {
protected string SendRequest(string serviceUrl, IGatewayRequest request) {

var postData = request.ToPostString();
var result = "";
var result = new StringBuilder();

//override the local cert policy - this is for Mono ONLY
//ServicePointManager.CertificatePolicy = new PolicyOverride();
Expand All @@ -75,14 +76,31 @@ protected string SendRequest(string serviceUrl, IGatewayRequest request) {

// returned values are returned as a stream, then read into a string
var response = (HttpWebResponse)webRequest.GetResponse();
using (StreamReader responseStream = new StreamReader(response.GetResponseStream())) {
result = responseStream.ReadToEnd();
responseStream.Close();

if (response != null)
{
var stream = response.GetResponseStream();

if (stream == null) return result.ToString();

using (var responseStream = new StreamReader(stream))
{
while (!responseStream.EndOfStream)
{
result.Append((char)responseStream.Read());
if (result.Length >= MaxResponseLength)
{
throw new Exception("response is too long.");
}
}

responseStream.Close();
}
}

// the response string is broken into an array
// The split character specified here must match the delimiting character specified above
return result;
return result.ToString();
}

public virtual IGatewayResponse Send (IGatewayRequest request, string description)
Expand Down
5 changes: 2 additions & 3 deletions Authorize.NET/AIM/Responses/ResponseBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
namespace AuthorizeNet {
public abstract class ResponseBase {
public string[] RawResponse;
private Dictionary<int, string> _apiKeyDict = new Dictionary<int, string>();

internal Dictionary<int, string> APIResponseKeys {
get {
return new Dictionary<int, string>();
}
get { return _apiKeyDict; }
}

internal int ParseInt(int index) {
Expand Down
9 changes: 0 additions & 9 deletions Authorize.NET/AIM/Responses/SIMResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ public SIMResponse(NameValueCollection post) {
_post = post;
}

/// <summary>
/// Validates that what was passed by Auth.net is valid
/// </summary>
public bool Validate(string merchantHash, string apiLogin) {
return Crypto.IsMatch(merchantHash, apiLogin, this.TransactionID, this.Amount, this.MD5Hash);

}


public SIMResponse() : this(HttpContext.Current.Request.Form) { }

public string MD5Hash {
Expand Down
Loading

0 comments on commit 6d99225

Please sign in to comment.