An Unofficial Alipay API for Python, It Contain these API:
- Generate direct payment url
- Generate partner trade payment url
- Generate standard mixed payment url
- Generate batch trans pay url
- Generate send goods confirm url
- Generate forex trade url
- Generate QR code url
- Verify notify
- Single Trade Query
- Generate Refund With Pwd URL
official document: https://b.alipay.com/order/techService.htm
Or you can use seller_id instead of `seller_email`:
Introduction: https://b.alipay.com/order/productDetail.htm?productId=2012111200373124
Introduction: https://b.alipay.com/order/productDetail.htm?productId=2012111200373121
>>> params = {
... 'out_trade_no': 'your_order_id',
... 'subject': 'your_order_subject',
... 'logistics_type': 'DIRECT',
... 'logistics_fee': '0',
... 'logistics_payment': 'SELLER_PAY',
... 'price': '10.00',
... 'quantity': '12',
... 'return_url': 'your_order_return_url',
... 'notify_url': 'your_order_notify_url'
... }
>>> alipay.create_partner_trade_by_buyer_url(**params)
'https://mapi.alipay.com/gateway.do?seller_email=.....'
Introduction: https://b.alipay.com/order/productDetail.htm?productId=2012111300373136
Introduction: https://b.alipay.com/order/productDetail.htm?productId=2012111200373121
>>> params = {
... 'batch_list': (), #批量付款用户列表
... 'account_name': 'seller_account_name', #卖家支付宝名称
... 'batch_no': 'batch_id', #转账流水号,须唯一
... 'notify_url': 'your_batch_notify_url' #异步通知地址
... }
>>> alipay.create_batch_trans_notify_url(**params)
'https://mapi.alipay.com/gateway.do?seller_email=xxx&detail_data=....'
Note: batch_list 为批量付款用户列表,具体格式如下例子:(如涉及中文请使用unicode字符)
Introduction: https://cshall.alipay.com/support/help_detail.htm?help_id=491097
Introduction: http://global.alipay.com/ospay/home.htm
>>> params = {
... 'out_trade_no': 'your_order_id',
... 'subject': 'your_order_subject',
... 'logistics_type': 'DIRECT',
... 'logistics_fee': '0',
... 'logistics_payment': 'SELLER_PAY',
... 'price': '10.00',
... 'quantity': '12',
... 'return_url': 'your_order_return_url',
... 'notify_url': 'your_order_notify_url'
... }
>>> # Create website payment for foreigners
>>> alipay.create_forex_trade_url(**params)
'https://mapi.alipay.com/gateway.do?service=create_forex_trade......'
>>> # Create mobile payment for foreigners
>>> alipay.create_forex_trade_wap_url(**params)
'https://mapi.alipay.com/gateway.do?service=create_forex_trade_wap......'
Generate QR code url ~~~~~~~~~~~~~~~~~~~
Introduction: https://b.alipay.com/order/productDetail.htm?productId=2012120700377303
Note: 如果你的 biz_data 中有 Unicode 字符,在 dumps 的时候需要把 ensure_ascii 设置为 False,即 json.dumps(d, ensure_ascii=False)
否则会遇到错误
verify notify from alipay server, example in Pyramid Application
Introduction: https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.XRddqH&treeId=62&articleId=104744&docType=1
Note: batch_list 为批量退款数据集,具体格式如下例子:(如涉及中文请使用unicode字符)
Include alipay either by setting your includes in your .ini, or by calling config.include('alipay').
now in your View