Update app.js
This commit is contained in:
@@ -20,7 +20,7 @@ const COUPON_URL = `${API_BASE}/etc/coupon`; // POST {code}
|
|||||||
const CHAT_URL = `${API_BASE}/etc/chat`; // POST {message,sessionId,email}
|
const CHAT_URL = `${API_BASE}/etc/chat`; // POST {message,sessionId,email}
|
||||||
const REFERRAL_URL = `${API_BASE}/etc/referral`; // POST {referrer,friend_name,friend_email,uuid}
|
const REFERRAL_URL = `${API_BASE}/etc/referral`; // POST {referrer,friend_name,friend_email,uuid}
|
||||||
// WIZZARD=false is written via AGENT_INFO_URL (POST { uuid, key, value })
|
// WIZZARD=false is written via AGENT_INFO_URL (POST { uuid, key, value })
|
||||||
const CREDITS_URL = `${API_BASE}/payment/credits`; // POST {key}
|
const CREDITS_URL = `${API_BASE}/payment`; // hidden form POST → 302 Stripe redirect
|
||||||
const CONTRACT_EXTEND_URL = "https://derez.ai"; // ← replace with Stripe payment link
|
const CONTRACT_EXTEND_URL = "https://derez.ai"; // ← replace with Stripe payment link
|
||||||
const CONTRACT_CANCEL_URL = "https://derez.ai"; // ← replace with Stripe cancellation link
|
const CONTRACT_CANCEL_URL = "https://derez.ai"; // ← replace with Stripe cancellation link
|
||||||
|
|
||||||
@@ -880,21 +880,43 @@ function renderKeys(keys) {
|
|||||||
.join("");
|
.join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buyCredits(keyName, btn) {
|
function buyCredits(keyName, btn) {
|
||||||
btnLoad(btn, "Processing\u2026");
|
btnLoad(btn, "Redirecting\u2026");
|
||||||
try {
|
|
||||||
const res = await fetch(CREDITS_URL, {
|
const params = new URLSearchParams(window.location.search);
|
||||||
method: "POST",
|
const activeAgent = agents.find((a) => a.UUID === activeUUID);
|
||||||
headers: { "Content-Type": "application/json" },
|
const couponInput = document.getElementById("coupon-input");
|
||||||
body: JSON.stringify({ key: keyName }),
|
const coupon = couponApplied && couponInput ? couponInput.value.trim() : "";
|
||||||
});
|
|
||||||
if (!res.ok) throw new Error(`Request failed (${res.status})`);
|
const fields = {
|
||||||
toast("Credits purchase initiated!", "success");
|
product: "prod_Ufj2wCf4rhemT8",
|
||||||
} catch (err) {
|
agent: activeUUID || "",
|
||||||
toast(err.message, "error");
|
period: "",
|
||||||
} finally {
|
location: activeAgent?.server || "",
|
||||||
btnReset(btn);
|
email: currentEmail || "",
|
||||||
|
coupon,
|
||||||
|
utm_source: params.get("utm_source") || "",
|
||||||
|
utm_medium: params.get("utm_medium") || "",
|
||||||
|
utm_campaign: params.get("utm_campaign") || "",
|
||||||
|
utm_term: params.get("utm_term") || "",
|
||||||
|
utm_content: params.get("utm_content") || "",
|
||||||
|
};
|
||||||
|
|
||||||
|
const form = document.createElement("form");
|
||||||
|
form.method = "POST";
|
||||||
|
form.action = CREDITS_URL;
|
||||||
|
form.target = "_self";
|
||||||
|
|
||||||
|
for (const [name, value] of Object.entries(fields)) {
|
||||||
|
const inp = document.createElement("input");
|
||||||
|
inp.type = "hidden";
|
||||||
|
inp.name = name;
|
||||||
|
inp.value = value;
|
||||||
|
form.appendChild(inp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.body.appendChild(form);
|
||||||
|
form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
|||||||
Reference in New Issue
Block a user