node-weixin-pay
Weixin Pay functions for node
支持QQ群:39287176
Install
$ npm install --save 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请求部分
4、发送统一支付请求
nodeWeixinPayapiorder;
5、发送订单查询请求
var config = nodeWeixinPayapi;
6、发送订单关闭请求
var config = nodeWeixinPayapi;
7、发送创建退款请求
var config = nodeWeixinPayrefund;
8、发送退款查询请求
var config = nodeWeixinPayrefund;
9、发送下载对账单请求
var config = nodeWeixinPay;
10、发送测速报告请求
var config = nodeWeixinPay;
处理微信回调
10、外理回调数据
//req.rawBody should be enabledvar req = rawBody: xml;var res = { };nodeWeixinPaycallback;
License
Apache-2.0 © calidion