Lasso Soft Inc. > Home

[AuthorizeNet_AIM_9]

LinkAuthorizeNet_AIM_9
AuthorSteve Piercy
CategoryCustom Tag
Version9.x
LicensePublic Domain
Posted06 Sep 2011
Updated06 Sep 2011
More by this author...

Description

This method is a conversion of the AuthorizeNet_AIM payment processing tag from Lasso 8 to Lasso 9.

This tag has one required parameter, -AIMParams, and two optional parameters, -testdeveloper and -testrequest.

AIMParams is an unnamed map of name/value pairs representing the parameters to be passed to Authorize.Net.

-testdeveloper is a boolean that when TRUE submits a test transaction to A.net's 'test' URL. Default is FALSE.

-testrequest is a boolean that when TRUE submits a test transaction request to the designated URL ('test' or 'secure') as set in the tag configuration or by the -testdeveloper keyword parameter. Default is FALSE.

This tag returns a value which is either a string or a map. If the returned value is a string, the string is a plain text error message returned by Authorize.Net indicating that you have not properly configured the Authorize.Net Merchant Interface or this tag's settings. If the returned value is a map, it contains the key/value pairs of non-empty parameters in the reponse returned by the Authorize.Net gateway.

If you like this tag, documentation, or think I need to spend less time at the computer and take my wife out on a date night, then consider sending a donation via PayPal to:

web@stevepiercy.com

Duke accepts donations of biscuits and cabbages. woof.

Sample Usage

Usage:[AuthorizeNet_AIM_9()]

Example:
[
	local(AIMParams) = map(
		'x_login'='ENTER_YOUR_LOGIN',
		'x_tran_key'='ENTER_YOUR_TRANSACTION_KEY',
		'x_type'='auth_only,
		'x_card_num'='5424000000000015',	// dummy CC#
		'x_exp_date'='1220',				// December 2020
		'x_amount'='0.01'
		// etc.
		)
	
	local(results) = AuthorizeNet_AIM_9(#AIMParams,-testdeveloper=true)
	#results
]

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

[
define authorizenet_aim_9(AIMParams::map, -testdeveloper::boolean=false, -testrequest=void) => {
/*

Configuration of this tag follows its documentation.

---------------------------------
Description
---------------------------------
This tag is a conversion of the AuthorizeNet_AIM payment processing tag from Lasso 8 to Lasso 9.

This tag has one required parameter, -AIMParams, and two optional parameters, -testdeveloper and -testrequest.

AIMParams is an unnamed map of name/value pairs representing the parameters to be passed to Authorize.Net.

-testdeveloper is a boolean that when TRUE submits a test transaction to A.net's 'test' URL.  Default is FALSE.

-testrequest is a boolean that when TRUE submits a test transaction request to the designated URL ('test' or 'secure') as set in the tag configuration or by the -testdeveloper keyword parameter.  Default is FALSE.

This tag returns a value which is either a string or a map.  If the returned value is a string, the string is a plain text error message returned by Authorize.Net indicating that you have not properly configured the Authorize.Net Merchant Interface or this tag's settings.  If the returned value is a map, it contains the key/value pairs of non-empty parameters in the reponse returned by the Authorize.Net gateway.

If you like this tag, documentation, or think I need to spend less time at the computer and take my wife out on a date night, then consider sending a donation via PayPal to:

web@stevepiercy.com

Duke accepts donations of biscuits and cabbages.  woof.


---------------------------------
Usage
---------------------------------
It is highly recommend to store this file on your web server in a location that cannot be served, preferably outside of your web root.  You do *not* want your login or transaction key to be served as a plain text file.

(1)  In your page that calls [AuthorizeNet_AIM_9], build a map of parameters to send to the tag.

	local(AIMParams = map(
		'x_first_name'	= $first_name,
		'x_last_name'	= $last_name,
		'x_amount'		= $amount,
	... and so on...))

(2)  When calling [AuthorizeNet_AIM_9], store the results in a variable.  This will allow you to easily code logic in your page to take appropriate action based on the results (Response Code, etc.) from Authorize.net.

	local(aim_results = AuthorizeNet_AIM_9(#AIMParams))

Optionally, use the following following parameters:

-testdeveloper=TRUE submits a test transaction to A.net's 'test' URL.  Default is FALSE.

-testrequest=TRUE submits a test transaction request to the designated URL ('test' or 'secure') as set in the tag configuration or by the -testdeveloper keyword parameter.  Default is FALSE.

The following sends a map of parameters to the tag, which posts the parameters to Authorize.net's test server as a test transaction request.

	local(aim_results = AuthorizeNet_AIM_9(#AIMParams,-testdeveloper=TRUE,-testrequest=TRUE))

(3)  Sample page logic.

    // evaluate results and make appropriate decisions
    if(#aim_results->find('x_response_code') == '1')
        // transaction approved
    else
        // transaction failed
        select(#aim_results->find('x_response_code'))
            case('2')
                //  declined
            case('3')
                //  transaction processing error
            case('4')
                //  held for review
            case
                //  undefined error
        /select
    /if


(4)  Sample message.  I recommend displaying a simple error message "Your request could not be processed.  Please contact us at _____ during normal business hours."  Don't encourage them to try again because it will just frustrate them, or possibly cause much worse problems (multiple payments, trigger an over limit event, trigger a fraud alert with the card issuer, etc.).  And in the case of an actual fraud, you don't want to tip off the fraudster of why the transaction was declined.

	$sample_msg += 'Thank you, ' + #aim_results->find('x_first_name') + '!  You have personally enriched me by $' + #aim_results->find('x_amount') + '.'

(5)  You can add merchant-defined results labels to #aimresultlabels, and access them after they are echoed by Authorize.Net.

(6)  To summarize, here is a code sample that sends an authorize-only transaction to the Authorize.net test server.

[
	local(AIMParams) = map(
		'x_login'='ENTER_YOUR_LOGIN',
		'x_tran_key'='ENTER_YOUR_TRANSACTION_KEY',
		'x_type'='auth_only,
		'x_card_num'='5424000000000015',	// dummy CC#
		'x_exp_date'='1220',				// December 2020
		'x_amount'='0.01'
		// etc.
		)
	
	local(results) = AuthorizeNet_AIM_9(#AIMParams,-testdeveloper=true)
	#results
]

For rapid testing, create a new file, paste this tag into it, copy the snippet above and paste it after the tag.  Load the page to see the results.

See the comments embedded in the code below for proper configuration.


---------------------------------
Additional eCommerce Resources
---------------------------------
The following information does not constitute an endorsement, warranty or guarantee of service.  This information is provided for the sake of comparison.  These are the lowest fees I have found over the years.

For further information on developing for AIM, download the AIM Guide:

http://www.authorize.net/support/AIM_guide.pdf

You can sign up for a developer account, or you can have the client purchase their own Authorize.net account and create a "webmaster" user that has the required access.

http://authorize.net/solutions/partnersolutions/certifieddeveloperprocess/
http://developer.authorize.net/testaccount/

In addition to this tag, there are the following requirements:
(1) Dedicated IP for SSL.

(2) SSL (~$10/month for both (1) and (2)).

(3) Secure certificate ($29.99/year from GoDaddy.com)

(4) Merchant account that accepts payments over the Internet.  Some brick and mortar retailers already have a merchant account, so sometimes it is easier to add this feature to their existing merchant account.  If you need a merchant account, you can support the continued development of the AuthorizeNet_AIM_9 tag by following this link:

http://www.freeauthnet.com/index.php?partner=100434

As of June 18, 2008, the merchant account costs $8.95/month, plus 2.14% of the transaction amount and  24 cents per transaction.  Current pricing can be found here:

http://stevepiercy.com/services.lasso

(5) payment gateway (an Authorize.net account, for example).  I am an Authorize.net account reseller.  You can support the continued development of the AuthorizeNet_AIM_9 tag by following this link:

https://ems.authorize.net/oap/home.aspx?SalesRepID=39&ResellerID=11937

As of June 18, 2008, the cost is $17.95/month, plus $99.00 account setup, plus $0.10 per transaction.  Current pricing can be found here:

http://stevepiercy.com/services.lasso

I am available as a consultant for ecommerce solutions.  Please see the following web page for more information:

http://stevepiercy.com/services.lasso



=================================
Version History: 1.0beta
Date: Sep 6, 2011
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM_9

*** BETA RELEASE ***
This version has not been tested against an actual Authorize.net gateway account.  It has been tested against a developer test account only.  Please let Steve know if you perform any tests against an actual Authorize.net gateway account and the results of your tests.

Modified to work with Lasso 9.  Thanks to Kyle Jessup for the void tip and LassoSoft for the Enigma Machine code converter.



=================================
Version History: 1.6.0
Date: Nov 5, 2010
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM

Modified to work with Lasso 9.

Added new Authorize.net field labels for Partial Authorization Transactions.  This allows customers to use multiple transactions to cover the total amount of the order, e.g., gift card and credit card.  See the AIM Developer Guide for details.

Purged ugly variable declarations.



=================================
Version History: 1.5.2
Date: Feb 2, 2010
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM

Disambiguated the parameter -testrequest.  Now setting it to FALSE or omitting it are equivalent.

Thanks to Marc Pinnell for pointing it out.



=================================
Version History: 1.5
Date: Jan 31, 2010
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM

Now the developer can set values in the map of parameters for x_login, x_tran_key and x_type.  Any parameters in the map that are passed into the tag will override any values hard-coded in the tag, except x_relay_response which you should leave alone.

Provided even better code samples and usage example.

Thanks to Marc Pinnell for the suggestion and donation for Duke biscuits.



=================================
Version History: 1.4
Date: Jan 17, 2010
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM

Added two new parameters:

-testdeveloper=TRUE submits a test transaction to A.net's 'test' URL.  Default is FALSE.  Optional.

-testrequest=TRUE submits a test transaction request to the designated URL ('test' or 'secure') as set in the tag configuration or by the -testdeveloper keyword parameter.  Default is FALSE.  Optional.

Thanks to Jason Huck for the suggestion and to Rick Dwyer for the donation for Duke biscuits.



=================================
Version History: 1.3
Date: Jan 28, 2009
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM

Gave code a colostomy.  Ugly, yucky, dirty colons!

Improved usage guidelines documentation.



=================================
Version History: 1.2
Date: Sep 26, 2007
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM

Added comments regarding AIM gateway response fields.

Improved usage guidelines documentation.

Corrected names of response labels for positions 39 and 40.

Added empty AIM 3.1 reserved fields for positions through 68.  May be used for future expansion of AIM.

Added check that compares the sizes of the aimresultlabels and AIMResultArray arrays to prevent "invalid position passed to get" error, and to generate ennumerated labels for results that are out of range of the labels array.



=================================
Version History: 1.1
Date: Oct 6, 2006
Author: Steve Piercy
URL: http://www.stevepiercy.com/
URL: http://tagSwap.net/AuthorizeNet_AIM

Updated for Lasso 8.1 and AIM 3.1.  Thanks to Jonathan Guthrie for schooling me on iterate.



=================================
Version History: 1.0
Date: March 3, 2003
Author: Trigger Consulting
URL: http://www.trigger.biz/

Disclaimer:
While Trigger Consulting has made every effort to deliver a high 
quality product, we do not guarantee that this product is free from 
defects.  The software is provided "as is," and you use the software 
at your own risk. Trigger Consulting makes no warranties as to 
performance, merchantability, fitness for a particular purpose, or 
any other warranties whether expressed or implied. No oral or written 
communication from or information provided by Trigger Consulting 
shall create a warranty. Under no circumstances shall Trigger 
Consulting be liable for direct, indirect, special, incidental, or 
consequential damages resulting from the use, misuse, or inability to 
use this software, even if Trigger Consulting has been advised of the 
possibility of such damages. These exclusions and limitations may not 
apply in all jurisdictions. You may have additional rights and some 
of these limitations may not apply to you.

AuthorizeNet_AIM is in the public domain and free for your 
use. Obviously, Trigger Consulting would appreciate credit where 
credit is due. No pun intended.



==================
CONFIGURATION
==================

Configuration includes configuring the Authorize.net website Merchant Interface, setting values in this tag, and passing values into this tag as a map of key/values.

In the Authorize.net Merchant Interface, obtain your transaction key.

	Account > Settings > API Login ID and Transaction Key

You will enter your transaction key below.

Next configure the response delimiter character.

	Account > Settings > Direct Response

Use a pipe and no encapsulation characters:

Delimited Response: (X) Yes    ( ) No
Default Field Separator 	| (pipe)  or [ ]
Field Encapsulation Character	[blank] or  [ ]

If you do not use the above settings then you must change the corresponding values as defined elsewhere in this tag.

Now enter configuration values for this tag below.

You can choose to either set configuration values in this tag below or pass them in as values in the map of AIM parameters.  Any values passed into this tag will override their corresponding values entered below.

*/
	if(local_defined('testrequest'))
		#testrequest->isnota(::boolean) ? return 'testrequest is not boolean'
	/if
	// Your API login ID for the payment gateway account
	local(x_login = 'ENTER_YOUR_LOGIN')
	// Your transaction key obtained from the Merchant Interface
	local(x_tran_key = 'ENTER_YOUR_TRANSACTION_KEY')
	// Most transaction types will be AUTH_CAPTURE.
	// See the AIM Guide for other types and further requirements.
	local(x_type = 'AUTH_CAPTURE')
	// If any of the following values have not been passed into this tag via the map of AIM parameters, then insert the configured values above.
	#AIMParams->find('x_login') == '' ? #AIMParams->insert('x_login' = #x_login)
	#AIMParams->find('x_tran_key') == '' ? #AIMParams->insert('x_tran_key' = #x_tran_key)
	#AIMParams->find('x_type') == '' ? #AIMParams->insert('x_type' = #x_type)
	// Initialize variables
	local(CurrentParam = null,
		AIMParamArray = array,
		AIMParamstring = string,
		AIMURL = string,
		AIMResult = string,
		AIMResultArray = array,
		AIMResultLabelArray = array,
		AIMCurrentResultLabel = null,
		output = null)
	/*
	The following URL will be used to send your POST parameters to Authorize.net.
	'test' is used for testing your developer x_login and x_tran_key values, whereas 'secure' is used for testing your merchant account values.
	
	Note that you can still submit test transactions to 'secure' either by setting the Authorize.net merchant interface to TEST MODE or by submitting a transaction with the parameter 'x_test_request'='TRUE'.
	*/
	if(#testdeveloper == true)
		#AIMURL = 'https://test.authorize.net/gateway/transact.dll'
	else
		#AIMURL = 'https://secure.authorize.net/gateway/transact.dll'
	/if
	if(local_defined('testrequest'))
		if(#testrequest == 'true')
			// Send a test transaction request to the designated server.
			#AIMParams->insert('x_test_request' = 'TRUE')
		else
			// Rely upon the TEST MODE configuration in the Authorize.net Merchant Interface.  Omitting -testrequest is equivalent to setting it to FALSE.
			#AIMParams->insert('x_test_request' = 'FALSE')
		/if
	/if
	/*
	The following commented parameters should be set through the merchant web interface on Authorize.net and are placed here for reference only.  However, if you set a parameter in Authorize.net, comment it below; and if you do not set a parameter in Authorize.net, then uncomment it here.  In other words, define parameters in one and only one place.
	*/
	//	#AIMParams->insert('x_test_request'='FALSE')
	//	#AIMParams->insert('x_version'='3.1')
	//	#AIMParams->insert('x_delim_data'='TRUE')
	#AIMParams->insert('x_relay_response' = 'FALSE')
	// Do not change
	iterate(#AIMParams, local(CurrentAIMParam))
		#AIMParamArray->insert(#CurrentAIMParam->first = #CurrentAIMParam->second)
	/iterate
	// The first 68 result labels are reserved by the AIM gateway for version 3.1.  Do not alter their order or names.
	local(aimresultlabels = array(
		'x_response_code',
		'x_response_subcode',
		'x_response_reason_code',
		'x_response_reason_text',
		'x_approval_code',
		'x_avs_result_code',
		'x_transaction_id',
		'x_invoice_num',
		'x_description',
		'x_amount',
		'x_method',
		'x_type',
		'x_cust_id',
		'x_first_name',
		'x_last_name',
		'x_company',
		'x_address',
		'x_city',
		'x_state',
		'x_zip',
		'x_country',
		'x_phone',
		'x_fax',
		'x_email',
		'x_ship_to_first_name',
		'x_ship_to_last_name',
		'x_ship_to_company',
		'x_ship_to_address',
		'x_ship_to_city',
		'x_ship_to_state',
		'x_ship_to_zip',
		'x_ship_to_country',
		'x_tax',
		'x_duty',
		'x_freight',
		'x_tax_exempt',
		'x_po_num',
		'x_MD5_hash',
		'x_card_code',
		'x_cavv_resp_code',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'x_acct_number_last4',
		'x_card_type',
		'x_split_tender_id',
		'x_prepaid_requested_amount',
		'x_prepaid_balance_on_card',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		'',
		// The following labels are optionally defined by the merchant and echoed by the AIM gateway.  If you do not add them here, they will not be echoed by the AIM Results Array and not added to the map #aim_results.
		'x_comments',
		'x_another_example'))

	// Send parameters to Authorize.net.  Cross fingers.
	#AIMResult = string(include_url(#AIMURL, -postparams = #AIMParamArray))
	/*
	The character used in the following split must be the same as the character you use in your Authorize.net settings:
	
	Account > Settings > Direct Response >  Direct Response Delimiter
	*/
	#AIMResultArray = #AIMResult->split('|')
	if(#AIMResultArray->Size == 1)
		// uh-oh.  There was a failure.  Check your configuration in the Merchant Interface or in this tag.
		#output = #AIMResult
	else
		// Yippee!  The gateway returned a response we can parse to determine whether the transaction was successful or has failed.
		#output = map
		iterate(#AIMResultArray, local(current_result))
			if(#aimresultlabels->size > loop_count)
				// We are within the range of defined results labels.
				local(current_label = #aimresultlabels->get(loop_count))
				if(#current_result != '')
					#output->insert(#current_label = #current_result)
				/if
			else
				// We are outside the range of defined results labels, and so we create ennumerated labels.
				local(current_label = 'x_out_of_range_label_' + loop_count)
				if(#current_result != '')
					#output->insert(#current_label = #current_result)
				/if
			/if
		/iterate
	/if
	return #output
}
]

Related Tags

Comments

06 Sep 2011, Steve Piercy

Initial Release version 1.0beta

*** BETA RELEASE ***
This version has not been tested against an actual Authorize.net gateway account. It has been tested against a developer test account only. Please let Steve know if you perform any tests against an actual Authorize.net gateway account and the results of your tests.

Modified to work with Lasso 9. Thanks to Kyle Jessup for the void tip and LassoSoft for the Enigma Machine code converter.

Please log in to comment

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2014 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft