egg-wxpay
Install
$ npm i egg-wxpay --saveor$ cnpm i egg-wxpay --save
Usage
// {app_root}/config/plugin.jsexportswxpay = enable: true package: 'egg-wxpay';
Configuration
// {app_root}/config/config.default.jsexportswxpay = partnerKey: '<partnerkey>' appId: '<appid>' mchId: '<mchid>' notifyUrl: '<notifyurl>' //http://www.notify.com/notify ca: '<location-of-your-apiclient-cert.pem>' // fs.readFileSync(path.join(__dirname, '../config/rootca.pem')) pfx: '<location-of-your-apiclient-cert.p12>' // fs.readFileSync(path.join(__dirname, '../config/apiclient_cert.p12')),;
see config/config.default.js for more detail.
Example
//app/controller/wx.jsasync { // 支付 const order = body: '微信支付' out_trade_no: // 订单号 唯一id total_fee: Math // 微信最小单位是分 spbill_create_ip: ip // 请求的ip地址 openid trade_type: 'JSAPI' ; const payargs = await thisappwxpay; thisctxbody = payargs;} // 回调//app/router.jsmodule { const router controller = app; ... router; ...}//app/controller/wx.jsasync { const out_trade_no = thisctxrequestbody;// 订单号 ...}
Questions & Suggestions
Please open an issue here.