Fetch the repository succeeded.
Wechat Pay v3 Node.js SDK.
yarn add @axolo/node-wechat-pay
For more usage please issue.
params
config | required | description |
---|---|---|
appId | yes | wechat pay appid |
mchId | yes | wechat pay mchid |
mchCert | yes | wehcat pay merchant certificate |
mchCertKey | yes | wehcat pay merchant certificate private key |
mchCertSn | yes | wechat pay merchant certificate serial number |
apiV3Key | yes | wechat pay api v3 secret key |
notifyUrl | yes | Wechat Pay Notify callback url |
notifySuccess | Wechat Pay Notify need response { code: 'SUCCESS' } event types |
|
platformCert | wehcat pay platform certificate | |
currency | default is CNY |
|
appType | mp = miniprogram | |
http | HTTP Client, default is built-in axios instance | |
error | class of Error, default is WechatPayError |
|
logger | function of logger, default is console |
|
cache | default is {} , it is reserved |
return
Object
of WechatPay
Node.js SDK instance.
http client for request wechat pay API.
params
param | required | description |
---|---|---|
config | yes | config of axios |
return
Promise
of wechat pay result as axios response.
return
String
of nonce_str
, random string.
return
String
of timestamp
, unix timestamp second.
params
param | required | description |
---|---|---|
payPackage | yes | package of wechat pay, like prepay_id=*** |
signType | signType of wechat pay, default is RSA |
return
Object
of wechat pay payment request
prop | description |
---|---|
appId | wehcat pay appid |
timeStamp | timestamp, seconds |
nonceStr | nonce string |
package | package of wechat pay, like prepay_id=*** |
paySign | base64 signature |
signType | signType of wechat pay, like RSA |
params
param | required | description |
---|---|---|
data | yes | Wechat Pay Notify request body |
return
Object
of Wechat Pay Notify decrypt resource with response suggestion.
prop | description |
---|---|
resource | decrytp resource |
response | response suggestion. like { code: 'SUCCESS' } |
const fs = require('fs');
const WechatPay = require('@axolo/node-wechat-pay');
const wechatPay = new WechatPay({
appType: 'mp',
appId: 'wechat_pay_appid',
mchId: 'wechat_pay_mchid',
mchCertSn: 'wechat_pay_mch_cert_serial_no',
mchCertKey: fs.readFileSync('wehcat_pay_mch_cert_private_key.pem'),
mchCert: fs.readFileSync('wehcat_pay_mch_cert.pem'),
apiV3Key: 'wechat_pay_api_v3_secret',
notifyUrl: 'https://url-of-wechat-pay-notify',
});
wechatPay.http.get('/v3/certificates').then(res => {
wechatPay.logger.log(res.data);
}).catch(err => {
wechatPay.logger.error(err);
});
yarn test
Yueming Fang
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。