Python/Django:我应该使用哪个authorize.net 库?

发布于 2024-08-09 00:45:49 字数 522 浏览 6 评论 0原文

我需要使用 Authorize.net 集成来进行订阅付款,可能使用 CIM。要求很简单——每月定期付款,有几个不同的价格点。客户信用卡信息将存储在authorize.net 中。

周围有很多库和代码片段,我正在寻找关于哪些最有效的建议。

  • Satchmo 似乎超出了我的需要,而且看起来很复杂。
  • Django-Bursar 似乎是我所需要的,但它被列为 alpha。
  • adroll/authorize 库 看起来也不错。
  • CIM XML API 看起来还不错,我可以直接与它们连接。

还有很多其他代码片段。

鉴于我的要求相当简单,现在最好的选择是什么?

I need authorize.net integration for subscription payments, likely using CIM. The requirements are simple - recurring monthly payments, with a few different price points. Customer credit card info will be stored a authorize.net .

There are quite a few libraries and code snippets around, I'm looking for recommendations as to which work best.

  • Satchmo seems more than I need, and it looks like it's complex.
  • Django-Bursar seems like what I need, but it's listed as alpha.
  • The adroll/authorize library also looks pretty good.
  • The CIM XML APIs don't look too bad, I could connect directly with them.

And there are quite a few other code snippets.

What's the best choice right now, given my fairly simple requirements?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

为人所爱 2024-08-16 00:45:50

无论如何,我们最终使用了 adroll 授权库。 Paython 和 django-authorizenet 看起来都很有趣,将进行检查。

For what it's worth we ended up using the adroll authorize library. Both Paython and django-authorizenet look interesting, will be checking those out.

趁年轻赶紧闹 2024-08-16 00:45:50

我意识到这有点晚了,但希望对其他人有帮助。

我最近遇到了 Py-Authorize ,与其他可用的软件包相比,它有一些很棒的文档。您可以通过以下方式安装它:

pip install Py-Authorize

它似乎安装了一个依赖项(colondar),当通过pip安装时该依赖项已过时,因此您可以获得最新的(在撰写本文时)通过执行以下操作:

pip install git+git://github.com/Pylons/[email protected]

文档位于: http://vcatalano.github.io/py -authorize/index.html

根据我的经验,效果很好,但是对于我正在使用它的项目,我只需要 AuthCapture 而不是 ARB 或任何东西......尝试一下。迄今为止我找到的最好的包。

I realize this is a bit late, but hopefully it helps others.

I recently came across Py-Authorize which has some great documentation, compared to the other packages available. You can install it via:

pip install Py-Authorize

It seems to install a dependency (colondar) which when installed via pip is outdated so you can get the latest (at the time of this writing) by doing the following:

pip install git+git://github.com/Pylons/[email protected]

The docs are here: http://vcatalano.github.io/py-authorize/index.html

Works great in my experience, however for the project I am using it on I only needed AuthCapture and not ARB or anything...give it a try. Best package I've found so far.

缱倦旧时光 2024-08-16 00:45:49

长话短说,现有的解决方案都不能满足我的需求。它们要么没有维护、没有注释、没有经过测试,要么缺少已保存的卡片。因此,我当然构建了自己的解决方案并将其开源:

AuthorizeSauce: https://github.com/jeffschenck/authorizesauce

处理基本交易(AIM API)、保存的卡(CIM API)和定期付款(ARB API)。它有完整的文档记录并具有完整的测试套件。

我预计最初的发布者早已继续前进,但如果它可以帮助其他人避免付款处理的一些痛苦,我会非常高兴。

Long story short, none of the existing solutions met my needs. They were either unmaintained, uncommented, untested, or lacked saved cards. So of course I built my own solution and open-sourced it:

AuthorizeSauce: https://github.com/jeffschenck/authorizesauce

It handles basic transactions (the AIM API), saved cards (the CIM API), and recurring payments (the ARB API). It is fully documented and has a full test suite.

I expect the original poster has long since moved on, but if it can help anyone else avoid some of the pain of payment processing, I'd be overjoyed.

¢好甜 2024-08-16 00:45:49

编辑: 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]

有更多选项、请求方式、解析响应中的细微差别...我假设AIM 中的 b/c A 代表 advanced,所有authorize.net 选项均可用。

http://developer.authorize.net/guides/AIM/

我知道你的问题lib 是最好的.. 好吧,最简单的方法可能是根据您的特定要求实现您自己的一点临时请求和响应,而不是尝试在 api 之上探索 api。

Edit: https://github.com/agiliq/merchant/blob/master/billing/gateways/authorize_net_gateway.py
looks pretty nice, haven't tried it yet.

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.

绿光 2024-08-16 00:45:49

总有 Paython: https://github.com/abunsen/Paython

目前支持 5+ 支付网关:

  1. Authorize.net
  2. First Data/Linkpoint
  3. Innovative Gateway(来自 intuit)
  4. PlugnPay
  5. Stripe

这是一个示例:

from paython import CreditCard, AuthorizeNet

首先设置一张卡:

credit_card = CreditCard(
      number = '4111111111111111',
      exp_mo = '02',
      exp_yr = '2012',
      first_name = 'John',
      last_name = 'Doe',
      cvv = '911',
      strict = False
  )

检查其是否有效:

if not credit_card.is_valid(): return 'houston, we have a problem' # checks card number + expiration date

设置要收费的客户数据,并非所有字段都是必需的:

customer_data = dict(
      address='123 Main St', 
      address2='Apt 1', 
      city='Pleasantville', 
      state='IA', 
      zipcode='54321', 
      country='US', 
      phone='654-369-9589', 
      email='[email protected]', 
      ip='127.0.0.1')

针对网关授权,选项包括调试输出或测试凭据:

  api = AuthorizeNet(username='test', password='testpassword', debug=True, test=True)
  gateway_response = api.auth(amount='0.05', credit_card=credit_card, billing_info=customer_data, shipping_info=None)

现在您可以解决:

  api = AuthorizeNet(username='test', password='testpassword', debug=True, test=True)
  gateway_response = api.settle(amount='0.05', trans_id='2156729380')

There is always Paython: https://github.com/abunsen/Paython

Currently supports 5+ payment gateways:

  1. Authorize.net
  2. First Data/Linkpoint
  3. Innovative Gateway (from intuit)
  4. PlugnPay
  5. Stripe

Here is an example:

from paython import CreditCard, AuthorizeNet

set up a card first:

credit_card = CreditCard(
      number = '4111111111111111',
      exp_mo = '02',
      exp_yr = '2012',
      first_name = 'John',
      last_name = 'Doe',
      cvv = '911',
      strict = False
  )

check if its valid:

if not credit_card.is_valid(): return 'houston, we have a problem' # checks card number + expiration date

Set up customer data to charge, not all fields are required:

customer_data = dict(
      address='123 Main St', 
      address2='Apt 1', 
      city='Pleasantville', 
      state='IA', 
      zipcode='54321', 
      country='US', 
      phone='654-369-9589', 
      email='[email protected]', 
      ip='127.0.0.1')

authorize against gateway, options include debug output or test credentials:

  api = AuthorizeNet(username='test', password='testpassword', debug=True, test=True)
  gateway_response = api.auth(amount='0.05', credit_card=credit_card, billing_info=customer_data, shipping_info=None)

now you can settle:

  api = AuthorizeNet(username='test', password='testpassword', debug=True, test=True)
  gateway_response = api.settle(amount='0.05', trans_id='2156729380')
你不是我要的菜∠ 2024-08-16 00:45:49

在未能找到支持 Authorize.net 所有功能的 API 之后,我最近为 Python 和 Authorize.net 编写了这个 API。

https://github.com/vcatalano/py-authorize

I recently wrote this API for Python and Authorize.net after failing to find one that supported all of Authorize.net's functionality.

https://github.com/vcatalano/py-authorize

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文