npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wxpay.js

v0.0.3

Published

WXPay Node.js SDK

Readme

微信支付 Node.js SDK

微信支付开发者文档中给出的API进行了封装。

WXPay类下提供了对应的方法:

|方法名 | 说明 | |--------|--------| |microPay| 刷卡支付 | |unifiedOrder | 统一下单| |orderQuery | 查询订单 | |reverse | 撤销订单 | |closeOrder|关闭订单| |refund|申请退款| |refundQuery|查询退款| |downloadBill|下载对账单| |report|交易保障| |shortUrl|转换短链接| |authCodeToOpenid|授权码查询openid|

各个方法都以Promise的形式实现。

参数为JS对象,返回类型也是JS对象。 方法内部会将参数会转换成含有appidmch_idnonce_strsign的XML格式数据; 通过HTTPS请求得到返回数据后会对其做必要的处理(例如验证签名,签名错误则抛出异常)。

对于downloadBill,无论是否成功都返回JS对象,且都含有return_codereturn_msg。 若成功,其中return_codeSUCCESS,另外data对应对账单数据。

安装

$ npm install wxpay.js --save

示例

以统一下单为例:

'use strict';

var fs = require('fs');
var WXPay = require('wxpay.js').WXPay;
var WXPayConstants = require('wxpay.js').WXPayConstants;

var APPID = 'wx8888888888',
    MCHID = '8888888',
    KEY = '8888888888888888888888888888888',
    CERT_FILE_CONTENT = fs.readFileSync('/path/to/apiclient_cert.p12'),
    CA_FILE_CONTENT = fs.readFileSync('/path/to/rootca.pem'),
    TIMEOUT = 10000; // 毫秒
    
var wxpay = new WXPay({
  appId: APPID,
  mchId: MCHID,
  key: KEY,
  certFileContent: CERT_FILE_CONTENT,
  caFileContent: CA_FILE_CONTENT,
  timeout: TIMEOUT,
  signType: WXPayConstants.SIGN_TYPE_HMACSHA256,  // 使用 HMAC-SHA256 签名,也可以选择  WXPayConstants.SIGN_TYPE_MD5
  useSandbox: false   // 不使用沙箱环境
});


var reqObj = {
  body: '商城-商品1',
  out_trade_no: '1478582754970',
  total_fee: 1,
  spbill_create_ip: '123.12.12.123',
  notify_url: 'http://www.example.com/wxpay/notify',
  trade_type: 'NATIVE'
};

wxpay.unifiedOrder(reqObj).then(function(respObj) {
  console.log(respObj);
}).catch(function(err) {
  console.log(err);
});

License

BSD