总有 Python: https://github.com/abunsen/Paython
目前支持 5+ 种支付网关:
- Authorize.net
- First Data/Linkpoint
- Innovative Gateway (from intuit)
- PlugnPay
- 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='john@localwoodshop.com',
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')