I am currently working on subscription integration with Authorize.Net using their ARB service. I am able to create a subscription without any issues. However; when I try to cancel the newly created subscription I get the E00059 error : The authentication type is not allowed for this method call. Both the create and cancel functions use the same authenticate function. So I am confused why one works but the other doesnt.
I am currently using the SDK in C#.Net to create the request scripts. I've been stumped for this issue for about a day now so any help would be greatly appreciated.
Thanks
02-25-2015 02:11 PM
There are 2 way to connect on the SDKs. one use the XML, the other is the API controller.
Which one are you using?
Can you post your code?
02-26-2015 04:12 AM
I am connecting using the XML method. I did not see an API controller so I am wonder if the SDK I refereced may be outdated. Below is my code for the cancel:
public void CancelSubscription(ref String result, String SubscriptionID) { ARBCancelSubscriptionRequest cancelSubscriptionRequest = new ARBCancelSubscriptionRequest(); //Populate Request with SubscriptionID & Merchant Authentication cancelSubscriptionRequest.subscriptionId = SubscriptionID; PopulateMerchantAuthentication(cancelSubscriptionRequest); bool bResult = true; object response = null; XmlDocument xmldoc = null; //Post Cancel Request bResult = PostRequest(cancelSubscriptionRequest, out xmldoc); //Process Response if (bResult) bResult = ProcessXmlResponse(xmldoc, out response); if (bResult) ProcessResponse(response); ANetApiResponse baseResponse = (ANetApiResponse)response; if (baseResponse.messages.resultCode == messageTypeEnum.Ok) { //Subscription canceled result = "Success"; } else { result = "Error"; for (int i = 0; i < baseResponse.messages.message.Length; i++) { result += "[" + baseResponse.messages.message[i].code + "]" + baseResponse.messages.message[i].text + "<br/>"; } } }
private void PopulateMerchantAuthentication(ANetApiRequest request) { request.merchantAuthentication = new merchantAuthenticationType(); request.merchantAuthentication.name = LoginID; request.merchantAuthentication.Item = TransactionKey; request.merchantAuthentication.ItemElementName = ItemChoiceType.transactionKey; }
public bool PostRequest(object apiRequest, out XmlDocument xmldoc) { bool bResult = false; XmlSerializer serializer; string _apiUrl = @"https://api.authorize.net/xml/v1/request.api "; xmldoc = null; try { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(_apiUrl); webRequest.Method = "POST"; webRequest.ContentType = "text/xml"; webRequest.KeepAlive = true; // Serialize the request serializer = new XmlSerializer(apiRequest.GetType()); XmlWriter writer = new XmlTextWriter(webRequest.GetRequestStream(), Encoding.UTF8); serializer.Serialize(writer, apiRequest); writer.Close(); // Get the response WebResponse webResponse = webRequest.GetResponse(); // Load the response from the API server into an XmlDocument. xmldoc = new XmlDocument(); xmldoc.Load(XmlReader.Create(webResponse.GetResponseStream())); bResult = true; } catch (Exception ex) { bResult = false; } return bResult; }
Please let me know if there is any additional information I can provide.
Thank you for your time.
02-26-2015 09:25 AM
The code look ok. might have to debug it to see if it got the correct value.
02-26-2015 12:36 PM