Skip to content

huhulab/wechatpay-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WechatPay

WechatPay is a sdk for wechat pay, Before using this, you need to set up the configuration of wechat pay.

About pay, please read the wechat pay document

How to install & uninstall

    # Install
    pip install git+https://github.com/huhulab/wechatpay-sdk.git@v0.1
    # or install the latest code
    pip install git+https://github.com/huhulab/wechatpay-sdk.git@master

    # Uninstall
    pip uninstall wechatpay-sdk

How to get openid

How to use?

    from wechatpay_sdk import WechatPay

    client = WechatPay(
        appid = 'your_appid',
        mch_id='your_mch_id',
        sign_key = 'your_sign_key',
        notify_url = 'your_notify_url',
        cert = '/path/your_cert.pem'
    )

    # For app sdk pay
    params = {
        'body': 'XX pay test',
        'out_trade_no': 'xxx-xxx-xxx',
        'total_fee': 1,
        'spbill_create_ip': '127.0.0.1'
    }
    ret = client.app_pay(params)

    # Order query
    ret = client.order_query(transaction_id='xxxxx') or client.order_query(out_trade_no='xxxx')

    # Refund order query
    params = {
        'out_order_no': 'xxxx',
    }
    ret = client.refund_order_query(params)