cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with AIM for transaction refunds

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 

 

 

 

 

 

 

AuthComm25
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

It the other Best Practice Fields

 

x_delim_data = TRUE

x_relay_response = FALSE

View solution in original post

12 REPLIES 12

look at the Minimum Required Fields

http://www.authorize.net/support/AIM_guide_XML.pdf

RaynorC1emen7
Expert

Hello Raynor and thanks for your respond.

I think that I do have all the fields now according to this link:

http://developer.authorize.net/guides/AIM/wwhelp/wwhimpl/js/html/wwhelp.htm#href=A_TransTypeFields.0...

 

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

http://developer.authorize.net/guides/AIM/wwhelp/wwhimpl/js/html/wwhelp.htm#href=A_TransTypeFields.0...

just a liitle down

Best Practice Fields

x_delim_ data = TRUE
x_delim_char
x_encap_char
x_relay_ esponse = FALSE*

I just look at your code. You doing a html post? that might be the reason why you getting an error.
AIM could be URL put or use the XML or json show in
http://developer.authorize.net/api/reference/#payment-transactions-refund-a-transaction

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

 

 

 

 

Your code show you are create a webpage, which is not AIM, that still SIM

There are sample code here

https://developer.authorize.net/downloads/samplecode/

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. 

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

 

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 !