This commit is contained in:
eric
2026-03-10 08:24:08 -05:00
parent ceb951f50e
commit 095a7fb260
2 changed files with 90 additions and 12 deletions

View File

@@ -13,6 +13,9 @@ import { usePayStatusPoll } from "@/app/lib/usePayStatusPoll";
const PB_URL =
process.env.NEXT_PUBLIC_POCKETBASE_URL || "https://pocketbase.hackrobot.cn";
/** 微信内支付渠道:zpay | xorpay,改此参数即可切换 */
const WECHAT_PAY_PROVIDER: "zpay" | "xorpay" = "zpay";
/** PC/H5:form POST 到 /api/pay,有中转页,默认 zpay */
function redirectToPayZpay(params: {
user_id: string;
@@ -206,7 +209,7 @@ export default function Home() {
const device = getDeviceFromEnv(env);
const totalFee = getPaymentConfig().defaultAmount ?? 880;
const base = { user_id: userId, return_url: returnUrl, total_fee: totalFee, type: "vip", channel: "wxpay" as const };
if (device === "wechat") {
if (device === "wechat" && WECHAT_PAY_PROVIDER === "xorpay") {
payWechatXorpay(base);
} else {
redirectToPayZpay({ ...base, device });
@@ -221,10 +224,11 @@ export default function Home() {
}
}, [userName]);
// 微信 H5 支付完成后可能不跳转,轮询检测到已支付则刷新
// 微信/手机 H5 支付完成后可能不跳转,轮询检测到已支付则刷新
usePayStatusPoll(() => {
savePaidType("vip");
saveUserName(getStorage("userId") || "");
window.location.reload();
});
useEffect(() => {