我也是小白,搜了很多长链接的分享,但是都报错 (可能是我不太会用),就让 grok 针对本次活动修了一下,以下代码亲测可用。
(async function () {
console.log(":hourglass_not_done: 正在为 thinkiafr 生成法国版支付长链接…");
try {
const session = await fetch ("/api/auth/session").then((r) => r.json());
if (!session.accessToken) {
throw new Error ("无法获取 Token,请确保已登录 ChatGPT");
}
const payload = {
plan_name: "chatgptteamplan",
team_plan_data: {
workspace_name: "myWorkspace",
price_interval: "month",
seat_quantity: 2
},
billing_details: {
country: "FR",
currency: "EUR"
},
cancel_url: "https://chatgpt.com/?promoCode = thinkiafr",
promo_code: "thinkiafr",
checkout_ui_mode: "hosted"
};
const response = await fetch (
"https://chatgpt.com/backend-api/payments/checkout",
{
method: "POST",
headers: {
Authorization: `Bearer ${session.accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
}
);
const data = await response.json();
if (data.url) {
console.clear();
console.log("% c✅ 成功生成带 thinkiafr 优惠的长链接:", "color: #10a37f; font-size: 22px; font-weight: bold;");
console.log(data.url);
console.log("\n% c 直接点开支付!当前显示 €15.01(2 席位/月付)", "color: gray; font-size: 16px;");
} else {
console.error("❌ 生成失败,响应:", data);
}
} catch (e) {
console.error("❌ 执行出错:", e);
}
})();
1 个帖子 - 1 位参与者