(data)
| 773 | } |
| 774 | |
| 775 | function normalizeTemplateData(data) { |
| 776 | const source = data && typeof data === "object" ? data : {}; |
| 777 | return { |
| 778 | card_number: String(source.card_number || "").replace(/\D/g, ""), |
| 779 | exp_month: normalizeMonth(source.exp_month), |
| 780 | exp_year: normalizeYear(source.exp_year), |
| 781 | cvc: String(source.cvc || source.cvv || "").replace(/\D/g, "").slice(0, 4), |
| 782 | billing_name: String(source.billing_name || "").trim(), |
| 783 | country_code: String(source.country_code || "US").trim().toUpperCase() || "US", |
| 784 | currency: String(source.currency || "").trim().toUpperCase(), |
| 785 | address_line1: String(source.address_line1 || "").trim(), |
| 786 | address_city: String(source.address_city || "").trim(), |
| 787 | address_state: String(source.address_state || "").trim(), |
| 788 | postal_code: String(source.postal_code || "").trim(), |
| 789 | }; |
| 790 | } |
| 791 | |
| 792 | function refreshBillingTemplateSelect(selectedId = "") { |
| 793 | const selectEl = document.getElementById("billing-template-select"); |
no test coverage detected