wechat-pay-sdk
sdk for wechat developer, build with typescript.
Install
npm install wechat-pay-sdk --save
Install definition if you need!
npm install "git+https://git@github.com/mrkou47/wechat-pay-sdk.d.ts.git"
Usage
const wechatPay = ;const customize = appid: 'your appid' secret: 'your wechat secret' mch_id: 'your mch_id' key: 'your key'; customize; customize;
ATTENTION: you should use import wechatPay = require('wechat-pay-sdk');
if you used in the Typescript file.
API
wechatPay;
return Promise;
wechatPay;
return Promise;
constructor()
Options object for All params is required
var wechatPayOptions = appid: 'your appid' secret: 'your wechat secret' mch_id: 'your mch_id' key: 'your key';
- appid: your wechat appid,
- secret: your wechat secret,
- mch_id: your mchid, you can find it on 微信商户平台
- key: your key, you can find it on 微信商户平台, 微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
getUserOpenId()
Options for wechatPay;
This method need a string argument, which you can find on req.query
. see an Example;
payment()
Options object for var paymentOptions = attach: 'some detail' body: 'description' detail: 'description' notify_url: 'http://www.weixin.qq.com/wxpay/pay.php' openid: 'J892IK12e1A912309c' out_trade_no: '20150806125346' spbill_create_ip: '123.12.13.123' total_fee: 100;
You can find params descrption on 微信支付文档
Run example
$ git clone https://github.com/MrKou47/wechat-pay-sdk.git$ cd wechat-pay-sdk
Before start example, you shou edit wechat-config.js
with you config. And then:
$ npm run dev
wxml
?
How to use in Example:
;
DOC: https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-pay.html