Contributor
Posts: 11
Registered: ‎07-21-2014
ColdFusion AIM integration

ColdFusion 9
MS SQL Server 2012
authorize.net API

In brief: I need to populate an authorize.net payment page using information from a form that is processed in coldfusion

Details: I need to do something fairly simple -- or, I am told it is simple. =) Here are the steps the client wants to happen:

1) A user fills out and submits a conference registration form; her information is processed and is put into a data table (good -- this part works!)

2) After she submits the form, she sees the authorize.net payment page where she pays conference registration fees (this is the part I cannot get to work)

3) Client would like the authorize.net payment page to already display the information (name, address, payment amount, and so on) that the user already typed in the ColdFusion form

Apparently the cfhttp tag is used for this, so I did some reading up on it: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ffc.html

So... I use CFHTTP to send an HTTP request to https://test.authorize.net/gateway/transact.dll

I downloaded some sample code from authorize.net -- it is given below.

Here is where I get confused.

1) How do I connect my conference registration page at http://nnvawi.org/register.cfm to this authorize.net code, below?

2) I would like the registrant to register at http://nnvawi.org/register.cfm, then go to the authorize.net payment page and see all of her contact information, and the conference fee that she selected, already populated in the payment fields.

Is this possible? Has anyone here done this woth ColdFusion?

Thank you for your advice.

Eric

 

 

***********

<cfsetting enablecfoutputonly="true">
<cfoutput>
<!--
This sample code is designed to connect to Authorize.net using the AIM method.
For API documentation or additional sample code, please visit:
http://developer.authorize.net
-->

<!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 />

</cfoutput>
<!--- ColdFusion's cfhttp object is specifically designed to create a post,
and retrieve the results.  Those results are accessed in cfhttp.filecontent --->
<!--- 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 --->
<cfhttp method="Post" url="https://test.authorize.net/gateway/transact.dll">
	<!--- the API Login ID and Transaction Key must be replaced with valid values --->
	<cfhttpparam type="Formfield" name="x_login" value="API_LOGIN_ID">
	<cfhttpparam type="Formfield" name="x_tran_key" value="TRANSACTION_KEY">
   
	<cfhttpparam type="Formfield" name="x_delim_data" value="TRUE">
	<cfhttpparam type="Formfield" name="x_delim_char" value="|">
	<cfhttpparam type="Formfield" name="x_relay_response" value="FALSE">

	<cfhttpparam type="Formfield" name="x_type" value="AUTH_CAPTURE">
	<cfhttpparam type="Formfield" name="x_method" value="CC">
	<cfhttpparam type="Formfield" name="x_card_num" value="4111111111111111">
	<cfhttpparam type="Formfield" name="x_exp_date" value="0115">

	<cfhttpparam type="Formfield" name="x_amount" value="19.99">
	<cfhttpparam type="Formfield" name="x_description" value="Sample Transaction">

	<cfhttpparam type="Formfield" name="x_first_name" value="John">
	<cfhttpparam type="Formfield" name="x_last_name" value="Doe">
	<cfhttpparam type="Formfield" name="x_address" value="1234 Street">
	<cfhttpparam type="Formfield" name="x_state" value="WA">
	<cfhttpparam type="Formfield" name="x_zip" value="98004">
	<!--- Additional fields can be added here as outlined in the AIM integration
	guide at: http://developer.authorize.net --->	
	<!--- The following fields show an example of how to include line item details, they are commented out by default.
	<cfhttpparam type="Formfield" name="x_line_item" value="item1<|>golf balls<|><|>2<|>18.95<|>Y">
	<cfhttpparam type="Formfield" name="x_line_item" value="item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y">
	<cfhttpparam type="Formfield" name="x_line_item" value="item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y">
	--->
</cfhttp>

<!--- Because coldfusion's ListToArray object ignores empty fields, we must
put a space in all empty fields to make sure that they are not skipped --->
<cfset post_response=Replace(cfhttp.filecontent,"||","| |", "all")>
<!--- the same command is run twice, because the first time it only adjusts
every other empty field --->
<cfset post_response=Replace(post_response,"||","| |", "all")>

<!--- now the ListToArray method can be used without skipping fields --->
<cfset response_array=ListToArray(post_response, "|")>

<!--- the results are output to the screen in the form of an html numbered list. --->
<cfoutput>
<OL>
<cfloop index="i" from="1" to="#arrayLen(response_array)#">
	<LI>#response_array[i]# &nbsp;</LI>
</cfloop>
</OL>
<!--- individual elements of the array could be accessed to read certain
response fields.  For example, response_array[1] would return the Response
Code, response_array[3] would return the Response Reason Code.
For a list of response fields, please review the AIM Implementation Guide --->

</BODY>
</HTML>
</cfoutput>
                                  
Who Me Too'd this topic