公众账号ID
仿真模式开关
密钥
测试用验签密钥
商户号
证书
拼接路径
签约,解约结果通知
router.post("/wechatpay/notify/contract", (req, res) => {
getXMLBody(req, options).then(data => {
pay
.contractNotify(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);
});
});
});
生成 FetchOptions 数据
申请解约
pay.deleteContract({
contract_id: "120061098828009406",
contract_termination_remark: "解约原因"
});
pay.deleteContract({
plan_id: "123",
contract_code: "1023658866",
contract_termination_remark: "解约原因"
});
下载对账单
pay.downloadBill({
bill_date: "20140603",
bill_type: "ALL"
})
获取私钥
查询订单
pay.papOrderQuery({
transaction_id: '1009660380201506130728806387'
})
pay.papOrderQuery({
out_trade_no: '120061098828009406'
})
申请扣款
pay.papPayApply({
body: "水电代扣",
out_trade_no: "1217752501201407033233368018",
total_fee: 888,
spbill_create_ip: "8.8.8.8",
notify_url: "https://example.com/wechatpay/pap/notify",
contract_id: "Wx15463511252015071056489715"
});
扣款结果通知
router.post("/wechatpay/notify/refund", (req, res) => {
getXMLBody(req, options).then(data => {
pay
.papPayNotify(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.queryContract({
contract_id: "120061098828009406"
});
pay.queryContract({
plan_id: 123,
contract_code: "1023658866"
});
申请退款
pay.refund({
out_trade_no: '1217752501201407033233368018',
out_refund_no: '1217752501201407033233368019',
total_fee: 100,
refund_fee: 80
})
查询退款
pay.refundQuery({
transaction_id: '1009660380201506130728806387'
})
pay.refundQuery({
out_trade_no: '120061098828009406'
})
仿真模式开关
校验 sign
Generated using TypeDoc
微信代扣基类
https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=17_2