cancel
Showing results for 
Search instead for 
Did you mean: 

Problems getting ARB transaction subscriptions to save

I am trying to send XML data to the ARB API to setup subscriptions, using an application I wrote in Classic ASP. I am actually doing two separate transactions. The first is a regular auth_capture to charge the credit card an initial amount of $20.00. I wait until that transaction goes through, receive success message from the API, clear out my objects, then create a new transaction for the ARB subscription. The auth_capture works fine, ARB does not. For the auth_capture I am sending x_login, x_Password and x_Tran_Key data. For the ARB I am sending name (same as x_login) and transactionKey (same as x_Tran_Key). I do not get a message back, no error message, no returned XML... the screen loads but the subscription does not appear when I check by logging into the Authorize.Net merchant website. My XML code is attached, I only removed the name, transactionKey and cardNumber data.
I am using a component called khttp.inet which I have used for sending/receiving XML in other applications. My ASP code looks like this:

set inet=server.CreateObject("khttp.inet")
set parser=server.CreateObject("Msxml2.DOMDocument.4.0")

inet.xml=xml
call inet.openurl("https://api.authorize.net/xml/v1/request.api","GET")
returncontent=inet.content

parser.async=false
parser.loadxml(inet.content)

on error resume next
inet.close
set inet=nothing
parser.close
set parser=nothing
on error goto 0

I assume https://api.authorize.net/xml/v1/request.api is correct. The component asks for a GET or a POST. I have been using GET, not sure if that matters to the API or not.
I have been using AIM for many years, this is the first time a client has asked me to setup ARB. I wish I had an error message or something, but i'm not getting anything. When I write the variable returncontent, it is blank. Unless there is a problem loading XML data as text. Where I have parser.loadxml(inet.content), in another application unrelated to this project, that brings in the XML fine. I'm not sure how to properly read that, though.
I would appreciate any assistance. Thank you!
<?xml version="1.0" encoding="utf-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
	<merchantAuthentication>
		<name></name>
		<transactionKey></transactionKey>
	</merchantAuthentication>
	<refId>Campaign 2012</refId>
	<subscription>
		<name>Campaign 2012</name>
		<paymentSchedule>
			<interval>
				<length>1</length>
				<unit>months</unit>
			</interval>
			<startDate>2011-11-30</startDate>
			<totalOccurrences>12</totalOccurrences>
		</paymentSchedule>
		<amount>12.00</amount>
		<payment>
			<creditCard>
				<cardNumber></cardNumber>
				<expirationDate>2014-04</expirationDate>
			</creditCard>
		</payment>
		<order>
			<invoiceNumber>12422</invoiceNumber>
		</order>
		<customer>
			<id>10000</id>
			<email>brad@bbdesign.com</email>
			<phoneNumber>610-693-6080</phoneNumber>
			<faxNumber></faxNumber>
		</customer>
		<billTo>
			<firstName>Brad</firstName>
			<lastName>Bansner</lastName>
			<company>BB Design</company>
			<address>245 Lamms Mill Road</address>
			<city>Wernersville</city>
			<state>PA</state>
			<zip>19565</zip>
			<country>UNITED STATES</country>
		</billTo>
	</subscription>
</ARBCreateSubscriptionRequest>
 
bbdesign
Contributor
20 REPLIES 20

Maybe this? Sounds like the default is ASCII / TEXT. Not the same as text/xml? I would imagine binary would not work.

 

.transfermodeinteger 0-1
Sets the http transfer mode:

0 = ascii / text
1 = binary
Defaults is:
0 ascii mode

Notes: You must set "binarysaveas" using a full path and file name.

 

Look like is just

inet.addHTTPHeaders "content-type","text/xml"

 

Thank you, sorry I missed that in the documentation. Now I get:

 

<?xml version="1.0" encoding="utf-8"?><ErrorResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Error</resultCode><message><code>E00003</code><text>Root element is missing.</text></message></messages></ErrorResponse>

 

My XML is attached. It looks accurate to me, do you see anything?

 

<?xml version="1.0" encoding="utf-8"?>
<ARBCreateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
	<merchantAuthentication>
		<name></name>
		<transactionKey></transactionKey>
	</merchantAuthentication>
	<refId>Campaign 2012</refId>
	<subscription>
		<name>Campaign 2012</name>
		<paymentSchedule>
			<interval>
				<length>1</length>
				<unit>months</unit>
			</interval>
			<startDate>2011-12-01</startDate>
			<totalOccurrences>12</totalOccurrences>
		</paymentSchedule>
		<amount>12.00</amount>
		<payment>
			<creditCard>
				<cardNumber></cardNumber>
				<expirationDate>2014-04</expirationDate>
			</creditCard>
		</payment>
		<order>
			<invoiceNumber>12431</invoiceNumber>
		</order>
		<customer>
			<id>10000</id>
			<email>brad@bbdesign.com</email>
			<phoneNumber>610-693-6080</phoneNumber>
			<faxNumber></faxNumber>
		</customer>
		<billTo>
			<firstName>Brad</firstName>
			<lastName>Bansner</lastName>
			<company>BB Design</company>
			<address>245 Lamms Mill Road</address>
			<city>Wernersville</city>
			<state>PA</state>
			<zip>19565</zip>
			<country>UNITED STATES</country>
		</billTo>
	</subscription>
</ARBCreateSubscriptionRequest>

Looks ok to me too, but are you sure it's actually being sent? Try posting to a URL of yours instead and then log the post.

I'm not quite sure how to do that. If I change this:

 

call inet2.openurl("https://api.authorize.net/xml/v1/request.api","GET")

 

...to something like this:

 

call inet2.openurl("http://www.mydomain.com/test.asp","GET")

 

How do I make test.asp accept the data? I normally have a variable, but I don't think there is a variable in this case? If I can get the (hopefully) incoming data, then I can store it to a DB and verify.

Try

 

inet.bypassUrlEncodeOnPost = 1
This will disable automatic urlencoding of post variables.

 

 And

 

Maybe it need the content length set, you need to change the ??? to the right length. I read that sometime there are issue with asp when sending "text/xml" without it.

inet.addHTTPHeaders "Content-Length","???"

I tried adding inet2.bypassUrlEncodeOnPost=1 but that had no affect. I tried adding this simple script to an ASP document that attemps to save the results:

 

<% for each item in request.querystring
cn1.execute("insert into tbl_log (timestamp, log) values ('" & now & "', '" & replace(request.querystring(item),"'","''") & "')")
next %>

 

I did not get anything in that table. But not sure how the component actually sends GET data when its an XML document. It handles regular POST and GET data differently than XML. I.e.:

 

This feature is an extension of the standard http POST method. To use this feature, use the same syntax as the POST example, but DO NOT call inet.addpostvars(). Instead, use the inet.xml property. The XML feature will work with Ebay's Web Services API. This feature was tested using the UPS website to return shipping rates. This requires a valid password from UPS. ( http://www.ups.com )

 

Regarding Content-Length... you mean the length of the XML I am sending? I would just count up all the characters before sending? If so, how does it handle tabs and line breaks, do those count toward the content-length? I haven't worked with that type of thing before.

 

Thank you!

For the Content-Length, it is the XML that you are sending. Should be able to use

len(xml)

 

Guys, thanks for all the help. As far as I can tell, my XML is perfect. But my KHTTP component is not communicating with the API. Can you recommend some other component I can install on a Microsoft server that has been proven to work with Authorize.Net ARB transactions? Hopefully something inexpensive or free. At this point, I just need to get this thing working for a client who is in a hurry. Thank you!

Sample code "CIM - ASP Classic" use XML to communicating with authorize.net. util.asp have the basic code to communicating to them.

It probably just need to change the xml and URL to work with ARB.