node-weixin-pay
Weixin 支付 API
支持QQ群:39287176
Install
$ npm install --save-exact node-weixin-pay
Usage
通用功能
1、初始化对象与基本数据
var nodeWeixinPay = ;var nodeWeixinConfig = ; // 必须var merchant = id: processenvMERCHANT_ID || 'id' key: processenvMERCHANT_KEY || 'key';var app = id: processenvAPP_ID || 'appid' secret: processenvAPP_SECRET || 'appsecret' token: processenvAPP_TOKEN || 'apptoken'; // 证书是可选的,但在退款,红包,企业支付时需要 var certificate = pkcs12: path //格式是文件名 key: StringcertKey; //或者 var certificate = pfx: confmerchant_pfx 'base64' //格式是文件二进制内容 pfxKey: confmerchant_id; //对于大部分的支付接口来说是需要config的var config = app: app merchant: merchant // 可选(除了退款外接口,可以不用添加) certificate: certificate; //校验数据的正确性nodeWeixinConfigapp;nodeWeixinConfigmerchant; var params = openid: processenvOPENID spbill_create_ip: '1.202.241.25' notify_url: 'http://wx.domain.com/weixin/pay/main' body: '测试支付' out_trade_no: '111' total_fee: '1' trade_type: 'JSAPI' appid: appid mch_id: merchantid nonce_str: 'XjUw56N8MjeCUqHCwqgiKwr2CJVgYUpe' ;
2、签名一个请求
var sign = nodeWeixinPay;
3、准备一个支付配置
var id = 'id';var config = nodeWeixinPay;
处理微信回调接口API
1、处理回调数据,所有的请求的处理结果回调
//req.rawBody should be enabledvar req = rawBody: xml;var res = { };nodeWeixinPaycallback;
基础API
1、发送统一支付请求
nodeWeixinPayapiorder;
2、发送订单查询请求
var config = nodeWeixinPayapi;
3、发送订单关闭请求
var config = nodeWeixinPayapi;
4、发送创建退款请求
var config = nodeWeixinPayapirefund;
5、发送退款查询请求
var config = nodeWeixinPayapirefund;
6、发送下载对账单请求
var config = nodeWeixinPayapi;
7、发送测速报告请求
var config = nodeWeixinPayapi;
微信红包接口
1、发起普通微信红包
var config = nodeWeixinPayapiredenvelope;
2、发起裂变微信红包
var config = nodeWeixinPayapiredenvelope;
3、发起红包查询
var config = nodeWeixinPayapiredenvelope;
企业付款接口
1、发起企业支付
var config = nodeWeixinPayapienterprise;
2、查询企业支付
var config = nodeWeixinPayapienterprise;
License
Apache-2.0 © calidion