[AuthorizeNet_AIM_9]

Description

Link: [AuthorizeNet_AIM_9]
Author: Steve Piercy
Category: Custom Tag
Version: 9.x
License: Public Domain
Posted: Sep. 06, 2011
Updated: Sep. 06, 2011
More by this author...

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.

Parameters

-AIMParams map, required A map of parameters to send to Authorize.net for transaction processing.
-testdeveloper boolean, optional -testdeveloper=TRUE submits a test transaction to Authorize.net's 'test' URL. Default is FALSE. Optional.
-testrequest boolean, 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.

Sample Usage

Usage:[AuthorizeNet_AIM_9(<map>)]

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
[
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

09/06/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.
Email:


Password:



Newest

Most Popular

Support tagSwap.net