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 🙏

© 2024 – Pkg Stats / Ryan Hefner

wx-pay-h5

v1.0.0

Published

1. 安装依赖包: 、、、 npm install wx-pay-h5 、、、 2. 导入 import * as weixinPay(You can use the alias name you want) from 'wx-pay-h5';

Downloads

3

Readme

该项目为微信H5支付的Demo,使用微信官方提供的JSAPI(jweixin-1.6.0.js版本)进行支付,实现了微信支付的基本功能。

微信官方文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#3

使用方法:

  1. 安装依赖包: 、、、 npm install wx-pay-h5 、、、

  2. 导入 import * as weixinPay(You can use the alias name you want) from 'wx-pay-h5';

  3. 使用

const resultWxPay = await weixinPay.pay(config,paymentParams);//接收微信支付结果

config为微信支付的配置信息,paymentParams为支付参数,具体参数请参考微信官方文档。 config示例:

const config = {
    debug: true,// 开启调试模式,调用的所有api的返回值会在console.log中打印,仅在pc端时才会打印。
    appId: 'wx1234567890abcdef',// 微信公众号appid
    timestamp: 1564666666,// 时间戳
    nonceStr: 'abcdefg',// 随机字符串
    signature: '1234567890abcdefg',// 签名
};

parmentParams示例:

const paymentParams = {
    timeStamp: '1564666666',
    nonceStr: 'abcdefg',
    package: 'wx2345678901234567890abcdefg',
    paySign: '1234567890abcdefg',
};

返回结果: 根据后端返回的结果,微信支付的结果会在回调函数中返回。

注意事项:

  • 请确保微信公众号已经开通微信支付功能。并且在微信公众号后台设置好支付授权目录。确保微信公众号已经绑定微信支付商户号。并且在微信支付商户平台设置好支付通知地址

  • 该支付只能在微信内置浏览器中使用。暂未开通其他浏览器微信扫码支付功能。

  • 参考官网确定jweixin-1.6.0.js版本是对应的,不同版本可能有不同接口,请注意版本兼容。

  • 请确保config和paymentParams参数正确,否则可能导致支付失败。

  • 获取config和paymentParams里面参数时,请注意和后端协调,拿到对应的参数。

  • 请确保后端接口正确返回微信支付结果,否则可能导致支付失败。调试时,可以选择是否开启微信支付的调试模式,可以看到微信支付的详细信息。