我在调试的时候发起的微信支付,在开发工具出现扫码弹窗后,取消了微信支付。然后我重云开发集合中删除了相关订单,也没有调用CloudPay.closeOrder()关闭订单。这种情况下,支付成功的回调函数会不断执行吗?如果是不断执行,如何解决这个问题。基本几分钟就调用一次。
const cloud = require("wx-server-sdk");
const TcbRouter = require("tcb-router");
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV,
});
exports.main = async (event, context) => {
const { type = "Default" } = JSON.parse(event.attach) || {};
event.$url = type;
const wxContext = cloud.getWXContext();
const app = new TcbRouter({ event });
const db = cloud.database();
const _ = db.command;
const $ = db.command.aggregate;
const createAt = db.serverDate();
const { outTradeNo: order_id, subMchId, resultCode } = event;
app.use(async (ctx, next) => {
ctx.data = {};
await next();
});
if (resultCode === "SUCCESS" && type !== "Default") {
const database = type === "Paying" ? "Order" : "StoredValue";
app.router(["Paying", "StoredValue"], async (ctx, next) => {
try {
const userCollection = db.collection(database);
const result = await userCollection
.where({
_id: order_id,
})
.update({
data: {
status: "Success",
},
});
ctx.body = { data: { errcode: 0, status: result.stats } };
} catch (error) {
ctx.body = { data: { errcode: 0, error: error.message } };
}
});
}
app.router("Default", async (ctx, next) => {
ctx.body = { data: { errcode: 0 } };
});
return app.serve();
};
https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_11.shtml