编辑:https ://github.com/agiliq/merchant/blob/master/billing/gateways/authorize_net_gateway.py
看起来不错,还没试过。
编辑:[对于我使用 authorize.net 的下一个项目,我将仔细看看:http: //github.com/zen4ever/django-authorizenet它看起来很不错。我不认为它支持定期付款。]
在过去,我做了一些一次性的实现。
对于 AIM 支付网关的简单发布,您可以使用以下内容:
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
要授权,您可以执行以下操作:
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])
然后,我们可以捕获:
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]
还有更多选项、请求方式、解析响应中的细微差别......我假设 b/c A
inAIM
代表advanced
所有 authorize.net 选项都可用。
http://developer.authorize.net/guides/AIM/
我知道你的问题是什么 lib 是最好的 .. 好吧,为你的特定要求实现你自己的一点点临时请求和响应可能是最简单的,而不是试图在 api 之上遍历 api。