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

wxpay-sdk

v1.1.1

Published

wxpay sdk 微信支付 微信

Downloads

3

Readme

##微信支付-公众号JSAPI支付 在第三方的页面上通过jsapi调用微信支付需要现在后台调用统一下单接口进行下单。此处的SDK封装了此过程 调用者只需要在后台如下方式调用

var wxPaySDKInstance = new WXPaySDK(wxAppId, mchId, mchKey);
wxPaySDKInstance.doOrder({
	openid: 'openid',
	body: '购买xxx商品',
	total_fee: 1, // 下单金额’分为单位
	notify_url: 'https://youdomain/xxx.php', // 支付成功后的回调地址,用来通知用户
	outtrade_no: '3234324234' // 商户自己的订单id
}, function (err, ret) {
	// 这里处理下单成功后的回调
})

##微信支付-刷卡支付SDK
对微信官方提供的刷卡支付api进行了封装,目前暴漏了支付、撤销、查询3个接口给业务代码。极大的降低了商户接入微信扫码支付的门槛

##哪些场景适合用刷卡(被扫)支付,看如下步骤

* 步骤1:用户选择被扫支付付款并打开微信,进入“我”->“钱包”->“刷卡”条码界面(如图5.1所示);
* 步骤2:收银员在商户系统操作生成支付订单,用户确认支付金额;
* 步骤3:商户收银员用扫码设备扫描用户的条码/二维码,商户收银系统提交支付;
* 步骤4:微信支付后台系统收到支付请求,根据验证密码规则判断是否验证用户的支付密码,不需要验证密码的交易直接发起扣款,需要验证密码的交易会弹出密码输入框(如图5.2所示)。支付成功后微信端会弹出成功页面(如图5.3所示),支付失败会弹出错误提示。

进入微信刷卡界面

![进入微信刷卡界面](http://cos.myqcloud.com/1000371/img_list/cover/1bd7d460b4b948a1e443154ee7c23efe.jpg)

输入支付密码,小额支付免输入密码

![输入支付密码](http://cos.myqcloud.com/1000371/img_list/cover/9895012eb95332d21f06aaf73fd7df78.jpg)

支付完成

![支付完成](http://cos.myqcloud.com/1000371/img_list/cover/2522a8c6b55e609f8f7e6b20f1879b77.jpg)


##SDK有哪些功能?

* 实现扫码支付,通过扫描用户手机的条码或者二维码提交被扫支付请求
* 从微信支付后台查询某单的支付状态
* 撤销某一个订单

##将SDK引入到你的项目中

```javascript
npm install wxpay-sdk --save

##调用示例

var wxPaySDKInstance = new WXPaySDK(wxAppId, mchId, mchKey);

// 发起一笔被扫支付 ,参数请参考微信支付被扫支付api文档
wxPaySDKInstance.pay(data, callback);

// 查询被扫支付订单信息,
// {transaction_id: 111, out_trade_no: 111}
wxPaySDKInstance.query(query, callback);

// 发起一笔撤销,对某个订单进行撤销
wxPaySDKInstance.reverse(data, callback);

##更多功能 http://mch.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_5

##有问题反馈 在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流

##捐助开发者 如果你觉得SDK对你的编码有帮助并且您诚心的认可我,那么你可以随意打赏一下作者。

微信扫描