一个为Python的Alipay Api

alipa的Python项目详细描述


python的一个非官方支付宝api
==
==


图片::https://img.shields.io/travis/lxneng/alipay.svg
:目标:https://travis ci.org/lxneng/alipay

…图片::https://img.shields.io/pypi/v/alipay.svg
:目标:https://pypi.python.org/pypi/alipay/

…图片::https://img.shields.io/pypi/dm/alipay.svg
:目标:https://pypi.python.org/pypi/alipay/

overview
---------------------------


它包含以下api:

-生成直接付款url
-生成合作伙伴贸易付款url
-生成标准混合付款url
-生成批量交易付款url
-生成发送货物确认url
-生成外汇贸易url
-生成二维码url
-验证通知
-单笔交易查询


官方文件:https://b.alipay.com/order/techservice.htm


install
--------


。代码块::bash


>gt;
>代码块::python

>;>;支付宝=支付宝(pid='您的支付宝pid',key='您的支付宝key',卖家身份是卖家身份,卖家身份是卖家身份,卖家身份是卖家身份。




>生成直接支付url
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~订单/productdetail.htm?产品ID=201211200373124

…代码块::python

>;>;支付宝。按用户URL创建"直接支付"(Out_Trade_No="您的订单ID",Subject="您的订单主题",Total_Fee="100.0",Return_URL="您的订单
"返回URL",Notify_URL="您的订单通知URL')
https://mapi.alipay.com/gateway.do?卖家电子邮箱:……'


>生成合作伙伴贸易支付url
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~HTM公司?产品ID=2012111200373121

…代码块::python

>;>params={
…'出口商品编号:'您的订单编号',
…'主题':'您要的主题',
…'物流类型:'直接',
…'物流费:'0',
…物流支付:'卖方支付',
…'价格:'10.00',
…数量':'12',
…'return戋url':'您的戋order戋return戋url',
…'通知url':'您的订单通知url'
…}
>;>>支付宝。按买家创建合作伙伴交易URL(**params)
'https://mapi.alipay.com/gateway.do?卖家电子邮箱:……'


>生成标准混合支付url
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/order/productdetail.htm?产品ID=201211130373136

…代码块::python

>>>支付宝.trade_create_by_buyer_url(**params)
https://mapi.alipay.com/gateway.do?卖家电子邮件=……'

generate batch trans pay url
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


introduction:https://b.alipay.com/order/productdetail.htm?产品ID=2012111200373121

…代码块::python

>;>params={
…'批次清单:(),批量付款户列表
…'帐户名:'卖家帐户名','批号:'批号'通知网址:你的批通知网址。}
>>gt;支付宝。创建"批量交易通知"url(**params)
'https://mapi.alipay.com/gateway.do?卖方电子邮件=xxx&detail\u data=..'

注:批次清单、格式:(中英文)代码块::python

>;>;批处理列表=({'account':'test@xxx.com',支20184;23453;账
…'姓名:u'convector试',支25903;20184;use25143;姓名
…'费用:'100','注意':'测试'},
…{'account':'test@xxx.com',支付宝账号
…'姓名:u'convector试',支25903;20184;use25143;姓名
…'费用:'100','注意:测试(test)>

>生成发送商品确认url
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~pay.com/support/help_detail.htm?帮助ID=491097

…代码块::python

>;>params={
…'交易编号:'您的支付宝交易ID',
…物流名称:'你的逻辑名称',
…'传输类型":"快速",
…"发票号:'您的发票号'
…}
>>gt;支付宝。通过支付宝平台发送商品确认(params)
'https://mapi.alipay.com/gateway.do?符号=……交易编号=…'

生成外汇交易URL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~http://global.alipay.com/ospay/home.htm

…代码块::python

>;>params={
…'出口商品编号:'您的订单编号',
…'主题':'您要的主题',
…'物流类型:'直接',
…'物流费:'0',
…物流支付:'卖方支付',
…'价格:'10.00',
…数量':'12',
…'return戋url':'您的戋order戋return戋url',
…'通知url':'您的订单通知url'
…}
>>>>为外国人创建网站支付
>>支付宝。创建外汇交易网址(**params)
'https://mapi.alipay.com/gateway.do?服务=创建外汇交易……'
>>>>为外国人创建移动支付
>>支付宝。创建外汇交易的wap网址(**params)
'https://mapi.alipay.com/gateway.do?服务=创建外汇交易wap……'



>生成二维码url
~~~~~~~~~~~~~~~~~~~~~






…代码块::python

>>>支付宝。添加"支付宝"qrcode_url(**params)
'https://mapi.alipay.com/gateway.do?卖家id=……….


注意:buz buz数据的unicode编码,转储转储,确保ascii的false,代码:`json.dumps(d,确保ascii=false)`verify notify notify

>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

验证通知从支付宝服务器,金字塔应用程序中的示例

…代码块::python

def alipy_notify(请求):
alipay=request.registry['alipay']
if alipay.verify_notify(**request.params):
在这里编写业务逻辑代码
否则:
这是一个无效的通知




url=wljyz-h6alfdliu7kr4lcvnqgxstmxx61fw0tdce8yzbqxflcd0cvfszaikbrfdvvlaq0q3wcj935a7kw-mrss0ia4wqu8clace5b8fiq

代码块::python

import re
xml=alipay.single庠trade庠query(out庠trade庠no="1000005")
re s=re.findall('<;trade庠status>;(\s+<;/trade庠status>;',xml)庠使用re查找trade庠状态,实际上xml解析更有用。
status=none if not res else res[0]
打印当交易成功时,状态将打印出交易成功的交易成功



>使用pwd url
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~br/>简介:https://doc.open.alipay.com/docs/doc.htm?SPM=A219A.7629140.0.0.XRddqH&treeId=62&articleId=104744&docType=1

.. code-block:: python

>>> params = {
... 'batch_list': (), #批量退款数据集
... 'batch_no': 'batch_id', #退款批次号,须唯一
... 'notify_url': 'your_batch_notify_url' #异步通知地址
... }
>>> alipay.refund_fastpay_by_platform_pwd(**params)
'https://mapi.alipay.com/gateway.do?seller_email=xxx&detail_data=....'

Note: batch_list 为批量退款数据集,具体格式如下例子:(如涉及中文请使用unicode字符)

.. code-block:: python

>>> batch_list = ({'trade_no': 'xxxxxxxx', #原付款支付宝交易号
... 'fee': '100', #退款总金额
... 'note': 'test'}, #退款原因
... {'trade_no': 'xxxxxxxx', #原付款支付宝交易号
... 'fee': '100', #退款总金额
... 'note': 'test'}) #退款原因

Example in Pyramid Application
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Include alipay either by setting your includes in your .ini, or by calling config.include('alipay').

.. code-block:: python

pyramid.includes = alipay

now in your View

.. code-block:: python

def some_view(request):
alipay = request.registry['alipay']
url = alipay.create_direct_pay_by_user_url(...)


Reference
---------------------------------------

- `Ruby Alipay GEM <https://github.com/chloerei/alipay>`_
- `Official document <https://b.alipay.com/order/techService.htm>`_


Changelog
==============================


0.7.4 - Feb.28, 2017
--------------------------------

- add `refund_fastpay_by_platform_pwd` method
https://github.com/lxneng/alipay/pull/26

0.7.3 - Dec.14, 2015
--------------------------------

- replace open() calls with io.open() for Python 3 compatibility,
fix `UnicodeDecodeError`
- add `create_direct_pay_by_user_url` doc for Wap site


0.7.2 - Nov.1, 2015
--------------------------------

- add `single_trade_query` method
https://github.com/lxneng/alipay/pull/20

0.7.1 - Sep.16, 2015
--------------------------------

- Fix verify_notify raise KeyError: 'sign' bug
https://github.com/lxneng/alipay/pull/18

0.7 - Sep.07, 2015
--------------------------------

- add `create_forex_trade_url` method
- add `create_forex_trade_wap_url` method
- add `create_batch_trans_notify_url` method

0.6 - Jul.27, 2015
--------------------------------

- add `send_goods_confirm_by_platform` method

0.5 - Apr.16, 2015
--------------------------------

- add `add_alipay_qrcode` method

0.4.2 - Feb.14, 2015
--------------------------------

- Fix argument type error of verify_notify in README

- FIX SEVERE FAULT IN `check_notify_remotely`


0.4.1 - Feb.09, 2015
--------------------------------

- Resolved README.rst is not formatted on pypi.python.org

0.4 - Feb.09, 2015
--------------------------------

- Seller id support


0.3 - Aug.03, 2014
--------------------------------

- Add wap payment support

0.2.3 - Nov.20, 2013
--------------------------------

- english version readme doc

0.2.2 - Nov.12, 2013
--------------------------------

- add includeme func for pyramid

- update readme

0.2.1 - Nov.11, 2013
--------------------------------

- fix rst doc

0.2 - Nov.11, 2013
--------------------------------

- add unittest

- update readme

- add verify_notify func

- add check_parameters func

- add travis.yml

- add tox.ini

0.1 - Nov.11, 2013
------------------------------

- first commit

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java:字符串。RTL设备语言用标志“+”格式化,数字后加符号   java GAE作为桌面应用程序(Swing)的服务提供商   java将InputStream转换为FileInputStream不适用于Apache POI   java外部Voronoi库“网格”:什么是草图和处理?   重载重写的泛型方法java   java显示组织上设置的错误。springframework。验证。jsp中的错误对象   java一些Spring模型属性没有显示在我的JSP中   java无法编译Guava 23的SimpleTimeLimiter示例   java如何更改JTree中的“根”目录名?   java如何在安卓中对相对布局产生连锁反应?   java错误:org。冬眠例外SQLGrammarException:无法提取结果集,dateAccessed是未知列   如何使用java监听JSON文件更新   由抽象封闭类创建的匿名内部类能否通过反射确定实现类?