MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / markCardPoolCodeUsed

Function markCardPoolCodeUsed

static/js/payment.js:1768–1792  ·  view source on GitHub ↗
(code, email = "")

Source from the content-addressed store, hash-verified

1766}
1767
1768function markCardPoolCodeUsed(code, email = "") {
1769 const normalizedCode = normalizeEfunCode(code);
1770 if (!normalizedCode) return false;
1771 const parsed = safeJsonParse(localStorage.getItem(CARD_POOL_REDEEM_STORAGE_KEY) || "[]", []);
1772 if (!Array.isArray(parsed)) return false;
1773 let changed = false;
1774 const nowIso = new Date().toISOString();
1775 const next = parsed.map((item) => {
1776 const itemCode = normalizeEfunCode(item?.code || "");
1777 if (!itemCode || itemCode !== normalizedCode) {
1778 return item;
1779 }
1780 changed = true;
1781 return {
1782 ...item,
1783 status: "used",
1784 used_by_email: String(email || item?.used_by_email || "").trim(),
1785 used_at: nowIso,
1786 };
1787 });
1788 if (changed) {
1789 localStorage.setItem(CARD_POOL_REDEEM_STORAGE_KEY, JSON.stringify(next));
1790 }
1791 return changed;
1792}
1793
1794function setEfunResult(content, isError = false) {
1795 const box = document.getElementById("efun-result-box");

Callers

nothing calls this directly

Calls 2

normalizeEfunCodeFunction · 0.85
safeJsonParseFunction · 0.85

Tested by

no test coverage detected