@zonos/elements 1.3.207 → 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/{CheckoutConfig-4afc683b.js → CheckoutConfig-27c82f94.js} +19 -0
- package/dist/cjs/{cart-3d961c6e.js → cart-2ec8cac2.js} +285 -64
- 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 +29 -9
- package/dist/cjs/{isDarkColor-35e8daec.js → isDarkColor-428965f4.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-ff33875b.js → localization-9b43376c.js} +3 -2
- package/dist/cjs/{paypal-dee5c109.js → paypal-6449314e.js} +5 -5
- package/dist/cjs/updateCheckoutSessionAttributes-a31bb681.js +50 -0
- 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 +98 -49
- package/dist/cjs/zonos-checkout.cjs.entry.js +87 -31
- 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 +79 -24
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +71 -36
- 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 -55
- package/dist/collection/components/store/hello/localization.js +1 -0
- 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/api/updateCheckoutSessionAttributes.js +46 -0
- package/dist/collection/components/utils/checkout/getAbandonedCartRenewTokenValue.js +17 -0
- package/dist/collection/components/utils/handleFetch.js +2 -1
- package/dist/collection/components/utils/logging/log.js +0 -5
- package/dist/collection/scripts/_getCartInfoById.js +3 -0
- package/dist/collection/types/checkout/api/CheckoutSession.js +14 -1
- package/dist/collection/types/checkout/api/CreateParty.js +1 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
- package/dist/collection/types/generated/graphql.internal.types.js +15 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/{CheckoutConfig-eb7d6954.js → CheckoutConfig-724d7bae.js} +19 -1
- package/dist/esm/{cart-5835676d.js → cart-2f84f632.js} +284 -65
- package/dist/esm/{debounce-eaee3a94.js → debounce-0e42da22.js} +1 -1
- package/dist/esm/{getBorderRadius-b18c924f.js → getBorderRadius-71b3b8ab.js} +1 -1
- package/dist/esm/{handleFetch-621e45bc.js → handleFetch-7dd4622b.js} +2 -6
- package/dist/esm/index.js +28 -11
- package/dist/esm/{isDarkColor-d8bb8659.js → isDarkColor-3a9d6108.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-4c7f64e8.js → localization-e17c211b.js} +3 -2
- package/dist/esm/{paypal-b4f106be.js → paypal-1cf701aa.js} +6 -6
- package/dist/esm/updateCheckoutSessionAttributes-5097e715.js +48 -0
- 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 +98 -49
- package/dist/esm/zonos-checkout.entry.js +87 -31
- 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-1e015fa5.js → zonosStore-00975763.js} +1 -1
- package/dist/esm-es5/CheckoutConfig-724d7bae.js +1 -0
- package/dist/esm-es5/cart-2f84f632.js +1 -0
- package/dist/esm-es5/{debounce-eaee3a94.js → debounce-0e42da22.js} +1 -1
- package/dist/esm-es5/{getBorderRadius-b18c924f.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-d8bb8659.js → isDarkColor-3a9d6108.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{localization-4c7f64e8.js → localization-e17c211b.js} +1 -1
- package/dist/esm-es5/{paypal-b4f106be.js → paypal-1cf701aa.js} +2 -2
- package/dist/esm-es5/updateCheckoutSessionAttributes-5097e715.js +1 -0
- 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-1e015fa5.js → zonosStore-00975763.js} +1 -1
- package/dist/scripts/index.d.ts +10 -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-checkout.d.ts +2 -0
- 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/components/utils/api/updateCheckoutSessionAttributes.d.ts +7 -0
- package/dist/types/components/utils/checkout/getAbandonedCartRenewTokenValue.d.ts +1 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +1 -0
- package/dist/types/types/checkout/api/CheckoutSession.d.ts +16 -0
- package/dist/types/types/checkout/api/CreateParty.d.ts +34 -0
- package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +2 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +2 -0
- package/dist/types/types/generated/graphql.frontend.types.ts +2 -0
- package/dist/types/types/generated/graphql.internal.types.d.ts +61 -5
- package/dist/types/types/generated/graphql.internal.types.ts +105 -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-4e9c8f9e.system.js → p-0751b878.system.js} +1 -1
- package/dist/zonos-elements/{p-abe218ab.system.entry.js → p-08b29f73.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-74bcb5cc.entry.js → p-0ca1d6dd.entry.js} +1 -1
- package/dist/zonos-elements/{p-12cd9d3a.entry.js → p-144b5006.entry.js} +1 -1
- package/dist/zonos-elements/{p-9e9ac7a2.system.js → p-19182dc7.system.js} +1 -1
- package/dist/zonos-elements/{p-eca09508.system.entry.js → p-1dc78af3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e337fa88.js → p-207bd04a.js} +1 -1
- package/dist/zonos-elements/p-20839c46.js +1 -0
- package/dist/zonos-elements/{p-1aa24297.system.entry.js → p-2122d2cc.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4fb88ebc.system.entry.js → p-239695e8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3196bf98.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-c666d557.system.js → p-3633a952.system.js} +1 -1
- package/dist/zonos-elements/{p-9b8a5372.entry.js → p-36b686b6.entry.js} +1 -1
- package/dist/zonos-elements/{p-658936c9.js → p-371d91d1.js} +2 -2
- package/dist/zonos-elements/{p-019f8637.entry.js → p-3934b38a.entry.js} +1 -1
- package/dist/zonos-elements/p-3c752420.system.js +1 -0
- package/dist/zonos-elements/p-3ee44728.system.js +1 -1
- package/dist/zonos-elements/p-40a4c8a2.system.js +1 -0
- package/dist/zonos-elements/{p-91c996d3.system.js → p-44c0a584.system.js} +2 -2
- package/dist/zonos-elements/{p-eb2560b6.system.entry.js → p-45a2f9b1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1327b935.system.js → p-4a1b4a2d.system.js} +1 -1
- package/dist/zonos-elements/p-4c70fd75.entry.js +1 -0
- package/dist/zonos-elements/{p-bab19e2a.entry.js → p-4d62f3de.entry.js} +1 -1
- package/dist/zonos-elements/{p-848e08e8.entry.js → p-4dbaa2c2.entry.js} +1 -1
- package/dist/zonos-elements/p-4ed73ff8.entry.js +1 -0
- package/dist/zonos-elements/{p-47e2cd31.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-41c1d7c4.entry.js → p-5956a9e0.entry.js} +1 -1
- package/dist/zonos-elements/{p-5616b304.entry.js → p-5b7686f8.entry.js} +1 -1
- package/dist/zonos-elements/{p-0c4c8d63.entry.js → p-63a4dac5.entry.js} +1 -1
- package/dist/zonos-elements/{p-f4d741de.system.entry.js → p-695bf400.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9fa17353.js → p-6aa728f2.js} +1 -1
- package/dist/zonos-elements/{p-ed20f2f7.js → p-71c6bdc3.js} +1 -1
- package/dist/zonos-elements/p-738a49c0.system.js +1 -0
- package/dist/zonos-elements/{p-469ccc66.system.entry.js → p-74276b82.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e0587eeb.entry.js → p-77e22be4.entry.js} +1 -1
- package/dist/zonos-elements/{p-3afc27ef.entry.js → p-78dd1c53.entry.js} +1 -1
- package/dist/zonos-elements/{p-620deb03.system.entry.js → p-7f9bbbb3.system.entry.js} +1 -1
- package/dist/zonos-elements/p-896f2358.system.entry.js +1 -0
- package/dist/zonos-elements/{p-719e14a8.system.entry.js → p-8f41d864.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4cb8b87f.system.entry.js → p-964e2587.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-93aeba62.system.entry.js → p-97831744.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-2866fd29.system.entry.js → p-9d95c896.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-abc83d01.entry.js → p-a24870af.entry.js} +1 -1
- package/dist/zonos-elements/p-a411ce2a.system.js +1 -0
- package/dist/zonos-elements/{p-1bc09abe.system.entry.js → p-a4686344.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-edcfb3a3.js → p-a6f77d44.js} +1 -1
- package/dist/zonos-elements/{p-b21b0330.entry.js → p-a8f421ac.entry.js} +1 -1
- package/dist/zonos-elements/{p-18149db1.entry.js → p-aa40d402.entry.js} +1 -1
- package/dist/zonos-elements/{p-536f69eb.entry.js → p-ad1e1dbc.entry.js} +1 -1
- package/dist/zonos-elements/p-b1bfeec9.system.entry.js +1 -0
- package/dist/zonos-elements/p-b2d81c98.js +1 -0
- package/dist/zonos-elements/{p-7777d85f.system.entry.js → p-baa88176.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1ad099ec.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-858b7908.system.entry.js → p-c345b306.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-22cb6880.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-16678764.js → p-d6a53ea6.js} +1 -1
- package/dist/zonos-elements/{p-265af369.system.entry.js → p-db424e02.system.entry.js} +1 -1
- package/dist/zonos-elements/p-eb77c0bf.system.js +1 -0
- package/dist/zonos-elements/{p-30778fde.system.entry.js → p-ef1ccec6.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-42a9557f.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/CheckoutConfig-eb7d6954.js +0 -1
- package/dist/esm-es5/cart-5835676d.js +0 -1
- package/dist/esm-es5/handleFetch-621e45bc.js +0 -1
- package/dist/zonos-elements/p-0de2c731.system.js +0 -1
- package/dist/zonos-elements/p-0fc02cde.js +0 -1
- package/dist/zonos-elements/p-1b75aa35.system.js +0 -1
- package/dist/zonos-elements/p-3a50124e.entry.js +0 -1
- package/dist/zonos-elements/p-3f1a2d31.js +0 -1
- package/dist/zonos-elements/p-5e1b2654.system.js +0 -1
- package/dist/zonos-elements/p-666164d9.system.js +0 -1
- package/dist/zonos-elements/p-9f78b79e.entry.js +0 -1
- package/dist/zonos-elements/p-a2b55d11.entry.js +0 -1
- package/dist/zonos-elements/p-aafcd40f.system.entry.js +0 -1
- package/dist/zonos-elements/p-b922c441.system.js +0 -1
- package/dist/zonos-elements/p-ba027b70.system.entry.js +0 -1
- package/dist/zonos-elements/p-c4e0f49a.system.entry.js +0 -1
- package/dist/zonos-elements/p-dbd23bea.entry.js +0 -1
- package/dist/zonos-elements/p-f9664811.js +0 -1
|
@@ -21,6 +21,7 @@ const { onChange: stripeStoreOnChange, reset, state: stripeStore, } = createStor
|
|
|
21
21
|
checkoutSettlementCurrency: 'USD',
|
|
22
22
|
clientSecret: sessionStorage.getItem('zonos--client-secret') || '',
|
|
23
23
|
companyName: '',
|
|
24
|
+
companyNameUsedWhenAsyncAddressUpdate: '',
|
|
24
25
|
customAddressErrors: {
|
|
25
26
|
city: '',
|
|
26
27
|
firstName: '',
|
|
@@ -47,6 +48,8 @@ const { onChange: stripeStoreOnChange, reset, state: stripeStore, } = createStor
|
|
|
47
48
|
hasPaymentError: false,
|
|
48
49
|
isFetchingLandedCost: false,
|
|
49
50
|
isFetchingSession: false,
|
|
51
|
+
partyBillingId: null,
|
|
52
|
+
partyShippingId: null,
|
|
50
53
|
shouldInventoryRefund: false,
|
|
51
54
|
shouldRenderPayInUsdButton: false,
|
|
52
55
|
/**
|
|
@@ -59,10 +62,12 @@ const { onChange: stripeStoreOnChange, reset, state: stripeStore, } = createStor
|
|
|
59
62
|
stripe: null,
|
|
60
63
|
stripeAddressElement: null,
|
|
61
64
|
stripeAddressEventData: null,
|
|
65
|
+
stripeAddressUsedWhenAsyncAddressUpdate: null,
|
|
62
66
|
stripeAddressUsedWhenFetchingLC: null,
|
|
63
67
|
stripeAddressUsedWhenValidatingAddress: null,
|
|
64
68
|
stripeBillingAddressElement: null,
|
|
65
69
|
stripeBillingAddressEventData: null,
|
|
70
|
+
stripeBillingAddressUsedWhenAsyncAddressUpdate: null,
|
|
66
71
|
stripeBillingAddressUsedWhenFetchingLC: null,
|
|
67
72
|
stripeBillingAddressUsedWhenValidatingAddress: null,
|
|
68
73
|
stripeCustomerSessionClientSecret: null,
|
|
@@ -76,7 +81,7 @@ const { onChange: stripeStoreOnChange, reset, state: stripeStore, } = createStor
|
|
|
76
81
|
stripePaymentEventData: null,
|
|
77
82
|
stripeShippingSameAsBilling: true,
|
|
78
83
|
taxId: '',
|
|
79
|
-
|
|
84
|
+
taxIdUsedWhenAsyncAddressUpdate: '',
|
|
80
85
|
translatedAddress: {
|
|
81
86
|
address: {},
|
|
82
87
|
billingAddress: {},
|
|
@@ -182,15 +187,178 @@ const checkIsAddressOutdatedForValidation = () => {
|
|
|
182
187
|
JSON.stringify((_d = stripeStore.stripeBillingAddressUsedWhenValidatingAddress) === null || _d === void 0 ? void 0 : _d.value);
|
|
183
188
|
return isAddressDataDirty || isBillingAddressDataDirty;
|
|
184
189
|
};
|
|
185
|
-
const
|
|
190
|
+
const checkIsAddressOutdatedForAsyncAddressUpdate = () => {
|
|
186
191
|
var _a, _b, _c, _d, _e, _f;
|
|
187
192
|
const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
|
|
188
193
|
JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
|
|
189
|
-
const isAddressDataDirty = JSON.stringify((_c = stripeStore.
|
|
190
|
-
|
|
194
|
+
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);
|
|
195
|
+
const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
|
|
196
|
+
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);
|
|
197
|
+
const isTaxIdDirty = stripeStore.taxIdUsedWhenAsyncAddressUpdate !== stripeStore.taxId;
|
|
198
|
+
const isCompanyNameDirty = stripeStore.companyNameUsedWhenAsyncAddressUpdate !==
|
|
199
|
+
stripeStore.companyName;
|
|
200
|
+
return (isLinkDataDirty ||
|
|
201
|
+
isAddressDataDirty ||
|
|
202
|
+
isBillingAddressDataDirty ||
|
|
203
|
+
isTaxIdDirty ||
|
|
204
|
+
isCompanyNameDirty);
|
|
205
|
+
};
|
|
206
|
+
const buildAddressForPartyCreate = ({ address, firstName, lastName, name, phone, }) => {
|
|
207
|
+
const _firstName = (name === null || name === void 0 ? void 0 : name.split(' ')[0]) || firstName || '';
|
|
208
|
+
const _lastName = (name === null || name === void 0 ? void 0 : name.split(' ')[1]) || lastName || '';
|
|
209
|
+
if (!_firstName || !_lastName) {
|
|
210
|
+
void sendErrorLog({
|
|
211
|
+
endpoint: 'PARTY_CREATE_NO_NAME_FOUND',
|
|
212
|
+
errors: ['No name found'],
|
|
213
|
+
metadata: {
|
|
214
|
+
allLogs,
|
|
215
|
+
cartId: window.Zonos.cartId,
|
|
216
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
217
|
+
firstName,
|
|
218
|
+
lastName,
|
|
219
|
+
name,
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (!phone) {
|
|
224
|
+
void sendErrorLog({
|
|
225
|
+
endpoint: 'PARTY_CREATE_NO_PHONE_FOUND',
|
|
226
|
+
errors: ['No phone found'],
|
|
227
|
+
metadata: {
|
|
228
|
+
allLogs,
|
|
229
|
+
cartId: window.Zonos.cartId,
|
|
230
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
231
|
+
phone,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
city: address.city,
|
|
237
|
+
country: address.country,
|
|
238
|
+
firstName: _firstName,
|
|
239
|
+
lastName: _lastName,
|
|
240
|
+
line1: address.line1,
|
|
241
|
+
line2: address.line2,
|
|
242
|
+
phone: phone || '',
|
|
243
|
+
postal_code: address.postal_code,
|
|
244
|
+
state: address.state,
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
const stripeStoreAsyncAddressUpdate = async () => {
|
|
248
|
+
var _a, _b, _c, _d;
|
|
249
|
+
if (!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete) ||
|
|
250
|
+
(!stripeStore.stripeShippingSameAsBilling &&
|
|
251
|
+
!((_b = stripeStore.stripeBillingAddressEventData) === null || _b === void 0 ? void 0 : _b.complete)) ||
|
|
252
|
+
!stripeStore.stripeBillingAddressEventData) {
|
|
253
|
+
return {
|
|
254
|
+
partiesCreated: false,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
// If there is no landed cost data, no need to create parties
|
|
258
|
+
if (!cartStore.landedCostData) {
|
|
259
|
+
return {
|
|
260
|
+
partiesCreated: false,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
const firstLandedCostRootId = (_c = cartStore.landedCostData.find(Boolean)) === null || _c === void 0 ? void 0 : _c.landedCost.rootId;
|
|
264
|
+
if (!firstLandedCostRootId) {
|
|
265
|
+
// do nothing if we don't have selected landed cost
|
|
266
|
+
void sendErrorLog({
|
|
267
|
+
endpoint: 'PF_NO_SELECTED_LANDED_COST',
|
|
268
|
+
errors: ['No selected landed cost'],
|
|
269
|
+
metadata: {
|
|
270
|
+
allLogs,
|
|
271
|
+
cartId: window.Zonos.cartId,
|
|
272
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
partiesCreated: false,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const isAddressOutdated = checkIsAddressOutdatedForAsyncAddressUpdate();
|
|
280
|
+
if (!isAddressOutdated) {
|
|
281
|
+
return {
|
|
282
|
+
partiesCreated: false,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
const address = buildAddressForPartyCreate({
|
|
286
|
+
address: stripeStore.stripeAddressEventData.value.address,
|
|
287
|
+
firstName: stripeStore.stripeAddressEventData.value.firstName,
|
|
288
|
+
lastName: stripeStore.stripeAddressEventData.value.lastName,
|
|
289
|
+
name: stripeStore.stripeAddressEventData.value.name,
|
|
290
|
+
phone: stripeStore.stripeAddressEventData.value.phone,
|
|
291
|
+
});
|
|
292
|
+
const billingAddress = stripeStore.stripeShippingSameAsBilling
|
|
293
|
+
? address
|
|
294
|
+
: buildAddressForPartyCreate({
|
|
295
|
+
address: stripeStore.stripeBillingAddressEventData.value.address,
|
|
296
|
+
firstName: stripeStore.stripeBillingAddressEventData.value.firstName,
|
|
297
|
+
lastName: stripeStore.stripeBillingAddressEventData.value.lastName,
|
|
298
|
+
name: stripeStore.stripeBillingAddressEventData.value.name,
|
|
299
|
+
phone: stripeStore.stripeBillingAddressEventData.value.phone,
|
|
300
|
+
});
|
|
301
|
+
const isE2ETest = new URLSearchParams(window.location.search).get('zonosE2ETest') === '1';
|
|
302
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/create-parties', {
|
|
303
|
+
body: {
|
|
304
|
+
address,
|
|
305
|
+
billingAddress,
|
|
306
|
+
companyName: stripeStore.companyName,
|
|
307
|
+
email: ((_d = stripeStore.stripeLinkEventData) === null || _d === void 0 ? void 0 : _d.value.email) || '',
|
|
308
|
+
isTest: isE2ETest,
|
|
309
|
+
rootId: firstLandedCostRootId,
|
|
310
|
+
taxId: stripeStore.taxId,
|
|
311
|
+
},
|
|
312
|
+
method: 'POST',
|
|
313
|
+
});
|
|
314
|
+
if (errors.length || !json) {
|
|
315
|
+
logError('Error occurs when creating parties', JSON.stringify(errors, null, 2));
|
|
316
|
+
void sendErrorLog({
|
|
317
|
+
endpoint: 'PF_PARTY_CREATE_FAILED',
|
|
318
|
+
errors: ['Failed to create parties'],
|
|
319
|
+
metadata: {
|
|
320
|
+
allLogs,
|
|
321
|
+
cartId: window.Zonos.cartId,
|
|
322
|
+
checkoutSessionId: storageStore.checkoutSessionId,
|
|
323
|
+
errors,
|
|
324
|
+
json,
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
return {
|
|
328
|
+
partiesCreated: false,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
stripeStore.companyNameUsedWhenAsyncAddressUpdate = stripeStore.companyName;
|
|
332
|
+
stripeStore.stripeAddressUsedWhenAsyncAddressUpdate =
|
|
333
|
+
stripeStore.stripeAddressEventData;
|
|
334
|
+
stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate =
|
|
335
|
+
stripeStore.stripeBillingAddressEventData;
|
|
336
|
+
stripeStore.taxIdUsedWhenAsyncAddressUpdate = stripeStore.taxId;
|
|
337
|
+
stripeStore.partyBillingId = json.billToPartyId;
|
|
338
|
+
stripeStore.partyShippingId = json.shipToPartyId;
|
|
339
|
+
return {
|
|
340
|
+
partiesCreated: true,
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Extract only the necessary address info for landed cost prefetch
|
|
345
|
+
*/
|
|
346
|
+
const buildAddressForLCPrefetch = (address) => {
|
|
347
|
+
return {
|
|
348
|
+
countryCode: address.address.country,
|
|
349
|
+
postalCode: address.address.postal_code,
|
|
350
|
+
state: address.address.state,
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
const checkIsAddressOutdatedForLCPrefetch = () => {
|
|
354
|
+
var _a, _b;
|
|
355
|
+
const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
|
|
356
|
+
JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
|
|
357
|
+
const isAddressDataDirty = stripeStore.stripeAddressEventData &&
|
|
358
|
+
JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeAddressEventData.value)) !== JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC);
|
|
191
359
|
const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
|
|
192
|
-
|
|
193
|
-
|
|
360
|
+
stripeStore.stripeBillingAddressEventData &&
|
|
361
|
+
JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeBillingAddressEventData.value)) !== JSON.stringify(stripeStore.stripeBillingAddressUsedWhenFetchingLC);
|
|
194
362
|
return isLinkDataDirty || isAddressDataDirty || isBillingAddressDataDirty;
|
|
195
363
|
};
|
|
196
364
|
/**
|
|
@@ -204,14 +372,64 @@ const isPrefetchInfoOutdated = () => {
|
|
|
204
372
|
((_a = cartStore.landedCostData.find(Boolean)) === null || _a === void 0 ? void 0 : _a.subtotals.items) !==
|
|
205
373
|
cartStore.subtotal;
|
|
206
374
|
const isAddressOutdated = checkIsAddressOutdatedForLCPrefetch();
|
|
207
|
-
|
|
208
|
-
|
|
375
|
+
log('isPrefetchInfoOutdated', 'info', {
|
|
376
|
+
isAddressOutdated,
|
|
377
|
+
});
|
|
209
378
|
return (
|
|
210
379
|
// if landed cost data is not available, we need to fetch it
|
|
211
|
-
!cartStore.landedCostData ||
|
|
380
|
+
(!cartStore.landedCostData && !stripeStore.isFetchingLandedCost) ||
|
|
212
381
|
isAddressOutdated ||
|
|
213
|
-
isTotalAmountChanged
|
|
214
|
-
|
|
382
|
+
isTotalAmountChanged);
|
|
383
|
+
};
|
|
384
|
+
const getCountryField = (country) => {
|
|
385
|
+
var _a, _b;
|
|
386
|
+
const countryFieldLabels = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryFields;
|
|
387
|
+
const stripeCountryFieldLabels = (_b = zonosStore.genericSettings) === null || _b === void 0 ? void 0 : _b.stripeCountryFieldLabels;
|
|
388
|
+
const stripeFoundCountryField = stripeCountryFieldLabels && country in stripeCountryFieldLabels
|
|
389
|
+
? stripeCountryFieldLabels[country]
|
|
390
|
+
: null;
|
|
391
|
+
const zonosFoundCountryField = countryFieldLabels && country in countryFieldLabels
|
|
392
|
+
? countryFieldLabels[country]
|
|
393
|
+
: null;
|
|
394
|
+
/**
|
|
395
|
+
* 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
|
|
396
|
+
* 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
|
|
397
|
+
**/
|
|
398
|
+
if (cartStore.addressFormRenderType === 'stripe') {
|
|
399
|
+
return stripeFoundCountryField || zonosFoundCountryField;
|
|
400
|
+
}
|
|
401
|
+
return zonosFoundCountryField;
|
|
402
|
+
};
|
|
403
|
+
const isAddressReadyToRequestLandedCost = () => {
|
|
404
|
+
var _a, _b, _c, _d;
|
|
405
|
+
const linkReady = !!((_a = stripeStore.stripeLinkEventData) === null || _a === void 0 ? void 0 : _a.complete);
|
|
406
|
+
const shippingAddressReady = !!((_b = stripeStore.stripeAddressEventData) === null || _b === void 0 ? void 0 : _b.complete);
|
|
407
|
+
const billingAddressReady = stripeStore.stripeShippingSameAsBilling
|
|
408
|
+
? shippingAddressReady
|
|
409
|
+
: !!((_c = stripeStore.stripeBillingAddressEventData) === null || _c === void 0 ? void 0 : _c.complete);
|
|
410
|
+
const shipToCountry = ((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value.address.country) || 'US';
|
|
411
|
+
const countryField = getCountryField(shipToCountry);
|
|
412
|
+
// Only send landed cost request if the address is complete when we can't get the country field
|
|
413
|
+
if (!countryField || !stripeStore.stripeAddressEventData) {
|
|
414
|
+
return shippingAddressReady && billingAddressReady && linkReady;
|
|
415
|
+
}
|
|
416
|
+
const isValidLine1 = stripeStore.stripeAddressEventData.value.address.line1.length > 0;
|
|
417
|
+
const isValidName = stripeStore.stripeAddressEventData.value.firstName &&
|
|
418
|
+
stripeStore.stripeAddressEventData.value.lastName;
|
|
419
|
+
const isStateValid = !countryField.stateRequired ||
|
|
420
|
+
(countryField.stateRequired &&
|
|
421
|
+
stripeStore.stripeAddressEventData.value.address.state.length > 0);
|
|
422
|
+
const isPostalCodeValid = !countryField.zipRequired ||
|
|
423
|
+
(countryField.zipRequired &&
|
|
424
|
+
stripeStore.stripeAddressEventData.value.address.postal_code.length >= 3);
|
|
425
|
+
const hasPhoneNumber = stripeStore.stripeAddressEventData.value.phone &&
|
|
426
|
+
stripeStore.stripeAddressEventData.value.phone.length > 0;
|
|
427
|
+
return (linkReady &&
|
|
428
|
+
isValidName &&
|
|
429
|
+
isValidLine1 &&
|
|
430
|
+
isStateValid &&
|
|
431
|
+
isPostalCodeValid &&
|
|
432
|
+
hasPhoneNumber);
|
|
215
433
|
};
|
|
216
434
|
const stripeCalculateLandedCost = async () => {
|
|
217
435
|
var _a;
|
|
@@ -260,26 +478,27 @@ const stripeCalculateLandedCost = async () => {
|
|
|
260
478
|
}
|
|
261
479
|
};
|
|
262
480
|
const stripeStorePrefetchLandedCost = async (params) => {
|
|
263
|
-
var _a, _b, _c, _d
|
|
481
|
+
var _a, _b, _c, _d;
|
|
264
482
|
const retries = (params === null || params === void 0 ? void 0 : params.retries) || 0;
|
|
265
483
|
const applyingPromocode = !!(params === null || params === void 0 ? void 0 : params.applyingPromocode);
|
|
266
|
-
const stripeAddressReady = !!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete);
|
|
267
|
-
const stripeLinkReady = !!((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.complete);
|
|
268
|
-
const stripeBillingAddressReady = stripeStore.stripeShippingSameAsBilling
|
|
269
|
-
? !!((_c = stripeStore.stripeLinkEventData) === null || _c === void 0 ? void 0 : _c.complete)
|
|
270
|
-
: !!((_d = stripeStore.stripeBillingAddressEventData) === null || _d === void 0 ? void 0 : _d.complete);
|
|
271
484
|
const shouldRefetch = isPrefetchInfoOutdated();
|
|
485
|
+
const isRequestReadyToPrefetch = isAddressReadyToRequestLandedCost();
|
|
486
|
+
// Should not do anything if the address is not ready to request landed cost
|
|
487
|
+
if (!isRequestReadyToPrefetch) {
|
|
488
|
+
return {
|
|
489
|
+
isRequestNotReady: true,
|
|
490
|
+
};
|
|
491
|
+
}
|
|
272
492
|
if (shouldRefetch) {
|
|
273
493
|
// if the info used when fetching landed cost is different from the current info, abort the previous request
|
|
274
|
-
(
|
|
494
|
+
(_a = stripeStore.fetchingLandedCostAbortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
275
495
|
stripeStore.fetchingLandedCostAbortController = null;
|
|
276
496
|
}
|
|
277
497
|
// Do not fetch if we are not ready or data is not outdated
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return;
|
|
498
|
+
if (!shouldRefetch && !applyingPromocode) {
|
|
499
|
+
return {
|
|
500
|
+
isRequestNotReady: false,
|
|
501
|
+
};
|
|
283
502
|
}
|
|
284
503
|
// 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)
|
|
285
504
|
if (retries) {
|
|
@@ -292,24 +511,31 @@ const stripeStorePrefetchLandedCost = async (params) => {
|
|
|
292
511
|
stripeStore.isFetchingLandedCost = true;
|
|
293
512
|
}
|
|
294
513
|
if (stripeStore.stripeAddressEventData) {
|
|
295
|
-
stripeStore.stripeAddressUsedWhenFetchingLC =
|
|
514
|
+
stripeStore.stripeAddressUsedWhenFetchingLC = {
|
|
515
|
+
countryCode: stripeStore.stripeAddressEventData.value.address.country,
|
|
516
|
+
postalCode: stripeStore.stripeAddressEventData.value.address.postal_code,
|
|
517
|
+
state: stripeStore.stripeAddressEventData.value.address.state,
|
|
518
|
+
};
|
|
296
519
|
}
|
|
297
520
|
if (stripeStore.stripeBillingAddressEventData) {
|
|
298
|
-
stripeStore.stripeBillingAddressUsedWhenFetchingLC =
|
|
521
|
+
stripeStore.stripeBillingAddressUsedWhenFetchingLC = {
|
|
522
|
+
countryCode: stripeStore.stripeBillingAddressEventData.value.address.country,
|
|
523
|
+
postalCode: stripeStore.stripeBillingAddressEventData.value.address.postal_code,
|
|
524
|
+
state: stripeStore.stripeBillingAddressEventData.value.address.state,
|
|
525
|
+
};
|
|
299
526
|
}
|
|
300
527
|
if (stripeStore.stripeLinkEventData) {
|
|
301
528
|
stripeStore.stripeLinkUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeLinkEventData);
|
|
302
529
|
}
|
|
303
|
-
stripeStore.taxIdUsedWhenFetchingLC = stripeStore.taxId;
|
|
304
530
|
try {
|
|
305
531
|
// Reset cart items to non-restricted state and restricted item list
|
|
306
532
|
cartStoreResetCartItems();
|
|
307
533
|
// fetch and apply landed cost
|
|
308
534
|
await stripeCalculateLandedCost();
|
|
309
535
|
// This is the cheapest service level since we already sorted them after fetching landed cost
|
|
310
|
-
const cheapestServiceLevel = (
|
|
536
|
+
const cheapestServiceLevel = (_b = cartStore.shippingData) === null || _b === void 0 ? void 0 : _b.find(Boolean);
|
|
311
537
|
// Landed cost that matches with service level
|
|
312
|
-
const matchLandedCost = (
|
|
538
|
+
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));
|
|
313
539
|
// apply new subtotal and total, this is mainly to show items in the presentment currency
|
|
314
540
|
const subtotals = !!matchLandedCost ? matchLandedCost.subtotals : null;
|
|
315
541
|
if (subtotals) {
|
|
@@ -333,9 +559,11 @@ const stripeStorePrefetchLandedCost = async (params) => {
|
|
|
333
559
|
if (retries < 1) {
|
|
334
560
|
// retry fetching landed cost one more time
|
|
335
561
|
await stripeStorePrefetchLandedCost(Object.assign(Object.assign({}, params), { retries: (retries || 0) + 1 }));
|
|
336
|
-
return
|
|
562
|
+
return {
|
|
563
|
+
isRequestNotReady: false,
|
|
564
|
+
};
|
|
337
565
|
}
|
|
338
|
-
const shipToAddress = (
|
|
566
|
+
const shipToAddress = (_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value;
|
|
339
567
|
void sendErrorLog({
|
|
340
568
|
endpoint: `Failed to fetch landed cost (${retries} retries)`,
|
|
341
569
|
errors: [err.message],
|
|
@@ -348,6 +576,9 @@ const stripeStorePrefetchLandedCost = async (params) => {
|
|
|
348
576
|
logError(err);
|
|
349
577
|
}
|
|
350
578
|
stripeStore.isFetchingLandedCost = false;
|
|
579
|
+
return {
|
|
580
|
+
isRequestNotReady: false,
|
|
581
|
+
};
|
|
351
582
|
};
|
|
352
583
|
const stripeStoreApplyPromoCode = async () => {
|
|
353
584
|
var _a, _b;
|
|
@@ -358,6 +589,8 @@ const stripeStoreApplyPromoCode = async () => {
|
|
|
358
589
|
if (cartStore.step === 'payment') {
|
|
359
590
|
cartStorePreviousStep();
|
|
360
591
|
}
|
|
592
|
+
// async update address with new root id from the new quote
|
|
593
|
+
await stripeStoreAsyncAddressUpdate();
|
|
361
594
|
// This is the cheapest service level since we already sorted them after fetching landed cost
|
|
362
595
|
const cheapestServiceLevel = (_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.find(Boolean);
|
|
363
596
|
// Landed cost that matches with service level
|
|
@@ -600,18 +833,6 @@ export const getCheckoutSessionBody = () => {
|
|
|
600
833
|
key: 'language',
|
|
601
834
|
value: localizationStore.selectedLocale,
|
|
602
835
|
},
|
|
603
|
-
{
|
|
604
|
-
key: 'appVersion',
|
|
605
|
-
value: window.Zonos.version,
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
key: 'appVersionNpmIntegration',
|
|
609
|
-
value: window.Zonos.isNpm ? '1' : '0',
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
key: 'legacyCheckoutFacade',
|
|
613
|
-
value: window.Zonos.isLegacyCheckout ? '1' : '0',
|
|
614
|
-
},
|
|
615
836
|
],
|
|
616
837
|
presentmentCountryCode: localizationStore.selectedCountryCode,
|
|
617
838
|
skipPaymentIntent: stripeStore.skipPaymentIntent,
|
|
@@ -748,6 +969,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
|
|
|
748
969
|
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
|
|
749
970
|
body: {
|
|
750
971
|
adjustmentsAmount,
|
|
972
|
+
billToPartyId: stripeStore.partyBillingId,
|
|
751
973
|
cartId,
|
|
752
974
|
currency,
|
|
753
975
|
customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
|
|
@@ -759,20 +981,9 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
|
|
|
759
981
|
key: 'language',
|
|
760
982
|
value: localizationStore.selectedLocale,
|
|
761
983
|
},
|
|
762
|
-
{
|
|
763
|
-
key: 'appVersion',
|
|
764
|
-
value: window.Zonos.version,
|
|
765
|
-
},
|
|
766
|
-
{
|
|
767
|
-
key: 'appVersionNpmIntegration',
|
|
768
|
-
value: window.Zonos.isNpm ? '1' : '0',
|
|
769
|
-
},
|
|
770
|
-
{
|
|
771
|
-
key: 'legacyCheckoutFacade',
|
|
772
|
-
value: window.Zonos.isLegacyCheckout ? '1' : '0',
|
|
773
|
-
},
|
|
774
984
|
],
|
|
775
985
|
presentmentCountryCode,
|
|
986
|
+
shipToPartyId: stripeStore.partyShippingId,
|
|
776
987
|
skipPaymentIntent: stripeStore.skipPaymentIntent,
|
|
777
988
|
varianceTestInput,
|
|
778
989
|
},
|
|
@@ -912,4 +1123,4 @@ stripeStoreOnChange('clientSecret', clientSecret => {
|
|
|
912
1123
|
sessionStorage.removeItem('zonos--client-secret');
|
|
913
1124
|
}
|
|
914
1125
|
});
|
|
915
|
-
export { initStripeElements, stripeCalculateLandedCost, stripeStore, stripeStoreApplyPromoCode, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreGetDomesticShippingSession, stripeStoreGetPaymentIntent, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreInitCheckoutSession, stripeStoreMessageBasedOnStatus, stripeStoreOnChange, stripeStorePrefetchLandedCost, stripeStoreRemovePromoCode, stripeStoreReset, stripeStoreResetPromoCode, stripeStoreRetrievePayment, stripeStoreSaveDomesticShippingSession, stripeStoreTranslateAddressToLatin, stripeStoreUpdateCheckoutSession, stripeStoreUpdateCheckoutSessionBaseCurrency, };
|
|
1126
|
+
export { initStripeElements, stripeCalculateLandedCost, stripeStore, stripeStoreApplyPromoCode, stripeStoreAsyncAddressUpdate, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreGetDomesticShippingSession, stripeStoreGetPaymentIntent, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreInitCheckoutSession, stripeStoreMessageBasedOnStatus, stripeStoreOnChange, stripeStorePrefetchLandedCost, stripeStoreRemovePromoCode, stripeStoreReset, stripeStoreResetPromoCode, stripeStoreRetrievePayment, stripeStoreSaveDomesticShippingSession, stripeStoreTranslateAddressToLatin, stripeStoreUpdateCheckoutSession, stripeStoreUpdateCheckoutSessionBaseCurrency, };
|
|
@@ -203,6 +203,7 @@ const updateCheckoutSessionLanguage = async () => {
|
|
|
203
203
|
body: {
|
|
204
204
|
id: storageStore.checkoutSessionId,
|
|
205
205
|
metadata: [
|
|
206
|
+
// This is being used from the backend to determine the language of the checkout session
|
|
206
207
|
{
|
|
207
208
|
key: 'language',
|
|
208
209
|
value: localizationStore.selectedLocale,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
|
-
import
|
|
2
|
+
import throttle from "lodash/throttle";
|
|
3
|
+
import { stripeStore, stripeStorePrefetchLandedCost, } from "../../store/checkout/stripe";
|
|
3
4
|
import { getFallbackDefaultCountryCode, localizationStore, } from "../../store/hello/localization";
|
|
4
5
|
import { storageStore, storageStoreOnChange, } from "../../store/storageStore";
|
|
5
6
|
import { translate } from "../../store/translationStore";
|
|
@@ -41,10 +42,16 @@ export class ZonosAddress {
|
|
|
41
42
|
* Local checkout session id to check if the address is filled after checkout is loaded
|
|
42
43
|
*/
|
|
43
44
|
this.checkoutSessionId = storageStore.checkoutSessionId;
|
|
45
|
+
/**
|
|
46
|
+
* Track previous country and postal code to detect changes
|
|
47
|
+
*/
|
|
48
|
+
this.prevCountry = null;
|
|
49
|
+
this.prevPostalCode = null;
|
|
44
50
|
/**
|
|
45
51
|
* Check if the tracking event is sent
|
|
46
52
|
*/
|
|
47
53
|
this.trackingSent = false;
|
|
54
|
+
this.prefetchLandedCost = throttle(stripeStorePrefetchLandedCost, 1000);
|
|
48
55
|
this.onStoreCheckoutSessionIdChanged = () => {
|
|
49
56
|
const onCheckoutSessionIdChange = () => {
|
|
50
57
|
this.checkoutSessionId = storageStore.checkoutSessionId;
|
|
@@ -78,6 +85,13 @@ export class ZonosAddress {
|
|
|
78
85
|
break;
|
|
79
86
|
}
|
|
80
87
|
}
|
|
88
|
+
// Only trigger landed cost prefetch for shipping address
|
|
89
|
+
if (type === 'shipping') {
|
|
90
|
+
// if line 1 has something, trigger prefetch
|
|
91
|
+
if (event.value.address.line1.length) {
|
|
92
|
+
void this.prefetchLandedCost();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
81
95
|
}
|
|
82
96
|
isAddressFilledChanged() {
|
|
83
97
|
// Sometimes address elements is loaded with prefilled data before checkout is loaded, need to not send the event if checkout session id is not available, and send the event after checkout is loaded
|
|
@@ -149,6 +163,11 @@ export class ZonosAddress {
|
|
|
149
163
|
},
|
|
150
164
|
});
|
|
151
165
|
addressElement.mount(this.el.querySelector('.zonos--address-component'));
|
|
166
|
+
// Initialize previous values if address data exists
|
|
167
|
+
if (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address) {
|
|
168
|
+
this.prevCountry = stripeAddressEventData.value.address.country;
|
|
169
|
+
this.prevPostalCode = stripeAddressEventData.value.address.postal_code;
|
|
170
|
+
}
|
|
152
171
|
addressElement.on('change', event => {
|
|
153
172
|
const eventValue = event.value;
|
|
154
173
|
if (!this.isDirtyAddress && eventValue.address.line1.length >= 3) {
|
|
@@ -280,7 +299,7 @@ export class ZonosAddress {
|
|
|
280
299
|
this.isAddressFilled = true;
|
|
281
300
|
}
|
|
282
301
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
283
|
-
return (h(Host, { key: '
|
|
302
|
+
return (h(Host, { key: '6cb2f40dc810982251bdb24bd373ef5dc5b26cd2', class: "zonos--address zonos--elements" }, h("zonos-text", { key: 'f7b393a508bc5f1921924090c365cdf41f23f0e7', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderTaxIdInput(), h("div", { key: '9bd11de0b90f7ad7328cf37694c7d4e2a2d73f06', class: "zonos--address-component" })));
|
|
284
303
|
}
|
|
285
304
|
static get is() { return "zonos-address"; }
|
|
286
305
|
static get encapsulation() { return "scoped"; }
|
|
@@ -385,7 +404,9 @@ export class ZonosAddress {
|
|
|
385
404
|
"stripe": {},
|
|
386
405
|
"isDirtyAddress": {},
|
|
387
406
|
"isAddressFilled": {},
|
|
388
|
-
"checkoutSessionId": {}
|
|
407
|
+
"checkoutSessionId": {},
|
|
408
|
+
"prevCountry": {},
|
|
409
|
+
"prevPostalCode": {}
|
|
389
410
|
};
|
|
390
411
|
}
|
|
391
412
|
static get events() {
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
import { h, Host, } from "@stencil/core";
|
|
14
14
|
import throttle from "lodash/throttle";
|
|
15
|
-
import { stripeStore } from "../../store/checkout/stripe";
|
|
15
|
+
import { stripeStore, stripeStorePrefetchLandedCost, } from "../../store/checkout/stripe";
|
|
16
16
|
import { localizationStore } from "../../store/hello/localization";
|
|
17
17
|
import { storageStore, storageStoreOnChange, } from "../../store/storageStore";
|
|
18
18
|
import { translate } from "../../store/translationStore";
|
|
@@ -283,6 +283,8 @@ export class ZonosAddress {
|
|
|
283
283
|
break;
|
|
284
284
|
default: {
|
|
285
285
|
stripeStore.stripeAddressEventData = event;
|
|
286
|
+
// send request to prefetch landed cost
|
|
287
|
+
void stripeStorePrefetchLandedCost();
|
|
286
288
|
break;
|
|
287
289
|
}
|
|
288
290
|
}
|
|
@@ -803,7 +805,7 @@ export class ZonosAddress {
|
|
|
803
805
|
this.state = event.detail;
|
|
804
806
|
}, options: stateOptions, required: (_k = this.countryField) === null || _k === void 0 ? void 0 : _k.stateRequired, selectLabel: translate(((_l = this.countryField) === null || _l === void 0 ? void 0 : _l.stateLabel) || 'State'), selectedValue: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.state, title: `${this.type} state` })), ((_m = this.countryField) === null || _m === void 0 ? void 0 : _m.zipShow) && (h("zonos-stripe-input", { "aria-describedby": ((_o = this.countryField) === null || _o === void 0 ? void 0 : _o.zipFormat)
|
|
805
807
|
? `zip-format-${this.type}`
|
|
806
|
-
: undefined, "aria-required": ((_p = this.countryField) === null || _p === void 0 ? void 0 : _p.zipRequired) ? 'true' : 'false', autoComplete: "shipping postal-code", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.postalCode : undefined, inputLabel: translate(((_q = this.countryField) === null || _q === void 0 ? void 0 : _q.zipLabel) || 'Zip'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.postal_code) || '', onInputChange: (event) => {
|
|
808
|
+
: undefined, "aria-required": ((_p = this.countryField) === null || _p === void 0 ? void 0 : _p.zipRequired) ? 'true' : 'false', autoComplete: "shipping postal-code", class: "zonos--custom-address-form-input", error: showError ? customAddressErrors.postalCode : undefined, inputLabel: translate(((_q = this.countryField) === null || _q === void 0 ? void 0 : _q.zipLabel) || 'Zip'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.postal_code) || '', name: "postalCode", onInputChange: (event) => {
|
|
807
809
|
this.validate({
|
|
808
810
|
type: this.type,
|
|
809
811
|
value: event.detail,
|
|
@@ -817,7 +819,7 @@ export class ZonosAddress {
|
|
|
817
819
|
* Therefore, we must update the value after validation to ensure correct error state
|
|
818
820
|
*/
|
|
819
821
|
this.postalCode = event.detail;
|
|
820
|
-
}, required: (_r = this.countryField) === null || _r === void 0 ? void 0 : _r.zipRequired }))), h("zonos-stripe-phone-input", { autoComplete: "shipping tel", class: "zonos--custom-address-form-input", countryCode: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.country, countryOptions: (_s = zonosStore.genericSettings) === null || _s === void 0 ? void 0 : _s.countryFields, error: showError ? customAddressErrors.phone : undefined, inputLabel: translate('Phone number'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.phone) || '', onInputValueChange: event => {
|
|
822
|
+
}, required: (_r = this.countryField) === null || _r === void 0 ? void 0 : _r.zipRequired, title: `${this.type} zip code` }))), h("zonos-stripe-phone-input", { autoComplete: "shipping tel", class: "zonos--custom-address-form-input", countryCode: stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address.country, countryOptions: (_s = zonosStore.genericSettings) === null || _s === void 0 ? void 0 : _s.countryFields, error: showError ? customAddressErrors.phone : undefined, inputLabel: translate('Phone number'), inputValue: (stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.phone) || '', onInputValueChange: event => {
|
|
821
823
|
const { isEmpty, phoneNumber, valid, wrongFormat } = event.detail;
|
|
822
824
|
// Validate the phone number
|
|
823
825
|
this.validate({
|
|
@@ -888,10 +890,10 @@ export class ZonosAddress {
|
|
|
888
890
|
this.country = localizationStore.selectedCountryCode;
|
|
889
891
|
}
|
|
890
892
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
891
|
-
return (h(Host, { key: '
|
|
893
|
+
return (h(Host, { key: '668f481c1b31dd6e756d95b5c382592681cea23d', class: classes([
|
|
892
894
|
'zonos--address zonos--elements',
|
|
893
895
|
`zonos--${this.type}-address`,
|
|
894
|
-
]) }, h("zonos-text", { key: '
|
|
896
|
+
]) }, h("zonos-text", { key: 'a31cd25d43d9262d408e6ced8330cbe1c51bdd47', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderCustomAddressForm()));
|
|
895
897
|
}
|
|
896
898
|
static get is() { return "zonos-custom-address"; }
|
|
897
899
|
static get encapsulation() { return "scoped"; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { prepCartCalculateLandedCost } from "./prepCalculateLandedCost";
|
|
2
2
|
import { handleFetch } from "../handleFetch";
|
|
3
3
|
export const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
|
|
4
|
-
var _a;
|
|
4
|
+
var _a, _b;
|
|
5
5
|
// request to get landed cost info
|
|
6
6
|
const { errors, json } = await handleFetch('/api/zonos-elements/cart-calculate-landed-cost', {
|
|
7
7
|
body: prepCartCalculateLandedCost(cartId),
|
|
@@ -9,7 +9,8 @@ export const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
|
|
|
9
9
|
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
10
10
|
});
|
|
11
11
|
if (errors.length || !json) {
|
|
12
|
-
const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.'
|
|
12
|
+
const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.' ||
|
|
13
|
+
((_b = errors[0]) === null || _b === void 0 ? void 0 : _b.message.includes('signal is aborted'));
|
|
13
14
|
const errorMessage = isAbortedRequest
|
|
14
15
|
? 'The landed cost calculation request was aborted to initiate a new one.'
|
|
15
16
|
: 'Failed to calculate landed cost';
|
|
@@ -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
|