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

@llcl/nest-wxpay

v1.0.0

Published

一款可以实现微信支付功能的nestjs模块, 支持商户平台证书、商户微信支付公钥验证签名

Downloads

161

Readme

声明

本仓库功能基于 https://github.com/jaques-tino/nest-wxpay

nestjs 微信支付

支持商户平台证书、商户微信支付公钥验证签名

安装

npm i --save @llcl/nest-wxpay
yarn add @llcl/nest-wxpay

注册模块

import { Module } from "@nestjs/common";
import { WechatModule } from "@llcl/nest-wxpay";

@Module({
  imports: [
    WechatModule.register({
      appid: "公众号的appid",
      mchid: "微信支付商户号",
      serial_no: "商户API证书序列号",
      privateKey: "商户API证书私钥",
      apiv3Key: "apiv3密钥",
      pubKey: "商户微信支付公钥", // 可选 商户微信支付公钥如果不为空则使用公钥验签,没有则用平台证书验签
    }),
  ],
})
// 或者
@Module({
  imports: [
    WechatModule.registerAsync({
      global: true,
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => {
        return {
          appid: configService.get<string>("公众号的appid"),
          mchid: configService.get<string>("微信支付商户号"),
          serial_no: configService.get<string>("商户API证书序列号"),
          privateKey: Buffer.from(configService.get<string>("商户API证书私钥")),
          apiv3Key: configService.get<string>("apiv3密钥"),
          pubKey: "商户微信支付公钥", // 可选 商户微信支付公钥如果不为空则使用公钥验签,没有则用平台证书验签
        };
      },
    }),
  ],
})
export class AppModule {}

发起jsapi支付

import { WechatService } from "@llcl/nest-wxpay";

// ...省略
async crateWxPay(params: CreateWechatPreOrder) {
  const { prepay_id } = await this.wechatService.createJsapiOrder({
    amount: { total: amount, currency: 'CNY' },
    description: '描述',
    notify_url: '支付回调地址',
    out_trade_no: '交易号',
    payer: { openid: '用户openid' },
    attach: '附加数据',
  });
  ...
}
// ...省略

支付注册回调验签

import { WechatService } from "@llcl/nest-wxpay;

// ...省略
const {
  "wechatpay-nonce": nonce_str,
  "wechatpay-signature": signature,
  "wechatpay-timestamp": timestamp,
  "wechatpay-serial": serial_no,
} = headers;
// 支持商户平台证书、商户微信支付公钥验证签名
const isVerify = await this.wechatService.verifySign({
  timestamp: Number(timestamp),
  nonce_str,
  requestBody: JSON.stringify(body),
  signature,
  serial_no,
});
if (!isVerify) return res.status(400).send({ code: "FAIL", message: "失败" });
// ...省略