谢谢,现在没有超时问题了,可是我写入的退款结果通知url并没有起作用,这是怎么回事呢,也是根据官方demo的支付成功通知改的
router.post('/pay-callback', wxpay.useWXCallback((msg, req, res, next) => {
// 处理商户业务逻辑
validateSign(msg);
const {
result_code,
err_code,
err_code_des,
out_trade_no,
time_end,
transaction_id,
bank_type,
} = msg;
new AV.Query(Order).equalTo('tradeId', out_trade_no).first({
useMasterKey: true,
}).then(order => {
if (!order) throw new Error(`找不到订单${out_trade_no}`);
if (order.status === 'SUCCESS') return;
return order.save({
status: result_code,
errorCode: err_code,
errorCodeDes: err_code_des,
paidAt: formatTime(time_end),
transactionId: transaction_id,
bankType: bank_type,
}, {
useMasterKey: true,
});
}).then(() => {
res.success();
}).catch(error => res.fail(error.message));
}));
router.post('/refund-callback', wxpay.useWXCallback((msg, req, res, next) => {
console.log('退款成功后返回信息',msg)
// 处理商户业务逻辑
validateSign(msg);
const {
result_code,
err_code,
err_code_des,
out_trade_no,
time_end,
transaction_id,
bank_type,
} = msg;
new AV.Query(Refund).equalTo('transaction_id', transaction_id).first({
useMasterKey: true,
}).then(refund => {
if (!refund) throw new Error(`找不到订单${out_trade_no}`);
if (refund.status === 'SUCCESS') return;
return refund.save({
status: result_code,
errorCode: err_code,
errorCodeDes: err_code_des,
paidAt: formatTime(time_end),
transactionId: transaction_id,
bankType: bank_type,
}, {
useMasterKey: true,
});
}).then(() => {
res.success();
}).catch(error => res.fail(error.message));
}));