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

@xinghe/wechat-payment-tools

v0.1.0

Published

A tool for wechat payment.

Downloads

6

Readme

wechat-payment-tools

A tool for wechat payment with SignatureRequest and XML-Object Convert .

Installation

npm install @xinghe/wechat-payment-tools

Usage

var WeChatPay = require('@xinghe/wechat-payment-tools');

var params = {
  appid: '',
  mch_id: '',
  nonce_str: WeChatPay.randomStr(),
  sign_type: 'MD5',
  ...
};

var signStr = WeChatPay.sign(params); // 签名字符串

API

  • sign

签名方法,返回签名字符串

| 参数名 | 类型 | 说明 | | --- | --- | --- | | data | Object | 待签名参数 | | secretKey | String | key为商户平台设置的密钥key |

  • filter

过滤函数,用于过滤空值,返回非空的签名参数对象

| 参数名 | 类型 | 说明 | | --- | --- | --- | | data | Object | 待签名参数对象 |

  • sort

升序排序方法,返回升序排序后key数组

| 参数名 | 类型 | 说明 | | --- | --- | --- | | keys | Array | 签名参数对象的key组成的数组 |

  • randomStr

随机字符串生成方法,返回签名随机字符串

  • md5

MD5加密方法,返回加密后的MD5字符串

| 参数名 | 类型 | 说明 | | --- | --- | --- | | unSignStr | String | 加密前的字符串 |

  • dataToArray

将Object对象转换为数组,返回[{key:value}]数组

| 参数名 | 类型 | 说明 | | --- | --- | --- | | data | Object | 加密前的字符串 |

  • objectToXml

将对象数据转换为xml格式

| 参数名 | 类型 | 说明 | | --- | --- | --- | | objArr | Array{Object} | 对象数组 |

  • xmlToObject

将xml字符串转换为对象

| 参数名 | 类型 | 说明 | | --- | --- | --- | | xmlStr | String | xml字符串 |

  • unifiedOrder

统一下单接口,返回Promise请求对象

| 参数名 | 类型 | 说明 | | --- | --- | --- | | xmlData | XMLData | xml格式参数 |

  • orderQuery

订单查询接口,返回Promise请求对象

| 参数名 | 类型 | 说明 | | --- | --- | --- | | xmlData | XMLData | xml格式参数 |

  • codeToSession

小程序获取openID接口,返回Promise请求对象

| 参数名 | 类型 | 说明 | | --- | --- | --- | | code | String | 临时凭证参数 |

  • fillZero

订单号补位方法,微信支付订单号位数不能太小,返回补位后的字符编号

| 参数名 | 类型 | 说明 | | --- | --- | --- | | id | String | 唯一编号 | | length | Number | 最小长度 |

  • strToDate

通过字符串时间格式 201902021222 转换为 Date对象

| 参数名 | 类型 | 说明 | | --- | --- | --- | | dateStr | String | 时间字符串 |