I've been working with the .Net SDK for Authorize.Net API from GitHub (version 1.8.3) and it seems that the CheckForErrors method in HttpXMLUtility is returning the incorrect response. It seemed as if the response was being altered and the response parameters like AuthCode and ResponseCode are missing.
This is being called from HttpXMLUtility.Send whether I do an Auth or a Capture. Both cases don't return an AuthCode.
In debugging it looks like the XML Response has 2 Child.Child level nodes. One is "messages" and the other is "directReponse". The way it is coded messages is the first Child.Child node, so it sets thingy.directReponse to the message and it never grabs the directReponse. (See current code below)
void CheckForErrors(ANetApiResponse response) { if (response.GetType() == typeof(createCustomerProfileTransactionResponse)) { //there's a directResponse we need to find... var thingy = (createCustomerProfileTransactionResponse)response; thingy.directResponse = null; for (var i = 0; i <= 1; i++) { if (null != _xmlDoc && null != _xmlDoc.ChildNodes[i]) { for (var j = 0; j <= 1; j++) { if (null != _xmlDoc.ChildNodes[i].ChildNodes[j]) { thingy.directResponse = _xmlDoc.ChildNodes[i].ChildNodes[j].InnerText; } if (null != thingy.directResponse) { break; } } } if (null != thingy.directResponse) { break; } } response = thingy; } else { if (response.messages.message.Length > 0) { if (response.messages.resultCode == messageTypeEnum.Error) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < response.messages.message.Length; i++) { sb.AppendFormat("Error processing request: {0} - {1}", response.messages.message[i].code, response.messages.message[i].text); } throw new InvalidOperationException(sb.ToString()); } } } }
Should this inner look not be checking specifically for the directReponse node if there are more than one Child.Child node?
Perhaps it should be modified as so:
void CheckForErrors(ANetApiResponse response) { if (response.GetType() == typeof(createCustomerProfileTransactionResponse)) { //there's a directResponse we need to find... var thingy = (createCustomerProfileTransactionResponse)response; thingy.directResponse = null; for (var i = 0; i <= 1; i++) { if (null != _xmlDoc && null != _xmlDoc.ChildNodes[i]) { for (var j = 0; j <= 1; j++) { if (null != _xmlDoc.ChildNodes[i].ChildNodes[j]) { if (_xmlDoc.ChildNodes[i].ChildNodes[j].Name == "directResponse") { thingy.directResponse = _xmlDoc.ChildNodes[i].ChildNodes[j].InnerText; } } if (null != thingy.directResponse) { break; } } } if (null != thingy.directResponse) { break; } } response = thingy; } else { if (response.messages.message.Length > 0) { if (response.messages.resultCode == messageTypeEnum.Error) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < response.messages.message.Length; i++) { sb.AppendFormat("Error processing request: {0} - {1}", response.messages.message[i].code, response.messages.message[i].text); } throw new InvalidOperationException(sb.ToString()); } } } }
Looking to get some feedback in case I'm not on the right track.
05-01-2015 12:30 PM
Thanks for reporting this. I see you also submitted the issue on GitHub and one of our developers confirmed a solution will be included in an upcoming release.
Thanks for your help!
Richard
05-01-2015 01:41 PM