@axolo/egg-wechat-pay

1.3.5 • Public • Published

egg-wechat-pay

node-wechat-pay Egg.js plugin.

Install

npm i @axolo/egg-wechat-pay --save

Usage

// {app_root}/config/plugin.js
exports.wechatPay = {
  enable: true,
  package: '@axolo/egg-wechat-pay',
};

Configuration

// {app_root}/config/config.default.js
exports.wechatPay = {
  clients: {
    mp: {
      appType: 'mp',
      appId: 'wechat_pay_appid',
      mchId: 'wechat_pay_mchid',
      mchCertSn: 'wechat_pay_mch_cert_serial_no',
      mchCertKey: 'wehcat_pay_mch_cert_private_key.pem',
      mchCert: 'wehcat_pay_mch_cert.pem',
      apiV3Key: 'wechat_pay_api_v3_secret',
      notifyUrl: 'https://api.huawo-trip.com/wechat-pay/notify/mp',
      currency: 'CNY',
      paySignType: 'RSA',
    },
  },
};

see config/config.default.js for more detail.

Example

'use strict';

const Controller = require('egg').Controller;

class WechatpayCertController extends Controller {
  async index() {
    const { app, ctx } = this;
    const wechatPay = app.wechatPay.get('mp');
    const { data: result } = await wechatPay.http.get('/v3/certificates');
    ctx.body = result;
  }
}

module.exports = WechatpayCertController;

Questions & Suggestions

Please open an issue here.

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.3.51latest

Version History

VersionDownloads (Last 7 Days)Published
1.3.51
1.3.40
1.3.10
1.3.00
1.2.00
1.0.10
1.0.00

Package Sidebar

Install

npm i @axolo/egg-wechat-pay

Weekly Downloads

1

Version

1.3.5

License

MIT

Unpacked Size

6.02 kB

Total Files

6

Last publish

Collaborators

  • axolo