Installations
npm install @sigodenjs/wechatpay
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.15.3
NPM Version
6.4.1
Score
74
Supply Chain
93.7
Quality
71.2
Maintenance
50
Vulnerability
97.3
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.91%)
JavaScript (0.09%)
Developer
Download Statistics
Total Downloads
8,055
Last Day
1
Last Week
6
Last Month
27
Last Year
873
GitHub Statistics
118 Stars
39 Commits
24 Forks
8 Watching
2 Branches
2 Contributors
Bundle Size
1.09 MB
Minified
375.04 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.1.1
Package Id
@sigodenjs/wechatpay@2.1.1
Size
46.23 kB
NPM Version
6.4.1
Node Version
10.15.3
Publised On
10 Jun 2019
Total Downloads
Cumulative downloads
Total Downloads
8,055
Last day
0%
1
Compared to previous day
Last week
-50%
6
Compared to previous week
Last month
50%
27
Compared to previous month
Last year
-24.3%
873
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
4
微信支付 node.js
微信支付 SDK,支持刷卡支付、公众号支付、扫码支付、APP 支付、H5 支付,以及优惠券,红包,企业付款,微信代扣
特性
- 使用 Typescript 编写,拥有更安全的类型和更好的代码提示
- 支持所有类型微信支付
- 支持微信代扣
- 提供调试模式
开始使用
1const path = require("path"); 2const fs = require("fs"); 3const { 4 PubPay, 5 RequestError, 6 CommunicationError, 7 utils: { getXMLBody } 8} = require("@sigodenjs/wechatpay"); 9 10const pay = new PubPay({ 11 appId: "wxb80e5bddb2d804f3", 12 key: "6Q9VX4N3WTBM9G9XBL7H1L9PB9ANHLY7", 13 mchId: "1434712502", 14 pfx: fs.readFileSync(path.resolve(__dirname, "cert.p12")) 15}); 16 17// 调用统一下单接口 18pay 19 .unifiedOrder({ 20 body: "腾讯充值中心-QQ会员充值", 21 out_trade_no: "1217752501201407033233368018", 22 total_fee: 888, 23 spbill_create_ip: "8.8.8.8", 24 notify_url: "https://example.com/wechatpay/notify", 25 trade_type: "JSAPI", 26 openid: "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o" 27 }) 28 .then(res => { 29 if (!pay.verifySign(res)) { 30 // 签名校验失败 31 throw new Error("签名校验失败"); 32 } 33 if (res.result_code === "FAIL") { 34 console.log(res.err_code, res.err_code_des); 35 } else { 36 console.log(res.prepay_id); 37 } 38 }) 39 .catch(err => { 40 if (err instanceof RequestError) { 41 // 请求错误 42 } else if (err instanceof CommunicationError) { 43 // return_code = FAIL 44 } 45 }); 46 47// 支付结果通知 48router.post("/wechatpay/notify", (req, res) => { 49 const options = { 50 length: req.headers["content-length"], 51 limit: "1mb", 52 encoding: "utf8" 53 }; 54 getXMLBody(req, options).then(data => { 55 pay 56 .payNotify(data, async parsedData => { 57 if (!pay.verifySign(parsedData)) { 58 // 签名校验失败 59 } 60 if (parsedData.result_code === "FAIL") { 61 // 业务逻辑失败 62 } 63 // ... 64 return { 65 return_code: "SUCCESS", 66 return_msg: "OK" 67 }; 68 }) 69 .then(returnData => { 70 res.set("Content-Type", "application/xml; charset=utf-8"); 71 res.end(returnData); 72 }); 73 }); 74});
类和接口
业务类
- AppPay: APP 支付
- Bank: 企业付款
- Coupon: 代金券
- LitePay: 小程序支付
- PubPay: 公众号支付
- PubQrPay: 扫码支付
- PubScanPay: 刷卡支付
- RedPack: 现金红包
- WapPay: H5 支付
- AppEntrust: APP 代扣
- LiteEntrust: 小程序代扣
- PubEntrsut: 公众号代扣
- WapEntrust: H5 代扣
综合类
如果你只使用了某一项支付,请使用业务类。但如果涉及多种支付,使用综合类更便捷。
支付相关接口
- batchQueryComment: 拉取订单评价数据
- downloadBill: 下载对账单
- downloadFundFlow: 下载资金账单
- orderQuery: 查询订单
- refund: 申请退款
- refundNotify: 退款结果通知处理
- refundQuery: 查询退款
- report: 交易保障
- closeOrder: 关闭订单
- payNotify: 支付结果通知
- unifiedOrder: 统一下单
- authCodeToOpenId - 授权码查询 OpenId
- microPay - 提交刷卡支付
- reverse - 撤销订单
- shortURL - 短链接转换
- getPublicKey: 获取 RSA 加密公钥
- getTransferInfo: 查询企业付款到零钱
- payBank: 企业付款到银行卡
- queryBank: 查询企业付款到银行卡
- transfers: 企业付款到零钱
- queryCouponStock: 查询代金券批次
- queryCouponsInfo: 查询代金券信息
- sendCoupon: 发放代金券
- getHbInfo: 查询红包记录
- sendGroupGroupRedPack: 发放裂变红包
- sendRedPack: 发放普通红包
代扣相关接口
- contractNotify: 签约,解约结果通知
- contractOrder: 支付中签约
- deleteContract: 申请解约
- entrust: 纯签约
- papOrderQuery: 查询订单
- papPayApply: 申请扣款
- papPayNotify: 扣款结果通知
- queryContract: 查询签约关系
- downloadBill: 下载对账单
- refund: 申请退款
- refundQuery: 查询退款
许可证
Copyright (c) 2018 sigoden
Licensed under the MIT license.
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
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/30 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 SAST tool detected
Details
- Warn: no pull requests merged into dev branch
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'
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