Forum Moderators: open

Message Too Old, No Replies

Error with Authorize AIM

         

morpheus83

10:32 am on Sep 14, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



I got this code from asp101.com/articles/dan/AuthNetXMLHTTP/default.asp

FORM PAGE
<HTML>
<BODY>
<FORM METHOD=post ACTION="orderScript.asp">
Description: <INPUT name=x_Description value="Qty 24 - Yellow Note Pads"><br>
Amount: <INPUT name=x_Amount value="4.95"><br>
Credit Card Number: <INPUT name=x_Card_Num value="4111111111111111"><br>
Expiration Date: <INPUT name=x_Exp_Date value="102003"><br>
First Name: <INPUT name=x_First_Name value="Fred"><br>
Last Name: <INPUT name=x_Last_Name value="Consumer"><br>
Address: <INPUT name=x_Address value="1500 N. Scenic Dr."><br>
City: <INPUT name=x_City value="Hollywood"><br>
State: <INPUT name=x_State value="CA"><br>
Zip Code: <INPUT name=x_ZIP value="90201"><br>
Phone: <INPUT name=x_Phone value="800-555-1212"><br>
Fax: <INPUT name=x_Fax value="800-555-1213"><br>
Email: <INPUT name=x_Email value="fred@testmail.com"><br>
<INPUT type=submit value=Submit name=submit>
</FORM>
</BODY>
</HTML>

HANDLER PAGE
<HTML>
<BODY>
<%
'First enter our loginID
PostData = "x_Login=testdrive" 'test account for Authorize.Net
PostData = PostData & "&x_Version=3.0"
PostData = PostData & "&x_Test_Request=TRUE" 'since we are testing
PostData = PostData & "&x_ADC_Delim_Data=TRUE" 'we want comma delimited
PostData = PostData & "&x_ADC_URL=FALSE" 'do not want to redirect

'Now add the form fields
PostData = PostData & "&x_Card_Num=" & Request.Form("x_Card_Num") & ""
PostData = PostData & "&x_Exp_Date=" & Request.Form("x_Exp_Date") & ""
PostData = PostData & "&x_Description=" & Request.Form("x_Description") & ""
PostData = PostData & "&x_Amount=" & Request.Form("x_Amount") & ""
PostData = PostData & "&x_First_Name=" & Request.Form("x_First_Name") & ""
PostData = PostData & "&x_Last_Name=" & Request.Form("x_Last_Name") & ""
PostData = PostData & "&x_company=" & Request.Form("x_company") & ""
PostData = PostData & "&x_Address=" & Request.Form("x_Address") & ""
PostData = PostData & "&x_City=" & Request.Form("x_City") & ""
PostData = PostData & "&x_State=" & Request.Form("x_State") & ""
PostData = PostData & "&x_ZIP=" & Request.Form("x_ZIP") & ""
PostData = PostData & "&x_Phone=" & Request.Form("x_Phone") & ""
PostData = PostData & "&x_Fax=" & Request.Form("x_Fax") & ""
PostData = PostData & "&x_Email=" & Request.Form("x_Email") & ""

'Send the transaction info as part of the querystring
set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.open "POST", "https://secure.authorize.net/gateway/transact.dll?" _
& PostData & "", false
xml.send ""
strStatus = xml.Status
strRetval = xml.responseText
set xml = nothing

'Response.Write "response = " & strRetVal & "<BR>" 'this will print out the
'entire return string
'for troubleshooting

'first we'll create an array from the return value by splitting on the
'commas and then we'll assign each member of the array to values that
'better describe them for the reader. Of course we'd probably want to
'do something else with these values like save them to a database,
'create an email to send to the webmaster and/or the user

strArrayVal = split(strRetVal, ",", -1)
x_response_code = strArrayVal(0)
'Response Code:
'1 = This transaction has been approved.
'2 = This transaction has been declined.
'3 = There has been an error processing this transaction.

x_response_subcode = strArrayVal(1)
x_response_reason_code = strArrayVal(2)
x_response_reason_text = strArrayVal(3)
x_auth_code = strArrayVal(4) '6 digit approval code
x_avs_code = strArrayVal(5)
'Address Verification system:
'A = Address (street) matches, Zip does not
'E = AVS error
'N = No match on address or zip
'P = AVS Not Applicable
'R = Retry, system unavailable or timed out
'S = service not supported by issuer
'U = address information is unavailable
'W = 9 digit Zip matches, address does not
'X = exact AVS match
'Y = address and 5 digit zip match
'Z = 5 digit zip matches, address does not

x_trans_id = strArrayVal(6) 'transaction id
x_invoice_num = strArrayVal(7)
x_description = strArrayVal(8)
x_amount = strArrayVal(9)
x_method = strArrayVal(10)
x_type = strArrayVal(11)
x_cust_id = strArrayVal(12)
x_first_name = strArrayVal(13)
x_last_name = strArrayVal(14)
x_company = strArrayVal(15)
x_address = strArrayVal(16)
x_city = strArrayVal(17)
x_state = strArrayVal(18)
x_zip = strArrayVal(19)
x_country = strArrayVal(20)
x_phone = strArrayVal(21)
x_fax = strArrayVal(22)
x_email = strArrayVal(23)
x_ship_to_first_name = strArrayVal(24)
x_ship_to_last_name = strArrayVal(25)
x_ship_to_company = strArrayVal(26)
x_ship_to_address = strArrayVal(27)
x_ship_to_city = strArrayVal(28)
x_ship_to_state = strArrayVal(29)
x_ship_to_zip = strArrayVal(30)
x_ship_to_country = strArrayVal(31)
x_tax = strArrayVal(32)
x_duty = strArrayVal(33)
x_freight = strArrayVal(34)
x_tax_exempt = strArrayVal(35)
x_po_num = strArrayVal(36)
x_md5_hash = strArrayVal(37)
%>

<H1>Order Receipt</H1>
<%
'Check the ErrorCode to make sure that the component was able to talk
'to the authorization network
If (strStatus <> 200) Then
Response.Write "An error occured during processing. " _
& "Please try again later."
else
If x_response_code = 1 Then
Response.Write("Thank you for your purchase.")
elseif x_response_code = 2 then
Response.Write("The transaction was not approved: " _
& x_response_reason_text)
Else
response.Write "An error occured during processing. " _
& "Please try again later."
End If
end if
%>

</BODY>
</HTML>

--------#*$!xxxx-----------
I tried using the code but it gives me an error "An error occured during processing, please try again later". I replaced the test login with my login. However I cannot figure out where to enter the Transaction key.

bmcgee

12:01 am on Sep 19, 2004 (gmt 0)

10+ Year Member



Add this line to send your transkey also:
PostData = PostData & "&x_tran_key=xyz123"

You might want to bump the version to 3.1 also.

duckhunter

11:31 pm on Sep 19, 2004 (gmt 0)

10+ Year Member



Which "Error Occurred during...." message are you encountering? Status <> 200 or the bottom one? It's possible from the last few days you are getting alot of what This Thread [webmasterworld.com] has been talking about. Authorize.NET has been under DDOS attack.

I've received the Error 12029 alot over the last few days instead of Status=200. That 12029 is usually indicative of the remote server not responding to a request. I believe it's layman's definition is 'Cannot Connect'.

Have you tried their Test Server: certification.authorize.net