Skip to main content

An Unofficial Alipay API for Python

Project description

An Unofficial Alipay API for Python

https://travis-ci.org/lxneng/alipay.png?branch=master https://pypip.in/d/alipay/badge.png

Overview

An Unofficial Alipay API for Python, It Contain these API:

  • Generate direct payment url

  • Generate partner trade payment url

  • Generate Standard mixed payment url

  • Verify notify

official document: https://b.alipay.com/order/techService.htm

Install

pip install alipay

Usage

Initialization

>>> from alipay import Alipay
>>> alipay = Alipay(pid='your_alipay_pid', key='your_alipay_key', seller_email='your_seller_mail')

Or you can use seller_id instead of seller_email:

>>> alipay = Alipay(pid='your_alipay_pid', key='your_alipay_key', seller_id='your_seller_id')

Generate direct payment url

生成即时到账支付链接

Introduction: https://b.alipay.com/order/productDetail.htm?productId=2012111200373124

>>> alipay.create_direct_pay_by_user_url(out_trade_no='your_order_id', subject='your_order_subject', total_fee='100.0', return_url='your_order
_return_url', notify_url='your_order_notify_url')
'https://mapi.alipay.com/gateway.do?seller_email=.....'

Generate partner trade payment url

生成担保交易支付链接

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=.....'

Generate Standard mixed payment url

生成标准双接口支付链接

Introduction: https://b.alipay.com/order/productDetail.htm?productId=2012111300373136

>>> alipay.trade_create_by_buyer_url(**params)
'https://mapi.alipay.com/gateway.do?seller_email=.....'

Verify notify

verify notify from alipay server, example in Pyramid Application

def alipy_notify(request):
    alipay = request.registry['alipay']
    if alipay.verify_notify(request.params):
            # this is a valid notify, code business logic here
    else:
        # this is a invalid notify

Example in Pyramid Application

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

pyramid.includes = alipay

now in your View

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

Reference

Changelog

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alipay-0.4.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

alipay-0.4.1-py2.py3-none-any.whl (9.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file alipay-0.4.1.tar.gz.

File metadata

  • Download URL: alipay-0.4.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for alipay-0.4.1.tar.gz
Algorithm Hash digest
SHA256 8e84cb250a9890d1ff26d4a7d461ba6dea7018914bbe96e82f8e93b61dd08179
MD5 f0d10efd9960be71e6a7164e15f1fca4
BLAKE2b-256 6407b8f3be503dea56d0d9d95ba9430fecb1ff6b23dd1be7da016131d7e20148

See more details on using hashes here.

Provenance

File details

Details for the file alipay-0.4.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for alipay-0.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0531e809aa9cde3880652fb18cd85f977fd9ceac380d3de9b56d56869ca88bd5
MD5 3c8b48c8aa573d367f78ca381dd73cdf
BLAKE2b-256 a449ca637d2d616faaa42b54736d53e6fc42392d4e804fe98dfc6fec8b0974bd

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page