Skip to content

Commit e1ecea1

Browse files
committed
Fixing issue#39 for CheckForErrors
1 parent b720cc5 commit e1ecea1

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Authorize.NET/Utility/HttpXmlUtility.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,22 @@ void CheckForErrors(ANetApiResponse response) {
9999
if (response.GetType() == typeof(createCustomerProfileTransactionResponse)) {
100100
//there's a directResponse we need to find...
101101
var thingy = (createCustomerProfileTransactionResponse)response;
102-
thingy.directResponse = _xmlDoc.ChildNodes[1].ChildNodes[1].InnerText;
102+
thingy.directResponse = null;
103+
for (var i = 0; i <= 1; i++)
104+
{
105+
if (null != _xmlDoc && null != _xmlDoc.ChildNodes[i])
106+
{
107+
for (var j = 0; j <= 1; j++)
108+
{
109+
if (null != _xmlDoc.ChildNodes[i].ChildNodes[j])
110+
{
111+
thingy.directResponse = _xmlDoc.ChildNodes[i].ChildNodes[j].InnerText;
112+
}
113+
if (null != thingy.directResponse) { break; }
114+
}
115+
}
116+
if (null != thingy.directResponse) { break; }
117+
}
103118
response = thingy;
104119
} else {
105120

AuthorizeNETtest/CustomerGatewayTest.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,5 +982,16 @@ public void SendTest_AuthOnly_ExtraOptions()
982982
Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
983983
Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
984984
}
985+
986+
[Test]
987+
public void TestCheckForErrorscreateCustomerProfileTransactionResponse()
988+
{
989+
const string profileId = "24231938";
990+
const string paymentProfileId = "22219473";
991+
var gateway = new CustomerGateway(ApiLogin, TransactionKey);
992+
var order = new Order(profileId, paymentProfileId, "") {Amount = (decimal) 25.10};
993+
var response = gateway.AuthorizeAndCapture(order);
994+
Assert.IsNotNull(response);
995+
}
985996
}
986997
}

0 commit comments

Comments
 (0)