Authorize.net AIM demo problems

I downloaded the sample AIM – ColdFusion code from Authorize.net. After uploading it I jumped right on and tried it out. I continually received this error…

The cfhttp tag requires at least one cfhttpparam tag for a POST operation.

…though everything in the code looks fine:
<cfhttp method="post" url="https://test.authorize.net/gateway/transact.dll">
<!-- Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts -->
<!-- <cfhttp method="post" url="https://secure.authorize.net/gateway/transact.dll"> -->
<!--
	First, we pass the required fields for this particular transaction type (CC/AUTH_CAPTURE)
-->
<cfhttpparam name="x_login" type="formfield" value="enter_your_login_ID">
<cfhttpparam name="x_tran_key" type="formfield" value="eoXaEm2LUnz2OiyQ">
<cfhttpparam name="x_method" type="formfield" value="CC">
<cfhttpparam name="x_type" type="formfield" value="AUTH_CAPTURE">
<cfhttpparam name="x_amount" type="formfield" value="19.99">
<cfhttpparam name="x_delim_data" type="formfield" value="TRUE">
<cfhttpparam name="x_delim_char" type="formfield" value="|">
<cfhttpparam name="x_relay_response" type="formfield" value="FALSE">
<cfhttpparam name="x_card_num" type="formfield" value="4111111111111111">
<cfhttpparam name="x_exp_date" type="formfield" value="05/05">

<!--
	Now we can add any of the optional-but-not-required fields.

	IMPORTANT: Although you could -- in theory --  set x_version to "3.0"
	we strongly urge you not to do so. By default, x_version is set to "3.1"
	(and that corresponds to the most recent documentation).

	If you change x_version, the following code will not produce the
	expected results, since the gateway response structure will be
	very different.

	For specific information about the 3.1 gateway response API, please
	see the AIM Guide at:
		http://www.authorizenet.com/support/AIM_guide.pdf
	or
		http://www.authorizenet.com/support/AIM_guide_SCC.pdf
		(specifically for shopping cart solutions)

-->
<cfhttpparam name="x_version" type="formfield" value="3.1">

<cfhttpparam name="x_invoice_num" type="formfield" value="041803-001">
<cfhttpparam name="x_description" type="formfield" value="ColdFusion: Simple AIM Example">
<cfhttpparam name="x_cust_id" type="formfield" value="SuperStore 007">

<!--
	And we can also pass merchant-defined fields.

	NOTE: Only the values of merchant-defined fields will be returned
	in the Authorize.Net gateway response "as is" -- meaning, only the
	value of those fields will get returned WITHOUT the name.
	Therefore, it's a good idea to add the description (or some kind
	of code) to the value, since that will help you identify the
	response for further processing.

	Of course, since YOU are passing the merchant-defined fields, you
	might as well capture their values BEFORE submitting the transaction
	(and thereby keep the passed string as "slim and trim" as possible).

	IMPORTANT: On the e-mail receipt for this transaction, however, the
	name of the merchant-defined field, as well as the value will be listed.

-->
<cfhttpparam name="custField_01" type="formfield" value="Promotion: Spring Sale">
<cfhttpparam name="custField_02" type="formfield" value="Custom Data String: abcdefghijklmnopqrstuvwxyz0123456789">

</cfhttp>

As it turns out, CF doesn’t much care for HTML comments inside of cfhttpparam. A search and replace of HTML comments with CF comments remedies the situation.

<cfhttp method="post" url="https://test.authorize.net/gateway/transact.dll">
<!--- Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts --->
<!--- <cfhttp method="post" url="https://secure.authorize.net/gateway/transact.dll"> --->
<!---
	First, we pass the required fields for this particular transaction type (CC/AUTH_CAPTURE)
--->
<cfhttpparam name="x_login" type="formfield" value="enter_your_login_ID">
<cfhttpparam name="x_tran_key" type="formfield" value="eoXaEm2LUnz2OiyQ">
<cfhttpparam name="x_method" type="formfield" value="CC">
<cfhttpparam name="x_type" type="formfield" value="AUTH_CAPTURE">
<cfhttpparam name="x_amount" type="formfield" value="19.99">
<cfhttpparam name="x_delim_data" type="formfield" value="TRUE">
<cfhttpparam name="x_delim_char" type="formfield" value="|">
<cfhttpparam name="x_relay_response" type="formfield" value="FALSE">
<cfhttpparam name="x_card_num" type="formfield" value="4111111111111111">
<cfhttpparam name="x_exp_date" type="formfield" value="05/05">

<!---
	Now we can add any of the optional-but-not-required fields.

	IMPORTANT: Although you could -- in theory --  set x_version to "3.0"
	we strongly urge you not to do so. By default, x_version is set to "3.1"
	(and that corresponds to the most recent documentation).

	If you change x_version, the following code will not produce the
	expected results, since the gateway response structure will be
	very different.

	For specific information about the 3.1 gateway response API, please
	see the AIM Guide at:
		http://www.authorizenet.com/support/AIM_guide.pdf
	or
		http://www.authorizenet.com/support/AIM_guide_SCC.pdf
		(specifically for shopping cart solutions)

--->
<cfhttpparam name="x_version" type="formfield" value="3.1">

<cfhttpparam name="x_invoice_num" type="formfield" value="041803-001">
<cfhttpparam name="x_description" type="formfield" value="ColdFusion: Simple AIM Example">
<cfhttpparam name="x_cust_id" type="formfield" value="SuperStore 007">

<!---
	And we can also pass merchant-defined fields.

	NOTE: Only the values of merchant-defined fields will be returned
	in the Authorize.Net gateway response "as is" -- meaning, only the
	value of those fields will get returned WITHOUT the name.
	Therefore, it's a good idea to add the description (or some kind
	of code) to the value, since that will help you identify the
	response for further processing.

	Of course, since YOU are passing the merchant-defined fields, you
	might as well capture their values BEFORE submitting the transaction
	(and thereby keep the passed string as "slim and trim" as possible).

	IMPORTANT: On the e-mail receipt for this transaction, however, the
	name of the merchant-defined field, as well as the value will be listed.

--->
<cfhttpparam name="custField_01" type="formfield" value="Promotion: Spring Sale">
<cfhttpparam name="custField_02" type="formfield" value="Custom Data String: abcdefghijklmnopqrstuvwxyz0123456789">

</cfhttp>

Is that a bug in CFHHTP?

UPDATE: Alert CF’er fgwenger noticed that the second cfhttp tag was wrapped in html comments, not CF comments. That was the correct solution!

2 Replies to “Authorize.net AIM demo problems”

  1. There are two open cfhttp tags. It looks like you have an HTML comment when you should have a CF comment. Maybe that’s just for your blog display.

Comments are closed.