2 Replies Latest reply on Oct 6, 2009 8:09 AM by craigkaminsky

    Authorize.net CIM form and API


      Has anyone built the forms and code for this API in CF?  I don't have a specific problem - I'm just looking for some shared code so that I can perhaps save some coding time.





        • 1. Re: Authorize.net CIM form and API
          JR "Bob" Dobbs-qSBHQ2 Level 3

          You might check for an Authorize.net project at RIA Forge.



          • 2. Re: Authorize.net CIM form and API
            craigkaminsky Level 3



            It's pretty basic (from a 2007 site!) but here's an old Authorize.net payment script I had. Any form will do and, based on the CFHTTP I have below, you just replace your form field variables where I have session.cart.get____(). I included the snippet of code that pulled out the response from the Authorize.net returned data. Like I said, it's pretty basic but I hope it gets you started in terms of submitting payments to Authorize.net.


            <!--- 4111-1111-1111-1111 (fake visa number) --->
            <!--- https://secure.authorize.net/gateway/transact.dll --->
            <!--- https://test.authorize.net/gateway/transact.dll --->
            <cfhttp method="post" url="https://secure.authorize.net/gateway/transact.dll">
                 <cfhttpparam name="x_login" type="formfield" value="YOUR LOGON">
                 <cfhttpparam name="x_tran_key" type="formfield" value="YOUR TRANSACTION KEY">
                 <cfhttpparam name="x_method" type="formfield" value="CC">
                 <cfhttpparam name="x_type" type="formfield" value="AUTH_CAPTURE">
                 <cfhttpparam name="x_amount" type="formfield" value="#Trim(session.cart.getPayment().getTotal())#">
                 <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="#Trim(session.cart.getPayment().getCardNumber())#">
                 <cfhttpparam name="x_exp_date" type="formfield" value="#session.cart.getPayment().getCardExpiration()#">
                 <cfhttpparam name="x_version" type="formfield" value="3.1">
                 <cfhttpparam name="x_invoice_num" type="formfield" value="#session.orderNumber#">
                 <cfhttpparam name="x_description" type="formfield" value="Order #DateFormat(Now(),'mm-dd-yyyy hh:mm')#">
                 <cfhttpparam name="x_first_name" type="formfield" value="#Trim(session.cart.getCustomer().getFirstName())#">
                 <cfhttpparam name="x_last_name" type="formfield" value="#Trim(session.cart.getCustomer().getLastname())#">
                 <cfhttpparam name="x_email" type="formfield" value="#Trim(session.cart.getCustomer().getEmail())#">
                 <cfhttpparam name="x_address" type="formfield" value="#Trim(session.cart.getCustomer().getAddress())#">
                 <cfhttpparam name="x_city" type="formfield" value="#Trim(session.cart.getCustomer().getCity())#">
                 <cfhttpparam name="x_state" type="formfield" value="#Trim(session.cart.getCustomer().getState())#">
                 <cfhttpparam name="x_zip" type="formfield" value="#Trim(session.cart.getCustomer().getZipCode())#">
                 <cfhttpparam name="x_email_customer" type="formfield" value="true">
                 <cfhttpparam name="x_merchant_email" type="formfield" value="EMAIL">
            <cfset api_response=cfhttp.fileContent />
            <!--- check the response headers to ensure that payment was good --->
                 aryApiResponse = ListToArray(api_response, "|");
            <cfif IsDefined("aryApiResponse") and ArrayLen(aryApiResponse) and Trim(aryApiResponse[1]) is not 1>
                 <cfset paymentReceived = false />
                 <cfif ArrayLen(aryApiResponse) gte 4>
                 <cfloop from="1" to="4" index="j">
                           tmpError = "<em>Payment Error</em> " & aryApiResponse[j] & ".";
                 <!--- we're good --->