diff --git a/app/api/pay/route.ts b/app/api/pay/route.ts index d48752d..0fb638a 100644 --- a/app/api/pay/route.ts +++ b/app/api/pay/route.ts @@ -68,36 +68,130 @@ function buildPayHtml( function buildQrHtml( imgSrc: string, returnUrl: string, - orderId: string + orderId: string, + opts?: { channel?: string; successDesc?: string; confirmUrl?: string } ): string { + const ch = (opts?.channel || "wxpay").toLowerCase(); + const isWx = ch === "wxpay" || ch === "wx" || ch === "wechat"; + const title = isWx ? "微信扫码支付" : "支付宝扫码支付"; + const hint = isWx ? "请使用微信扫描下方二维码完成支付" : "请使用支付宝扫描下方二维码完成支付"; + const successDesc = opts?.successDesc || "支付成功,即将跳转"; + const confirmUrl = opts?.confirmUrl || "/api/pay/confirm"; + const esc = (s: string) => + s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c] || c); return `
-支付成功后将自动跳转
-${esc(hint)}
+等待支付中...
+