I’m trying to implement a code to refund transaction credit card with AIM. These are the fields that I am sending to the Authorize.net server for the refund:
x_version = "3.1"
x_login = loginID.ToString
x_amount = TransactionTotal.ToString
x_type = "credit"
x_trans_id = TransactionIDToCredit
x_card_num = CreditCardFourDigits.ToString
x_relay_response = True
x_description" = Description
After I get the values for each one of these variables, I send them in an HTML form to the Authorize.net server and hopefully expect a response from them. But there are some problems with my code or this way to get refunds is not available any more. This is the message that I’m receiving from server:
x_response_code: 3
x_response_reason_code: 92
x_response_reason_text: The gateway no longer supports the requested method of integration.
And this is part of my coding on the page:
'Here we create a HTML form in the code behind to POST the information to the credit card gateway Dim collections As New NameValueCollection() collections.Add("x_version", "3.1") collections.Add("x_login", loginID.ToString) collections.Add("x_amount", TransactionTotal.ToString) collections.Add("x_type", "credit") collections.Add("x_trans_id", TransactionIDToCredit.ToString) collections.Add("x_card_num", CreditCardFourDigits.ToString) collections.Add("x_relay_response", "True") collections.Add("x_description", Description.ToString) collections.Add("x_relay_url", "http://bglocal.com/RelayPage.aspx") 'This is the URL for the page on my site that receive the relay massage from the credit card gateway Dim remoteUrl As String = "https://test.authorize.net/gateway/transact.dll" 'This URL is only for testing purposes / sandbox account Dim html As String = "<html><head>" html += "</head><body onload='document.forms[0].submit()'>" html += String.Format("<form name='AimForm' method='POST' action='{0}'>", remoteUrl) For Each key As String In collections.Keys html += String.Format("<input name='{0}' type='Hidden' value='{1}'>", key, collections(key)) Next html += "</form></body></html>" Response.Clear() Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1") Response.HeaderEncoding = Encoding.GetEncoding("ISO-8859-1") Response.Charset = "ISO-8859-1" Response.Write(html) Response.End()
Thanks
Solved! Go to Solution.
05-18-2015 09:51 AM
It the other Best Practice Fields
x_delim_data = TRUE
x_relay_response = FALSE
05-26-2015 05:10 AM
look at the Minimum Required Fields
05-18-2015 10:54 AM
Hello Raynor and thanks for your respond.
I think that I do have all the fields now according to this link:
The one that you gave me at : http://www.authorize.net/support/AIM_guide_XML.pdf on page 79, is not that clear.
Now, according to the first link here, I have everything, but still I am receiving the same error. Any idea what is going on?
These are the fields in order that I'm submitting with the HTML form for refund :
Dim collections As New NameValueCollection()
collections.Add("x_version", "3.1")
collections.Add("x_login", loginID.ToString)
collections.Add("x_amount", TransactionTotal.ToString)
collections.Add("x_type", "CREDIT")
collections.Add("x_tran_key", "5748NG65VSmlk2Qz")
collections.Add("x_trans_id", TransactionIDToCredit.ToString)
collections.Add("x_card_num", CreditCardFourDigits.ToString)
collections.Add("x_relay_response", "True")
collections.Add("x_description", Description.ToString)
Thanks
05-18-2015 12:50 PM - edited 05-18-2015 12:59 PM
just a liitle down
Best Practice Fields
05-18-2015 12:56 PM - edited 05-18-2015 01:04 PM
OK, fields were added and is not working at all. Here is a list of my fields now:
collections.Add("x_version", "3.1")
collections.Add("x_login", loginID.ToString)
collections.Add("x_amount", TransactionTotal.ToString)
collections.Add("x_type", "CREDIT")
collections.Add("x_tran_key", "5748NG65VSzzy2Qz")
collections.Add("x_delim_Data", "True")
collections.Add("x_delim_char", ",")
collections.Add("x_encap_char", ";")
collections.Add("x_relay_esponse", "False")
collections.Add("x_trans_id", TransactionIDToCredit.ToString)
collections.Add("x_card_num", CreditCardFourDigits.ToString)
collections.Add("x_relay_response", "True")
collections.Add("x_description", Description.ToString)
What is going on, any idea? Thanks
05-18-2015 01:32 PM
Your code show you are create a webpage, which is not AIM, that still SIM
There are sample code here
05-18-2015 02:08 PM
I don't known what you mean by creating a webpage, I just placing all the variables in a form and sending them to the refund gateway. That is the same way that I did it with DPM and it works. Maybe this is not the way for refund, so, please tell me. The last link that you gave me is not that specific, there is a lot there. To make things worse Authorize.net online manuals and info webpages are not user friendly at all. I don't know if you work for this company or not, but is a pain in the butt to put things together here when coding for an account. This company should change all the accounts / methods to one method only, like one fit all. Too much confusion. Finally, please let me know if I have to use a form to send the variables to the gateway or please tell me how this should be done. Thank you a lot.
05-18-2015 02:36 PM - edited 05-18-2015 02:38 PM
You code show it create a html form and submit it that not AIM, it might work for you with DPM but AIM is not DPM.
Dim html As String = "<html><head>" html += "</head><body onload='document.forms[0].submit()'>" html += String.Format("<form name='AimForm' method='POST' action='{0}'>", remoteUrl) For Each key As String In collections.Keys html += String.Format("<input name='{0}' type='Hidden' value='{1}'>", key, collections(key)) Next html += "</form></body></html>" Response.Clear() Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1") Response.HeaderEncoding = Encoding.GetEncoding("ISO-8859-1") Response.Charset = "ISO-8859-1" Response.Write(html) Response.End()
The link have AIM sample code
scroll to "Advanced Integration Method (AIM)" then "AIM - VB.NET"
And no, I don't work for authorize.net.
Finally, please let me know if I have to use a form to send the variables to the gateway or please tell me how this should be done. Thank you a lot.
AIM don't use form post period, either use the URL or XML or json method. but NO form POST
05-18-2015 03:55 PM - edited 05-18-2015 03:56 PM
Thanks a lot for your help.
This is what I got so far. The following code is working fine for the refund:
Dim post_values As New Dictionary(Of String, String) post_values.Add("x_version", "3.1") post_values.Add("x_login", loginID.ToString) post_values.Add("x_amount", TransactionTotal.ToString) post_values.Add("x_type", "CREDIT") post_values.Add("x_tran_key", transactionKey.ToString) post_values.Add("x_delim_char", "|") post_values.Add("x_description", Description.ToString) post_values.Add("x_card_num", CreditCardFourDigits.ToString) post_values.Add("x_trans_id", TransactionIDToCredit.ToString) 'THIS REMOTE URL SHOULD BE CHANGE DEPENDING WHAT ACCOUNT IS IN USE, SANDBOX OR REAL ONE. 'IT COULD BE CHANGE IT IN THE CLASS AuthorizeDoNetValues Dim remoteUrl = AuthorizeDotNetValues.remoteUrl 'This is the remote URL where the data to charge credit cards are send. ' This section takes the input fields and converts them to the proper format ' for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4" Dim post_string As String = "" For Each field As KeyValuePair(Of String, String) In post_values post_string &= field.Key & "=" & HttpUtility.UrlEncode(field.Value) & "&" Next post_string = Left(post_string, Len(post_string) - 1) ' create an HttpWebRequest object to communicate with Authorize.net Dim objRequest As HttpWebRequest = CType(WebRequest.Create(remoteUrl), HttpWebRequest) objRequest.Method = "POST" objRequest.ContentLength = post_string.Length objRequest.ContentType = "application/x-www-form-urlencoded" ' post data is sent as a stream Dim myWriter As StreamWriter = Nothing myWriter = New StreamWriter(objRequest.GetRequestStream()) myWriter.Write(post_string) myWriter.Close()
However, the code for the gateway response is not working. This is what I got for that, and I just wanted right now up to the alert window in order to see what is the message that I'm receiving from the gateway:
' returned values are returned as a stream, then read into a string Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse) Dim responseStream As New StreamReader(objResponse.GetResponseStream()) Dim post_response As String = responseStream.ReadToEnd() responseStream.Close() 'This variable is for the Alert window Dim strMessage As String AlertWindow.CreateMessageAlert(Me, post_response, "strKey1")
The message that I'm getting in the alert message is: 92 , The gateway no longer supports the requested method of integration.
So, at this point I'm like half way through, how could I fix this error?
Thanks a lot for your help !
05-25-2015 06:22 PM
For AIM, you need to pass your transactionKey
read this again.
05-25-2015 06:34 PM - edited 05-25-2015 06:35 PM