Reply
Highlighted
Member
Posts: 3
Registered: ‎01-04-2011

integrating ARB using classic ASP

I am trying to integrate ARB using classic ASP. There is no sample code available from Authorize.net for this. I followed the PHP code and the reference guide to set up the XML file, but I am confused how to post this to authorize.net in order to get a response back.

 

in AIM for a single transaction, there were several methods of posting. I successfully used this method:

 

 Dim objHttp
 Set objHTTP = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
 objHTTP.Open "GET", "https://secure.authorize.net/gateway/transact.dll?" & vPostData, false
 objHTTP.Send()
 strRetval = objHTTP.ResponseText

Do I use something similar for ARB? If so, how do I correctly send the XML file using this? There were other options in the AIM guide, such as XMLHTTP - should I use that?

 

I would assume that someone has done this before, and I just need a few lines of code to finish up this aspect of the project. Thank you.

Highlighted
Member
Posts: 2
Registered: ‎01-04-2011

Re: integrating ARB using classic ASP

Have you read the ARB PDF guide?  All you pretty much have to do is POST the XML payload to one of the API urls and parse the results.

 

I would check a ASP programming forum or Stackoverflow on how to post XML data with ASP.

 

Highlighted
Member
Posts: 3
Registered: ‎01-04-2011

Re: integrating ARB using classic ASP

I have read the ARB guide, but it  provides no information on how to post the XML file.

 

I used the AIM code that posted a message using XMLHTTP, and modified it slightly to post the ARB XML file:

 

Dim xml
Dim strStatus
Dim strRetval
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.open "get", "https://api.authorize.net/xml/v1/request.api", false
xml.send vPostData
strStatus = xml.Status
strRetval = xml.responseText
Set xml = nothing

It doesn't work.

Error code :E00002 (The content-type specified is not supported)

 

Do you know what I need to do to correct this error? The XML that I am submitting seems to be well-formed, as you can see below:

 

<?xml version="1.0" encoding="utf-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
 <merchantAuthentication>
  <name>xxxxx</name>
  <transactionKey>xxxxx</transactionKey>
 </merchantAuthentication>
 <refId>12</refId>
 <subscription>
  <name>Larry Seltzer</name>
  <paymentSchedule>
   <interval>
    <length>12</length>
    <unit>months</unit>
   </interval>
   <startDate>2011-1-4</startDate>
   <totalOccurrences>12</totalOccurrences>
   <trialOccurrences>0</trialOccurrences>
  </paymentSchedule>
  <amount>10</amount>
  <trialAmount>0</trialAmount>
  <payment>
   <creditCard>
    <cardNumber>4111111111111111</cardNumber>
    <expirationDate>2011-01</expirationDate>
   </creditCard>
  </payment>
  <billTo>
   <firstName>Larry</firstName>
   <lastName>Seltzer</lastName>
  </billTo>
 </subscription>
</ARBCreateSubscriptionRequest>

 

Highlighted
Member
Posts: 3
Registered: ‎01-04-2011

Re: integrating ARB using classic ASP

If I can't get a solution for this here, where else can I turn for a solution? Are there places where I can hire an expert for a few dollars to offer a solution?

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: integrating ARB using classic ASP

[ Edited ]

Have you look at the sample code at

http://developer.authorize.net/resources/files/samplecode/asp_cim.zip

 

It not for ARB but it use classic ASP with XML.

Highlighted
Member
Posts: 2
Registered: ‎01-05-2011

Re: integrating ARB using classic ASP

I've been using this classic asp ARB snippet for years... just replace the info with your own.... hope it helps:

 

<%
ReDim arrVars(2, 0)
Sub add(iName, iValue)
  x = ubound(arrVars, 2) + 1
  Redim Preserve arrVars(2, x)
  arrVars(0, x - 1) = iName
  arrVars(1, x - 1) = iValue
End Sub
add "x_login", "XXXXXXX"
add "x_tran_key", "XXXXXXXXXXXXXXX"
add "x_version", "3.1"
add "x_test_request", "false" 'Used for testing
add "x_delim_data", "true"
add "x_delim_char", "|"
add "x_relay_response", "false"
add "x_first_name", request("bFirstname")
add "x_last_name", request("bLastname")
add "x_company", request("bCompany")
add "x_call address", request("bStreet1")
add "x_city", request("bCity")
add "x_state", request("bState")
add "x_zip", request("bZip")
add "x_country", "US"
add "x_phone", request("bPhone")
add "x_cust_id", request("memberID")
add "x_customer_ip", request.servervariables("remote_call addr")
add "x_email", request("email")
add "x_email_customer", "false"
'add "x_merchant_email", "you@yourwebsite.com"
add "x_invoice_num", request.requestID & "-" & day(date) & month(date) & year(date)
add "x_description", "Toolshop Purchase"
add "x_ship_to_first_name", request("sFirstname")
add "x_ship_to_last_name", request("sLastname")
add "x_ship_to_company", request("sCompany")
add "x_ship_to_call address", request("sStreet1")
add "x_ship_to_city", request("sCity")
add "x_ship_to_state", request("sState")
add "x_ship_to_zip", request("sZip")
add "x_ship_to_country", "US"
add "x_amount", request("orderTotal")
add "x_currency_code", "USD"
add "x_method", "CC"
add "x_type", "AUTH_CAPTURE"
add "x_recurring_billing", "no"
add "x_card_num", request("cardNumber")
add "x_exp_date", request("expMonth") & "/" & request("expYear")
add "x_card_code", request("CID")
IF request("bState") = "MI" then
  add "x_tax", "6%"
Else
  add "x_tax", "0%"
End IF
add "x_tax_exempt", "false"
add "x_freight", request("shipping")
Dim qs 'short for querystring
For i = 0 to ubound(arrVars, 2) - 1 Step 1
  qs = qs & arrVars(0, i) & "=" & arrVars(1, i) & "&"
Next
qs = left(qs,len(qs)-1)
Dim http, strStatus, strRetval
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
  http.setRequestHeader "User-Agent" ,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
   http.Send qs
  strStatus = http.Status
  strResult = http.responsetext
Set http = nothing
Dim arrResult
arrResult = split(strResult, "|", -1)
IF arrResult(0) <> "1" Then
  request("arrResult") = arrResult
  response.redirect "transactionError.asp"
End IF
transactionID = arrResult(6) ' Use for saving to your DB and/or confirmation email later
%>

 

Highlighted
Member
Posts: 5
Registered: ‎10-15-2013

Re: integrating ARB using classic ASP

sefi thanks for this - but the code is for AIM, not for ARB (Irecurring billing). for example - your code doesnt ask how long the subscription is , how oten to charge the card etc...

 

do you have sample for ARB ?

 

thanks!