egg plugin for tenpay
$ npm i egg-tenpay --save
// {app_root}/config/plugin.js
exports.tenpay = {
enable: true,
package: 'egg-tenpay'
};
//参考 [tenpay](https://github.com/befinal/node-tenpay)配置
// {app_root}/config/config.default.js
exports.tenpay = {
client: {
appid: 'appid',
mchid: 'mchid',
partnerKey: 'partnerKey',
notify_url: 'notify_url',
sandbox: true // sandbox是插件加的
}
};
see config/config.default.js for more detail.
// api调用
const result = await app.tenpay.getPayParams({
out_trade_no: '商户内部订单号',
body: '商品简单描述',
total_fee: '订单金额(分)',
openid: '付款用户的openid'
});
// 中间件
// router.js
router.post('/notify',app.middleware.tenpay('pay', app),controller.home.notify);
Please open an issue here.