公众账号ID
仿真模式开关
密钥
测试用验签密钥
商户号
证书
授权码查询 OpenId
pay.authCodeToOpenId({
auth_code: "120061098828009406"
});
拉取订单评价数据
pay.batchQueryComment({
begin_time: "20170724000000",
end_time: "20170725000000",
offset: 0
});
拼接路径
生成 FetchOptions 数据
下载对账单
pay.downloadBill({
bill_date: "20140603",
bill_type: "ALL"
});
下载资金账单
pay.downloadFundFlow({
bill_date: "20140603",
account_type: "Basic",
tar_type: "GZIP"
});
获取私钥
提交刷卡支付
pay.microPay({
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.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",
user_ip: "8.8.8.8",
trades: `!CDATA[
[
{
out_trade_no: "out_trade_no_test_1",
begin_time: "20160602203256",
end_time: "20160602203257",
state: "OK",
err_msg: ""
},
{
out_trade_no: "out_trade_no_test_2",
begin_time: "20160602203260",
end_time: "20160602203262",
state: "FAIL",
err_msg: "SYSTEMERROR"
}
]
];`
});
撤销订单
pay.reverse({
transaction_id: '1009660380201506130728806387'
})
pay.reverse({
out_trade_no: '120061098828009406'
})
仿真模式开关
短链接转换
pay.shortURL({
long_url:
"weixin://wxpay/bizpayurl?sign=XXX&appid=XX&mch_id=XX&product_id=XX&time_stamp=XX&nonce_str=XX"
});
校验 sign
Generated using TypeDoc
刷卡支付
const pay = new PubScanPay({ appId: "wxb80e5bddb2d804f3", key: "6Q9VX4N3WTBM9G9XBL7H1L9PB9ANHLY7", mchId: "1434712502", pfx: fs.readFileSync(path.resolve(__dirname, "cert.p12")) });
https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_1