Skip to content

Latest commit

 

History

History
64 lines (50 loc) · 1.48 KB

README.md

File metadata and controls

64 lines (50 loc) · 1.48 KB

egg-alipay

Official Document

Install

npm i @axolo/egg-alipay --save

Usage

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

Configuration

// {app_root}/config/config.default.js
const fs = require('fs');
const path = require('path');
const alipayPrivateKeyPath = 'path/to/your-alipay-app-private-key.pem';
const alipayPublicKeyPath = 'path/to/alipay-public-key.pem';
const alipayPrivateKey = fs.readFileSync(path.join(appInfo.baseDir, alipayPrivateKeyPath), 'ascii');
const alipayPublicKey = fs.readFileSync(path.join(appInfo.baseDir, alipayPublicKeyPath), 'ascii');
exports.alipay = {
  default: {
    AlipaySdk: require('alipay-sdk').default,
    camelcase: true,
  },
  clients: {
    sandbox: {
      gateway: 'https://openapi.alipaydev.com/gateway.do', // sandbox
      appId: 'your-alipay-app-id',
      alipayPublicKey,
      privateKey: alipayPrivateKey,
      notifyUrl: 'url/to/your-alipay-notify',
    },
  },
};

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

Document

member description
AlipaySdk class of AlipaySdk
sdk instance of AlipaySdk
config config of AlipaySdk instance

Questions & Suggestions

Please open an issue here.

License

MIT