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

Function redeemEfunAndFill

static/js/payment.js:1821–1860  ·  view source on GitHub ↗
(showToast = true, overrideConfig = null)

Source from the content-addressed store, hash-verified

1819}
1820
1821async function redeemEfunAndFill(showToast = true, overrideConfig = null) {
1822 const config = {
1823 ...collectEfunConfig(),
1824 ...(overrideConfig || {}),
1825 };
1826 config.code = normalizeEfunCode(config.code || "");
1827 setInputValue("efun-code-input", config.code);
1828 if (!config.code) {
1829 throw new Error("请先填写 CDK 激活码");
1830 }
1831 if (!EFUN_CODE_REGEX.test(config.code)) {
1832 throw new Error("CDK 格式无效");
1833 }
1834 const payload = {
1835 code: config.code,
1836 base_url: config.base_url,
1837 api_key: config.api_key,
1838 };
1839 const data = await callEfunApi("redeem", payload);
1840 const card = data?.card || {};
1841 const number = String(card.card_number || "").replace(/\s+/g, "");
1842 const month = String(card.exp_month || "").trim();
1843 const year = String(card.exp_year || "").trim();
1844 const cvc = String(card.cvc || "").trim();
1845
1846 if (number) setInputValue("card-number-input", number);
1847 if (month || year) setInputValue("card-expiry-input", formatExpiryInput(month, year));
1848 if (cvc) setInputValue("card-cvc-input", cvc);
1849 if (!getInputValue("billing-country-input")) setInputValue("billing-country-input", "US");
1850 if (!getInputValue("billing-currency-input")) setInputValue("billing-currency-input", "USD");
1851
1852 storage.set(EFUN_CODE_STORAGE_KEY, config.code);
1853 storage.set(EFUN_BASE_URL_STORAGE_KEY, String(config.base_url || EFUN_BASE_URL_DEFAULT));
1854 setEfunResult(data?.raw || data);
1855
1856 if (showToast) {
1857 toast.success(`EFun 开卡成功,已回填卡号 ${String(card.masked || "").trim() || ""}`);
1858 }
1859 return data;
1860}
1861
1862async function queryEfunCard() {
1863 const config = collectEfunConfig();

Callers

nothing calls this directly

Calls 8

collectEfunConfigFunction · 0.85
normalizeEfunCodeFunction · 0.85
setInputValueFunction · 0.85
callEfunApiFunction · 0.85
formatExpiryInputFunction · 0.85
getInputValueFunction · 0.85
setEfunResultFunction · 0.85
successMethod · 0.80

Tested by

no test coverage detected