(parsed)
| 616 | } |
| 617 | |
| 618 | function fillBillingForm(parsed) { |
| 619 | if (!parsed || typeof parsed !== "object") return; |
| 620 | |
| 621 | if (parsed.card_number) setInputValue("card-number-input", parsed.card_number); |
| 622 | if (parsed.exp_month || parsed.exp_year) { |
| 623 | setInputValue("card-expiry-input", formatExpiryInput(parsed.exp_month, parsed.exp_year)); |
| 624 | } |
| 625 | if (parsed.cvc || parsed.cvv) setInputValue("card-cvc-input", String(parsed.cvc || parsed.cvv || "")); |
| 626 | if (parsed.billing_name) setInputValue("billing-name-input", parsed.billing_name); |
| 627 | if (parsed.address_line1) setInputValue("billing-line1-input", parsed.address_line1); |
| 628 | if (parsed.address_city) setInputValue("billing-city-input", parsed.address_city); |
| 629 | if (parsed.address_state) setInputValue("billing-state-input", parsed.address_state); |
| 630 | if (parsed.postal_code) setInputValue("billing-postal-input", parsed.postal_code); |
| 631 | |
| 632 | if (parsed.country_code) { |
| 633 | const countryEl = document.getElementById("billing-country-input"); |
| 634 | if (countryEl) countryEl.value = parsed.country_code; |
| 635 | } |
| 636 | |
| 637 | if (parsed.currency) { |
| 638 | setInputValue("billing-currency-input", parsed.currency); |
| 639 | } else { |
| 640 | onBillingCountryChanged(); |
| 641 | } |
| 642 | |
| 643 | persistBillingProfileNonSensitive(); |
| 644 | } |
| 645 | |
| 646 | function onBillingCountryChanged() { |
| 647 | const country = (document.getElementById("billing-country-input")?.value || "US").toUpperCase(); |
no test coverage detected