Gathering detailed insights and metrics for wechat-pay-nodejs
Gathering detailed insights and metrics for wechat-pay-nodejs
Gathering detailed insights and metrics for wechat-pay-nodejs
Gathering detailed insights and metrics for wechat-pay-nodejs
npm install wechat-pay-nodejs
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
22 Stars
8 Commits
2 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Jul 06, 2025
Latest Version
0.2.3
Package Id
wechat-pay-nodejs@0.2.3
Unpacked Size
81.63 kB
Size
17.86 kB
File Count
28
NPM Version
8.11.0
Node Version
16.15.1
Published on
Jun 20, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
微信支付 APIv3 非官方 Node.js 语言开发库。 支持 直连商户 和 服务商接口
npm install wechat-pay-nodejs
1import { WechatPay } from "wechat-pay-nodejs"; 2 3const wechatPay = new WechatPay({ 4 appid: '{appid}', // 应用ID 5 mchid: '{mchid}', // 直连商户号 6 cert_private_content: Buffer.from('{apiclient_key.pem}'), // 商户API私钥内容 7 cert_public_content: Buffer.from('{apiclient_cert.pem}'), // 商户API证书内容 8 user_agent: '{User-Agent}', // 选填 9})
1import { WechatPayPartner } from "wechat-pay-nodejs"; 2 3const wechatPayPartner = new WechatPayPartner({ 4 appid: '{sp_appid}', // 服务商应用ID 5 mchid: '{sp_mchid}', // 服务商户号 6 cert_private_content: Buffer.from('{apiclient_key.pem}'), // 服务商API私钥内容 7 cert_public_content: Buffer.from('{apiclient_cert.pem}'), // 服务商API证书内容 8 user_agent: '{User-Agent}', // 选填 9})
1import { PrepayJsApiPartnerParams } from "wechat-pay-nodejs/typings"; 2 3const params : PrepayJsApiPartnerParams = { 4 sub_mchid: '{sub_mchid}', // 子商户号 5 description: '{description}', // 商品描述 6 out_trade_no: '{out_trade_no}', // 商户订单号 7 notify_url: '{notify_url}', // 通知地址 8 amount: { 9 total: 100, // 订单金额 10 }, 11 payer: { 12 sp_openid: '{sp_openid}', // 用户服务标识 13 } 14}; 15 16const result = await wechatPayPartner.prepayJsapi(params);
1import { VerifyParams } from "wechat-pay-nodejs/typings"; 2 3const headers = '{HTTP Headers}'; 4const timestamp = headers['wechatpay-timestamp']; 5const nonce = headers['wechatpay-nonce']; 6const serialNumber = headers['wechatpay-serial']; 7const signature = headers['wechatpay-signature']; 8const certificates = '{certificates}'; // 微信平台证书列表 (调用getCertificates接口获取,建议缓存10小时) 9const verifyParams : VerifyParams = { 10 timestamp: timestamp, // HTTP头Wechatpay-Timestamp 中的应答时间戳 11 nonce: nonce, // HTTP头Wechatpay-Nonce 中的应答随机串 12 body: '{body}', // 应答主体(response Body),需要按照接口返回的顺序进行验签,错误的顺序将导致验签失败 13 serialNumber: serialNumber, // HTTP头Wechatpay-Serial 证书序列号 14 signature: signature, // HTTP头Wechatpay-Signature 签名 15 apiSecret: '{api_v3_key}', // APIv3密钥 16 certificates: certificates, // 微信证书列表 17} 18const result = wechatPay.verify(verifyParams);
1const decryptedDataText = wechatPay.decryptAesGcm({ 2 ciphertext: '{resource.ciphertext}', // 密文 3 associatedData: '{resource.associated_data}', // 附加数据 4 nonce: '{resource.nonce}', // 随机串 5 apiV3Key: '{api_v3_ke}', // APIv3密钥 6})
分类 | 接口名称 | 函数名 |
---|---|---|
基础支付 | JSAPI下单 | prepayJsapi |
基础支付 | H5下单API | prepayH5 |
基础支付 | APP下单API | prepayApp |
基础支付 | Native下单API | prepayNative |
基础支付 | 微信支付订单号查询订单 | queryOrderById |
基础支付 | 商户订单号查询订单 | queryOrderByOutTradeNo |
基础支付 | 关闭订单API | closeOrder |
基础支付 | 申请退款API | createRefund |
基础支付 | 查询单笔退款API | queryRefundByOutRefundNo |
基础支付 | 申请交易账单API | tradeBill |
基础支付 | 申请资金账单API | fundFlowBill |
基础支付 | 下载账单API | downloadBill |
其他能力 | 微信支付平台证书 - 获取平台证书 | getCertificates |
分类 | 接口名称 | 函数名 |
---|---|---|
基础支付 | JSAPI下单 | prepayJsapi |
基础支付 | H5下单API | prepayH5 |
基础支付 | APP下单API | prepayApp |
基础支付 | Native下单API | prepayNative |
基础支付 | 微信支付订单号查询订单 | queryOrderById |
基础支付 | 商户订单号查询订单 | queryOrderByOutTradeNo |
基础支付 | 关闭订单API | closeOrder |
基础支付 | 申请退款API | createRefund |
基础支付 | 查询单笔退款API | queryRefundByOutRefundNo |
基础支付 | 申请交易账单API | tradeBill |
基础支付 | 申请资金账单API | fundFlowBill |
基础支付 | 下载账单API | downloadBill |
基础支付 | 申请单个子商户资金账单 | subMerchantFundFlowBill |
其他能力 | 微信支付平台证书 - 获取平台证书 | getCertificates |
1import { objToQueryString } from "wechat-pay-nodejs/lib/utils"; 2 3/** 4 * 分账结果 5 */ 6type QueryProfitSharingOrderResult = { 7 transaction_id: string, // 微信订单号 8 out_order_no: string, // 商户分账单号 9 order_id: string, // 微信分账单号 10 state: string, // 分账单状态 11 receivers: { 12 amount: number, // 分账金额 13 description: string, // 分账描述 14 type: string, // 分账接收方类型 15 account: string, // 分账接收方账号 16 result: string, // 分账结果 17 fail_reason: string, // 分账失败原因 18 detail_id: string, // 分账明细单号 19 create_time: string, // 分账创建时间 20 finish_time: string, // 分账完成时间 21 }[], // 分账接收方列表 22} 23 24/** 25 * 查询分账结果API 26 * @param transactionId 微信订单号 27 * @param outOrderNo 商户分账单号 28 */ 29async queryProfitSharingOrder(transactionId: string, outOrderNo: string) : Promise<BaseResponse<QueryProfitSharingOrderResult>>{ 30 let apiUrl = `/v3/profitsharing/orders/${outOrderNo}`; 31 32 const params = { 33 transaction_id: transactionId 34 } 35 36 apiUrl = apiUrl + objToQueryString(params) 37 38 // 接口请求 39 const result = await wechatPay.callApi<QueryProfitSharingOrderResult>({ 40 method: HttpMethod.GET, 41 apiUrl 42 }) 43}
No vulnerabilities found.
No security vulnerabilities found.