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

sfpay

v1.1.2

Published

sfpay

Downloads

14

Readme

sfpay

An async/await version of sfpay.

Installation

npm install sfpay

Usage

扫码支付

import SFPay from 'sfpay';

const sfPay = new SFPay({
    key: 'xxxxxxxxxxxxxxxxxxxx',
    spId: 'xxxx',
    muchId: 'xxxxxxxxxxxxxxxxx'
});

function async sPay() {
    const result = await sfPay.sPay({
        out_trade_no: `20170104${Math.random().toString().substr(2, 10)}`,
        body: '扫码支付测试',
        total_fee: 100,
        mch_create_ip: '127.0.0.1',
        notify_url: 'http://127.0.0.1/order/api/notify',
        time_start: '201612310629',
        time_expire: '201612310829',
        goods_tag: 'mj',
        product_id: 'qr1001'
    });
    console.log(`result:${JSON.stringify(result)}`);
}

订单查询

function async tradeQry() {
    const result = await sfPay.tradeQry({ out_trade_no: "xxxxxx" });
    console.log(`result:${JSON.stringify(result)}`);
}

退款

function async rfd() {
    const result = await sfPay.rfd({
        out_trade_no: 'xxxxxxxxxxxxxxxxxxxx',
        out_refund_no: 'xxxxxxxxxxxxxxxxxxxx',
        total_fee: 100,
        refund_fee: 100,
        refund_channel: 'BALANCE'
    });
    console.log(`result:${JSON.stringify(result)}`);
}

退款查询

function async rfdq() {
    const result = await sfPay.rfdq({
        out_trade_no: 'xxxxxxxxxxxxxxxxxxxx'
    });
    console.log(`result:${JSON.stringify(result)}`);
}

商户自助注册

商户自助注册

function async reg() {
    // 商户自助注册在 new SFPay() 的时候 muchId 参数可不传或者值为空
    const params = {
        mcht_name: 'xxxxxxxxxxx公司',
        mcht_short_name: 'xxxx',
    	address: 'xxxxxxxxxxxxxxxxxxxx',
    	leg_name: 'xxx',
    	leg_phone: 'xxxxxxxxxxxxx',
    	leg_email: 'xxxxxxxxxxxxxxxxxxx',
    	acc_no: 'xxxxxxxxxxxxxxxxxx',
    	acc_bank_name: 'xxxxxxxxxxxxxxxxxxxx',
    	acc_bank_no: 'xxxxxxxxxxxxxxxxx',
    	service_tel: 'xxxxxxxxxxxxxxxxxxx',
    	id_type: 'xxxxxxxxxxxxxxxxxx',
    	id_no: 'xxxxxxxxxxxxxxxxxxxx',
    	settle_cycle: 'xxxxxxxxxx',
    	settle_type: 'xxxxxxxxxxxxxxx',
    	settle_rate: 0,
    	extra_rate_type: 'xxxxxxxxxxxx',
    	extra_rate: 0
    };
    const result = await sfPay.reg(params);
    console.log(`result:${JSON.stringify(result)}`);
}

条码支付

条码支付

function async mPay() {
    const result = await sfPay.mPay({
        out_trade_no: `20170103${Math.random().toString().substr(2, 10)}`,
        body: '测试条码支付',
        total_fee: 1,
        mch_create_ip: '127.0.0.1',
        auth_code: 'xxxxxx',
        time_start: '20170103104500',
        time_expire: '20170103160000',
        goods_tag: 'coupon'
    });
    console.log(`result:${JSON.stringify(result)}`);
}

公众号支付 (JS API)

公众号支付

function async jPay() {
    const result = await sfPay.jPay({
        out_trade_no: `20170103${Math.random().toString().substr(2, 10)}`,
        wx_appid: 'xxxxxxxxxxxxxxxx',
        openid: 'xxxxxxxxxxxxxxxxxxxxx',
        body: '测试jsAPI支付',
        total_fee: 100,
        mch_create_ip: '127.0.0.1',
        notify_url: 'http://xxxxxxxxxxxxx/order/api/notify',
        goods_tag: 'coupon'
    });
    console.log(`result:${JSON.stringify(result)}`);
}

网页端调起支付API

function onBridgeReady(){
   WeixinJSBridge.invoke(
       'getBrandWCPayRequest', {
           "appId" : "wx2421b1c4370ec43b",     //公众号名称,由商户传入
           "timeStamp":" 1395712654",         //时间戳,自1970年以来的秒数
           "nonceStr" : "e61463f8efa94090b1f366cccfbbb444", //随机串
           "package" : "prepay_id=u802345jgfjsdfgsdg888",
           "signType" : "MD5",         //微信签名方式:
           "paySign" : "70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名
       },
       function(res){
           if(res.err_msg == "get_brand_wcpay_request:ok" ) {}     // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回    ok,但并不保证它绝对可靠。
       }
   );
}
if (typeof WeixinJSBridge == "undefined"){
   if( document.addEventListener ){
       document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
   }else if (document.attachEvent){
       document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
       document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
   }
}else{
   onBridgeReady();
}