Python实现微信支付
一、准备环境
1、要有微信公众号,商户平台账号
https://pay.weixin.qq.com/wiki/doc/api/index.html
安装 requests库
pip install -r requirements.txt
安装第三方库
python setup.py install
示例
以统一下单为例:
#coding: utf-8
from pywxpay import WXPay
wxpay = WXPay(app_id=‘wx8888888998’,
mch_id=‘8888888’,
key=‘123434556677888999987766543543322’,
cert_pem_path=’/path/to/apiclient_cert.pem’,
key_pem_path=’/path/to/apiclient_key.pem’,
timeout=6.0)
wxpay_resp_dict = wxpay.unifiedorder(dict(device_info=‘WEB’,
body=‘测试商家-商品类目’,
detail=’’,
out_trade_no=‘2016090910595900000012’,
total_fee=1,
fee_type=‘CNY’,
notify_url=‘http://www.debug5.com’,
spbill_create_ip=‘123.12.12.123’,
trade_type=‘NATIVE’)
)
print( wxpay_resp_dict )
github地址:https://github.com/whisnos/wxpay.git
https://github.com/whisnos/wxpay
第一发表于:http://www.debug5.com
程序猿的道德修养:
本博客源码Github地址:
https://github.com/whisnos/myblog
(仅供学习使用)请随手给个star,谢谢