From a1696c2d0b8336b85af9f7c8024769be37f793ce Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 10 Mar 2026 07:13:36 -0500 Subject: [PATCH] 's' --- app/api/pay/route.ts | 10 +++++++++- app/page.tsx | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/api/pay/route.ts b/app/api/pay/route.ts index e219b8a..091fe8b 100644 --- a/app/api/pay/route.ts +++ b/app/api/pay/route.ts @@ -104,7 +104,15 @@ export async function POST(request: NextRequest) { const payConfig = getPaymentConfig(); const apiUrl = payConfig.apiUrl.replace(/\/$/, ""); - const user_id = String(body?.user_id || "").trim(); + let user_id = String(body?.user_id || "").trim(); + if (user_id.startsWith("{") && user_id.includes("data")) { + try { + const parsed = JSON.parse(user_id) as { data?: string }; + if (parsed?.data) user_id = String(parsed.data).trim(); + } catch { + /* ignore */ + } + } const return_url = String(body?.return_url || "").trim(); const total_fee = Number(body?.total_fee) || 180; const type = String(body?.type || "vip"); diff --git a/app/page.tsx b/app/page.tsx index 6b67087..eb89b84 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -84,6 +84,17 @@ export default function Home() { const getOrCreateUserId = useCallback(() => { let userId = getStorage("userId"); + if (userId?.startsWith("{") && userId.includes("data")) { + try { + const parsed = JSON.parse(userId) as { data?: string }; + if (parsed?.data) { + userId = parsed.data; + setStorage("userId", userId); + } + } catch { + userId = null; + } + } if (!userId) { userId = `user${Date.now()}`; setStorage("userId", userId);