@zonos/elements 1.3.208 → 1.3.209
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/{cart-47c17ebf.js → cart-2ec8cac2.js} +285 -40
- package/dist/cjs/{debounce-0b9c0f8a.js → debounce-465a4328.js} +1 -1
- package/dist/cjs/{getBorderRadius-c424eb05.js → getBorderRadius-1b5e33cf.js} +1 -1
- package/dist/cjs/{handleFetch-969d05d8.js → handleFetch-05227713.js} +2 -6
- package/dist/cjs/index.cjs.js +8 -8
- package/dist/cjs/{isDarkColor-35e8daec.js → isDarkColor-428965f4.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-e9089be5.js → localization-9b43376c.js} +2 -2
- package/dist/cjs/{paypal-3a803d21.js → paypal-6449314e.js} +5 -5
- package/dist/cjs/{updateCheckoutSessionAttributes-d0332530.js → updateCheckoutSessionAttributes-a31bb681.js} +2 -2
- package/dist/cjs/zonos-address_11.cjs.entry.js +104 -84
- 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 +3 -3
- package/dist/cjs/zonos-card.cjs.entry.js +2 -2
- package/dist/cjs/zonos-cart-items_14.cjs.entry.js +91 -41
- package/dist/cjs/zonos-checkout.cjs.entry.js +45 -21
- package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
- package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +13 -9
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +7 -7
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
- package/dist/cjs/zonos-hello.cjs.entry.js +4 -4
- package/dist/cjs/zonos-input.cjs.entry.js +2 -2
- 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-shipping-rich-radio.cjs.entry.js +2 -2
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +3 -3
- package/dist/cjs/zonos-text.cjs.entry.js +1 -1
- package/dist/cjs/zonos-toggle.cjs.entry.js +1 -1
- package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
- package/dist/cjs/{zonosStore-7c1e1bc1.js → zonosStore-f8ee56aa.js} +1 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +36 -12
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +63 -25
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +33 -11
- package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +2 -2
- package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +9 -5
- package/dist/collection/components/store/checkout/cart.js +9 -2
- package/dist/collection/components/store/checkout/stripe.js +266 -31
- package/dist/collection/components/stripe/zonos-address/zonos-address.css +2 -1
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +24 -3
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +2 -1
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +7 -5
- package/dist/collection/components/utils/api/cartCalculateLandedCost.js +3 -2
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +2 -2
- package/dist/collection/components/utils/handleFetch.js +2 -1
- package/dist/collection/components/utils/logging/log.js +0 -5
- package/dist/collection/types/checkout/api/CreateParty.js +1 -0
- package/dist/collection/types/generated/graphql.internal.types.js +3 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/{cart-5b417c0d.js → cart-2f84f632.js} +284 -41
- package/dist/esm/{debounce-7ebfa15b.js → debounce-0e42da22.js} +1 -1
- package/dist/esm/{getBorderRadius-174305ff.js → getBorderRadius-71b3b8ab.js} +1 -1
- package/dist/esm/{handleFetch-621e45bc.js → handleFetch-7dd4622b.js} +2 -6
- package/dist/esm/index.js +8 -8
- package/dist/esm/{isDarkColor-915b06b8.js → isDarkColor-3a9d6108.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-669a1714.js → localization-e17c211b.js} +2 -2
- package/dist/esm/{paypal-3a0cf86b.js → paypal-1cf701aa.js} +6 -6
- package/dist/esm/{updateCheckoutSessionAttributes-183ca6c1.js → updateCheckoutSessionAttributes-5097e715.js} +2 -2
- package/dist/esm/zonos-address_11.entry.js +104 -84
- 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 +3 -3
- package/dist/esm/zonos-card.entry.js +2 -2
- package/dist/esm/zonos-cart-items_14.entry.js +91 -41
- package/dist/esm/zonos-checkout.entry.js +45 -21
- package/dist/esm/zonos-collapse.entry.js +1 -1
- package/dist/esm/zonos-controller.entry.js +6 -6
- package/dist/esm/zonos-country-flag.entry.js +3 -3
- package/dist/esm/zonos-country-select_4.entry.js +13 -9
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-empty-state-payment_4.entry.js +7 -7
- package/dist/esm/zonos-hello-dialog.entry.js +3 -3
- package/dist/esm/zonos-hello.entry.js +4 -4
- package/dist/esm/zonos-input.entry.js +2 -2
- package/dist/esm/zonos-language-select_2.entry.js +3 -3
- package/dist/esm/zonos-logo.entry.js +1 -1
- package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
- package/dist/esm/zonos-stripe-input.entry.js +3 -3
- package/dist/esm/zonos-text.entry.js +1 -1
- package/dist/esm/zonos-toggle.entry.js +1 -1
- package/dist/esm/zonos-v-stack.entry.js +1 -1
- package/dist/esm/{zonosStore-504a7030.js → zonosStore-00975763.js} +1 -1
- package/dist/esm-es5/cart-2f84f632.js +1 -0
- package/dist/esm-es5/{debounce-7ebfa15b.js → debounce-0e42da22.js} +1 -1
- package/dist/esm-es5/{getBorderRadius-174305ff.js → getBorderRadius-71b3b8ab.js} +1 -1
- package/dist/esm-es5/handleFetch-7dd4622b.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{isDarkColor-915b06b8.js → isDarkColor-3a9d6108.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{localization-669a1714.js → localization-e17c211b.js} +1 -1
- package/dist/esm-es5/{paypal-3a0cf86b.js → paypal-1cf701aa.js} +2 -2
- package/dist/esm-es5/{updateCheckoutSessionAttributes-183ca6c1.js → updateCheckoutSessionAttributes-5097e715.js} +1 -1
- package/dist/esm-es5/zonos-address_11.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.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collapse.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-empty-state-payment_4.entry.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-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-logo.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-toggle.entry.js +1 -1
- package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-504a7030.js → zonosStore-00975763.js} +1 -1
- package/dist/scripts/index.d.ts +8 -0
- 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 +8 -4
- package/dist/types/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.d.ts +3 -0
- package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +1 -0
- package/dist/types/components/store/checkout/cart.d.ts +6 -2
- package/dist/types/components/store/checkout/stripe.d.ts +33 -6
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +6 -0
- package/dist/types/types/checkout/api/CheckoutSession.d.ts +2 -0
- package/dist/types/types/checkout/api/CreateParty.d.ts +34 -0
- package/dist/types/types/generated/graphql.internal.types.d.ts +21 -5
- package/dist/types/types/generated/graphql.internal.types.ts +26 -3
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/utils/ZonosSettings.d.ts +6 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-c5455a34.system.js → p-0751b878.system.js} +1 -1
- package/dist/zonos-elements/{p-39039ab7.system.entry.js → p-08b29f73.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0731fbba.entry.js → p-0ca1d6dd.entry.js} +1 -1
- package/dist/zonos-elements/{p-e1c2b8f8.entry.js → p-144b5006.entry.js} +1 -1
- package/dist/zonos-elements/{p-d5bdbbb3.system.js → p-19182dc7.system.js} +1 -1
- package/dist/zonos-elements/{p-066afca1.system.entry.js → p-1dc78af3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5f2a2ca7.js → p-207bd04a.js} +1 -1
- package/dist/zonos-elements/p-20839c46.js +1 -0
- package/dist/zonos-elements/{p-63ca1242.system.entry.js → p-2122d2cc.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a09bdd20.system.entry.js → p-239695e8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-6b406abd.entry.js → p-23fe7661.entry.js} +1 -1
- package/dist/zonos-elements/p-2652198d.js +1 -0
- package/dist/zonos-elements/p-30a9f802.system.entry.js +1 -0
- package/dist/zonos-elements/{p-4451a598.system.js → p-3633a952.system.js} +1 -1
- package/dist/zonos-elements/{p-6be43ba8.entry.js → p-36b686b6.entry.js} +1 -1
- package/dist/zonos-elements/{p-b7a5b367.js → p-371d91d1.js} +2 -2
- package/dist/zonos-elements/{p-081fa4a8.entry.js → p-3934b38a.entry.js} +1 -1
- package/dist/zonos-elements/{p-a4d995a2.system.js → p-3c752420.system.js} +1 -1
- package/dist/zonos-elements/p-3ee44728.system.js +1 -1
- package/dist/zonos-elements/{p-7f568108.system.js → p-44c0a584.system.js} +2 -2
- package/dist/zonos-elements/{p-cd376c7a.system.entry.js → p-45a2f9b1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0d908c15.system.js → p-4a1b4a2d.system.js} +1 -1
- package/dist/zonos-elements/p-4c70fd75.entry.js +1 -0
- package/dist/zonos-elements/{p-07905246.entry.js → p-4d62f3de.entry.js} +1 -1
- package/dist/zonos-elements/{p-bb850bb7.entry.js → p-4dbaa2c2.entry.js} +1 -1
- package/dist/zonos-elements/{p-0fb14108.entry.js → p-4ed73ff8.entry.js} +1 -1
- package/dist/zonos-elements/{p-ef594c0c.entry.js → p-4f5513dc.entry.js} +1 -1
- package/dist/zonos-elements/p-542acc2c.js +1 -0
- package/dist/zonos-elements/p-5711e187.system.js +1 -0
- package/dist/zonos-elements/{p-c607d026.entry.js → p-5956a9e0.entry.js} +1 -1
- package/dist/zonos-elements/{p-d096d7f2.entry.js → p-5b7686f8.entry.js} +1 -1
- package/dist/zonos-elements/{p-67f807bc.entry.js → p-63a4dac5.entry.js} +1 -1
- package/dist/zonos-elements/{p-51d596a0.system.entry.js → p-695bf400.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d35d17f3.js → p-6aa728f2.js} +1 -1
- package/dist/zonos-elements/{p-4bf54953.js → p-71c6bdc3.js} +1 -1
- package/dist/zonos-elements/{p-0f368368.system.js → p-738a49c0.system.js} +1 -1
- package/dist/zonos-elements/{p-7e346632.system.entry.js → p-74276b82.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d1a31577.entry.js → p-77e22be4.entry.js} +1 -1
- package/dist/zonos-elements/{p-a3a8ba10.entry.js → p-78dd1c53.entry.js} +1 -1
- package/dist/zonos-elements/{p-3d6f6367.system.entry.js → p-7f9bbbb3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ea30d92d.system.entry.js → p-896f2358.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a63bac79.system.entry.js → p-8f41d864.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1f706fc9.system.entry.js → p-964e2587.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1530f958.system.entry.js → p-97831744.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-160da12a.system.entry.js → p-9d95c896.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4f04b499.entry.js → p-a24870af.entry.js} +1 -1
- package/dist/zonos-elements/p-a411ce2a.system.js +1 -0
- package/dist/zonos-elements/{p-5c772fab.system.entry.js → p-a4686344.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a158b406.js → p-a6f77d44.js} +1 -1
- package/dist/zonos-elements/{p-fc3a6495.entry.js → p-a8f421ac.entry.js} +1 -1
- package/dist/zonos-elements/{p-da304b78.entry.js → p-aa40d402.entry.js} +1 -1
- package/dist/zonos-elements/{p-6c991320.entry.js → p-ad1e1dbc.entry.js} +1 -1
- package/dist/zonos-elements/p-b1bfeec9.system.entry.js +1 -0
- package/dist/zonos-elements/{p-ab6efb03.system.entry.js → p-baa88176.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-963fa567.system.entry.js → p-bf9cb85f.system.entry.js} +1 -1
- package/dist/zonos-elements/p-bfdb4e7a.entry.js +1 -0
- package/dist/zonos-elements/{p-803e59d2.system.entry.js → p-c345b306.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a958c4f0.system.entry.js → p-d1697144.system.entry.js} +1 -1
- package/dist/zonos-elements/p-d1c0bf92.entry.js +1 -0
- package/dist/zonos-elements/{p-b3fa7f19.js → p-d6a53ea6.js} +1 -1
- package/dist/zonos-elements/{p-02463cc1.system.entry.js → p-db424e02.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-39428328.system.js → p-eb77c0bf.system.js} +1 -1
- package/dist/zonos-elements/{p-f49834d4.system.entry.js → p-ef1ccec6.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5d909d3d.entry.js → p-fdf5b8f4.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/cart-5b417c0d.js +0 -1
- package/dist/esm-es5/handleFetch-621e45bc.js +0 -1
- package/dist/zonos-elements/p-0794c530.entry.js +0 -1
- package/dist/zonos-elements/p-0fc02cde.js +0 -1
- package/dist/zonos-elements/p-1b3e92ea.system.entry.js +0 -1
- package/dist/zonos-elements/p-1b75aa35.system.js +0 -1
- package/dist/zonos-elements/p-2d4e0280.entry.js +0 -1
- package/dist/zonos-elements/p-40a2a649.js +0 -1
- package/dist/zonos-elements/p-5539386e.system.entry.js +0 -1
- package/dist/zonos-elements/p-91553cf0.system.js +0 -1
- package/dist/zonos-elements/p-c740353c.js +0 -1
- package/dist/zonos-elements/p-f1f3a846.entry.js +0 -1
|
@@ -33,7 +33,7 @@ export const prepCartCalculateLandedCost = (cartId) => {
|
|
|
33
33
|
const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
|
|
34
34
|
? stripeStore.stripeAddressEventData
|
|
35
35
|
: stripeStore.stripeBillingAddressEventData;
|
|
36
|
-
if (!
|
|
36
|
+
if (!stripeAddressData || !stripeBillingAddressData) {
|
|
37
37
|
throw new Error('Missing stripe address data');
|
|
38
38
|
}
|
|
39
39
|
// Attempt to get translated address if available
|
|
@@ -110,7 +110,7 @@ export const prepCalculateLandedCost = () => {
|
|
|
110
110
|
? stripeStore.stripeAddressEventData
|
|
111
111
|
: stripeStore.stripeBillingAddressEventData;
|
|
112
112
|
log({ stripeAddressData, stripeBillingAddressData }, 'info');
|
|
113
|
-
if (!
|
|
113
|
+
if (!stripeAddressData || !stripeBillingAddressData) {
|
|
114
114
|
throw new Error('Missing stripe address data');
|
|
115
115
|
}
|
|
116
116
|
// Attempt to get translated address if available
|
|
@@ -176,12 +176,13 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
176
176
|
}
|
|
177
177
|
const nextFallbackApiType = getNextFallbackApiType(basePathType);
|
|
178
178
|
const unknownError = errors.find(({ type }) => type === 'unknown');
|
|
179
|
+
const isAbortError = errors.find(({ message }) => message.includes('signal is aborted'));
|
|
179
180
|
const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
|
|
180
181
|
const shouldCallFallback =
|
|
181
182
|
// If next fallback is available, and the error is unknown (Failed to fetch) or 404
|
|
182
183
|
nextFallbackApiType && isUnknownError;
|
|
183
184
|
// Should log the error if it's unknown error
|
|
184
|
-
if (isUnknownError) {
|
|
185
|
+
if (isUnknownError || isAbortError) {
|
|
185
186
|
void sendErrorLog({
|
|
186
187
|
endpoint: fallbackApiList[basePathType] + path,
|
|
187
188
|
errors: errors.map(({ message }) => `API: ${message}`),
|
|
@@ -35,11 +35,6 @@ export const log = (message, type, ..._additionalInfo) => {
|
|
|
35
35
|
!!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
36
36
|
// if debug is false, do not log
|
|
37
37
|
if (!isDebug) {
|
|
38
|
-
// log errors to the console if the type is error
|
|
39
|
-
if (type === 'error') {
|
|
40
|
-
// eslint-disable-next-line no-console
|
|
41
|
-
console.error(message, ...additionalInfo);
|
|
42
|
-
}
|
|
43
38
|
return;
|
|
44
39
|
}
|
|
45
40
|
let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2952,6 +2952,9 @@ export function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
2952
2952
|
organizations(variables, requestHeaders) {
|
|
2953
2953
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'organizations', 'query');
|
|
2954
2954
|
},
|
|
2955
|
+
partyCreate(variables, requestHeaders) {
|
|
2956
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'partyCreate', 'mutation');
|
|
2957
|
+
},
|
|
2955
2958
|
partyInfo(variables, requestHeaders) {
|
|
2956
2959
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'partyInfo', 'query');
|
|
2957
2960
|
},
|
|
@@ -3,6 +3,7 @@ import "./global.d";
|
|
|
3
3
|
export * from '../components.d';
|
|
4
4
|
export * from './checkout/api/CalculateLandedCost';
|
|
5
5
|
export * from './checkout/api/CheckoutSession';
|
|
6
|
+
export * from './checkout/api/CreateParty';
|
|
6
7
|
export * from './checkout/api/legacy/InventoryCheck';
|
|
7
8
|
export * from './checkout/api/NormalizedTempCart';
|
|
8
9
|
export * from './checkout/api/Paypal';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { z as zonosStore, c as createStore } from './zonosStore-
|
|
2
|
-
import { s as storageStore, l as localizationStore, t as translate, f as filterValidTests, b as storageStoreSetEnabledVariantTestKeys } from './localization-
|
|
3
|
-
import { l as log, f as fallbackApiList, h as handleFetch, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, d as allLogs, b as logError, j as jsonParse } from './handleFetch-
|
|
4
|
-
import { i as isDarkColor } from './isDarkColor-
|
|
5
|
-
import { g as getBorderRadius } from './getBorderRadius-
|
|
1
|
+
import { z as zonosStore, c as createStore } from './zonosStore-00975763.js';
|
|
2
|
+
import { s as storageStore, l as localizationStore, t as translate, f as filterValidTests, b as storageStoreSetEnabledVariantTestKeys } from './localization-e17c211b.js';
|
|
3
|
+
import { l as log, f as fallbackApiList, h as handleFetch, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, d as allLogs, b as logError, j as jsonParse } from './handleFetch-7dd4622b.js';
|
|
4
|
+
import { i as isDarkColor } from './isDarkColor-3a9d6108.js';
|
|
5
|
+
import { g as getBorderRadius } from './getBorderRadius-71b3b8ab.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Extract value from translated object
|
|
@@ -35,7 +35,7 @@ const prepCartCalculateLandedCost = (cartId) => {
|
|
|
35
35
|
const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
|
|
36
36
|
? stripeStore.stripeAddressEventData
|
|
37
37
|
: stripeStore.stripeBillingAddressEventData;
|
|
38
|
-
if (!
|
|
38
|
+
if (!stripeAddressData || !stripeBillingAddressData) {
|
|
39
39
|
throw new Error('Missing stripe address data');
|
|
40
40
|
}
|
|
41
41
|
// Attempt to get translated address if available
|
|
@@ -112,7 +112,7 @@ const prepCalculateLandedCost = () => {
|
|
|
112
112
|
? stripeStore.stripeAddressEventData
|
|
113
113
|
: stripeStore.stripeBillingAddressEventData;
|
|
114
114
|
log({ stripeAddressData, stripeBillingAddressData }, 'info');
|
|
115
|
-
if (!
|
|
115
|
+
if (!stripeAddressData || !stripeBillingAddressData) {
|
|
116
116
|
throw new Error('Missing stripe address data');
|
|
117
117
|
}
|
|
118
118
|
// Attempt to get translated address if available
|
|
@@ -254,7 +254,7 @@ const calculateLandedCost = async (abortController) => {
|
|
|
254
254
|
};
|
|
255
255
|
|
|
256
256
|
const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
|
|
257
|
-
var _a;
|
|
257
|
+
var _a, _b;
|
|
258
258
|
// request to get landed cost info
|
|
259
259
|
const { errors, json } = await handleFetch('/api/zonos-elements/cart-calculate-landed-cost', {
|
|
260
260
|
body: prepCartCalculateLandedCost(cartId),
|
|
@@ -262,7 +262,8 @@ const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
|
|
|
262
262
|
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
263
263
|
});
|
|
264
264
|
if (errors.length || !json) {
|
|
265
|
-
const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.'
|
|
265
|
+
const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.' ||
|
|
266
|
+
((_b = errors[0]) === null || _b === void 0 ? void 0 : _b.message.includes('signal is aborted'));
|
|
266
267
|
const errorMessage = isAbortedRequest
|
|
267
268
|
? 'The landed cost calculation request was aborted to initiate a new one.'
|
|
268
269
|
: 'Failed to calculate landed cost';
|
|
@@ -597,6 +598,7 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
|
|
|
597
598
|
checkoutSettlementCurrency: 'USD',
|
|
598
599
|
clientSecret: sessionStorage.getItem('zonos--client-secret') || '',
|
|
599
600
|
companyName: '',
|
|
601
|
+
companyNameUsedWhenAsyncAddressUpdate: '',
|
|
600
602
|
customAddressErrors: {
|
|
601
603
|
city: '',
|
|
602
604
|
firstName: '',
|
|
@@ -623,6 +625,8 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
|
|
|
623
625
|
hasPaymentError: false,
|
|
624
626
|
isFetchingLandedCost: false,
|
|
625
627
|
isFetchingSession: false,
|
|
628
|
+
partyBillingId: null,
|
|
629
|
+
partyShippingId: null,
|
|
626
630
|
shouldInventoryRefund: false,
|
|
627
631
|
shouldRenderPayInUsdButton: false,
|
|
628
632
|
/**
|
|
@@ -635,10 +639,12 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
|
|
|
635
639
|
stripe: null,
|
|
636
640
|
stripeAddressElement: null,
|
|
637
641
|
stripeAddressEventData: null,
|
|
642
|
+
stripeAddressUsedWhenAsyncAddressUpdate: null,
|
|
638
643
|
stripeAddressUsedWhenFetchingLC: null,
|
|
639
644
|
stripeAddressUsedWhenValidatingAddress: null,
|
|
640
645
|
stripeBillingAddressElement: null,
|
|
641
646
|
stripeBillingAddressEventData: null,
|
|
647
|
+
stripeBillingAddressUsedWhenAsyncAddressUpdate: null,
|
|
642
648
|
stripeBillingAddressUsedWhenFetchingLC: null,
|
|
643
649
|
stripeBillingAddressUsedWhenValidatingAddress: null,
|
|
644
650
|
stripeCustomerSessionClientSecret: null,
|
|
@@ -652,7 +658,7 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = c
|
|
|
652
658
|
stripePaymentEventData: null,
|
|
653
659
|
stripeShippingSameAsBilling: true,
|
|
654
660
|
taxId: '',
|
|
655
|
-
|
|
661
|
+
taxIdUsedWhenAsyncAddressUpdate: '',
|
|
656
662
|
translatedAddress: {
|
|
657
663
|
address: {},
|
|
658
664
|
billingAddress: {},
|
|
@@ -757,15 +763,178 @@ const checkIsAddressOutdatedForValidation = () => {
|
|
|
757
763
|
JSON.stringify((_d = stripeStore.stripeBillingAddressUsedWhenValidatingAddress) === null || _d === void 0 ? void 0 : _d.value);
|
|
758
764
|
return isAddressDataDirty || isBillingAddressDataDirty;
|
|
759
765
|
};
|
|
760
|
-
const
|
|
766
|
+
const checkIsAddressOutdatedForAsyncAddressUpdate = () => {
|
|
761
767
|
var _a, _b, _c, _d, _e, _f;
|
|
762
768
|
const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
|
|
763
769
|
JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
|
|
764
|
-
const isAddressDataDirty = JSON.stringify((_c = stripeStore.
|
|
765
|
-
JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
|
|
770
|
+
const isAddressDataDirty = JSON.stringify((_c = stripeStore.stripeAddressUsedWhenAsyncAddressUpdate) === null || _c === void 0 ? void 0 : _c.value) !== JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
|
|
766
771
|
const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
|
|
767
|
-
JSON.stringify((_e = stripeStore.
|
|
768
|
-
|
|
772
|
+
JSON.stringify((_e = stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate) === null || _e === void 0 ? void 0 : _e.value) !== JSON.stringify((_f = stripeStore.stripeBillingAddressEventData) === null || _f === void 0 ? void 0 : _f.value);
|
|
773
|
+
const isTaxIdDirty = stripeStore.taxIdUsedWhenAsyncAddressUpdate !== stripeStore.taxId;
|
|
774
|
+
const isCompanyNameDirty = stripeStore.companyNameUsedWhenAsyncAddressUpdate !==
|
|
775
|
+
stripeStore.companyName;
|
|
776
|
+
return (isLinkDataDirty ||
|
|
777
|
+
isAddressDataDirty ||
|
|
778
|
+
isBillingAddressDataDirty ||
|
|
779
|
+
isTaxIdDirty ||
|
|
780
|
+
isCompanyNameDirty);
|
|
781
|
+
};
|
|
782
|
+
const buildAddressForPartyCreate = ({ address, firstName, lastName, name, phone, }) => {
|
|
783
|
+
const _firstName = (name === null || name === void 0 ? void 0 : name.split(' ')[0]) || firstName || '';
|
|
784
|
+
const _lastName = (name === null || name === void 0 ? void 0 : name.split(' ')[1]) || lastName || '';
|
|
785
|
+
if (!_firstName || !_lastName) {
|
|
786
|
+
void sendErrorLog({
|
|
787
|
+
endpoint: 'PARTY_CREATE_NO_NAME_FOUND',
|
|
788
|
+
errors: ['No name found'],
|
|
789
|
+
metadata: {
|
|
790
|
+
allLogs,
|
|
791
|
+
cartId: window.Zonos.cartId,
|
|
792
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
793
|
+
firstName,
|
|
794
|
+
lastName,
|
|
795
|
+
name,
|
|
796
|
+
},
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
if (!phone) {
|
|
800
|
+
void sendErrorLog({
|
|
801
|
+
endpoint: 'PARTY_CREATE_NO_PHONE_FOUND',
|
|
802
|
+
errors: ['No phone found'],
|
|
803
|
+
metadata: {
|
|
804
|
+
allLogs,
|
|
805
|
+
cartId: window.Zonos.cartId,
|
|
806
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
807
|
+
phone,
|
|
808
|
+
},
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
return {
|
|
812
|
+
city: address.city,
|
|
813
|
+
country: address.country,
|
|
814
|
+
firstName: _firstName,
|
|
815
|
+
lastName: _lastName,
|
|
816
|
+
line1: address.line1,
|
|
817
|
+
line2: address.line2,
|
|
818
|
+
phone: phone || '',
|
|
819
|
+
postal_code: address.postal_code,
|
|
820
|
+
state: address.state,
|
|
821
|
+
};
|
|
822
|
+
};
|
|
823
|
+
const stripeStoreAsyncAddressUpdate = async () => {
|
|
824
|
+
var _a, _b, _c, _d;
|
|
825
|
+
if (!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete) ||
|
|
826
|
+
(!stripeStore.stripeShippingSameAsBilling &&
|
|
827
|
+
!((_b = stripeStore.stripeBillingAddressEventData) === null || _b === void 0 ? void 0 : _b.complete)) ||
|
|
828
|
+
!stripeStore.stripeBillingAddressEventData) {
|
|
829
|
+
return {
|
|
830
|
+
partiesCreated: false,
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
// If there is no landed cost data, no need to create parties
|
|
834
|
+
if (!cartStore.landedCostData) {
|
|
835
|
+
return {
|
|
836
|
+
partiesCreated: false,
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
const firstLandedCostRootId = (_c = cartStore.landedCostData.find(Boolean)) === null || _c === void 0 ? void 0 : _c.landedCost.rootId;
|
|
840
|
+
if (!firstLandedCostRootId) {
|
|
841
|
+
// do nothing if we don't have selected landed cost
|
|
842
|
+
void sendErrorLog({
|
|
843
|
+
endpoint: 'PF_NO_SELECTED_LANDED_COST',
|
|
844
|
+
errors: ['No selected landed cost'],
|
|
845
|
+
metadata: {
|
|
846
|
+
allLogs,
|
|
847
|
+
cartId: window.Zonos.cartId,
|
|
848
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
849
|
+
},
|
|
850
|
+
});
|
|
851
|
+
return {
|
|
852
|
+
partiesCreated: false,
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
const isAddressOutdated = checkIsAddressOutdatedForAsyncAddressUpdate();
|
|
856
|
+
if (!isAddressOutdated) {
|
|
857
|
+
return {
|
|
858
|
+
partiesCreated: false,
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
const address = buildAddressForPartyCreate({
|
|
862
|
+
address: stripeStore.stripeAddressEventData.value.address,
|
|
863
|
+
firstName: stripeStore.stripeAddressEventData.value.firstName,
|
|
864
|
+
lastName: stripeStore.stripeAddressEventData.value.lastName,
|
|
865
|
+
name: stripeStore.stripeAddressEventData.value.name,
|
|
866
|
+
phone: stripeStore.stripeAddressEventData.value.phone,
|
|
867
|
+
});
|
|
868
|
+
const billingAddress = stripeStore.stripeShippingSameAsBilling
|
|
869
|
+
? address
|
|
870
|
+
: buildAddressForPartyCreate({
|
|
871
|
+
address: stripeStore.stripeBillingAddressEventData.value.address,
|
|
872
|
+
firstName: stripeStore.stripeBillingAddressEventData.value.firstName,
|
|
873
|
+
lastName: stripeStore.stripeBillingAddressEventData.value.lastName,
|
|
874
|
+
name: stripeStore.stripeBillingAddressEventData.value.name,
|
|
875
|
+
phone: stripeStore.stripeBillingAddressEventData.value.phone,
|
|
876
|
+
});
|
|
877
|
+
const isE2ETest = new URLSearchParams(window.location.search).get('zonosE2ETest') === '1';
|
|
878
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/create-parties', {
|
|
879
|
+
body: {
|
|
880
|
+
address,
|
|
881
|
+
billingAddress,
|
|
882
|
+
companyName: stripeStore.companyName,
|
|
883
|
+
email: ((_d = stripeStore.stripeLinkEventData) === null || _d === void 0 ? void 0 : _d.value.email) || '',
|
|
884
|
+
isTest: isE2ETest,
|
|
885
|
+
rootId: firstLandedCostRootId,
|
|
886
|
+
taxId: stripeStore.taxId,
|
|
887
|
+
},
|
|
888
|
+
method: 'POST',
|
|
889
|
+
});
|
|
890
|
+
if (errors.length || !json) {
|
|
891
|
+
logError('Error occurs when creating parties', JSON.stringify(errors, null, 2));
|
|
892
|
+
void sendErrorLog({
|
|
893
|
+
endpoint: 'PF_PARTY_CREATE_FAILED',
|
|
894
|
+
errors: ['Failed to create parties'],
|
|
895
|
+
metadata: {
|
|
896
|
+
allLogs,
|
|
897
|
+
cartId: window.Zonos.cartId,
|
|
898
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
899
|
+
errors,
|
|
900
|
+
json,
|
|
901
|
+
},
|
|
902
|
+
});
|
|
903
|
+
return {
|
|
904
|
+
partiesCreated: false,
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
stripeStore.companyNameUsedWhenAsyncAddressUpdate = stripeStore.companyName;
|
|
908
|
+
stripeStore.stripeAddressUsedWhenAsyncAddressUpdate =
|
|
909
|
+
stripeStore.stripeAddressEventData;
|
|
910
|
+
stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate =
|
|
911
|
+
stripeStore.stripeBillingAddressEventData;
|
|
912
|
+
stripeStore.taxIdUsedWhenAsyncAddressUpdate = stripeStore.taxId;
|
|
913
|
+
stripeStore.partyBillingId = json.billToPartyId;
|
|
914
|
+
stripeStore.partyShippingId = json.shipToPartyId;
|
|
915
|
+
return {
|
|
916
|
+
partiesCreated: true,
|
|
917
|
+
};
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* Extract only the necessary address info for landed cost prefetch
|
|
921
|
+
*/
|
|
922
|
+
const buildAddressForLCPrefetch = (address) => {
|
|
923
|
+
return {
|
|
924
|
+
countryCode: address.address.country,
|
|
925
|
+
postalCode: address.address.postal_code,
|
|
926
|
+
state: address.address.state,
|
|
927
|
+
};
|
|
928
|
+
};
|
|
929
|
+
const checkIsAddressOutdatedForLCPrefetch = () => {
|
|
930
|
+
var _a, _b;
|
|
931
|
+
const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
|
|
932
|
+
JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
|
|
933
|
+
const isAddressDataDirty = stripeStore.stripeAddressEventData &&
|
|
934
|
+
JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeAddressEventData.value)) !== JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC);
|
|
935
|
+
const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
|
|
936
|
+
stripeStore.stripeBillingAddressEventData &&
|
|
937
|
+
JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeBillingAddressEventData.value)) !== JSON.stringify(stripeStore.stripeBillingAddressUsedWhenFetchingLC);
|
|
769
938
|
return isLinkDataDirty || isAddressDataDirty || isBillingAddressDataDirty;
|
|
770
939
|
};
|
|
771
940
|
/**
|
|
@@ -779,14 +948,64 @@ const isPrefetchInfoOutdated = () => {
|
|
|
779
948
|
((_a = cartStore.landedCostData.find(Boolean)) === null || _a === void 0 ? void 0 : _a.subtotals.items) !==
|
|
780
949
|
cartStore.subtotal;
|
|
781
950
|
const isAddressOutdated = checkIsAddressOutdatedForLCPrefetch();
|
|
782
|
-
|
|
783
|
-
|
|
951
|
+
log('isPrefetchInfoOutdated', 'info', {
|
|
952
|
+
isAddressOutdated,
|
|
953
|
+
});
|
|
784
954
|
return (
|
|
785
955
|
// if landed cost data is not available, we need to fetch it
|
|
786
|
-
!cartStore.landedCostData ||
|
|
956
|
+
(!cartStore.landedCostData && !stripeStore.isFetchingLandedCost) ||
|
|
787
957
|
isAddressOutdated ||
|
|
788
|
-
isTotalAmountChanged
|
|
789
|
-
|
|
958
|
+
isTotalAmountChanged);
|
|
959
|
+
};
|
|
960
|
+
const getCountryField = (country) => {
|
|
961
|
+
var _a, _b;
|
|
962
|
+
const countryFieldLabels = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryFields;
|
|
963
|
+
const stripeCountryFieldLabels = (_b = zonosStore.genericSettings) === null || _b === void 0 ? void 0 : _b.stripeCountryFieldLabels;
|
|
964
|
+
const stripeFoundCountryField = stripeCountryFieldLabels && country in stripeCountryFieldLabels
|
|
965
|
+
? stripeCountryFieldLabels[country]
|
|
966
|
+
: null;
|
|
967
|
+
const zonosFoundCountryField = countryFieldLabels && country in countryFieldLabels
|
|
968
|
+
? countryFieldLabels[country]
|
|
969
|
+
: null;
|
|
970
|
+
/**
|
|
971
|
+
* If the address form is using Stripe component, use Stripe country field label if there is one, if not just use one from our countryFieldLabel data
|
|
972
|
+
* stripeCountryFieldLabels is the list we collect from Stripe, and extract only country that state/zip is required and different from what we have in our countryFieldLabel data
|
|
973
|
+
**/
|
|
974
|
+
if (cartStore.addressFormRenderType === 'stripe') {
|
|
975
|
+
return stripeFoundCountryField || zonosFoundCountryField;
|
|
976
|
+
}
|
|
977
|
+
return zonosFoundCountryField;
|
|
978
|
+
};
|
|
979
|
+
const isAddressReadyToRequestLandedCost = () => {
|
|
980
|
+
var _a, _b, _c, _d;
|
|
981
|
+
const linkReady = !!((_a = stripeStore.stripeLinkEventData) === null || _a === void 0 ? void 0 : _a.complete);
|
|
982
|
+
const shippingAddressReady = !!((_b = stripeStore.stripeAddressEventData) === null || _b === void 0 ? void 0 : _b.complete);
|
|
983
|
+
const billingAddressReady = stripeStore.stripeShippingSameAsBilling
|
|
984
|
+
? shippingAddressReady
|
|
985
|
+
: !!((_c = stripeStore.stripeBillingAddressEventData) === null || _c === void 0 ? void 0 : _c.complete);
|
|
986
|
+
const shipToCountry = ((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value.address.country) || 'US';
|
|
987
|
+
const countryField = getCountryField(shipToCountry);
|
|
988
|
+
// Only send landed cost request if the address is complete when we can't get the country field
|
|
989
|
+
if (!countryField || !stripeStore.stripeAddressEventData) {
|
|
990
|
+
return shippingAddressReady && billingAddressReady && linkReady;
|
|
991
|
+
}
|
|
992
|
+
const isValidLine1 = stripeStore.stripeAddressEventData.value.address.line1.length > 0;
|
|
993
|
+
const isValidName = stripeStore.stripeAddressEventData.value.firstName &&
|
|
994
|
+
stripeStore.stripeAddressEventData.value.lastName;
|
|
995
|
+
const isStateValid = !countryField.stateRequired ||
|
|
996
|
+
(countryField.stateRequired &&
|
|
997
|
+
stripeStore.stripeAddressEventData.value.address.state.length > 0);
|
|
998
|
+
const isPostalCodeValid = !countryField.zipRequired ||
|
|
999
|
+
(countryField.zipRequired &&
|
|
1000
|
+
stripeStore.stripeAddressEventData.value.address.postal_code.length >= 3);
|
|
1001
|
+
const hasPhoneNumber = stripeStore.stripeAddressEventData.value.phone &&
|
|
1002
|
+
stripeStore.stripeAddressEventData.value.phone.length > 0;
|
|
1003
|
+
return (linkReady &&
|
|
1004
|
+
isValidName &&
|
|
1005
|
+
isValidLine1 &&
|
|
1006
|
+
isStateValid &&
|
|
1007
|
+
isPostalCodeValid &&
|
|
1008
|
+
hasPhoneNumber);
|
|
790
1009
|
};
|
|
791
1010
|
const stripeCalculateLandedCost = async () => {
|
|
792
1011
|
var _a;
|
|
@@ -835,26 +1054,27 @@ const stripeCalculateLandedCost = async () => {
|
|
|
835
1054
|
}
|
|
836
1055
|
};
|
|
837
1056
|
const stripeStorePrefetchLandedCost = async (params) => {
|
|
838
|
-
var _a, _b, _c, _d
|
|
1057
|
+
var _a, _b, _c, _d;
|
|
839
1058
|
const retries = (params === null || params === void 0 ? void 0 : params.retries) || 0;
|
|
840
1059
|
const applyingPromocode = !!(params === null || params === void 0 ? void 0 : params.applyingPromocode);
|
|
841
|
-
const stripeAddressReady = !!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete);
|
|
842
|
-
const stripeLinkReady = !!((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.complete);
|
|
843
|
-
const stripeBillingAddressReady = stripeStore.stripeShippingSameAsBilling
|
|
844
|
-
? !!((_c = stripeStore.stripeLinkEventData) === null || _c === void 0 ? void 0 : _c.complete)
|
|
845
|
-
: !!((_d = stripeStore.stripeBillingAddressEventData) === null || _d === void 0 ? void 0 : _d.complete);
|
|
846
1060
|
const shouldRefetch = isPrefetchInfoOutdated();
|
|
1061
|
+
const isRequestReadyToPrefetch = isAddressReadyToRequestLandedCost();
|
|
1062
|
+
// Should not do anything if the address is not ready to request landed cost
|
|
1063
|
+
if (!isRequestReadyToPrefetch) {
|
|
1064
|
+
return {
|
|
1065
|
+
isRequestNotReady: true,
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
847
1068
|
if (shouldRefetch) {
|
|
848
1069
|
// if the info used when fetching landed cost is different from the current info, abort the previous request
|
|
849
|
-
(
|
|
1070
|
+
(_a = stripeStore.fetchingLandedCostAbortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
850
1071
|
stripeStore.fetchingLandedCostAbortController = null;
|
|
851
1072
|
}
|
|
852
1073
|
// Do not fetch if we are not ready or data is not outdated
|
|
853
|
-
if (
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
return;
|
|
1074
|
+
if (!shouldRefetch && !applyingPromocode) {
|
|
1075
|
+
return {
|
|
1076
|
+
isRequestNotReady: false,
|
|
1077
|
+
};
|
|
858
1078
|
}
|
|
859
1079
|
// If there is retries, stop loading for a moment and then showing the spinner again (this is just so customer can see that checkout is doing something and not stuck)
|
|
860
1080
|
if (retries) {
|
|
@@ -867,24 +1087,31 @@ const stripeStorePrefetchLandedCost = async (params) => {
|
|
|
867
1087
|
stripeStore.isFetchingLandedCost = true;
|
|
868
1088
|
}
|
|
869
1089
|
if (stripeStore.stripeAddressEventData) {
|
|
870
|
-
stripeStore.stripeAddressUsedWhenFetchingLC =
|
|
1090
|
+
stripeStore.stripeAddressUsedWhenFetchingLC = {
|
|
1091
|
+
countryCode: stripeStore.stripeAddressEventData.value.address.country,
|
|
1092
|
+
postalCode: stripeStore.stripeAddressEventData.value.address.postal_code,
|
|
1093
|
+
state: stripeStore.stripeAddressEventData.value.address.state,
|
|
1094
|
+
};
|
|
871
1095
|
}
|
|
872
1096
|
if (stripeStore.stripeBillingAddressEventData) {
|
|
873
|
-
stripeStore.stripeBillingAddressUsedWhenFetchingLC =
|
|
1097
|
+
stripeStore.stripeBillingAddressUsedWhenFetchingLC = {
|
|
1098
|
+
countryCode: stripeStore.stripeBillingAddressEventData.value.address.country,
|
|
1099
|
+
postalCode: stripeStore.stripeBillingAddressEventData.value.address.postal_code,
|
|
1100
|
+
state: stripeStore.stripeBillingAddressEventData.value.address.state,
|
|
1101
|
+
};
|
|
874
1102
|
}
|
|
875
1103
|
if (stripeStore.stripeLinkEventData) {
|
|
876
1104
|
stripeStore.stripeLinkUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeLinkEventData);
|
|
877
1105
|
}
|
|
878
|
-
stripeStore.taxIdUsedWhenFetchingLC = stripeStore.taxId;
|
|
879
1106
|
try {
|
|
880
1107
|
// Reset cart items to non-restricted state and restricted item list
|
|
881
1108
|
cartStoreResetCartItems();
|
|
882
1109
|
// fetch and apply landed cost
|
|
883
1110
|
await stripeCalculateLandedCost();
|
|
884
1111
|
// This is the cheapest service level since we already sorted them after fetching landed cost
|
|
885
|
-
const cheapestServiceLevel = (
|
|
1112
|
+
const cheapestServiceLevel = (_b = cartStore.shippingData) === null || _b === void 0 ? void 0 : _b.find(Boolean);
|
|
886
1113
|
// Landed cost that matches with service level
|
|
887
|
-
const matchLandedCost = (
|
|
1114
|
+
const matchLandedCost = (_c = cartStore.landedCostData) === null || _c === void 0 ? void 0 : _c.find(x => x.landedCost.shipmentRating.id === (cheapestServiceLevel === null || cheapestServiceLevel === void 0 ? void 0 : cheapestServiceLevel.id));
|
|
888
1115
|
// apply new subtotal and total, this is mainly to show items in the presentment currency
|
|
889
1116
|
const subtotals = !!matchLandedCost ? matchLandedCost.subtotals : null;
|
|
890
1117
|
if (subtotals) {
|
|
@@ -908,9 +1135,11 @@ const stripeStorePrefetchLandedCost = async (params) => {
|
|
|
908
1135
|
if (retries < 1) {
|
|
909
1136
|
// retry fetching landed cost one more time
|
|
910
1137
|
await stripeStorePrefetchLandedCost(Object.assign(Object.assign({}, params), { retries: (retries || 0) + 1 }));
|
|
911
|
-
return
|
|
1138
|
+
return {
|
|
1139
|
+
isRequestNotReady: false,
|
|
1140
|
+
};
|
|
912
1141
|
}
|
|
913
|
-
const shipToAddress = (
|
|
1142
|
+
const shipToAddress = (_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value;
|
|
914
1143
|
void sendErrorLog({
|
|
915
1144
|
endpoint: `Failed to fetch landed cost (${retries} retries)`,
|
|
916
1145
|
errors: [err.message],
|
|
@@ -923,6 +1152,9 @@ const stripeStorePrefetchLandedCost = async (params) => {
|
|
|
923
1152
|
logError(err);
|
|
924
1153
|
}
|
|
925
1154
|
stripeStore.isFetchingLandedCost = false;
|
|
1155
|
+
return {
|
|
1156
|
+
isRequestNotReady: false,
|
|
1157
|
+
};
|
|
926
1158
|
};
|
|
927
1159
|
const stripeStoreApplyPromoCode = async () => {
|
|
928
1160
|
var _a, _b;
|
|
@@ -933,6 +1165,8 @@ const stripeStoreApplyPromoCode = async () => {
|
|
|
933
1165
|
if (cartStore.step === 'payment') {
|
|
934
1166
|
cartStorePreviousStep();
|
|
935
1167
|
}
|
|
1168
|
+
// async update address with new root id from the new quote
|
|
1169
|
+
await stripeStoreAsyncAddressUpdate();
|
|
936
1170
|
// This is the cheapest service level since we already sorted them after fetching landed cost
|
|
937
1171
|
const cheapestServiceLevel = (_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.find(Boolean);
|
|
938
1172
|
// Landed cost that matches with service level
|
|
@@ -1311,6 +1545,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
|
|
|
1311
1545
|
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
|
|
1312
1546
|
body: {
|
|
1313
1547
|
adjustmentsAmount,
|
|
1548
|
+
billToPartyId: stripeStore.partyBillingId,
|
|
1314
1549
|
cartId,
|
|
1315
1550
|
currency,
|
|
1316
1551
|
customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
|
|
@@ -1324,6 +1559,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
|
|
|
1324
1559
|
},
|
|
1325
1560
|
],
|
|
1326
1561
|
presentmentCountryCode,
|
|
1562
|
+
shipToPartyId: stripeStore.partyShippingId,
|
|
1327
1563
|
skipPaymentIntent: stripeStore.skipPaymentIntent,
|
|
1328
1564
|
varianceTestInput,
|
|
1329
1565
|
},
|
|
@@ -1464,7 +1700,8 @@ stripeStoreOnChange('clientSecret', clientSecret => {
|
|
|
1464
1700
|
}
|
|
1465
1701
|
});
|
|
1466
1702
|
|
|
1467
|
-
const { reset, state: cartStore } = createStore(() => ({
|
|
1703
|
+
const { onChange: cartStoreOnChange, reset, state: cartStore, } = createStore(() => ({
|
|
1704
|
+
addressFormRenderType: 'stripe',
|
|
1468
1705
|
adjustmentTotal: 0,
|
|
1469
1706
|
adjustments: [],
|
|
1470
1707
|
checkoutSession: null,
|
|
@@ -1679,12 +1916,14 @@ const cartStoreReCalculateTotal = async ({ adjustmentsAmount, cartId, currency,
|
|
|
1679
1916
|
}
|
|
1680
1917
|
const { errors, json } = await stripeStoreUpdateCheckoutSession({
|
|
1681
1918
|
adjustmentsAmount,
|
|
1919
|
+
billToPartyId: stripeStore.partyBillingId,
|
|
1682
1920
|
cartId,
|
|
1683
1921
|
currency,
|
|
1684
1922
|
id: storageStore.checkoutSessionId,
|
|
1685
1923
|
itemsAmount,
|
|
1686
1924
|
landedCostId,
|
|
1687
1925
|
presentmentCountryCode: localizationStore.selectedCountryCode,
|
|
1926
|
+
shipToPartyId: stripeStore.partyShippingId,
|
|
1688
1927
|
varianceTestInput: storageStore.enabledVariantTestKeys || [],
|
|
1689
1928
|
});
|
|
1690
1929
|
if (errors.length > 0 || !json) {
|
|
@@ -1768,9 +2007,11 @@ const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption, lan
|
|
|
1768
2007
|
// update session with selected landed cost
|
|
1769
2008
|
const updateCalculateStatus = await cartStoreReCalculateTotal({
|
|
1770
2009
|
adjustmentsAmount: cartStore.adjustmentTotal,
|
|
2010
|
+
billToPartyId: stripeStore.partyBillingId,
|
|
1771
2011
|
cartId: window.Zonos.cartId,
|
|
1772
2012
|
dutiesTaxesFeesEstimate: dutiesTaxesFeesEstimate,
|
|
1773
2013
|
landedCostId: (_f = selectedLandedCost.landedCost) === null || _f === void 0 ? void 0 : _f.id,
|
|
2014
|
+
shipToPartyId: stripeStore.partyShippingId,
|
|
1774
2015
|
varianceTestInput: storageStore.enabledVariantTestKeys || [],
|
|
1775
2016
|
});
|
|
1776
2017
|
// update conditionally render pay in USD button
|
|
@@ -1833,10 +2074,12 @@ const cartStoreUpdateItems = async ({ adjustments, cartItems, }) => {
|
|
|
1833
2074
|
stripeStore.isFetchingSession = true;
|
|
1834
2075
|
await cartStoreReCalculateTotal({
|
|
1835
2076
|
adjustmentsAmount: adjustmentTotal,
|
|
2077
|
+
billToPartyId: stripeStore.partyBillingId,
|
|
1836
2078
|
cartId: window.Zonos.cartId,
|
|
1837
2079
|
currency: currency,
|
|
1838
2080
|
dutiesTaxesFeesEstimate: 0,
|
|
1839
2081
|
itemsAmount: total,
|
|
2082
|
+
shipToPartyId: stripeStore.partyShippingId,
|
|
1840
2083
|
// attempt to init session on failure to update checkout session
|
|
1841
2084
|
shouldInitSessionOnFailure: true,
|
|
1842
2085
|
varianceTestInput: storageStore.enabledVariantTestKeys || [],
|
|
@@ -1892,4 +2135,4 @@ const cartStoreResetTabItems = () => {
|
|
|
1892
2135
|
cartStoreResetSelectedShippingOption();
|
|
1893
2136
|
};
|
|
1894
2137
|
|
|
1895
|
-
export { cartStoreHasOneEligibleItem as A, stripeStoreApplyPromoCode as B, stripeStoreRemovePromoCode as C, stripeStoreResetPromoCode as D, stripeStoreMessageBasedOnStatus as E, stripeStoreTranslateAddressToLatin as F,
|
|
2138
|
+
export { cartStoreHasOneEligibleItem as A, stripeStoreApplyPromoCode as B, stripeStoreRemovePromoCode as C, stripeStoreResetPromoCode as D, stripeStoreMessageBasedOnStatus as E, stripeStoreTranslateAddressToLatin as F, cartStoreOnChange as G, stripeStoreAsyncAddressUpdate as H, cartStoreUpdateSelectedShippingOption as I, cartStoreGetShippingTransitInfo as J, sortServiceLevelOptionsByAmount as K, cartStoreGetMethod as L, stripeStoreCleanupDomesticShippingSession as a, stripeStoreSaveDomesticShippingSession as b, stripeStore as c, stripeStoreRetrievePayment as d, cartStore as e, cartStoreUpdateItems as f, cartStoreReset as g, cartStoreResetTabItems as h, initStripeElements as i, cartStoreClearCheckoutInterval as j, stripeStoreInitCheckoutSession as k, stripeStoreGetPaymentIntent as l, cartStoreStartCheckoutInterval as m, getCheckoutSessionBody as n, cartStoreUpdateToErrorState as o, cartStoreSetCheckoutSession as p, stripeStorePrefetchLandedCost as q, cartStoreNextStep as r, stripeStoreGetDomesticShippingSession as s, trackConversionEvent as t, stripeStoreUpdateCheckoutSessionBaseCurrency as u, stripeStoreHandleInventoryCheck as v, stripeStoreConfirmPayment as w, stripeStoreHandleInventoryRefund as x, stripeStoreReset as y, validateCheckoutSession as z };
|
|
@@ -35,11 +35,6 @@ const log = (message, type, ..._additionalInfo) => {
|
|
|
35
35
|
!!window.location.search.match(/\?.*(&*)zonosDebug=1/);
|
|
36
36
|
// if debug is false, do not log
|
|
37
37
|
if (!isDebug) {
|
|
38
|
-
// log errors to the console if the type is error
|
|
39
|
-
if (type === 'error') {
|
|
40
|
-
// eslint-disable-next-line no-console
|
|
41
|
-
console.error(message, ...additionalInfo);
|
|
42
|
-
}
|
|
43
38
|
return;
|
|
44
39
|
}
|
|
45
40
|
let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
|
|
@@ -432,12 +427,13 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
432
427
|
}
|
|
433
428
|
const nextFallbackApiType = getNextFallbackApiType(basePathType);
|
|
434
429
|
const unknownError = errors.find(({ type }) => type === 'unknown');
|
|
430
|
+
const isAbortError = errors.find(({ message }) => message.includes('signal is aborted'));
|
|
435
431
|
const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
|
|
436
432
|
const shouldCallFallback =
|
|
437
433
|
// If next fallback is available, and the error is unknown (Failed to fetch) or 404
|
|
438
434
|
nextFallbackApiType && isUnknownError;
|
|
439
435
|
// Should log the error if it's unknown error
|
|
440
|
-
if (isUnknownError) {
|
|
436
|
+
if (isUnknownError || isAbortError) {
|
|
441
437
|
void sendErrorLog({
|
|
442
438
|
endpoint: fallbackApiList[basePathType] + path,
|
|
443
439
|
errors: errors.map(({ message }) => `API: ${message}`),
|