I would suggest using AIM (read docs...Auth.net suggests it too). You can
create an MD5 in their control panel and use that in your code to make the
call. Below is code I used the other day from an old project kinda "redone"
a bit for this new project. I'm open to any suggestions someone may have
about my coding techniques as well.

Oh, Base.cfc (which this extends) is simply a function with a generic init()
so all cfc's extend it to receive their init() method.

<cfset checkout = CreateObject("component",
"Checkout").init(settings=StructNew())>

(instead of StructNew pass in a struct with settings if needed; in this case
the ordersEmail is used in the cfc so that's a needed setting)

Hope it helps....

<cfcomponent displayname="Checkout.cfc" hint="Checkout functionality"
extends="Base">
    <cffunction name="authorize" access="public" returntype="any">
        <cfargument name="billingFirstName"     required="yes"
type="string">
        <cfargument name="billingLastName"     required="yes" type="string">
        <cfargument name="billingCompany"                     type="string"
default="">
        <cfargument name="billingAddress"         required="yes"
type="string">
        <cfargument name="billingCity"         required="yes" type="string">
        <cfargument name="billingState"         required="yes"
type="string">
        <cfargument name="billingZip"         required="yes" type="string">
        <cfargument name="billingPhone"         required="yes"
type="string">
        <cfargument name="billingEmail"         required="yes" type="string"
hint="this is where the email will go">
        <cfargument name="shippingFirstName"     required="yes"
type="string">
        <cfargument name="shippingLastName"     required="yes"
type="string">
        <cfargument name="shippingCompany"                 type="string"
default="">
        <cfargument name="shippingAddress"     required="yes" type="string">
        <cfargument name="shippingCity"         required="yes"
type="string">
        <cfargument name="shippingState"         required="yes"
type="string">
        <cfargument name="shippingZip"         required="yes" type="string">
        <cfargument name="shippingPhone"         required="yes"
type="string">
        <cfargument name="cardNumber"            required="yes"
type="string">
        <cfargument name="cardExpiration"         required="yes"
type="string">
        <cfargument name="cardSecurityCode"     required="yes"
type="string">

        <cfset var response = StructNew()>
        <cfset var cfhttp    = "">
        <cfset var temp    = "">
        <cftransaction action="begin">
            <cftry>
                    <!------ post to authorize.net gateway ------->
                    <cfhttp url="
https://secure.authorize.net/gateway/transact.dll"; method="post">
                        <cfhttpparam type="FORMFIELD" name="x_Login"
value="username">
                        <cfhttpparam type="FORMFIELD" name="x_Password"
value="password">
                        <cfhttpparam type="FORMFIELD"
name="x_merchant_email" value="#variables.settings.ordersEmail#">
                        <cfhttpparam type="FORMFIELD" name="x_delim_data"
value="true">
                        <cfhttpparam type="FORMFIELD" name="x_test_request"
value="false">

                        <cfhttpparam type="FORMFIELD" name="x_type"
value="AUTH_CAPTURE">
                        <cfhttpparam type="FORMFIELD" name="x_method"
value="cc">

                        <cfhttpparam type="FORMFIELD" name="x_amount"
value="#session.order.total#">
                        <cfhttpparam type="FORMFIELD" name="x_card_num"
value="#arguments.cardNumber#">
                        <cfhttpparam type="FORMFIELD" name="x_exp_date"
value="#arguments.cardExpiration#">
                        <cfhttpparam type="FORMFIELD" name="x_card_code"
value="#arguments.cardSecurityID#">

                        <!--- If you want an email to go to the customer via
authorize.net change this to false. Make sure authorize.net is configured
properly. --->
                        <cfhttpparam type="FORMFIELD"
name="x_email_customer" value="false">

                        <cfhttpparam type="FORMFIELD" name="x_first_name"
value="#arguments.billingFirstName#">
                        <cfhttpparam type="FORMFIELD" name="x_last_name"
value="#arguments.billingLastName#">
                        <cfhttpparam type="FORMFIELD" name="x_company"
value="#arguments.billingCompany#">
                        <cfhttpparam type="FORMFIELD" name="x_address"
value="#arguments.billingAddress#">
                        <cfhttpparam type="FORMFIELD" name="x_city"
value="#arguments.billingCity#">
                        <cfhttpparam type="FORMFIELD" name="x_state"
value="#arguments.billingState#">
                        <cfhttpparam type="FORMFIELD" name="x_zip"
value="#arguments.billingZip#">

                        <cfhttpparam type="FORMFIELD" name="x_customer_ip"
value="#cgi.remote_address#">
                        <cfhttpparam type="FORMFIELD" name="x_Email"
value="#arguments.billingEmail#">
                        <cfhttpparam type="FORMFIELD" name="x_Phone"
value="#arguments.billingPhone#">

                        <cfhttpparam type="FORMFIELD"
name="x_ship_to_first_name" value="#arguments.shippingFirstName#">
                        <cfhttpparam type="FORMFIELD"
name="x_ship_to_last_name" value="#arguments.shippingLastName#">
                        <cfhttpparam type="FORMFIELD"
name="x_ship_to_company" value="#arguments.shippingCompany#">
                        <cfhttpparam type="FORMFIELD"
name="x_ship_to_address" value="#arguments.shippingAddress#">
                        <cfhttpparam type="FORMFIELD" name="x_ship_to_city"
value="#arguments.shippingCity#">
                        <cfhttpparam type="FORMFIELD" name="x_ship_to_state"
value="#arguments.shippingState#">
                        <cfhttpparam type="FORMFIELD" name="x_ship_to_zip"
value="#arguments.shippingZip#">

                        <cfhttpparam type="FORMFIELD" name="x_Description"
value="Motorcoat Order">
                    </cfhttp>

                    <!--- 1 approved, 2 declined, 3 error --->
                    <cfset response.code         = ListGetAt(
cfhttp.fileContent, '1', ",")>
                    <!--- A code used by the system for internal transaction
tracking. --->
                    <cfset response.subCode         = ListGetAt(
cfhttp.fileContent, '2', ",")>
                    <!--- A code representing more details about the result
of the transaction. --->
                    <cfset response.reasonCode     = ListGetAt(
cfhttp.fileContent, '3', ",")>
                    <!--- Brief description of the result, which corresponds
with the Response Reason Code. --->
                    <cfset response.reasonText     = ListGetAt(
cfhttp.fileContent, '4', ",")>
                    <!--- The six-digit alphanumeric authorization or
approval code. --->
                    <cfset response.authCode     = ListGetAt(
cfhttp.fileContent, '5', ",")>
                    <!--- Indicates the result of Address Verification
System (AVS) checks: A = Address (Street) matches, ZIP does not
                            B = Address information not provided for AVS
check
                            E = AVS error
                            G = Non-U.S. Card Issuing Bank
                            N = No Match on Address (Street) or ZIP
                            P = AVS not applicable for this transaction
                            R = Retry  System unavailable or timed out
                            S = Service not supported by issuer
                            U = Address information is unavailable
                            W = 9 digit ZIP matches, Address (Street) does
not
                            X = Address (Street) and 9 digit ZIP match
                            Y = Address (Street) and 5 digit ZIP match
                            Z = 5 digit ZIP matches, Address (Street) does
not --->
                    <cfset response.avsCode         = ListGetAt(
cfhttp.fileContent, '6', ",")>
                    <!--- This number identifies the transaction in the
system and can be used to submit a modification of this transaction at a
later time, such as voiding, crediting or capturing the transaction. --->
                    <cfset response.transactionID = ListGetAt(
cfhttp.fileContent, '7', ",")>
                <cfcatch type="any">
                    <cftransaction action="rollback"/>
                    <cfset response.reason_text = cfcatch.message>
                </cfcatch>
            </cftry>

            <cfreturn response>
        </cftransaction>
    </cffunction>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225716
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to