On 8/18/2014 12:36 AM, Eric Bourland wrote:
> Has anyone here tried out the ColdFusion SIM* sample code from authorize.net? 
> I

A version of the below has been working great for me. I use it as a 
include on my form processing page that also records the appropriate 
data to the customers record in the database (NOT the credit card info! 
NEVER do this!)



<!--- Get our Merchant Account User ID, Transaction Key and Amount --->
<cfset x_login = "xxxxxxxxxx">
<cfset x_tran_key="xxxxxxxxxx">
<cfset x_amount="#FORM.x_amount#">

<!--- Open a connection to Authorize.Net using CFHTTP --->

<cfhttp url="https://secure.authorize.net/gateway/transact.dll"; 
method="post">

<!--- Set the Merchant Information --->

   <cfhttpparam type="formField" name="x_login" value="#x_login#">
   <cfhttpparam type="formField" name="x_tran_key" value="#x_tran_key#">
   <cfhttpparam type="formfield" name="x_test_request" value="false">
   <cfhttpparam type="formField" name="x_version" value="3.1">

   <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">

<!--- Set the CUSTOMER INFORMATION --->
   <cfhttpparam type="formfield" name="x_cust_id" value="-">
   <cfhttpparam type="formfield" name="x_FirstName" 
value="#form.x_FirstName#">
   <cfhttpparam type="formfield" name="x_LastName" 
value="#form.x_LastName#">
   <cfhttpparam type="formfield" name="x_Company" value="#form.x_Company#">
   <cfhttpparam type="formfield" name="x_Address" value="#form.x_Address#">
   <cfhttpparam type="formfield" name="x_City" value="#form.x_City#">
   <cfhttpparam type="formfield" name="x_State" value="#form.x_State#">
   <cfhttpparam type="formfield" name="x_Zip" value="#form.x_Zip#">
   <cfhttpparam type="formfield" name="x_Country" value="#form.X_Country#">
   <cfhttpparam type="formfield" name="x_PhoneNumber" 
value="#form.x_PhoneNumber#">

<!--- TRANSACTION INFORMATION FOR Credit Card --->
<!--- I needed to send some extra data along, so it's all in the 
x_description field and I can parse it back out when/if needed --->
   <cfhttpparam type="formField" name="x_invoice_num" 
value="#form.invoiceNUMBER#">
   <cfhttpparam type="formField" name="x_description" 
value="#form.policyNUMBER# - Invoice:#form.invoiceNUMBER# - 
#form.policyTYPE# - #form.x_Company#">
   <cfhttpparam type="formField" name="x_amount" value="#x_amount#">
   <cfhttpparam type="formField" name="x_type" value="AUTH_CAPTURE">
   <cfhttpparam type="formfield" name="x_ship_to_company" 
value="Premium: #form.initial_amount# Handling: #form.handler#">
   <cfhttpparam type="formField" name="x_card_num" 
value="#form.x_cardNumber#">
   <cfhttpparam type="formField" name="x_exp_date" 
value="#form.x_exp_date#">
   <cfhttpparam type="formField" name="x_card_code" 
value="#form.x_card_code#" />

</cfhttp>

<!--- Get the Authorize.net response  --->

<cfset AuthList = "#cfhttp.FileContent#">

<!--- JUST FOR TESTING if needed <cfdump var="#cfhttp.FileContent#" 
expand="yes">  --->

<cfset request.responseCODE = #trim(listGetAt(AuthList, 1, "|"))#>
<cfset request.response = #trim(listGetAt(AuthList, 4, "|"))#>
<cfset request.transactionID = #trim(listGetAt(AuthList, 7, "|"))#>
<cfset request.invoiceNUM = #trim(listGetAt(AuthList, 8, "|"))#>
<cfset request.DESC = #trim(listGetAt(AuthList, 9, "|"))#>

<!---BLOCK BELOW WILL OUTPUT THE AUTHONET RESPONSE

<p><strong>Response:</strong> #request.response#<br />
<strong>Transaction Id:</strong> #request.transactionID#<br />
<strong>Invoice Number:</strong> #request.invoiceNUM#<br />
<strong>Description:</strong> #request.DESC#</p>

END RESPONSE CODE--->

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:359127
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to