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

时间:2022-06-01 21:30:45

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 .

我需要授权。net集成的订阅支付,可能使用CIM。这些要求是简单的-循环每月付款,有几个不同的价格点。客户信用卡信息将被存储在一个授权网站上。

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.
  • Django-Bursar似乎是我需要的,但它被列为alpha。
  • The adroll/authorize library also looks pretty good.
  • adroll/授权库也很不错。
  • The CIM XML APIs don't look too bad, I could connect directly with them.
  • CIM XML api看起来不太糟糕,我可以直接与它们连接。

And there are quite a few other code snippets.

还有很多其他的代码片段。

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

考虑到我的简单要求,现在最好的选择是什么?

6 个解决方案

#1


15  

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

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.

它处理基本事务(AIM API)、保存的卡(CIM API)和经常性支付(ARB API)。它有完整的文档和完整的测试套件。

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.

我想最初的海报早就被删除了,但如果它能帮助其他人避免支付过程中的一些痛苦,我会非常高兴。

#2


9  

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

编辑:https://github.com/agiliq/businessant/blob/master/billing/gateways/authorize_net_gateway.py看起来不错,还没有尝试过。

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.]

编辑:[对于使用authorize.net的下一个项目,我将仔细查看:http://github.com/zen4ever/django- authorizenzenet,它看起来很不错。但我不认为它支持经常性支付。

In the past I have made little one-off implementations.

在过去,我很少做一次性的实现。

For simple post to the AIM payment gateway, you can use something like this:

对于简单的post到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

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.

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

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

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.

我知道你的问题是什么是最好的。好吧,可能最简单的方法是实现您自己的一些特殊请求和响应,以满足您的特定需求,而不是尝试通过api之上的api来获取。

#3


6  

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

一直都有Paython: https://github.com/abunsen/Paython

Currently supports 5+ payment gateways:

目前支持5+支付网关:

  1. Authorize.net
  2. Authorize.net
  3. First Data/Linkpoint
  4. 第一个数据/ Linkpoint
  5. Innovative Gateway (from intuit)
  6. 创新的网关(直觉)
  7. PlugnPay
  8. PlugnPay
  9. Stripe
  10. 条纹

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='john@localwoodshop.com', 
      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')

#4


3  

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

我最近为Python和Authorize.net编写了这个API,但没有找到一个支持Authorize.net所有功能的API。

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

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

#5


1  

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.

值得的是,我们最终使用了adroll授权库。Paython和django-authorizenet看起来都很有趣,将会对它们进行检查。

#6


1  

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:

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

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:

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

pip install git+git://github.com/Pylons/colander.git@1.0b1

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

文档在这里: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.

在我的经验中,它非常有用,但是对于我正在使用它的项目,我只需要AuthCapture,而不需要ARB或任何东西……试一试。到目前为止我找到的最好的包装。

#1


15  

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

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.

它处理基本事务(AIM API)、保存的卡(CIM API)和经常性支付(ARB API)。它有完整的文档和完整的测试套件。

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.

我想最初的海报早就被删除了,但如果它能帮助其他人避免支付过程中的一些痛苦,我会非常高兴。

#2


9  

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

编辑:https://github.com/agiliq/businessant/blob/master/billing/gateways/authorize_net_gateway.py看起来不错,还没有尝试过。

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.]

编辑:[对于使用authorize.net的下一个项目,我将仔细查看:http://github.com/zen4ever/django- authorizenzenet,它看起来很不错。但我不认为它支持经常性支付。

In the past I have made little one-off implementations.

在过去,我很少做一次性的实现。

For simple post to the AIM payment gateway, you can use something like this:

对于简单的post到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

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.

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

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

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.

我知道你的问题是什么是最好的。好吧,可能最简单的方法是实现您自己的一些特殊请求和响应,以满足您的特定需求,而不是尝试通过api之上的api来获取。

#3


6  

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

一直都有Paython: https://github.com/abunsen/Paython

Currently supports 5+ payment gateways:

目前支持5+支付网关:

  1. Authorize.net
  2. Authorize.net
  3. First Data/Linkpoint
  4. 第一个数据/ Linkpoint
  5. Innovative Gateway (from intuit)
  6. 创新的网关(直觉)
  7. PlugnPay
  8. PlugnPay
  9. Stripe
  10. 条纹

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='john@localwoodshop.com', 
      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')

#4


3  

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

我最近为Python和Authorize.net编写了这个API,但没有找到一个支持Authorize.net所有功能的API。

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

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

#5


1  

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.

值得的是,我们最终使用了adroll授权库。Paython和django-authorizenet看起来都很有趣,将会对它们进行检查。

#6


1  

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:

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

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:

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

pip install git+git://github.com/Pylons/colander.git@1.0b1

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

文档在这里: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.

在我的经验中,它非常有用,但是对于我正在使用它的项目,我只需要AuthCapture,而不需要ARB或任何东西……试一试。到目前为止我找到的最好的包装。