Installations
npm install node-weixin-pay
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
6.10.0
NPM Version
3.10.10
Score
70.7
Supply Chain
90.5
Quality
71.8
Maintenance
50
Vulnerability
97
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Download Statistics
Total Downloads
28,816
Last Day
3
Last Week
11
Last Month
27
Last Year
2,395
GitHub Statistics
100 Stars
70 Commits
32 Forks
7 Watching
2 Branches
2 Contributors
Bundle Size
951.28 kB
Minified
253.22 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.5.1
Package Id
node-weixin-pay@0.5.1
Size
7.85 kB
NPM Version
3.10.10
Node Version
6.10.0
Total Downloads
Cumulative downloads
Total Downloads
28,816
Last day
0%
3
Compared to previous day
Last week
266.7%
11
Compared to previous week
Last month
-91.8%
27
Compared to previous month
Last year
105.8%
2,395
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
node-weixin-pay
Weixin 支付 API
支持QQ群:39287176
Install
1$ npm install --save-exact node-weixin-pay
Usage
通用功能
1、初始化对象与基本数据
1 2var nodeWeixinPay = require('node-weixin-pay'); 3var nodeWeixinConfig = require('node-weixin-config'); 4 5// 必须 6var merchant = { 7 id: process.env.MERCHANT_ID || 'id', 8 key: process.env.MERCHANT_KEY || 'key' 9}; 10var app = { 11 id: process.env.APP_ID || 'appid', 12 secret: process.env.APP_SECRET || 'appsecret', 13 token: process.env.APP_TOKEN || 'apptoken' 14}; 15 16// 证书是可选的,但在退款,红包,企业支付时需要 17 18var certificate = { 19 pkcs12: path.resolve(certPKCS12File), //格式是文件名 20 key: String(certKey) 21}; 22 23//或者 24 25var certificate = { 26 pfx: new Buffer(conf.merchant_pfx, 'base64'), //格式是文件二进制内容 27 pfxKey: conf.merchant_id 28}; 29 30//对于大部分的支付接口来说是需要config的 31var config = { 32 app: app, 33 merchant: merchant, 34 // 可选(除了退款外接口,可以不用添加) 35 certificate: certificate 36}; 37 38//校验数据的正确性 39nodeWeixinConfig.app.init(app); 40nodeWeixinConfig.merchant.init(merchant); 41 42var params = { openid: process.env.OPENID, 43 spbill_create_ip: '1.202.241.25', 44 notify_url: 'http://wx.domain.com/weixin/pay/main', 45 body: '测试支付', 46 out_trade_no: '111', 47 total_fee: '1', 48 trade_type: 'JSAPI', 49 appid: app.id, 50 mch_id: merchant.id, 51 nonce_str: 'XjUw56N8MjeCUqHCwqgiKwr2CJVgYUpe' }; 52
2、签名一个请求
1 2var sign = nodeWeixinPay.sign(merchant, params);
3、准备一个支付配置
1var id = 'id'; 2var config = nodeWeixinPay.prepay(app, merchant, id);
处理微信回调接口API
1、处理回调数据,所有的请求的处理结果回调
1//req.rawBody should be enabled 2var req = {rawBody: xml}; 3var res = { 4 json: function() { 5 6 } 7}; 8nodeWeixinPay.callback.notify(app, merchant, req, res, function(error, data) { 9});
基础API
1、发送统一支付请求
1nodeWeixinPay.api.order.unified(config, params, function(error, data) { 2});
2、发送订单查询请求
1var config = nodeWeixinPay.api.query(config, params, function(error, data) { 2});
3、发送订单关闭请求
1var config = nodeWeixinPay.api.close(config, params, function(error, data) { 2});
4、发送创建退款请求
1var config = nodeWeixinPay.api.refund.create(config, params, function(error, data) { 2});
5、发送退款查询请求
1var config = nodeWeixinPay.api.refund.query(config, params, function(error, data) { 2});
6、发送下载对账单请求
1var config = nodeWeixinPay.api.statements(config, params, function(error, data) { 2});
7、发送测速报告请求
1var config = nodeWeixinPay.api.report(config, params, function(error, data) { 2});
微信红包接口
1、发起普通微信红包
1var config = nodeWeixinPay.api.redenvelope.create(config, params, function(error, data) { 2});
2、发起裂变微信红包
1var config = nodeWeixinPay.api.redenvelope.distribute(config, params, function(error, data) { 2});
3、发起红包查询
1var config = nodeWeixinPay.api.redenvelope.query(config, params, function(error, data) { 2});
企业付款接口
1、发起企业支付
1var config = nodeWeixinPay.api.enterprise.create(config, params, function(error, data) { 2});
2、查询企业支付
1var config = nodeWeixinPay.api.enterprise.query(config, params, function(error, data) { 2});
License
Apache-2.0 © calidion
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Score
3
/10
Last Scanned on 2025-01-06
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More