cancel
Showing results for 
Search instead for 
Did you mean: 

Sample code for Simple AIM using ASP

I've been having trouble getting authorize.net to work.  I downloaded the sample code, signed up for a test account, and replaced the x_login and x_tran_key, but it always gives me this message:

 

  1. 13 
  2. The merchant login ID or password is invalid or the account is inactive. 
  3.  
  4.  
  5.  
  6. 19.99 
  7.  
  8. auth_capture 
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. F5FB0412546E713FCEC05FA033DCD235 

 

I've also tried my company's normal x_login/x_tran_key combo and it says the same thing. Any idea what I'm doing wrong?

 

Thank you.

jbooth88
Member
8 REPLIES 8

Try viewing the browser page source when you run it. Make sure there isn't any extra space.

RaynorC1emen7
Expert

It looks to be about what I expect it should, besides the error message:

 

<OL>
 <LI>3&nbsp;</LI>
 <LI>2&nbsp;</LI>
 <LI>13&nbsp;</LI>
 <LI>The merchant login ID or password is invalid or the account is inactive.&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>P&nbsp;</LI>
 <LI>0&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>19.99&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>auth_capture&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>&nbsp;</LI>
 <LI>F5FB0412546E713FCEC05FA033DCD235&nbsp;</LI>
 </OL>

Sorry, what I mean was at the "Submit Payment" button screen, check the loginID, transactionKey, etc.

Oh, right. Well the x_login/x_tran_key strings don't have any extra space.

 

post_values.Add "x_login", "7c6BAa7Q8Ku"
post_values.Add "x_tran_key", "7kzH87fM8Scm53ff"

 

That's just my test account that I activated this morning.

I just try it with your test account info and it work fine. You didn't change the URL to secure.authorize.net which is for production account?

and sometime it required to set the

objRequest.setRequestHeader "Content-length", post_string.length

Added that line in and it's giving me the same thing.

 

This is what I'm using:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML lang='en'>
<HEAD>
<TITLE> Sample AIM Implementation </TITLE>
</HEAD>
<BODY>
<P> This sample code is designed to generate a post using Authorize.net's
Advanced Integration Method (AIM) and display the results of this post to
the screen. </P>
<P> For details on how this is accomplished, please review the readme file,
the comments in the sample code, and the Authorize.net AIM API documentation
found at http://developer.authorize.net </P>
<HR />

<%

' By default, this sample code is designed to post to our test server for
' developer accounts: https://test.authorize.net/gateway/transact.dll
' for real accounts (even in test mode), please make sure that you are
' posting to: https://secure.authorize.net/gateway/transact.dll
Dim post_url
post_url = "https://test.authorize.net/gateway/transact.dll"

Dim post_values
Set post_values = CreateObject("Scripting.Dictionary")
post_values.CompareMode = vbTextCompare

'the API Login ID and Transaction Key must be replaced with valid values
post_values.Add "x_login", "7c6BAa7Q8Ku"
post_values.Add "x_tran_key", "7kzH87fM8Scm53ff"

post_values.Add "x_delim_data", "TRUE"
post_values.Add "x_delim_char", "|"
post_values.Add "x_relay_response", "FALSE"

post_values.Add "x_type", "AUTH_CAPTURE"
post_values.Add "x_method", "CC"
post_values.Add "x_card_num", "4111111111111111"
post_values.Add "x_exp_date", "0115"

post_values.Add "x_amount", "19.99"
post_values.Add "x_description", "Sample Transaction"

post_values.Add "x_first_name", "John"
post_values.Add "x_last_name", "Doe"
post_values.Add "x_address", "1234 Street"
post_values.Add "x_state", "WA"
post_values.Add "x_zip", "98004"
' Additional fields can be added here as outlined in the AIM integration
' guide at: http://developer.authorize.net

' 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
post_string = ""
For Each Key In post_values
post_string=post_string & Key & "=" & Server.URLEncode(post_values(Key)) & "&"
Next
post_string = Left(post_string,Len(post_string)-1)

' The following section provides an example of how to add line item details to
' the post string. Because line items may consist of multiple values with the
' same key/name, they cannot be simply added into the above array.
'
' This section is commented out by default.
'
'Dim line_items(3)
'line_items(0) = "item1<|>golf balls<|><|>2<|>18.95<|>Y"
'line_items(1) = "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y"
'line_items(2) = "item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y"
'
'For Each item In line_items
' post_string = post_string & "&x_line_item=" & Server.URLEncode(item)
'Next

' We use xmlHTTP to submit the input values and record the response
Dim objRequest, post_response
Set objRequest = Server.CreateObject("Microsoft.XMLHTTP")
objRequest.setRequestHeader "Content-length", post_string.length
objRequest.open "POST", post_url, false
objRequest.send post_string
post_response = objRequest.responseText
Set objRequest = nothing

' the response string is broken into an array using the specified delimiting character
Dim response_array
response_array = split(post_response, post_values("x_delim_char"), -1)

' the results are output to the screen in the form of an html numbered list.
Response.Write("<OL>" & vbCrLf)
For Each value in response_array
Response.Write("<LI>" & value & "&nbsp;</LI>" & vbCrLf)
Next
Response.Write("</OL>" & vbCrLf)
' individual elements of the array could be accessed to read certain response
' fields. For example, response_array(0) would return the Response Code,
' response_array(2) would return the Response Reason Code.
' for a list of response fields, please review the AIM Implementation Guide

%>
</BODY>
</HTML>

Can you run that with something like fiddler2, because it look to me that it is not sending any of the post values.

Ah! It's working now.  It had something to do with the SSL configuration.  Thank you for working with me this morning.