ColdFusion 9
MS SQL Server 2012
authorize.net API
Hi. I need help with a problem, and am hoping someone here can guide me on the right path.
In brief: I need to populate an
authorize.net payment page using information from a simple form that is processed in coldfusion.
Details: I need to do something fairly simple -- or, I am told it is simple. =) Here is what the client wants to happen:
After the user fills out and submits the simple registration form, she should then see the
authorize.net payment page where she pays conference registration fees; the 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
I downloaded some sample code from
authorize.net -- it is given below.
I would like the registrant to register her information -- name, address, conference fee -- 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.
Has anyone here done this with ColdFusion? I am not clear how to integrate the cfhttp code with my existing, simple registration form.
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]# </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>
*******
Eric Bourland
Internet Project Development
Washington DC
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358931