A relative to wechat pay project
Project description
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](https://pay.weixin.qq.com/wiki/doc/api/index.html)
#### how to install
```
git clone git@github.com:fanhan/wechatpay.git
cd wechatpay
python setup.py install
```
[how to get openid](https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=4_4)
#### how to use?
```python
from wechatpay import WechatPay
class Pay(WechatPay):
appid = 'your_appid'
mch_id = 'your_mch_id'
appSecret = 'your_appSecret'
partnerKey = 'your_partnerKey'
notify_url = 'your_notify_url'
# if need cert
cert = '/path/your_cert.pem'
# for app sdk pay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1'
}
ret = Pay().app_pay(params)
# for qr code pay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1',
'product_id': '1111'
}
ret = Pay().qrcode_pay(params)
# for jsapi pay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1',
'openid': 'xxxxxx' # from wechat service get openid
}
ret = Pay().jsapi_pay(params)
# for micropay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1',
'auth_code': 'xxxxxx'
}
ret = Pay().micropay(params)
# order query
ret = Pay().order_query(transaction_id='xxxxx') or Pay().order_query(out_trade_no='xxxx')
# order reverse
# need cert
out_trade_no = 'xxxx'
ret = Pay().order_reverse(out_trade_no)
# order refund
# need cert
params = {
'out_order_no': 'xxxx',
'out_refund_no': 'xxxx',
'total_fee': 1,
'refund_fee': 1,
}
ret = Pay().order_refund(params)
# refund order query
params = {
'out_order_no': 'xxxx',
}
ret = Pay().refund_order_query(params)
```
=============
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](https://pay.weixin.qq.com/wiki/doc/api/index.html)
#### how to install
```
git clone git@github.com:fanhan/wechatpay.git
cd wechatpay
python setup.py install
```
[how to get openid](https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=4_4)
#### how to use?
```python
from wechatpay import WechatPay
class Pay(WechatPay):
appid = 'your_appid'
mch_id = 'your_mch_id'
appSecret = 'your_appSecret'
partnerKey = 'your_partnerKey'
notify_url = 'your_notify_url'
# if need cert
cert = '/path/your_cert.pem'
# for app sdk pay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1'
}
ret = Pay().app_pay(params)
# for qr code pay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1',
'product_id': '1111'
}
ret = Pay().qrcode_pay(params)
# for jsapi pay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1',
'openid': 'xxxxxx' # from wechat service get openid
}
ret = Pay().jsapi_pay(params)
# for micropay
params = {
'body': '',
'out_trade_no': '',
'total_fee': 1,
'fee_type': 'CNY',
'spbill_create_ip': '127.0.0.1',
'auth_code': 'xxxxxx'
}
ret = Pay().micropay(params)
# order query
ret = Pay().order_query(transaction_id='xxxxx') or Pay().order_query(out_trade_no='xxxx')
# order reverse
# need cert
out_trade_no = 'xxxx'
ret = Pay().order_reverse(out_trade_no)
# order refund
# need cert
params = {
'out_order_no': 'xxxx',
'out_refund_no': 'xxxx',
'total_fee': 1,
'refund_fee': 1,
}
ret = Pay().order_refund(params)
# refund order query
params = {
'out_order_no': 'xxxx',
}
ret = Pay().refund_order_query(params)
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wechat_pay-0.2.tar.gz
(5.6 kB
view details)
File details
Details for the file wechat_pay-0.2.tar.gz
.
File metadata
- Download URL: wechat_pay-0.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 672c066bc4d9ca5eb71e6f0e3fb3c4ac6a10906be1eb05144413c138e3387edf |
|
MD5 | 959872352c7542e6585c6f00aaaf08be |
|
BLAKE2b-256 | 14179c6a91ee18d88eee1c5e06945b399c4796254b49fa887c12780e12f5358e |