This commit is contained in:
eric
2026-03-10 07:13:36 -05:00
parent 585be56314
commit a1696c2d0b
2 changed files with 20 additions and 1 deletions

View File

@@ -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");

View File

@@ -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);