@zonos/elements 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{TaxId-Q6aDqqWv.js → TaxId-ChhNwG04.js} +36 -0
- package/dist/cjs/{cart-B6Aty-21.js → cart-BJpqPdFU.js} +100 -64
- package/dist/cjs/{collect-DnrvaXUI.js → collect-CyUttsvB.js} +4 -4
- package/dist/cjs/{debounce-Cd2emZPn.js → debounce-BhgA8_3W.js} +2 -2
- package/dist/cjs/{debounce-vY0QYT6o.js → debounce-DRPMxNew.js} +1 -1
- package/dist/cjs/{getBorderRadius-CyYZw4qq.js → getBorderRadius-CJ_95w3o.js} +1 -1
- package/dist/cjs/{getMissingRequiredShippingFields-D03ICqss.js → getMissingRequiredShippingFields-DEbNbRAZ.js} +1 -1
- package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
- package/dist/cjs/{hasInclusivePrice-CPCoVeU3.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
- package/dist/cjs/index.cjs.js +116 -13
- package/dist/cjs/{invoice-Cj8W7NW0.js → invoice-DzRkkpLu.js} +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-BzNeXeDe.js → localization-BhNVhLZs.js} +725 -89
- package/dist/cjs/{paypal-CuKshRmZ.js → paypal-DCSqbdjW.js} +5 -5
- package/dist/cjs/{placeTestOrder-7czjwkjm.js → placeTestOrder-Bkip4PUT.js} +3 -3
- package/dist/cjs/{renderCheckoutCurrency-BH8t2b2x.js → renderCheckoutCurrency-BDvEZ3Hv.js} +2 -2
- package/dist/cjs/shouldRenderShortAddressCodeInput-gpu_bMfp.js +21 -0
- package/dist/cjs/{shouldShowLanguageSelect-yAbtCmd8.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
- package/dist/cjs/{submitGtag-D79e8u6s.js → submitGtag-D4sB7w4z.js} +2 -2
- package/dist/cjs/{throttle-zSVRQLC0.js → taxIdFields-e4OCgr8K.js} +57 -2
- package/dist/cjs/taxIdRules-BBj8kQxJ.js +58 -0
- package/dist/cjs/{updateCheckoutSessionAttributes-jMtfOL2m.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +2 -2
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +26 -31
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-address_4.cjs.entry.js +28 -31
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +8 -7
- package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
- package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
- package/dist/cjs/zonos-button_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-card_5.cjs.entry.js +9 -8
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +91 -86
- package/dist/cjs/zonos-checkbox_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-checkout.cjs.entry.js +15 -14
- package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +7 -6
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +13 -12
- package/dist/cjs/zonos-collect.cjs.entry.js +10 -9
- package/dist/cjs/zonos-controller.cjs.entry.js +10 -9
- package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +4 -4
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +5 -5
- package/dist/cjs/zonos-hello.cjs.entry.js +5 -5
- package/dist/cjs/zonos-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +9 -8
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +13 -12
- package/dist/cjs/zonos-invoice.cjs.entry.js +10 -9
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +8 -7
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-text.cjs.entry.js +1 -1
- package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
- package/dist/cjs/{zonosStore-Bx9jK82G.js → zonosStore-CDV83QyK.js} +2 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +12 -4
- package/dist/collection/components/main/zonos-controller.js +3 -2
- package/dist/collection/components/store/checkout/cart.js +3 -2
- package/dist/collection/components/store/checkout/stripe.js +20 -21
- package/dist/collection/components/store/storageStore.js +7 -6
- package/dist/collection/components/store/translationStore/strings.arabic.js +35 -2
- package/dist/collection/components/store/translationStore/strings.base.js +35 -2
- package/dist/collection/components/store/translationStore/strings.chinese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.danish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.dutch.js +35 -2
- package/dist/collection/components/store/translationStore/strings.french.js +35 -2
- package/dist/collection/components/store/translationStore/strings.german.js +35 -2
- package/dist/collection/components/store/translationStore/strings.hebrew.js +35 -2
- package/dist/collection/components/store/translationStore/strings.indonesian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.italian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.japanese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.korean.js +35 -2
- package/dist/collection/components/store/translationStore/strings.norwegian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.polish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.portuguese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.russian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.spanish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.swedish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.turkish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +35 -2
- package/dist/collection/components/store/zonosStore.js +2 -1
- package/dist/collection/components/stripe/zonos-address/zonos-address.css +5 -0
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +37 -22
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +5 -0
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +34 -21
- package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
- package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +24 -35
- package/dist/collection/components/utils/checkout/getCheckoutTaxIdPayload.js +16 -0
- package/dist/collection/components/utils/checkout/getTaxIdFieldState.js +26 -0
- package/dist/collection/components/utils/checkout/resolveTaxIdSelection.js +23 -0
- package/dist/collection/components/utils/checkout/shouldRenderTaxIdInput.js +7 -11
- package/dist/collection/components/utils/checkout/taxIdFields.js +29 -0
- package/dist/collection/components/utils/handleFetch.js +19 -9
- package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
- package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
- package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
- package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
- package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
- package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
- package/dist/collection/components/utils/safeStorage.js +39 -0
- package/dist/collection/components/utils/taxId/taxIdRules.js +44 -0
- package/dist/collection/components/utils/taxIdValidationResult.js +57 -58
- package/dist/collection/index.js +1 -0
- package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
- package/dist/collection/scripts/_zonosBase.js +6 -2
- package/dist/collection/types/checkout/TaxId.js +31 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
- package/dist/collection/types/generated/graphql.internal.types.js +215 -1
- package/dist/esm/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +32 -1
- package/dist/esm/{cart-BoQp8Ema.js → cart-BS5mSI8x.js} +100 -65
- package/dist/esm/{collect-Eo4gtyql.js → collect-B9ZxDDl7.js} +4 -4
- package/dist/esm/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +1 -1
- package/dist/esm/{debounce-CrmpwbEE.js → debounce-DWqMT4lo.js} +2 -2
- package/dist/esm/{getBorderRadius-DYfkeXdx.js → getBorderRadius-BiGd45jw.js} +1 -1
- package/dist/esm/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-BkEV865q.js} +1 -1
- package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
- package/dist/esm/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
- package/dist/esm/index.js +106 -13
- package/dist/esm/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-BIh-4pc_.js → localization-CXHiWcJp.js} +725 -89
- package/dist/esm/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +5 -5
- package/dist/esm/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +3 -3
- package/dist/esm/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
- package/dist/esm/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +19 -0
- package/dist/esm/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
- package/dist/esm/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +2 -2
- package/dist/esm/taxIdFields-BUKnHMaL.js +139 -0
- package/dist/esm/taxIdRules-xYlx7ZXW.js +47 -0
- package/dist/esm/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +2 -2
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +24 -29
- package/dist/esm/zonos-address-display_2.entry.js +4 -4
- package/dist/esm/zonos-address_4.entry.js +26 -29
- package/dist/esm/zonos-airwallex-payment.entry.js +8 -7
- package/dist/esm/zonos-badge.entry.js +1 -1
- package/dist/esm/zonos-banner.entry.js +1 -1
- package/dist/esm/zonos-button_3.entry.js +2 -2
- package/dist/esm/zonos-card_5.entry.js +9 -8
- package/dist/esm/zonos-cart-items_12.entry.js +90 -85
- package/dist/esm/zonos-checkbox_2.entry.js +2 -2
- package/dist/esm/zonos-checkout.entry.js +15 -14
- package/dist/esm/zonos-collapse.entry.js +1 -1
- package/dist/esm/zonos-collect-cart-items_3.entry.js +7 -6
- package/dist/esm/zonos-collect-finish_6.entry.js +13 -12
- package/dist/esm/zonos-collect.entry.js +10 -9
- package/dist/esm/zonos-controller.entry.js +10 -9
- package/dist/esm/zonos-country-flag.entry.js +3 -3
- package/dist/esm/zonos-country-select_4.entry.js +4 -4
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +5 -5
- package/dist/esm/zonos-hello.entry.js +5 -5
- package/dist/esm/zonos-input.entry.js +2 -2
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +9 -8
- package/dist/esm/zonos-invoice-finish_5.entry.js +13 -12
- package/dist/esm/zonos-invoice.entry.js +10 -9
- package/dist/esm/zonos-language-select_2.entry.js +3 -3
- package/dist/esm/zonos-logo.entry.js +1 -1
- package/dist/esm/zonos-policy-consent_2.entry.js +8 -7
- package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
- package/dist/esm/zonos-stripe-input.entry.js +2 -2
- package/dist/esm/zonos-text.entry.js +1 -1
- package/dist/esm/zonos-v-stack.entry.js +1 -1
- package/dist/esm/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +2 -1
- package/dist/esm-es5/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +2 -1
- package/dist/esm-es5/{cart-BoQp8Ema.js → cart-BS5mSI8x.js} +42 -31
- package/dist/esm-es5/{collect-Eo4gtyql.js → collect-B9ZxDDl7.js} +1 -1
- package/dist/esm-es5/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +7 -7
- package/dist/esm-es5/debounce-DWqMT4lo.js +1 -0
- package/dist/esm-es5/getBorderRadius-BiGd45jw.js +8 -0
- package/dist/esm-es5/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-BkEV865q.js} +3 -3
- package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
- package/dist/esm-es5/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
- package/dist/esm-es5/index.js +30 -12
- package/dist/esm-es5/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/localization-CXHiWcJp.js +345 -0
- package/dist/esm-es5/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +1 -1
- package/dist/esm-es5/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +8 -0
- package/dist/esm-es5/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
- package/dist/esm-es5/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +1 -1
- package/dist/esm-es5/taxIdFields-BUKnHMaL.js +46 -0
- package/dist/esm-es5/taxIdRules-xYlx7ZXW.js +6 -0
- package/dist/esm-es5/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +253 -254
- package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +8 -9
- package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-badge.entry.js +1 -1
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_3.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +6 -6
- package/dist/esm-es5/zonos-cart-items_12.entry.js +137 -136
- package/dist/esm-es5/zonos-checkbox_2.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +3 -3
- package/dist/esm-es5/zonos-collapse.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +6 -6
- package/dist/esm-es5/zonos-controller.entry.js +5 -5
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +2 -2
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-input.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +2 -2
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +3 -3
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-logo.entry.js +1 -1
- package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +1 -1
- package/dist/scripts/index.d.ts +103 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +4 -0
- package/dist/types/components/store/checkout/stripe.d.ts +9 -0
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.base.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.danish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.french.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.german.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.italian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.korean.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.polish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.russian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +34 -1
- package/dist/types/components/store/zonosStore.d.ts +2 -1
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +4 -1
- package/dist/types/components/stripe/zonos-custom-address/zonos-custom-address.d.ts +4 -1
- package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
- package/dist/types/components/utils/checkout/getCheckoutTaxIdPayload.d.ts +6 -0
- package/dist/types/components/utils/checkout/getTaxIdFieldState.d.ts +18 -0
- package/dist/types/components/utils/checkout/resolveTaxIdSelection.d.ts +12 -0
- package/dist/types/components/utils/checkout/shouldRenderTaxIdInput.d.ts +2 -1
- package/dist/types/components/utils/checkout/taxIdFields.d.ts +11 -0
- package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
- package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
- package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
- package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
- package/dist/types/components/utils/safeStorage.d.ts +4 -0
- package/dist/types/components/utils/taxId/taxIdRules.d.ts +37 -0
- package/dist/types/components/utils/taxIdValidationResult.d.ts +8 -2
- package/dist/types/components.d.ts +22 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
- package/dist/types/types/checkout/TaxId.d.ts +45 -0
- package/dist/types/types/checkout/api/CalculateLandedCost.d.ts +11 -0
- package/dist/types/types/checkout/api/CreateParty.d.ts +2 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
- package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
- package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
- package/dist/types/types/generated/graphql.internal.types.ts +341 -1
- package/dist/types/types/utils/ZonosSettings.d.ts +5 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-08b01c96.entry.js +1 -0
- package/dist/zonos-elements/{p-c961caaf.entry.js → p-0909ef77.entry.js} +1 -1
- package/dist/zonos-elements/{p-23352709.system.entry.js → p-13015d34.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-6c41b00c.entry.js → p-13d5b2f9.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b80aff2.system.entry.js → p-150047b3.system.entry.js} +25 -25
- package/dist/zonos-elements/p-1986cc37.entry.js +1 -0
- package/dist/zonos-elements/{p-CBx5nYet.system.js → p-1OG3IJgY.system.js} +1 -1
- package/dist/zonos-elements/{p-d3d0656a.entry.js → p-1a5acbcd.entry.js} +1 -1
- package/dist/zonos-elements/{p-756d303f.system.entry.js → p-20eb00de.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9c33f7ed.system.entry.js → p-30bf4700.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d168023b.entry.js → p-3466bcba.entry.js} +1 -1
- package/dist/zonos-elements/p-383343c7.entry.js +1 -0
- package/dist/zonos-elements/{p-06030d3b.system.entry.js → p-3a506614.system.entry.js} +54 -54
- package/dist/zonos-elements/p-43c0ebe9.entry.js +1 -0
- package/dist/zonos-elements/{p-acd50b0b.entry.js → p-4612facd.entry.js} +1 -1
- package/dist/zonos-elements/{p-244e0302.system.entry.js → p-4715045c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-4b65f192.entry.js +1 -0
- package/dist/zonos-elements/{p-5967a1c1.system.entry.js → p-573a4e7c.system.entry.js} +6 -6
- package/dist/zonos-elements/p-59fc32af.entry.js +1 -0
- package/dist/zonos-elements/{p-d82fd8a9.system.entry.js → p-5a296dbc.system.entry.js} +117 -116
- package/dist/zonos-elements/{p-193d9722.entry.js → p-61312d5b.entry.js} +1 -1
- package/dist/zonos-elements/{p-6abec43f.system.entry.js → p-68325c5a.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-0b81f8b9.system.entry.js → p-6db7317a.system.entry.js} +6 -6
- package/dist/zonos-elements/{p-51400242.system.entry.js → p-709d1561.system.entry.js} +3 -3
- package/dist/zonos-elements/p-71d29603.entry.js +1 -0
- package/dist/zonos-elements/{p-7bd99479.system.entry.js → p-7214c953.system.entry.js} +21 -21
- package/dist/zonos-elements/p-74659d88.entry.js +1 -0
- package/dist/zonos-elements/{p-55916c90.entry.js → p-7f1bea9b.entry.js} +1 -1
- package/dist/zonos-elements/{p-0fca452b.entry.js → p-7fe83919.entry.js} +1 -1
- package/dist/zonos-elements/{p-1c150f26.entry.js → p-821e413a.entry.js} +1 -1
- package/dist/zonos-elements/{p-c403f004.system.entry.js → p-82e45d0c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1409de3b.system.entry.js → p-88e20e99.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-195f6e38.system.entry.js → p-89a3c4db.system.entry.js} +1 -1
- package/dist/zonos-elements/p-8ac26831.entry.js +1 -0
- package/dist/zonos-elements/{p-a40fd99b.system.entry.js → p-8f9f859f.system.entry.js} +39 -40
- package/dist/zonos-elements/{p-92fe9a1f.system.entry.js → p-902cca23.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0a4a7742.system.entry.js → p-93860183.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b5882fbb.system.entry.js → p-9449b4f4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-31043c2e.system.entry.js → p-96b250d8.system.entry.js} +298 -299
- package/dist/zonos-elements/p-97729873.entry.js +1 -0
- package/dist/zonos-elements/{p-1bac5ac1.system.entry.js → p-990fcf81.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7f031592.system.entry.js → p-9b3668a4.system.entry.js} +155 -155
- package/dist/zonos-elements/{p-249c1ee1.system.entry.js → p-9df31243.system.entry.js} +3 -3
- package/dist/zonos-elements/p-BD-9rD53.js +1 -0
- package/dist/zonos-elements/p-BI6VAB5B.js +1 -0
- package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
- package/dist/zonos-elements/p-BJ_kE5rM.js +1 -0
- package/dist/zonos-elements/{p-Be3Hpms1.system.js → p-BKUlQxBd.system.js} +1 -1
- package/dist/zonos-elements/p-BUfCTQXY.system.js +528 -0
- package/dist/zonos-elements/{p-CZD8WvyY.system.js → p-BnQyot7Y.system.js} +23 -23
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +2 -2
- package/dist/zonos-elements/{p-0mGRBGcf.js → p-C-zdj7MK.js} +1 -1
- package/dist/zonos-elements/p-C5fs3rIR.js +1 -0
- package/dist/zonos-elements/{p-sz4L-ZnB.js → p-CJmWr75U.js} +1 -1
- package/dist/zonos-elements/{p-XDxdMlQl.system.js → p-CMneHjck.system.js} +15 -15
- package/dist/zonos-elements/p-CP7KnfR3.system.js +245 -0
- package/dist/zonos-elements/p-CVRbGFV3.js +1 -0
- package/dist/zonos-elements/p-CYxMfUL7.system.js +1 -0
- package/dist/zonos-elements/p-Cl5yV0ak.js +1 -0
- package/dist/zonos-elements/{p-kaOxUR9u.system.js → p-Cp1IAJvW.system.js} +5 -5
- package/dist/zonos-elements/{p-W82paT5F.js → p-CqB9AfBf.js} +1 -1
- package/dist/zonos-elements/p-CzKlS3E-.system.js +6 -0
- package/dist/zonos-elements/p-D-Lnf8mS.system.js +345 -0
- package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
- package/dist/zonos-elements/{p-c9QtIdJX.js → p-D4xpkSsK.js} +1 -1
- package/dist/zonos-elements/p-DATNIakn.js +1 -0
- package/dist/zonos-elements/{p-D4MevhAL.system.js → p-DC1OPJDq.system.js} +3 -3
- package/dist/zonos-elements/{p-8PPEbm_0.system.js → p-DIab60nK.system.js} +12 -12
- package/dist/zonos-elements/p-DKnphvmJ.js +1 -0
- package/dist/zonos-elements/{p-Cye-evFK.js → p-DMIgN_sT.js} +1 -1
- package/dist/zonos-elements/{p-BuU_p5DP.system.js → p-DTgUqgwV.system.js} +2 -2
- package/dist/zonos-elements/p-DW7I0zOF.js +1 -0
- package/dist/zonos-elements/{p-DoEHepOc.system.js → p-DXlojp_Y.system.js} +1 -1
- package/dist/zonos-elements/p-DqVePqqx.system.js +8 -0
- package/dist/zonos-elements/{p-B4Ufchqh.system.js → p-DrS-0mk7.system.js} +3 -3
- package/dist/zonos-elements/{p-7abqRc9V.js → p-DrbN3rPL.js} +2 -2
- package/dist/zonos-elements/{p-Cby4EkFu.system.js → p-DsBuZ6ob.system.js} +2 -1
- package/dist/zonos-elements/{p-DI2vXnXc.system.js → p-Dv5a-V6w.system.js} +1 -1
- package/dist/zonos-elements/p-Dwg61Ft_.js +1 -0
- package/dist/zonos-elements/{p-474e8a92.system.entry.js → p-a1022808.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-17c7ea4a.system.entry.js → p-a3c147d2.system.entry.js} +3 -3
- package/dist/zonos-elements/p-aK18R41t.js +1 -0
- package/dist/zonos-elements/{p-83aa1c8c.entry.js → p-ad04bba2.entry.js} +1 -1
- package/dist/zonos-elements/p-af4ad54b.entry.js +1 -0
- package/dist/zonos-elements/p-af741506.entry.js +1 -0
- package/dist/zonos-elements/{p-a938c174.entry.js → p-b51010b9.entry.js} +1 -1
- package/dist/zonos-elements/{p-6db7c0b1.system.entry.js → p-b540c636.system.entry.js} +2 -2
- package/dist/zonos-elements/p-bac94956.entry.js +1 -0
- package/dist/zonos-elements/{p-69c3e367.system.entry.js → p-bb1b414a.system.entry.js} +9 -9
- package/dist/zonos-elements/{p-b79036fc.entry.js → p-bfa9e32a.entry.js} +1 -1
- package/dist/zonos-elements/{p-dfc87b10.system.entry.js → p-c33b8f6a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-cf6bf7a4.entry.js +1 -0
- package/dist/zonos-elements/{p-CEK_Wk6v.system.js → p-dJcbnNlE.system.js} +1 -1
- package/dist/zonos-elements/p-db40b9c3.entry.js +1 -0
- package/dist/zonos-elements/p-dd003161.entry.js +1 -0
- package/dist/zonos-elements/{p-2603dce0.entry.js → p-e216cc8c.entry.js} +1 -1
- package/dist/zonos-elements/p-e374aaa4.entry.js +1 -0
- package/dist/zonos-elements/{p-155ed3d3.system.entry.js → p-e43470f7.system.entry.js} +21 -21
- package/dist/zonos-elements/p-ebc7ea54.system.entry.js +13 -0
- package/dist/zonos-elements/{p-11defdca.system.entry.js → p-f2ed52bc.system.entry.js} +8 -8
- package/dist/zonos-elements/{p-d4d2b39e.entry.js → p-fddf3556.entry.js} +1 -1
- package/dist/zonos-elements/p-gEViRqvf.js +1 -0
- package/dist/zonos-elements/{p-BpDCLBwW.js → p-n5PZKz1k.js} +1 -1
- package/dist/zonos-elements/{p-C_z9WL8a.js → p-r-YGHhLa.js} +1 -1
- package/dist/zonos-elements/{p-XqkqjeNV.system.js → p-yv7ekcdG.system.js} +2 -2
- package/dist/zonos-elements/{p-DQZncB2d.system.js → p-zsTASoh2.system.js} +3 -3
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/shouldRenderTaxIdInput-TxekHCp7.js +0 -43
- package/dist/esm/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -40
- package/dist/esm/throttle-Cvlvb-dm.js +0 -85
- package/dist/esm-es5/debounce-CrmpwbEE.js +0 -1
- package/dist/esm-es5/getBorderRadius-DYfkeXdx.js +0 -8
- package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
- package/dist/esm-es5/localization-BIh-4pc_.js +0 -348
- package/dist/esm-es5/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -17
- package/dist/esm-es5/throttle-Cvlvb-dm.js +0 -46
- package/dist/zonos-elements/p-06fe2939.entry.js +0 -1
- package/dist/zonos-elements/p-24f3c547.entry.js +0 -1
- package/dist/zonos-elements/p-30b3c9d3.entry.js +0 -1
- package/dist/zonos-elements/p-39ee1558.entry.js +0 -1
- package/dist/zonos-elements/p-3a2da031.entry.js +0 -1
- package/dist/zonos-elements/p-4679f0ec.entry.js +0 -1
- package/dist/zonos-elements/p-4806b264.system.entry.js +0 -13
- package/dist/zonos-elements/p-5873ab8e.entry.js +0 -1
- package/dist/zonos-elements/p-725e29bb.entry.js +0 -1
- package/dist/zonos-elements/p-BGktDPwA.system.js +0 -1
- package/dist/zonos-elements/p-Bi-s0fp_.system.js +0 -17
- package/dist/zonos-elements/p-CFbfEmjN.js +0 -1
- package/dist/zonos-elements/p-CUaf1cEg.js +0 -1
- package/dist/zonos-elements/p-CXxvn4GX.system.js +0 -227
- package/dist/zonos-elements/p-CcJF6xhQ.js +0 -1
- package/dist/zonos-elements/p-Cxuiqv1I.js +0 -1
- package/dist/zonos-elements/p-D-bZg-Pc.js +0 -1
- package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
- package/dist/zonos-elements/p-DOD2I44l.system.js +0 -348
- package/dist/zonos-elements/p-DS-qw_qc.system.js +0 -517
- package/dist/zonos-elements/p-DZ2mevDK.js +0 -1
- package/dist/zonos-elements/p-DnjGkbEy.js +0 -1
- package/dist/zonos-elements/p-FRWZayxL.js +0 -1
- package/dist/zonos-elements/p-Mrz_lnC1.js +0 -1
- package/dist/zonos-elements/p-ad9ff14c.entry.js +0 -1
- package/dist/zonos-elements/p-bb3546c0.entry.js +0 -1
- package/dist/zonos-elements/p-c1cbfdba.entry.js +0 -1
- package/dist/zonos-elements/p-c47ce656.entry.js +0 -1
- package/dist/zonos-elements/p-c9d5d8f1.entry.js +0 -1
- package/dist/zonos-elements/p-clDfq9AL.js +0 -1
- package/dist/zonos-elements/p-d74bc3e8.entry.js +0 -1
- package/dist/zonos-elements/p-d8b312e5.entry.js +0 -1
- package/dist/zonos-elements/p-db87b0dd.entry.js +0 -1
- package/dist/zonos-elements/p-defc2d18.entry.js +0 -1
- package/dist/zonos-elements/p-rVp8hgWw.js +0 -1
- package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
|
@@ -4,17 +4,16 @@ import { stripeStore, stripeStoreOnChange, stripeStorePrefetchLandedCost, } from
|
|
|
4
4
|
import { getFallbackDefaultCountryCode, localizationStore, } from "../../store/hello/localization";
|
|
5
5
|
import { storageStore, storageStoreOnChange, } from "../../store/storageStore";
|
|
6
6
|
import { translate } from "../../store/translationStore";
|
|
7
|
-
import { zonosStore } from "../../store/zonosStore";
|
|
7
|
+
import { getShouldRequirePeruTaxId, zonosStore, } from "../../store/zonosStore";
|
|
8
8
|
import { trackConversionEvent } from "../../utils/api/trackConversionEvent";
|
|
9
9
|
import { buildAddressContacts } from "../../utils/checkout/buildAddressContacts";
|
|
10
10
|
import { isCheckoutMobile } from "../../utils/checkout/isCheckoutMobile";
|
|
11
11
|
import { shouldRenderShortAddressCodeInput } from "../../utils/checkout/shouldRenderShortAddressCodeInput";
|
|
12
|
-
import {
|
|
12
|
+
import { renderTaxIdFields } from "../../utils/checkout/taxIdFields";
|
|
13
13
|
import { classes } from "../../utils/classes";
|
|
14
14
|
import { extractName } from "../../utils/extractName";
|
|
15
15
|
import { log } from "../../utils/logging/log";
|
|
16
16
|
import { logError } from "../../utils/logging/logError";
|
|
17
|
-
import { countryRequireTaxId, shipToTaxIdLabels, } from "../../../types/checkout/TaxId";
|
|
18
17
|
/**
|
|
19
18
|
* This component is a wrapper for the stripe address element that would render default style object
|
|
20
19
|
*/
|
|
@@ -29,6 +28,10 @@ export class ZonosAddress {
|
|
|
29
28
|
* Default address for stripe
|
|
30
29
|
*/
|
|
31
30
|
this.defaultAddress = [];
|
|
31
|
+
/**
|
|
32
|
+
* Which tax id control the error belongs on. Empty when there is no error.
|
|
33
|
+
*/
|
|
34
|
+
this.taxIdErrorField = '';
|
|
32
35
|
/**
|
|
33
36
|
* Error message for tax id input
|
|
34
37
|
*/
|
|
@@ -237,9 +240,6 @@ export class ZonosAddress {
|
|
|
237
240
|
}
|
|
238
241
|
void this.watchInitStripe();
|
|
239
242
|
}
|
|
240
|
-
isInTaxIdCountry(countryCode) {
|
|
241
|
-
return countryRequireTaxId.includes(countryCode);
|
|
242
|
-
}
|
|
243
243
|
/**
|
|
244
244
|
* Render tax id input based on ship to country code
|
|
245
245
|
*/
|
|
@@ -254,23 +254,18 @@ export class ZonosAddress {
|
|
|
254
254
|
if (!countryCode) {
|
|
255
255
|
return null;
|
|
256
256
|
}
|
|
257
|
-
|
|
258
|
-
if (!this.isInTaxIdCountry(countryCode)) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
const taxIdInputRendered = shouldRenderTaxIdInput({
|
|
257
|
+
return renderTaxIdFields({
|
|
262
258
|
companyName: stripeStore.companyName,
|
|
263
259
|
countryCode,
|
|
260
|
+
errorField: this.taxIdErrorField,
|
|
261
|
+
errorMessage: this.taxIdErrorMessage,
|
|
262
|
+
onTaxIdChange: value => {
|
|
263
|
+
this.taxIdChanged.emit(value);
|
|
264
|
+
},
|
|
265
|
+
shouldRequirePeruTaxId: getShouldRequirePeruTaxId(),
|
|
266
|
+
taxId: stripeStore.taxId || '',
|
|
267
|
+
taxIdType: stripeStore.taxIdType,
|
|
264
268
|
});
|
|
265
|
-
// Don't render tax id input if the country doesn't require tax id
|
|
266
|
-
if (!taxIdInputRendered) {
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
const taxIdInputInfo = shipToTaxIdLabels[countryCode];
|
|
270
|
-
return (h("div", { class: "zonos--tax-id-input" }, h("zonos-stripe-input", { inputLabel: translate(taxIdInputInfo.friendlyName), inputPlaceholder: taxIdInputInfo.placeholder, inputValue: stripeStore.taxId || '', isError: !!this.taxIdErrorMessage, onInputChange: (event) => {
|
|
271
|
-
stripeStore.taxId = event.detail;
|
|
272
|
-
this.taxIdChanged.emit(event.detail);
|
|
273
|
-
} }), this.taxIdErrorMessage && (h("zonos-text", { textColor: "red-600", type: "caption" }, this.taxIdErrorMessage))));
|
|
274
269
|
}
|
|
275
270
|
/**
|
|
276
271
|
* Render short address code input based on ship to country code
|
|
@@ -357,11 +352,11 @@ export class ZonosAddress {
|
|
|
357
352
|
this.isAddressFilled = true;
|
|
358
353
|
}
|
|
359
354
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
360
|
-
return (h(Host, { key: '
|
|
355
|
+
return (h(Host, { key: 'bbf12ad9213fbbbaf6c14ecb0cb7acb0679f3d6e', class: classes([
|
|
361
356
|
'zonos--address',
|
|
362
357
|
'zonos--elements',
|
|
363
358
|
`zonos--${this.type}-address`,
|
|
364
|
-
]) }, this.titleText && (h("zonos-text", { key: '
|
|
359
|
+
]) }, this.titleText && (h("zonos-text", { key: 'a81550755a359e1a9c46acc99eef7749959187ee', class: "zonos--title", type: "semiBoldLabel" }, this.titleText)), h("slot", { key: 'bdba9c19992622bcf0354366080b1932c0e28bb2', name: "below-title" }), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderShortAddressCodeInput(), h("div", { key: 'b376efea8ef5d57f525be9b6eed3f98c67b2834e', class: "zonos--address-component" })));
|
|
365
360
|
}
|
|
366
361
|
static get is() { return "zonos-address"; }
|
|
367
362
|
static get encapsulation() { return "scoped"; }
|
|
@@ -440,6 +435,26 @@ export class ZonosAddress {
|
|
|
440
435
|
"setter": false,
|
|
441
436
|
"defaultValue": "[]"
|
|
442
437
|
},
|
|
438
|
+
"taxIdErrorField": {
|
|
439
|
+
"type": "string",
|
|
440
|
+
"mutable": false,
|
|
441
|
+
"complexType": {
|
|
442
|
+
"original": "'type' | 'value' | ''",
|
|
443
|
+
"resolved": "\"\" | \"type\" | \"value\"",
|
|
444
|
+
"references": {}
|
|
445
|
+
},
|
|
446
|
+
"required": false,
|
|
447
|
+
"optional": false,
|
|
448
|
+
"docs": {
|
|
449
|
+
"tags": [],
|
|
450
|
+
"text": "Which tax id control the error belongs on. Empty when there is no error."
|
|
451
|
+
},
|
|
452
|
+
"getter": false,
|
|
453
|
+
"setter": false,
|
|
454
|
+
"reflect": false,
|
|
455
|
+
"attribute": "tax-id-error-field",
|
|
456
|
+
"defaultValue": "''"
|
|
457
|
+
},
|
|
443
458
|
"taxIdErrorMessage": {
|
|
444
459
|
"type": "string",
|
|
445
460
|
"mutable": false,
|
|
@@ -16,18 +16,17 @@ import { stripeStore, stripeStorePrefetchLandedCost, } from "../../store/checkou
|
|
|
16
16
|
import { localizationStore } from "../../store/hello/localization";
|
|
17
17
|
import { storageStore, storageStoreOnChange, } from "../../store/storageStore";
|
|
18
18
|
import { translate } from "../../store/translationStore";
|
|
19
|
-
import { zonosStore } from "../../store/zonosStore";
|
|
19
|
+
import { getShouldRequirePeruTaxId, zonosStore, } from "../../store/zonosStore";
|
|
20
20
|
import { trackConversionEvent } from "../../utils/api/trackConversionEvent";
|
|
21
21
|
import { isValidZip } from "../../utils/checkout/form/isValidZip";
|
|
22
22
|
import { getAddressCountryOptions, } from "../../utils/checkout/getAddressCountryOptions";
|
|
23
23
|
import { isCheckoutMobile } from "../../utils/checkout/isCheckoutMobile";
|
|
24
24
|
import { shouldRenderShortAddressCodeInput } from "../../utils/checkout/shouldRenderShortAddressCodeInput";
|
|
25
|
-
import {
|
|
25
|
+
import { renderTaxIdFields } from "../../utils/checkout/taxIdFields";
|
|
26
26
|
import { classes } from "../../utils/classes";
|
|
27
27
|
import { extractName } from "../../utils/extractName";
|
|
28
28
|
import { log } from "../../utils/logging/log";
|
|
29
29
|
import { mergeAddress } from "../../utils/mergeAddress";
|
|
30
|
-
import { countryRequireTaxId, shipToTaxIdLabels, } from "../../../types/checkout/TaxId";
|
|
31
30
|
/**
|
|
32
31
|
* This component is a wrapper for the stripe address element that would render default style object
|
|
33
32
|
*/
|
|
@@ -38,6 +37,10 @@ export class ZonosAddress {
|
|
|
38
37
|
* Default address for stripe
|
|
39
38
|
*/
|
|
40
39
|
this.defaultAddress = [];
|
|
40
|
+
/**
|
|
41
|
+
* Which tax id control the error belongs on. Empty when there is no error.
|
|
42
|
+
*/
|
|
43
|
+
this.taxIdErrorField = '';
|
|
41
44
|
/**
|
|
42
45
|
* Error message for tax id input
|
|
43
46
|
*/
|
|
@@ -364,9 +367,6 @@ export class ZonosAddress {
|
|
|
364
367
|
const hasErrors = line1 || postalCode || state || city || firstName || lastName || phone;
|
|
365
368
|
return !hasErrors;
|
|
366
369
|
}
|
|
367
|
-
isInTaxIdCountry(countryCode) {
|
|
368
|
-
return countryRequireTaxId.includes(countryCode);
|
|
369
|
-
}
|
|
370
370
|
/**
|
|
371
371
|
* Render tax id input based on ship to country code
|
|
372
372
|
*/
|
|
@@ -381,22 +381,15 @@ export class ZonosAddress {
|
|
|
381
381
|
if (!countryCode) {
|
|
382
382
|
return null;
|
|
383
383
|
}
|
|
384
|
-
|
|
385
|
-
if (!this.isInTaxIdCountry(countryCode)) {
|
|
386
|
-
return null;
|
|
387
|
-
}
|
|
388
|
-
const taxIdInputRendered = shouldRenderTaxIdInput({
|
|
384
|
+
return renderTaxIdFields({
|
|
389
385
|
companyName: stripeStore.companyName,
|
|
390
386
|
countryCode,
|
|
387
|
+
errorField: this.taxIdErrorField,
|
|
388
|
+
errorMessage: this.taxIdErrorMessage,
|
|
389
|
+
shouldRequirePeruTaxId: getShouldRequirePeruTaxId(),
|
|
390
|
+
taxId: stripeStore.taxId || '',
|
|
391
|
+
taxIdType: stripeStore.taxIdType,
|
|
391
392
|
});
|
|
392
|
-
// Don't render tax id input if the country doesn't require tax id
|
|
393
|
-
if (!taxIdInputRendered) {
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
const taxIdInputInfo = shipToTaxIdLabels[countryCode];
|
|
397
|
-
return (h("div", { class: "zonos--tax-id-input" }, h("zonos-stripe-input", { error: this.taxIdErrorMessage, inputLabel: translate(taxIdInputInfo.friendlyName), inputPlaceholder: taxIdInputInfo.placeholder, inputValue: stripeStore.taxId || '', isError: !!this.taxIdErrorMessage, onInputChange: (event) => {
|
|
398
|
-
stripeStore.taxId = event.detail;
|
|
399
|
-
} })));
|
|
400
393
|
}
|
|
401
394
|
/**
|
|
402
395
|
* Render short address code input based on ship to country code
|
|
@@ -933,10 +926,10 @@ export class ZonosAddress {
|
|
|
933
926
|
this.country = localizationStore.selectedCountryCode;
|
|
934
927
|
}
|
|
935
928
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
936
|
-
return (h(Host, { key: '
|
|
929
|
+
return (h(Host, { key: 'd3bb2635d41dd74ba52ff37034f348fc0a763366', class: classes([
|
|
937
930
|
'zonos--address zonos--elements',
|
|
938
931
|
`zonos--${this.type}-address`,
|
|
939
|
-
]) }, h("zonos-text", { key: '
|
|
932
|
+
]) }, h("zonos-text", { key: '7d3f67988eac13616f3470f46f05060e194c2df7', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("slot", { key: '1bd63bd015542ec3302f087bcbf3d9549f342c25', name: "below-title" }), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderShortAddressCodeInput(), this.renderCustomAddressForm()));
|
|
940
933
|
}
|
|
941
934
|
static get is() { return "zonos-custom-address"; }
|
|
942
935
|
static get encapsulation() { return "scoped"; }
|
|
@@ -1015,6 +1008,26 @@ export class ZonosAddress {
|
|
|
1015
1008
|
"setter": false,
|
|
1016
1009
|
"defaultValue": "[]"
|
|
1017
1010
|
},
|
|
1011
|
+
"taxIdErrorField": {
|
|
1012
|
+
"type": "string",
|
|
1013
|
+
"mutable": false,
|
|
1014
|
+
"complexType": {
|
|
1015
|
+
"original": "'type' | 'value' | ''",
|
|
1016
|
+
"resolved": "\"\" | \"type\" | \"value\"",
|
|
1017
|
+
"references": {}
|
|
1018
|
+
},
|
|
1019
|
+
"required": false,
|
|
1020
|
+
"optional": false,
|
|
1021
|
+
"docs": {
|
|
1022
|
+
"tags": [],
|
|
1023
|
+
"text": "Which tax id control the error belongs on. Empty when there is no error."
|
|
1024
|
+
},
|
|
1025
|
+
"getter": false,
|
|
1026
|
+
"setter": false,
|
|
1027
|
+
"reflect": false,
|
|
1028
|
+
"attribute": "tax-id-error-field",
|
|
1029
|
+
"defaultValue": "''"
|
|
1030
|
+
},
|
|
1018
1031
|
"taxIdErrorMessage": {
|
|
1019
1032
|
"type": "string",
|
|
1020
1033
|
"mutable": false,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const restores = [];
|
|
2
|
+
/** Replace a storage getter so the next read throws SecurityError. */
|
|
3
|
+
export const blockStorage = (area) => {
|
|
4
|
+
const descriptor = Object.getOwnPropertyDescriptor(window, area);
|
|
5
|
+
Object.defineProperty(window, area, {
|
|
6
|
+
configurable: true,
|
|
7
|
+
get() {
|
|
8
|
+
throw new DOMException('The operation is insecure', 'SecurityError');
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
restores.push(() => {
|
|
12
|
+
if (descriptor) {
|
|
13
|
+
Object.defineProperty(window, area, descriptor);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
Reflect.deleteProperty(window, area);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export const restoreBlockedStorage = () => {
|
|
20
|
+
var _a;
|
|
21
|
+
while (restores.length > 0) {
|
|
22
|
+
(_a = restores.pop()) === null || _a === void 0 ? void 0 : _a();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { handleFetch } from "../handleFetch";
|
|
2
2
|
import { logError } from "../logging/logError";
|
|
3
|
+
import { safeSetItem } from "../safeStorage";
|
|
3
4
|
const defaultUsExchangeRate = {
|
|
4
5
|
exchangeRate: {
|
|
5
6
|
rate: 1,
|
|
@@ -33,7 +34,7 @@ export const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, t
|
|
|
33
34
|
const { rate, targetFormat } = json.exchangeRateCreate;
|
|
34
35
|
const maxAge = json.maxAge;
|
|
35
36
|
if (rate) {
|
|
36
|
-
|
|
37
|
+
safeSetItem('session', `${country}_rate`, JSON.stringify(rate));
|
|
37
38
|
const exchangeRate = { rate, targetFormat };
|
|
38
39
|
return { exchangeRate, maxAge };
|
|
39
40
|
}
|
|
@@ -2,9 +2,19 @@ import { cartStore } from "../../store/checkout/cart";
|
|
|
2
2
|
import { stripeStore } from "../../store/checkout/stripe";
|
|
3
3
|
import { localizationStore } from "../../store/hello/localization";
|
|
4
4
|
import { storageStore } from "../../store/storageStore";
|
|
5
|
+
import { getCheckoutTaxIdPayload } from "../checkout/getCheckoutTaxIdPayload";
|
|
5
6
|
import { extractName } from "../extractName";
|
|
6
7
|
import { getOverridenZCountry } from "../getOverridenZCountry";
|
|
7
8
|
import { log } from "../logging/log";
|
|
9
|
+
const shipToTaxIdFields = (countryCode) => {
|
|
10
|
+
const taxIdPayload = getCheckoutTaxIdPayload(countryCode);
|
|
11
|
+
if (!taxIdPayload) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
return Object.assign({ shipToTaxId: taxIdPayload.taxId }, (taxIdPayload.taxIdType
|
|
15
|
+
? { shipToTaxIdType: taxIdPayload.taxIdType }
|
|
16
|
+
: {}));
|
|
17
|
+
};
|
|
8
18
|
/**
|
|
9
19
|
* Extract value from translated object
|
|
10
20
|
*/
|
|
@@ -55,16 +65,15 @@ export const prepCartCalculateLandedCost = (cartId) => {
|
|
|
55
65
|
name: translatedBillingAddress.name,
|
|
56
66
|
});
|
|
57
67
|
const checkoutSessionCountry = getOverridenZCountry() || 'US';
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
const shipToTaxId = shipToTaxIdFields(translatedShippingAddress.country);
|
|
69
|
+
return Object.assign(Object.assign({ billingAddress: {
|
|
60
70
|
addressLine1: translatedBillingAddress.line1,
|
|
61
71
|
addressLine2: translatedBillingAddress.line2 || '',
|
|
62
72
|
city: translatedBillingAddress.city,
|
|
63
73
|
country: translatedBillingAddress.country,
|
|
64
74
|
postalCode: translatedBillingAddress.postal_code,
|
|
65
75
|
state: translatedBillingAddress.state,
|
|
66
|
-
},
|
|
67
|
-
billingContact: {
|
|
76
|
+
}, billingContact: {
|
|
68
77
|
// firstName and lastName should be valid now since stripe only mark
|
|
69
78
|
// the address as complete when both fields are filled.
|
|
70
79
|
firstName: billingFirstName,
|
|
@@ -72,13 +81,9 @@ export const prepCartCalculateLandedCost = (cartId) => {
|
|
|
72
81
|
phone: translatedBillingAddress.phone,
|
|
73
82
|
},
|
|
74
83
|
// Use the first item's currency code
|
|
75
|
-
cartCurrencyCode: (_a = cartStore.items[0]) === null || _a === void 0 ? void 0 : _a.currencyCode,
|
|
76
|
-
cartId,
|
|
77
|
-
checkoutSessionCountry: checkoutSessionCountry ||
|
|
84
|
+
cartCurrencyCode: (_a = cartStore.items[0]) === null || _a === void 0 ? void 0 : _a.currencyCode, cartId, checkoutSessionCountry: checkoutSessionCountry ||
|
|
78
85
|
localizationStore.selectedCountryCode ||
|
|
79
|
-
undefined,
|
|
80
|
-
checkoutSessionId: storageStore.checkoutSessionId || '',
|
|
81
|
-
contact: {
|
|
86
|
+
undefined, checkoutSessionId: storageStore.checkoutSessionId || '', contact: {
|
|
82
87
|
companyName: stripeStore.companyName,
|
|
83
88
|
email: stripeLinkData === null || stripeLinkData === void 0 ? void 0 : stripeLinkData.value.email,
|
|
84
89
|
// firstName and lastName should be valid now since stripe only mark
|
|
@@ -86,9 +91,7 @@ export const prepCartCalculateLandedCost = (cartId) => {
|
|
|
86
91
|
firstName: shippingFirstName,
|
|
87
92
|
lastName: shippingLastName,
|
|
88
93
|
phone: translatedShippingAddress.phone,
|
|
89
|
-
},
|
|
90
|
-
isTest: !!isE2ETest,
|
|
91
|
-
landedCostAdjustments: cartStore.promoCode
|
|
94
|
+
}, isTest: !!isE2ETest, landedCostAdjustments: cartStore.promoCode
|
|
92
95
|
? [
|
|
93
96
|
{
|
|
94
97
|
amount: 0,
|
|
@@ -98,18 +101,14 @@ export const prepCartCalculateLandedCost = (cartId) => {
|
|
|
98
101
|
type: 'PROMO_CODE',
|
|
99
102
|
},
|
|
100
103
|
]
|
|
101
|
-
: [],
|
|
102
|
-
shipToShortAddressCode: stripeStore.shortAddressCode,
|
|
103
|
-
shipToTaxId: stripeStore.taxId,
|
|
104
|
-
shippingAddress: {
|
|
104
|
+
: [], shipToShortAddressCode: stripeStore.shortAddressCode }, shipToTaxId), { shippingAddress: {
|
|
105
105
|
addressLine1: translatedShippingAddress.line1,
|
|
106
106
|
addressLine2: translatedShippingAddress.line2,
|
|
107
107
|
city: translatedShippingAddress.city,
|
|
108
108
|
country: translatedShippingAddress.country,
|
|
109
109
|
postalCode: translatedShippingAddress.postal_code,
|
|
110
110
|
state: translatedShippingAddress.state,
|
|
111
|
-
}
|
|
112
|
-
};
|
|
111
|
+
} });
|
|
113
112
|
};
|
|
114
113
|
export const prepCalculateLandedCost = () => {
|
|
115
114
|
const isE2ETest = new URLSearchParams(window.location.search).get('zonosE2ETest') === '1';
|
|
@@ -157,24 +156,21 @@ export const prepCalculateLandedCost = () => {
|
|
|
157
156
|
...convertedCartAdjuments,
|
|
158
157
|
]
|
|
159
158
|
: convertedCartAdjuments;
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
const shipToTaxId = shipToTaxIdFields(translatedShippingAddress.country);
|
|
160
|
+
return Object.assign(Object.assign({ billingAddress: {
|
|
162
161
|
addressLine1: translatedBillingAddress.line1,
|
|
163
162
|
addressLine2: translatedBillingAddress.line2 || '',
|
|
164
163
|
city: translatedBillingAddress.city,
|
|
165
164
|
country: translatedBillingAddress.country,
|
|
166
165
|
postalCode: translatedBillingAddress.postal_code,
|
|
167
166
|
state: translatedBillingAddress.state,
|
|
168
|
-
},
|
|
169
|
-
billingContact: {
|
|
167
|
+
}, billingContact: {
|
|
170
168
|
// firstName and lastName should be valid now since stripe only mark
|
|
171
169
|
// the address as complete when both fields are filled.
|
|
172
170
|
firstName: billingFirstName,
|
|
173
171
|
lastName: billingLastName,
|
|
174
172
|
phone: translatedBillingAddress.phone,
|
|
175
|
-
},
|
|
176
|
-
checkoutSessionId: storageStore.checkoutSessionId || '',
|
|
177
|
-
contact: {
|
|
173
|
+
}, checkoutSessionId: storageStore.checkoutSessionId || '', contact: {
|
|
178
174
|
companyName: stripeStore.companyName,
|
|
179
175
|
email: stripeLinkData === null || stripeLinkData === void 0 ? void 0 : stripeLinkData.value.email,
|
|
180
176
|
// firstName and lastName should be valid now since stripe only mark
|
|
@@ -182,19 +178,12 @@ export const prepCalculateLandedCost = () => {
|
|
|
182
178
|
firstName: shippingFirstName,
|
|
183
179
|
lastName: shippingLastName,
|
|
184
180
|
phone: translatedShippingAddress.phone,
|
|
185
|
-
},
|
|
186
|
-
isTest: isE2ETest,
|
|
187
|
-
items: cartStore.items,
|
|
188
|
-
landedCostAdjustments: adjustments,
|
|
189
|
-
shipToShortAddressCode: stripeStore.shortAddressCode,
|
|
190
|
-
shipToTaxId: stripeStore.taxId,
|
|
191
|
-
shippingAddress: {
|
|
181
|
+
}, isTest: isE2ETest, items: cartStore.items, landedCostAdjustments: adjustments, shipToShortAddressCode: stripeStore.shortAddressCode }, shipToTaxId), { shippingAddress: {
|
|
192
182
|
addressLine1: translatedShippingAddress.line1,
|
|
193
183
|
addressLine2: translatedShippingAddress.line2,
|
|
194
184
|
city: translatedShippingAddress.city,
|
|
195
185
|
country: translatedShippingAddress.country,
|
|
196
186
|
postalCode: translatedShippingAddress.postal_code,
|
|
197
187
|
state: translatedShippingAddress.state,
|
|
198
|
-
}
|
|
199
|
-
};
|
|
188
|
+
} });
|
|
200
189
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { stripeStore } from "../../store/checkout/stripe";
|
|
2
|
+
import { getShouldRequirePeruTaxId } from "../../store/zonosStore";
|
|
3
|
+
import { resolveTaxIdSelection } from "./resolveTaxIdSelection";
|
|
4
|
+
/** Tax id to send for the destination, or null while the field is hidden. */
|
|
5
|
+
export const getCheckoutTaxIdPayload = (countryCode) => {
|
|
6
|
+
const { selectedType, send } = resolveTaxIdSelection({
|
|
7
|
+
companyName: stripeStore.companyName,
|
|
8
|
+
countryCode,
|
|
9
|
+
shouldRequirePeruTaxId: getShouldRequirePeruTaxId(),
|
|
10
|
+
taxIdType: stripeStore.taxIdType,
|
|
11
|
+
});
|
|
12
|
+
if (!send) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return Object.assign({ taxId: stripeStore.taxId }, (selectedType ? { taxIdType: selectedType.value } : {}));
|
|
16
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resolveTaxIdSelection } from "./resolveTaxIdSelection";
|
|
2
|
+
import { taxIdLabelForCheckout } from "../taxId/taxIdRules";
|
|
3
|
+
export const getTaxIdFieldState = ({ companyName, countryCode, errorField, errorMessage, shouldRequirePeruTaxId, taxIdType, }) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const { rendered, selectedType, send, typeOptions } = resolveTaxIdSelection({
|
|
6
|
+
companyName,
|
|
7
|
+
countryCode,
|
|
8
|
+
shouldRequirePeruTaxId,
|
|
9
|
+
taxIdType,
|
|
10
|
+
});
|
|
11
|
+
if (!rendered) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const singleTypeLabel = typeOptions
|
|
15
|
+
? null
|
|
16
|
+
: taxIdLabelForCheckout(countryCode);
|
|
17
|
+
return {
|
|
18
|
+
inputLabel: (_a = selectedType === null || selectedType === void 0 ? void 0 : selectedType.label) !== null && _a !== void 0 ? _a : singleTypeLabel === null || singleTypeLabel === void 0 ? void 0 : singleTypeLabel.friendlyName,
|
|
19
|
+
inputPlaceholder: (_b = selectedType === null || selectedType === void 0 ? void 0 : selectedType.placeholder) !== null && _b !== void 0 ? _b : singleTypeLabel === null || singleTypeLabel === void 0 ? void 0 : singleTypeLabel.placeholder,
|
|
20
|
+
selectedValue: (selectedType === null || selectedType === void 0 ? void 0 : selectedType.value) || '',
|
|
21
|
+
showValueInput: send,
|
|
22
|
+
typeError: errorField === 'type' ? errorMessage : '',
|
|
23
|
+
typeOptions,
|
|
24
|
+
valueError: errorField === 'value' ? errorMessage : '',
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { shouldRenderTaxIdInput } from "./shouldRenderTaxIdInput";
|
|
2
|
+
import { taxIdTypeOptionsForCheckout } from "../taxId/taxIdRules";
|
|
3
|
+
/** Whether the field is showing, and which of this country's types is selected. */
|
|
4
|
+
export const resolveTaxIdSelection = ({ companyName, countryCode, shouldRequirePeruTaxId, taxIdType, }) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const typeOptions = taxIdTypeOptionsForCheckout({
|
|
7
|
+
countryCode,
|
|
8
|
+
shouldRequirePeruTaxId,
|
|
9
|
+
});
|
|
10
|
+
const selectedType = (_a = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.find(option => option.value === taxIdType)) !== null && _a !== void 0 ? _a : null;
|
|
11
|
+
const rendered = shouldRenderTaxIdInput({
|
|
12
|
+
companyName,
|
|
13
|
+
countryCode,
|
|
14
|
+
shouldRequirePeruTaxId,
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
rendered,
|
|
18
|
+
selectedType,
|
|
19
|
+
// A multi-type country sends a number only after the shopper picks a type.
|
|
20
|
+
send: rendered && (!typeOptions || !!selectedType),
|
|
21
|
+
typeOptions,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
return countryRequireTaxId.includes(countryCode);
|
|
4
|
-
};
|
|
1
|
+
import { isPeruTaxIdActive } from "../taxId/taxIdRules";
|
|
2
|
+
import { euCountryCodes, isCountryRequireTaxId, } from "../../../types/checkout/TaxId";
|
|
5
3
|
/**
|
|
6
4
|
* Checks if the tax ID input should be rendered based on the company name and country code.
|
|
7
5
|
*/
|
|
8
|
-
export const shouldRenderTaxIdInput = ({ companyName, countryCode, }) => {
|
|
6
|
+
export const shouldRenderTaxIdInput = ({ companyName, countryCode, shouldRequirePeruTaxId, }) => {
|
|
7
|
+
if (isPeruTaxIdActive({ countryCode, shouldRequirePeruTaxId })) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
9
10
|
// Only show the tax ID input if the country is in the EU and the company name is provided
|
|
10
11
|
if (euCountryCodes.includes(countryCode)) {
|
|
11
12
|
return companyName.trim().length > 0;
|
|
12
13
|
}
|
|
13
14
|
// If country require tax id, show the input
|
|
14
|
-
|
|
15
|
-
if (isCountryRequireTaxId) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
// If country doesn't require tax ID, no need to show the input
|
|
19
|
-
return false;
|
|
15
|
+
return isCountryRequireTaxId(countryCode);
|
|
20
16
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { stripeStore } from "../../store/checkout/stripe";
|
|
3
|
+
import { translate } from "../../store/translationStore";
|
|
4
|
+
import { getTaxIdFieldState } from "./getTaxIdFieldState";
|
|
5
|
+
import { isCheckoutTaxIdTypeValue } from "../taxId/taxIdRules";
|
|
6
|
+
export const renderTaxIdFields = ({ companyName, countryCode, errorField, errorMessage, onTaxIdChange, shouldRequirePeruTaxId, taxId, taxIdType, }) => {
|
|
7
|
+
const state = getTaxIdFieldState({
|
|
8
|
+
companyName,
|
|
9
|
+
countryCode,
|
|
10
|
+
errorField,
|
|
11
|
+
errorMessage,
|
|
12
|
+
shouldRequirePeruTaxId,
|
|
13
|
+
taxIdType,
|
|
14
|
+
});
|
|
15
|
+
if (!state) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return (h("div", { class: "zonos--tax-id-input" }, state.typeOptions && (h("zonos-stripe-select", { error: state.typeError, isError: !!state.typeError, onSelectChange: (event) => {
|
|
19
|
+
if (isCheckoutTaxIdTypeValue(event.detail)) {
|
|
20
|
+
stripeStore.taxIdType = event.detail;
|
|
21
|
+
}
|
|
22
|
+
}, options: state.typeOptions.map(option => ({
|
|
23
|
+
label: translate(option.label),
|
|
24
|
+
value: option.value,
|
|
25
|
+
})), selectLabel: translate('Tax id type'), selectedValue: state.selectedValue, value: state.selectedValue })), state.showValueInput && (h("zonos-stripe-input", { error: state.valueError, inputLabel: state.inputLabel ? translate(state.inputLabel) : '', inputPlaceholder: state.inputPlaceholder || '', inputValue: taxId, isError: !!state.valueError, onInputChange: (event) => {
|
|
26
|
+
stripeStore.taxId = event.detail;
|
|
27
|
+
onTaxIdChange === null || onTaxIdChange === void 0 ? void 0 : onTaxIdChange(event.detail);
|
|
28
|
+
} }))));
|
|
29
|
+
};
|
|
@@ -17,6 +17,7 @@ import { jsonParse } from "./jsonParse";
|
|
|
17
17
|
import { log } from "./logging/log";
|
|
18
18
|
import { prepLoadTimeApiLog } from "./logging/prepLoadTimeApiLog";
|
|
19
19
|
import { sendErrorLog } from "./logging/sendErrorLog";
|
|
20
|
+
const isGatewayStatus = (status) => status === 502 || status === 503 || status === 504;
|
|
20
21
|
const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
|
|
21
22
|
try {
|
|
22
23
|
const text = await response.text();
|
|
@@ -137,28 +138,31 @@ const handleRequest = async ({ basePathType, options, path, }) => {
|
|
|
137
138
|
}
|
|
138
139
|
catch (_a) {
|
|
139
140
|
const message = 'Unknown error';
|
|
141
|
+
// A gateway HTML or empty body still carries a status a GET can fail over
|
|
142
|
+
// on. Other non-JSON statuses, including 404 and 500, keep the previous
|
|
143
|
+
// null response so they do not fail over.
|
|
140
144
|
return {
|
|
141
145
|
baseUrl,
|
|
142
146
|
errors: [{ message: `${status}: ${message}`, type: status }],
|
|
143
147
|
json: null,
|
|
144
|
-
response: null,
|
|
148
|
+
response: isGatewayStatus(response.status) ? response : null,
|
|
145
149
|
zonosMode,
|
|
146
150
|
};
|
|
147
151
|
}
|
|
148
152
|
};
|
|
149
153
|
const handleRequestWithFallback = async ({ basePathType: _basePathType, options, path, }) => {
|
|
150
|
-
var _a, _b;
|
|
154
|
+
var _a, _b, _c;
|
|
151
155
|
// use vercel API if the path is `/api/bigcommerce`
|
|
152
156
|
const isBigcommerceEndpoint = path.startsWith('/api/bigcommerce');
|
|
153
157
|
const basePathType = isBigcommerceEndpoint
|
|
154
158
|
? 'vercel'
|
|
155
159
|
: _basePathType;
|
|
156
160
|
const startTime = performance.now();
|
|
157
|
-
const
|
|
161
|
+
const _d = await handleRequest({
|
|
158
162
|
basePathType,
|
|
159
163
|
options,
|
|
160
164
|
path,
|
|
161
|
-
}), { errors, response } =
|
|
165
|
+
}), { errors, response } = _d, rest = __rest(_d, ["errors", "response"]);
|
|
162
166
|
const endTime = performance.now();
|
|
163
167
|
const duration = endTime - startTime;
|
|
164
168
|
// Send the load time api log
|
|
@@ -180,10 +184,16 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
180
184
|
(message.includes('signal is aborted') ||
|
|
181
185
|
message.includes('The operation was aborted') ||
|
|
182
186
|
message.includes('Fetch is aborted')));
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
+
const statusCode = response === null || response === void 0 ? void 0 : response.status;
|
|
188
|
+
const gateway = statusCode !== undefined && isGatewayStatus(statusCode);
|
|
189
|
+
// handleFetch sets method, and a missing method is a GET.
|
|
190
|
+
const isIdempotentGet = ((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'GET').toUpperCase() === 'GET';
|
|
191
|
+
const failedWithoutGateway = !!unknownError || statusCode === 404 || statusCode === 500;
|
|
192
|
+
const isUnknownError = failedWithoutGateway || gateway;
|
|
193
|
+
// Replay 502, 503, and 504 only for GET. A gateway timeout on a POST can
|
|
194
|
+
// mean the first host is still finishing a payment or order write.
|
|
195
|
+
const shouldCallFallback = nextFallbackApiType &&
|
|
196
|
+
(failedWithoutGateway || (gateway && isIdempotentGet));
|
|
187
197
|
// Should log the error if it's unknown error
|
|
188
198
|
if (isUnknownError && !isAbortError) {
|
|
189
199
|
void sendErrorLog({
|
|
@@ -193,7 +203,7 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
193
203
|
currentBasePath: basePathType,
|
|
194
204
|
nextFallbackApiType,
|
|
195
205
|
requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
|
|
196
|
-
requestPayload: jsonParse((
|
|
206
|
+
requestPayload: jsonParse((_b = options === null || options === void 0 ? void 0 : options.body) === null || _b === void 0 ? void 0 : _b.toString()) || ((_c = options === null || options === void 0 ? void 0 : options.body) === null || _c === void 0 ? void 0 : _c.toString()),
|
|
197
207
|
shouldCallFallback,
|
|
198
208
|
status: response === null || response === void 0 ? void 0 : response.status,
|
|
199
209
|
statusText: response === null || response === void 0 ? void 0 : response.statusText,
|