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

easy-wechat-pay

v1.0.1

Published

A plugin to make wechat pay easy

Downloads

1

Readme

How to install ?

npm install easy-wechat-pay --save

How to use ?

Base config , just need to write once

const wxPay = require('easy-wechat-pay');
const testConfig = {
    appid: '',      //replace by your appid
    mch_id: '',     //replace by your merchant id
    signKey: ''     //replace by your pay sign key
}
wxPay.publicPay.setBaseConfig(
    testConfig.appid,
    testConfig.mch_id,
    testConfig.signKey
);

The following example only shows the parameters that must be filled in. Please refer to the official documentation for parameter types and values. Official documentation


Unified order

let postData = {
    body: '',
    out_trade_no: '',
    total_fee: 1,
    notify_url: '',
    openid: ''
};
wxPay.publicPay.unifiedorder(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Order query

//You need choose one between 'transaction_id' and 'out_trade_no'

let postData = {
    out_trade_no: '100000000001'
};
wxPay.publicPay.orderquery(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Close order

let postData = {
    out_trade_no: ''
};
wxPay.publicPay.closeorder(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Refund

 let postData = {
    out_trade_no: '',
    out_refund_no: '',
    total_fee: 1,
    refund_fee: 1,
};
wxPay.publicPay.refund(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Refund query

// You need to choose one of the following options.
['out_trade_no', 'transaction_id', 'out_refund_no', 'refund_id']


let postData = {
    out_trade_no: '',
};
// let postData = {
//     transaction_id: '1217752501201407033233368018',
// };
// let postData = {
//     out_refund_no: '900000000001',
// };
// let postData = {
//     refund_id: '1217752501201407033233368018',
// };
wxPay.publicPay.refundquery(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Download bill

 let postData = {
    bill_date: '',
    bill_type: ''   //'ALL', 'SUCCESS', 'REFUND', 'RECHARGE_REFUND'
};
wxPay.publicPay.downloadfundflow(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Download fund flow

 let postData = {
    bill_date: '',
    account_type: ''   //'Basic', 'Operation', 'Fees'
};
wxPay.publicPay.downloadfundflow(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Report

let postData = {
    interface_url: 'https://api.mch.weixin.qq.com/pay/unifiedorder',
    execute_time: 1000,
    return_code: 'SUCCESS',
    return_msg: 'OK',
    result_code: 'SUCCESS',
    user_ip: '8.8.8.8'
};
wxPay.publicPay.report(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });

Batch query comment

let postData = {
    begin_time: '20170724000000',
    end_time: '20170725000000',
    offset: '0'
};
wxPay.publicPay.batchquerycomment(postData)
    .then((result) => {
        wxPay.utils.parseXml2Json(result.text).then((jsonResult) => {
            console.log(jsonResult.xml);
        })
    }).catch((err) => {
        console.log(err.text);
    });