Skip to content

Commit 029cc8e

Browse files
committed
code changes for refactoring ResponseReasonCode and GetValuebyIndex
code changes for refactoring ResponseReasonCode and GetValuebyIndex
1 parent 0542bbe commit 029cc8e

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

Authorize.NET/AIM/Responses/GatewayResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public string ResponseCode {
7878
return ParseResponse(0);
7979
}
8080
}
81-
public string ReasonResponseCode
81+
public string ResponseReasonCode
8282
{
8383
get
8484
{

Authorize.NET/AIM/Responses/IGatewayResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public interface IGatewayResponse {
99
string ResponseCode { get; }
1010
string Message { get; }
1111
string TransactionID { get; }
12+
string ResponseReasonCode { get; }
13+
string GetValueByIndex(int position);
1214
}
1315
}

Authorize.NET/AIM/Responses/SIMResponse.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public string ResponseCode {
3636
return FindKey("x_response_code");
3737
}
3838
}
39+
40+
public string ResponseReasonCode
41+
{
42+
get { throw new NotImplementedException(); }
43+
}
44+
3945
public string Message {
4046
get {
4147
return FindKey("x_response_reason_text");
@@ -101,6 +107,21 @@ string FindKey(string key) {
101107
return result;
102108
}
103109

110+
public string GetValueByIndex(int position)
111+
{
112+
return ParseResponse(position);
113+
}
114+
115+
internal string ParseResponse(int index)
116+
{
117+
var result = "";
118+
if (_post.AllKeys.Count() > index)
119+
{
120+
result = _post[index];
121+
}
122+
return result;
123+
}
124+
104125
public override string ToString() {
105126
var sb = new StringBuilder();
106127
sb.AppendFormat("<li>Code = {0}", this.ResponseCode);

Authorize.NET/CP/CardPresentResponse.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ public string ResponseCode {
158158
get { return ParseResponse(1); }
159159
}
160160

161+
/// <summary>
162+
/// Gets the response reason code.
163+
/// </summary>
164+
/// <value>The response reason code.</value>
165+
public string ResponseReasonCode {
166+
get { return ParseResponse(2); }
167+
}
168+
161169
/// <summary>
162170
/// Gets the message.
163171
/// </summary>
@@ -174,6 +182,16 @@ public string TransactionID {
174182
get { return ParseResponse(7); }
175183
}
176184

185+
/// <summary>
186+
/// Gets the value by index
187+
/// </summary>
188+
/// <param name="position">position of the response to be returned</param>
189+
/// <returns>Returns index value.</returns>
190+
public string GetValueByIndex(int position)
191+
{
192+
return ParseResponse(position);
193+
}
194+
177195
#endregion
178196
}
179197
}

AuthorizeNETtest/GatewayTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void SendTest_FailedCredit_ReasonResponseCode()
217217
Assert.AreEqual(expected.Approved, actual.Approved);
218218
Assert.AreEqual(expected.Message, actual.Message);
219219
Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);
220-
Assert.AreEqual(((GatewayResponse)expected).ReasonResponseCode, ((GatewayResponse)expected).ReasonResponseCode);
220+
Assert.AreEqual(((GatewayResponse)expected).ResponseReasonCode, ((GatewayResponse)expected).ResponseReasonCode);
221221

222222
Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
223223
Assert.AreEqual(expected.TransactionID, actual.TransactionID);

0 commit comments

Comments
 (0)