公众账号ID
仿真模式开关
密钥
测试用验签密钥
商户号
证书
授权码查询 OpenId
pay.authCodeToOpenId({
auth_code: "120061098828009406"
});
拉取订单评价数据
pay.batchQueryComment({
begin_time: "20170724000000",
end_time: "20170725000000",
offset: 0
});
关闭订单
pay.closeOrder({
out_trade_no: '120061098828009406'
})
拼接路径
生成 FetchOptions 数据
下载对账单
pay.downloadBill({
bill_date: "20140603",
bill_type: "ALL"
});
下载资金账单
pay.downloadFundFlow({
bill_date: "20140603",
account_type: "Basic",
tar_type: "GZIP"
});
查询红包记录
pay.getHbInfo({
mch_billno: "10000098201411111234567890"
});
获取私钥
获取RSA加密公钥
pay.getPublicKey({
sign_type: SignType.MD5
});
查询企业付款到零钱
pay.getTransferInfo({
partner_trade_no: "10000098201411111234567890"
});
提交刷卡支付
pay.microPay({
device_info: "013467007045764",
body: "深圳腾大- QQ公仔",
out_trade_no: "1217752501201407033233368018",
total_fee: 888,
spbill_create_ip: "8.8.8.8",
auth_code: "120061098828009406"
});
查询订单
pay.orderQuery({
transaction_id: '1009660380201506130728806387'
})
pay.orderQuery({
out_trade_no: '120061098828009406'
});
企业付款到银行卡
pay.payBank({
partner_trade_no: "1212121221227",
enc_bank_no: utils.rsa(pemKey, "6225760017946512"),
enc_true_name: utils.rsa(pemKey, "王小王"),
bank_code: "1001",
amount: 100,
desc: "理财"
});
// pemKey 通过 `pay.getPublicKey` 获取
支付结果通知
router.post("/wechatpay/notify/refund", (req, res) => {
getXMLBody(req, options).then(data => {
pay
.payNotify(data, async parsedData => {
// ...
return {
return_code: "SUCCESS",
return_msg: "OK"
};
})
.then(returnData => {
res.set("Content-Type", "application/xml; charset=utf-8");
res.end(returnData);
});
});
});
查询企业付款到银行卡
pay.queryBank({
partner_trade_no: "1212121221227"
});
查询代金券批次
pay.queryCouponStock({
coupon_stock_id: "1757"
});
查询代金券信息
pay.queryCouponsInfo({
coupon_id: "1565",
openid: "onqOjjrXT-776SpHnfexGm1_P7iE",
stock_id: "58818"
});
申请退款
pay.refund({
out_trade_no: '1217752501201407033233368018',
out_refund_no: '1217752501201407033233368019',
total_fee: 100,
refund_fee: 80
});
退款结果通知处理
router.post("/wechatpay/notify/refund", (req, res) => {
getXMLBody(req, options).then(data => {
pay
.refundNotify(data, async parsedData => {
if (!pay.verifySign(parsedData)) {
// 签名校验失败
}
if (parsedData.result_code === "FAIL") {
// 业务逻辑失败
}
// ...
return {
return_code: "SUCCESS",
return_msg: "OK"
};
})
.then(returnData => {
res.set("Content-Type", "application/xml; charset=utf-8");
res.end(returnData);
});
});
});
查询退款
pay.refundQuery({
transaction_id: '1009660380201506130728806387'
});
pay.refundQuery({
out_trade_no: '120061098828009406'
});
交易保障
pay.report({
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"
});
撤销订单
pay.reverse({
transaction_id: '1009660380201506130728806387'
})
pay.reverse({
out_trade_no: '120061098828009406'
})
发放代金券
pay.sendCoupon({
coupon_stock_id: "1757",
openid_count: 1,
partner_trade_no: "1000009820141203515766",
openid: "onqOjjrXT-776SpHnfexGm1_P7iE"
});
发放裂变红包
pay.sendGroupGroupRedPack({
mch_billno: "10000098201411111234567890",
send_name: "天虹百货",
re_openid: "oxTWIuGaIt6gTKsQRLau2M0yL16E",
total_amount: 1000,
total_num: 1,
wishing: "红包祝福语",
act_name: "猜灯谜抢红包活动",
remark: "猜越多得越多,快来抢!"
});
发放普通红包
pay.sendRedPack({
mch_billno: "10000098201411111234567890",
send_name: "天虹百货",
re_openid: "oxTWIuGaIt6gTKsQRLau2M0yL16E",
total_amount: 1000,
total_num: 1,
wishing: "红包祝福语",
client_ip: "192.168.0.1",
act_name: "猜灯谜抢红包活动",
remark: "猜越多得越多,快来抢!"
});
仿真模式开关
短链接转换
pay.shortURL({
long_url:
"weixin://wxpay/bizpayurl?sign=XXX&appid=XX&mch_id=XX&product_id=XX&time_stamp=XX&nonce_str=XX"
});
企业付款到零钱
pay.transfers({
partner_trade_no: "10000098201411111234567890",
openid: "oxTWIuGaIt6gTKsQRLau2M0yL16E",
check_name: "FORCE_CHECK",
amount: 10099,
desc: "理赔",
spbill_create_ip: "192.168.0.1"
});
统一下单
pay.unifiedOrder({
trade_type: "APP",
body: "腾讯充值中心-QQ会员充值",
out_trade_no: "1217752501201407033233368018",
total_fee: 888,
spbill_create_ip: "8.8.8.8",
notify_url: "https://example.com/wechatpay/notify"
});
校验 sign
Generated using TypeDoc
总和类,糅合所有接口
const pay = new Pay({ appId: "wxb80e5bddb2d804f3", key: "6Q9VX4N3WTBM9G9XBL7H1L9PB9ANHLY7", mchId: "1434712502", pfx: fs.readFileSync(path.resolve(__dirname, "cert.p12")) });