Skip to main content

Python SDK for WechatPay V3

Project description

pywechatpay

PyPI version

介绍

pywechatpay 是微信支付 V3 版接口的库.

安装

从 PyPi 安装:

$ pip install pywechatpay

使用教程

准备

参考微信官方文档准备好密钥, 证书文件和配置( 证书/密钥/签名介绍)

初始化

from pywechatpay import WechatPay

mch_private_key_string = """
-----BEGIN PRIVATE KEY-----
xxx
-----END PRIVATE KEY-----
"""
wechat_public_key_string = """
-----BEGIN PUBLIC KEY-----
xxx
-----END PUBLIC KEY-----
"""

wechatpay = WechatPay(
    mchid="xxx",
    mch_serial_no="xxx",
    mch_private_key_string=mch_private_key_string.strip(),
    wechat_public_key_string=wechat_public_key_string.strip(),
    notify_url="http://xxx.com",
    app_appid="xxx",
    offi_appid="xxx",
    mini_appid="xxx",
)

接口

order_string = wechatpay.pay_transactions_app(
    description="test", out_trade_no="test0001", amount=1,
)
order_string = wechatpay.pay_transactions_h5(
    description="test", out_trade_no="test0001", amount=1,
)
order_string = wechatpay.pay_transactions_jsapi(
    description="test", out_trade_no="test0001", amount=1, payer="xxx"
)
order_string = wechatpay.pay_transactions_jsapi(
    description="test", out_trade_no="test0001", amount=1, payer="xxx", tag="mini"
)
result = wechatpay.pay_transactions_out_trade_no("test0001")

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

pywechatpay-0.0.3.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

pywechatpay-0.0.3-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

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