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

Function randomBillingByCountry

static/js/payment.js:670–713  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

668}
669
670async function randomBillingByCountry() {
671 const country = String(getInputValue("billing-country-input") || "US").toUpperCase();
672 setButtonLoading("random-billing-btn", "生成中...", true);
673 setRandomBillingHint("正在获取随机账单资料...", "info");
674 try {
675 const data = await api.get(`/payment/random-billing?country=${encodeURIComponent(country)}`);
676 const profile = data?.profile || {};
677 if (!profile || typeof profile !== "object") {
678 throw new Error("返回的账单资料格式无效");
679 }
680
681 fillBillingForm({
682 billing_name: profile.billing_name || "",
683 country_code: profile.country_code || country,
684 currency: profile.currency || "",
685 address_line1: profile.address_line1 || "",
686 address_city: profile.address_city || "",
687 address_state: profile.address_state || "",
688 postal_code: profile.postal_code || "",
689 });
690
691 const source = String(profile.source || "unknown");
692 let sourceLabel = "本地兜底";
693 if (source === "meiguodizhi") sourceLabel = "meiguodizhi";
694 if (source === "local_geo") sourceLabel = "本地生成";
695 if (source === "local_geo_fallback") sourceLabel = "本地兜底";
696 const fallbackReason = String(profile.fallback_reason || "").trim();
697 const city = String(profile.address_city || "-");
698 const state = String(profile.address_state || "-");
699 const postal = String(profile.postal_code || "-");
700 if ((source === "local_fallback" || source === "local_geo_fallback") && fallbackReason) {
701 setRandomBillingHint(`来源: ${sourceLabel} | ${city}, ${state}, ${postal} | 外部失败: ${fallbackReason}`, "error");
702 toast.warning(`外部地址源不可用,已切换本地兜底:${fallbackReason}`);
703 } else {
704 setRandomBillingHint(`来源: ${sourceLabel} | ${city}, ${state}, ${postal}`, "success");
705 toast.success(`已按 ${country} 随机填充账单资料(${sourceLabel})`);
706 }
707 } catch (error) {
708 setRandomBillingHint(`随机失败: ${formatErrorMessage(error)}`, "error");
709 toast.error(`随机账单资料失败: ${formatErrorMessage(error)}`);
710 } finally {
711 setButtonLoading("random-billing-btn", "生成中...", false);
712 }
713}
714
715function collectBillingFormData() {
716 const expiry = parseExpiryInput(getInputValue("card-expiry-input"));

Callers

nothing calls this directly

Calls 9

getInputValueFunction · 0.85
setButtonLoadingFunction · 0.85
setRandomBillingHintFunction · 0.85
fillBillingFormFunction · 0.85
formatErrorMessageFunction · 0.85
warningMethod · 0.80
successMethod · 0.80
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected