Edit: [For the next project I have that uses authorize.net, I'm going to take a close look at:
http://github.com/zen4ever/django-authorizenet
It looks pretty nice. I don't think that it has support for recurring payments though.
]
In the past I have made little one-off implementations.
For simple post to the AIM payment gateway, you can use something like this:
URL = 'https://test.authorize.net/gateway/transact.dll'
API = {'x_login':'XXX',
'x_tran_key':'XXX', 'x_method':'CC', 'x_type':'AUTH_ONLY',
'x_delim_data':'TRUE', 'x_duplicate_window':'10', 'x_delim_char':'|',
'x_relay_response':'FALSE', 'x_version':'3.1'}
def call_auth(amount, card_num, exp_date, card_code, zip_code, request_ip=None):
'''Call authorize.net and get a result dict back'''
import urllib2, urllib
payment_post = API
payment_post['x_amount'] = amount
payment_post['x_card_num'] = card_num
payment_post['x_exp_date'] = exp_date
payment_post['x_card_code'] = card_code
payment_post['x_zip'] = zip_code
payment_request = urllib2.Request(URL, urllib.urlencode(payment_post))
r = urllib2.urlopen(payment_request).read()
return r
def call_capture(trans_id): # r.split('|')[6] we get back from the first call, trans_id
capture_post = API
capture_post['x_type'] = 'PRIOR_AUTH_CAPTURE'
capture_post['x_trans_id'] = trans_id
capture_request = urllib2.Request(URL, urllib.urlencode(capture_post))
r = urllib2.urlopen(capture_request).read()
return r
To authorize, you do something like:
r = authorize.call_auth(
unicode(decimal_total),
request.POST.get('card_num'),
request.POST.get('exp_date'),
request.POST.get('card_code'),
request.POST.get('zip_code') if request.POST.get('zip_code') else address.zip_code,
)
if r.split('|')[0] == '1':
# it's good, we have authorized the card...
else:
error = "%s Please try again." % (r.split('|')[3])
then, we can capture:
r = authorize.call_capture(trans_id) # r.split('|')[6] in first response..
if r.split('|')[0] == '1':
# we captured it.
else:
error = r.split('|')[3]
There are more options, ways to request, nuances in the response to parse... I assume b/c A
in AIM
stands for advanced
that all of the authorize.net options are available.
http://developer.authorize.net/guides/AIM/
I know that your question is what lib is best .. well, it might be easiest just to implement your own little bit of ad-hoc request and response for your specific requirements rather than trying to trove through an api on top of an api.