Django支付宝
django-alipay2的Python项目详细描述
支付宝
快速启动
安装:
pip install django_alipay2
将“支付宝”添加到已安装的应用程序设置中,如下所示:
INSTALLED_APPS = [ ... 'alipay', ]
[可选]在项目url.py中包含支付宝urlconf,如下所示:
url(r'^alipay/', include('alipay.urls')),
迁移:
python manage.py migrate
将配置“支付宝”添加到settings.py,如下所示:
# account below is for sandbox ALIPAY = { 'pid': '2088101122136241', 'key': '760bdzec6y9goq7ctyx96ezkz78287de', 'seller_email': 'overseas_kgtest@163.com', 'gateway': 'https://openapi.alipaydev.com/gateway.do?', 'server_url': 'http://localhost:8000' } # you may add an 'api_provider' to support multiple seller ALIPAY = { 'api_provider': 'some_package.sub_package.get_alipay_alipay' # input:seller_email, output:AlipayAPI }
创建支付宝重定向:
import uuid payment = AlipayPayment.objects.create( out_no=uuid.uuid4(), subject='充值', body='1年365元', amount_total=0.01, user=None, # 可以指定user seller_email='your_seller_email@domain.com', # reference_id='1' # 可选 ) return redirect('alipay_redirect', out_no=payment.out_no)