@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.
Files changed (215) hide show
  1. package/dist/cjs/{cart-47c17ebf.js → cart-2ec8cac2.js} +285 -40
  2. package/dist/cjs/{debounce-0b9c0f8a.js → debounce-465a4328.js} +1 -1
  3. package/dist/cjs/{getBorderRadius-c424eb05.js → getBorderRadius-1b5e33cf.js} +1 -1
  4. package/dist/cjs/{handleFetch-969d05d8.js → handleFetch-05227713.js} +2 -6
  5. package/dist/cjs/index.cjs.js +8 -8
  6. package/dist/cjs/{isDarkColor-35e8daec.js → isDarkColor-428965f4.js} +1 -1
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/{localization-e9089be5.js → localization-9b43376c.js} +2 -2
  9. package/dist/cjs/{paypal-3a803d21.js → paypal-6449314e.js} +5 -5
  10. package/dist/cjs/{updateCheckoutSessionAttributes-d0332530.js → updateCheckoutSessionAttributes-a31bb681.js} +2 -2
  11. package/dist/cjs/zonos-address_11.cjs.entry.js +104 -84
  12. package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  15. package/dist/cjs/zonos-card.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-cart-items_14.cjs.entry.js +91 -41
  17. package/dist/cjs/zonos-checkout.cjs.entry.js +45 -21
  18. package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
  19. package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
  20. package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
  21. package/dist/cjs/zonos-country-select_4.cjs.entry.js +13 -9
  22. package/dist/cjs/zonos-elements.cjs.js +1 -1
  23. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +7 -7
  24. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  25. package/dist/cjs/zonos-hello.cjs.entry.js +4 -4
  26. package/dist/cjs/zonos-input.cjs.entry.js +2 -2
  27. package/dist/cjs/zonos-language-select_2.cjs.entry.js +3 -3
  28. package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
  29. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
  30. package/dist/cjs/zonos-stripe-input.cjs.entry.js +3 -3
  31. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  32. package/dist/cjs/zonos-toggle.cjs.entry.js +1 -1
  33. package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
  34. package/dist/cjs/{zonosStore-7c1e1bc1.js → zonosStore-f8ee56aa.js} +1 -0
  35. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +36 -12
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +63 -25
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +33 -11
  38. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +2 -2
  39. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +9 -5
  40. package/dist/collection/components/store/checkout/cart.js +9 -2
  41. package/dist/collection/components/store/checkout/stripe.js +266 -31
  42. package/dist/collection/components/stripe/zonos-address/zonos-address.css +2 -1
  43. package/dist/collection/components/stripe/zonos-address/zonos-address.js +24 -3
  44. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +2 -1
  45. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +7 -5
  46. package/dist/collection/components/utils/api/cartCalculateLandedCost.js +3 -2
  47. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +2 -2
  48. package/dist/collection/components/utils/handleFetch.js +2 -1
  49. package/dist/collection/components/utils/logging/log.js +0 -5
  50. package/dist/collection/types/checkout/api/CreateParty.js +1 -0
  51. package/dist/collection/types/generated/graphql.internal.types.js +3 -0
  52. package/dist/collection/types/index.js +1 -0
  53. package/dist/esm/{cart-5b417c0d.js → cart-2f84f632.js} +284 -41
  54. package/dist/esm/{debounce-7ebfa15b.js → debounce-0e42da22.js} +1 -1
  55. package/dist/esm/{getBorderRadius-174305ff.js → getBorderRadius-71b3b8ab.js} +1 -1
  56. package/dist/esm/{handleFetch-621e45bc.js → handleFetch-7dd4622b.js} +2 -6
  57. package/dist/esm/index.js +8 -8
  58. package/dist/esm/{isDarkColor-915b06b8.js → isDarkColor-3a9d6108.js} +1 -1
  59. package/dist/esm/loader.js +1 -1
  60. package/dist/esm/{localization-669a1714.js → localization-e17c211b.js} +2 -2
  61. package/dist/esm/{paypal-3a0cf86b.js → paypal-1cf701aa.js} +6 -6
  62. package/dist/esm/{updateCheckoutSessionAttributes-183ca6c1.js → updateCheckoutSessionAttributes-5097e715.js} +2 -2
  63. package/dist/esm/zonos-address_11.entry.js +104 -84
  64. package/dist/esm/zonos-badge.entry.js +1 -1
  65. package/dist/esm/zonos-banner.entry.js +1 -1
  66. package/dist/esm/zonos-button_3.entry.js +3 -3
  67. package/dist/esm/zonos-card.entry.js +2 -2
  68. package/dist/esm/zonos-cart-items_14.entry.js +91 -41
  69. package/dist/esm/zonos-checkout.entry.js +45 -21
  70. package/dist/esm/zonos-collapse.entry.js +1 -1
  71. package/dist/esm/zonos-controller.entry.js +6 -6
  72. package/dist/esm/zonos-country-flag.entry.js +3 -3
  73. package/dist/esm/zonos-country-select_4.entry.js +13 -9
  74. package/dist/esm/zonos-elements.js +1 -1
  75. package/dist/esm/zonos-empty-state-payment_4.entry.js +7 -7
  76. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  77. package/dist/esm/zonos-hello.entry.js +4 -4
  78. package/dist/esm/zonos-input.entry.js +2 -2
  79. package/dist/esm/zonos-language-select_2.entry.js +3 -3
  80. package/dist/esm/zonos-logo.entry.js +1 -1
  81. package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
  82. package/dist/esm/zonos-stripe-input.entry.js +3 -3
  83. package/dist/esm/zonos-text.entry.js +1 -1
  84. package/dist/esm/zonos-toggle.entry.js +1 -1
  85. package/dist/esm/zonos-v-stack.entry.js +1 -1
  86. package/dist/esm/{zonosStore-504a7030.js → zonosStore-00975763.js} +1 -1
  87. package/dist/esm-es5/cart-2f84f632.js +1 -0
  88. package/dist/esm-es5/{debounce-7ebfa15b.js → debounce-0e42da22.js} +1 -1
  89. package/dist/esm-es5/{getBorderRadius-174305ff.js → getBorderRadius-71b3b8ab.js} +1 -1
  90. package/dist/esm-es5/handleFetch-7dd4622b.js +1 -0
  91. package/dist/esm-es5/index.js +1 -1
  92. package/dist/esm-es5/{isDarkColor-915b06b8.js → isDarkColor-3a9d6108.js} +1 -1
  93. package/dist/esm-es5/loader.js +1 -1
  94. package/dist/esm-es5/{localization-669a1714.js → localization-e17c211b.js} +1 -1
  95. package/dist/esm-es5/{paypal-3a0cf86b.js → paypal-1cf701aa.js} +2 -2
  96. package/dist/esm-es5/{updateCheckoutSessionAttributes-183ca6c1.js → updateCheckoutSessionAttributes-5097e715.js} +1 -1
  97. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  98. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  99. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  100. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  101. package/dist/esm-es5/zonos-card.entry.js +1 -1
  102. package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
  103. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  104. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  105. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  106. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  107. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  108. package/dist/esm-es5/zonos-elements.js +1 -1
  109. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  110. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  111. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  112. package/dist/esm-es5/zonos-input.entry.js +1 -1
  113. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  114. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  115. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  116. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  117. package/dist/esm-es5/zonos-text.entry.js +1 -1
  118. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  119. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  120. package/dist/esm-es5/{zonosStore-504a7030.js → zonosStore-00975763.js} +1 -1
  121. package/dist/scripts/index.d.ts +8 -0
  122. package/dist/scripts/index.js +1 -1
  123. package/dist/scripts/loadZonos.js +1 -1
  124. package/dist/scripts/zonos.js +1 -1
  125. package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +8 -4
  126. package/dist/types/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.d.ts +3 -0
  127. package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +1 -0
  128. package/dist/types/components/store/checkout/cart.d.ts +6 -2
  129. package/dist/types/components/store/checkout/stripe.d.ts +33 -6
  130. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +6 -0
  131. package/dist/types/types/checkout/api/CheckoutSession.d.ts +2 -0
  132. package/dist/types/types/checkout/api/CreateParty.d.ts +34 -0
  133. package/dist/types/types/generated/graphql.internal.types.d.ts +21 -5
  134. package/dist/types/types/generated/graphql.internal.types.ts +26 -3
  135. package/dist/types/types/index.d.ts +1 -0
  136. package/dist/types/types/utils/ZonosSettings.d.ts +6 -0
  137. package/dist/zonos-elements/index.esm.js +1 -1
  138. package/dist/zonos-elements/{p-c5455a34.system.js → p-0751b878.system.js} +1 -1
  139. package/dist/zonos-elements/{p-39039ab7.system.entry.js → p-08b29f73.system.entry.js} +1 -1
  140. package/dist/zonos-elements/{p-0731fbba.entry.js → p-0ca1d6dd.entry.js} +1 -1
  141. package/dist/zonos-elements/{p-e1c2b8f8.entry.js → p-144b5006.entry.js} +1 -1
  142. package/dist/zonos-elements/{p-d5bdbbb3.system.js → p-19182dc7.system.js} +1 -1
  143. package/dist/zonos-elements/{p-066afca1.system.entry.js → p-1dc78af3.system.entry.js} +1 -1
  144. package/dist/zonos-elements/{p-5f2a2ca7.js → p-207bd04a.js} +1 -1
  145. package/dist/zonos-elements/p-20839c46.js +1 -0
  146. package/dist/zonos-elements/{p-63ca1242.system.entry.js → p-2122d2cc.system.entry.js} +1 -1
  147. package/dist/zonos-elements/{p-a09bdd20.system.entry.js → p-239695e8.system.entry.js} +1 -1
  148. package/dist/zonos-elements/{p-6b406abd.entry.js → p-23fe7661.entry.js} +1 -1
  149. package/dist/zonos-elements/p-2652198d.js +1 -0
  150. package/dist/zonos-elements/p-30a9f802.system.entry.js +1 -0
  151. package/dist/zonos-elements/{p-4451a598.system.js → p-3633a952.system.js} +1 -1
  152. package/dist/zonos-elements/{p-6be43ba8.entry.js → p-36b686b6.entry.js} +1 -1
  153. package/dist/zonos-elements/{p-b7a5b367.js → p-371d91d1.js} +2 -2
  154. package/dist/zonos-elements/{p-081fa4a8.entry.js → p-3934b38a.entry.js} +1 -1
  155. package/dist/zonos-elements/{p-a4d995a2.system.js → p-3c752420.system.js} +1 -1
  156. package/dist/zonos-elements/p-3ee44728.system.js +1 -1
  157. package/dist/zonos-elements/{p-7f568108.system.js → p-44c0a584.system.js} +2 -2
  158. package/dist/zonos-elements/{p-cd376c7a.system.entry.js → p-45a2f9b1.system.entry.js} +1 -1
  159. package/dist/zonos-elements/{p-0d908c15.system.js → p-4a1b4a2d.system.js} +1 -1
  160. package/dist/zonos-elements/p-4c70fd75.entry.js +1 -0
  161. package/dist/zonos-elements/{p-07905246.entry.js → p-4d62f3de.entry.js} +1 -1
  162. package/dist/zonos-elements/{p-bb850bb7.entry.js → p-4dbaa2c2.entry.js} +1 -1
  163. package/dist/zonos-elements/{p-0fb14108.entry.js → p-4ed73ff8.entry.js} +1 -1
  164. package/dist/zonos-elements/{p-ef594c0c.entry.js → p-4f5513dc.entry.js} +1 -1
  165. package/dist/zonos-elements/p-542acc2c.js +1 -0
  166. package/dist/zonos-elements/p-5711e187.system.js +1 -0
  167. package/dist/zonos-elements/{p-c607d026.entry.js → p-5956a9e0.entry.js} +1 -1
  168. package/dist/zonos-elements/{p-d096d7f2.entry.js → p-5b7686f8.entry.js} +1 -1
  169. package/dist/zonos-elements/{p-67f807bc.entry.js → p-63a4dac5.entry.js} +1 -1
  170. package/dist/zonos-elements/{p-51d596a0.system.entry.js → p-695bf400.system.entry.js} +1 -1
  171. package/dist/zonos-elements/{p-d35d17f3.js → p-6aa728f2.js} +1 -1
  172. package/dist/zonos-elements/{p-4bf54953.js → p-71c6bdc3.js} +1 -1
  173. package/dist/zonos-elements/{p-0f368368.system.js → p-738a49c0.system.js} +1 -1
  174. package/dist/zonos-elements/{p-7e346632.system.entry.js → p-74276b82.system.entry.js} +1 -1
  175. package/dist/zonos-elements/{p-d1a31577.entry.js → p-77e22be4.entry.js} +1 -1
  176. package/dist/zonos-elements/{p-a3a8ba10.entry.js → p-78dd1c53.entry.js} +1 -1
  177. package/dist/zonos-elements/{p-3d6f6367.system.entry.js → p-7f9bbbb3.system.entry.js} +1 -1
  178. package/dist/zonos-elements/{p-ea30d92d.system.entry.js → p-896f2358.system.entry.js} +1 -1
  179. package/dist/zonos-elements/{p-a63bac79.system.entry.js → p-8f41d864.system.entry.js} +1 -1
  180. package/dist/zonos-elements/{p-1f706fc9.system.entry.js → p-964e2587.system.entry.js} +1 -1
  181. package/dist/zonos-elements/{p-1530f958.system.entry.js → p-97831744.system.entry.js} +1 -1
  182. package/dist/zonos-elements/{p-160da12a.system.entry.js → p-9d95c896.system.entry.js} +1 -1
  183. package/dist/zonos-elements/{p-4f04b499.entry.js → p-a24870af.entry.js} +1 -1
  184. package/dist/zonos-elements/p-a411ce2a.system.js +1 -0
  185. package/dist/zonos-elements/{p-5c772fab.system.entry.js → p-a4686344.system.entry.js} +1 -1
  186. package/dist/zonos-elements/{p-a158b406.js → p-a6f77d44.js} +1 -1
  187. package/dist/zonos-elements/{p-fc3a6495.entry.js → p-a8f421ac.entry.js} +1 -1
  188. package/dist/zonos-elements/{p-da304b78.entry.js → p-aa40d402.entry.js} +1 -1
  189. package/dist/zonos-elements/{p-6c991320.entry.js → p-ad1e1dbc.entry.js} +1 -1
  190. package/dist/zonos-elements/p-b1bfeec9.system.entry.js +1 -0
  191. package/dist/zonos-elements/{p-ab6efb03.system.entry.js → p-baa88176.system.entry.js} +1 -1
  192. package/dist/zonos-elements/{p-963fa567.system.entry.js → p-bf9cb85f.system.entry.js} +1 -1
  193. package/dist/zonos-elements/p-bfdb4e7a.entry.js +1 -0
  194. package/dist/zonos-elements/{p-803e59d2.system.entry.js → p-c345b306.system.entry.js} +1 -1
  195. package/dist/zonos-elements/{p-a958c4f0.system.entry.js → p-d1697144.system.entry.js} +1 -1
  196. package/dist/zonos-elements/p-d1c0bf92.entry.js +1 -0
  197. package/dist/zonos-elements/{p-b3fa7f19.js → p-d6a53ea6.js} +1 -1
  198. package/dist/zonos-elements/{p-02463cc1.system.entry.js → p-db424e02.system.entry.js} +1 -1
  199. package/dist/zonos-elements/{p-39428328.system.js → p-eb77c0bf.system.js} +1 -1
  200. package/dist/zonos-elements/{p-f49834d4.system.entry.js → p-ef1ccec6.system.entry.js} +1 -1
  201. package/dist/zonos-elements/{p-5d909d3d.entry.js → p-fdf5b8f4.entry.js} +1 -1
  202. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  203. package/package.json +1 -1
  204. package/dist/esm-es5/cart-5b417c0d.js +0 -1
  205. package/dist/esm-es5/handleFetch-621e45bc.js +0 -1
  206. package/dist/zonos-elements/p-0794c530.entry.js +0 -1
  207. package/dist/zonos-elements/p-0fc02cde.js +0 -1
  208. package/dist/zonos-elements/p-1b3e92ea.system.entry.js +0 -1
  209. package/dist/zonos-elements/p-1b75aa35.system.js +0 -1
  210. package/dist/zonos-elements/p-2d4e0280.entry.js +0 -1
  211. package/dist/zonos-elements/p-40a2a649.js +0 -1
  212. package/dist/zonos-elements/p-5539386e.system.entry.js +0 -1
  213. package/dist/zonos-elements/p-91553cf0.system.js +0 -1
  214. package/dist/zonos-elements/p-c740353c.js +0 -1
  215. package/dist/zonos-elements/p-f1f3a846.entry.js +0 -1
@@ -9,7 +9,8 @@ import { allLogs, log } from "../../utils/logging/log";
9
9
  import { logError } from "../../utils/logging/logError";
10
10
  import { sendErrorLog } from "../../utils/logging/sendErrorLog";
11
11
  import { filterValidTests } from "../../utils/varianceTest/filterValidTests";
12
- const { reset, state: cartStore } = createStore(() => ({
12
+ const { onChange: cartStoreOnChange, reset, state: cartStore, } = createStore(() => ({
13
+ addressFormRenderType: 'stripe',
13
14
  adjustmentTotal: 0,
14
15
  adjustments: [],
15
16
  checkoutSession: null,
@@ -224,12 +225,14 @@ const cartStoreReCalculateTotal = async ({ adjustmentsAmount, cartId, currency,
224
225
  }
225
226
  const { errors, json } = await stripeStoreUpdateCheckoutSession({
226
227
  adjustmentsAmount,
228
+ billToPartyId: stripeStore.partyBillingId,
227
229
  cartId,
228
230
  currency,
229
231
  id: storageStore.checkoutSessionId,
230
232
  itemsAmount,
231
233
  landedCostId,
232
234
  presentmentCountryCode: localizationStore.selectedCountryCode,
235
+ shipToPartyId: stripeStore.partyShippingId,
233
236
  varianceTestInput: storageStore.enabledVariantTestKeys || [],
234
237
  });
235
238
  if (errors.length > 0 || !json) {
@@ -313,9 +316,11 @@ const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption, lan
313
316
  // update session with selected landed cost
314
317
  const updateCalculateStatus = await cartStoreReCalculateTotal({
315
318
  adjustmentsAmount: cartStore.adjustmentTotal,
319
+ billToPartyId: stripeStore.partyBillingId,
316
320
  cartId: window.Zonos.cartId,
317
321
  dutiesTaxesFeesEstimate: dutiesTaxesFeesEstimate,
318
322
  landedCostId: (_f = selectedLandedCost.landedCost) === null || _f === void 0 ? void 0 : _f.id,
323
+ shipToPartyId: stripeStore.partyShippingId,
319
324
  varianceTestInput: storageStore.enabledVariantTestKeys || [],
320
325
  });
321
326
  // update conditionally render pay in USD button
@@ -378,10 +383,12 @@ const cartStoreUpdateItems = async ({ adjustments, cartItems, }) => {
378
383
  stripeStore.isFetchingSession = true;
379
384
  await cartStoreReCalculateTotal({
380
385
  adjustmentsAmount: adjustmentTotal,
386
+ billToPartyId: stripeStore.partyBillingId,
381
387
  cartId: window.Zonos.cartId,
382
388
  currency: currency,
383
389
  dutiesTaxesFeesEstimate: 0,
384
390
  itemsAmount: total,
391
+ shipToPartyId: stripeStore.partyShippingId,
385
392
  // attempt to init session on failure to update checkout session
386
393
  shouldInitSessionOnFailure: true,
387
394
  varianceTestInput: storageStore.enabledVariantTestKeys || [],
@@ -436,4 +443,4 @@ const cartStoreResetTabItems = () => {
436
443
  cartStore.tabItems = Object.assign(Object.assign({}, cartStore.tabItems), { 'customer-info': Object.assign(Object.assign({}, cartStore.tabItems['customer-info']), { isDone: false }), payment: Object.assign(Object.assign({}, cartStore.tabItems.payment), { isDone: false }), shipping: Object.assign(Object.assign({}, cartStore.tabItems.shipping), { isDone: false }) });
437
444
  cartStoreResetSelectedShippingOption();
438
445
  };
439
- export { cartStore, cartStoreApplySubtotals, cartStoreCheckItemRestrictions, cartStoreClearCheckoutInterval, cartStoreGetMethod, cartStoreGetShippingTransitInfo, cartStoreHasOneEligibleItem, cartStoreNextStep, cartStorePreviousStep, cartStoreReset, cartStoreResetCartItems, cartStoreResetTabItems, cartStoreSetCheckoutSession, cartStoreStartCheckoutInterval, cartStoreUpdateItems, cartStoreUpdateSelectedShippingOption, cartStoreUpdateToErrorState, };
446
+ export { cartStore, cartStoreApplySubtotals, cartStoreCheckItemRestrictions, cartStoreClearCheckoutInterval, cartStoreGetMethod, cartStoreGetShippingTransitInfo, cartStoreHasOneEligibleItem, cartStoreNextStep, cartStoreOnChange, cartStorePreviousStep, cartStoreReset, cartStoreResetCartItems, cartStoreResetTabItems, cartStoreSetCheckoutSession, cartStoreStartCheckoutInterval, cartStoreUpdateItems, cartStoreUpdateSelectedShippingOption, cartStoreUpdateToErrorState, };
@@ -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
- taxIdUsedWhenFetchingLC: '',
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 checkIsAddressOutdatedForLCPrefetch = () => {
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.stripeAddressUsedWhenFetchingLC) === null || _c === void 0 ? void 0 : _c.value) !==
190
- JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
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
- JSON.stringify((_e = stripeStore.stripeBillingAddressEventData) === null || _e === void 0 ? void 0 : _e.value) !==
193
- JSON.stringify((_f = stripeStore.stripeBillingAddressUsedWhenFetchingLC) === null || _f === void 0 ? void 0 : _f.value);
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
- // Auto prefetch landed cost if tax id is updated
208
- const isTaxIdDirty = stripeStore.taxIdUsedWhenFetchingLC !== stripeStore.taxId;
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
- isTaxIdDirty);
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, _e, _f, _g, _h;
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
- (_e = stripeStore.fetchingLandedCostAbortController) === null || _e === void 0 ? void 0 : _e.abort();
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 ((!shouldRefetch && !applyingPromocode) ||
279
- !stripeAddressReady ||
280
- !stripeLinkReady ||
281
- !stripeBillingAddressReady) {
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 = Object.assign({}, stripeStore.stripeAddressEventData);
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 = Object.assign({}, stripeStore.stripeBillingAddressEventData);
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 = (_f = cartStore.shippingData) === null || _f === void 0 ? void 0 : _f.find(Boolean);
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 = (_g = cartStore.landedCostData) === null || _g === void 0 ? void 0 : _g.find(x => x.landedCost.shipmentRating.id === (cheapestServiceLevel === null || cheapestServiceLevel === void 0 ? void 0 : cheapestServiceLevel.id));
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 = (_h = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _h === void 0 ? void 0 : _h.value;
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
@@ -736,6 +969,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
736
969
  const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
737
970
  body: {
738
971
  adjustmentsAmount,
972
+ billToPartyId: stripeStore.partyBillingId,
739
973
  cartId,
740
974
  currency,
741
975
  customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
@@ -749,6 +983,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
749
983
  },
750
984
  ],
751
985
  presentmentCountryCode,
986
+ shipToPartyId: stripeStore.partyShippingId,
752
987
  skipPaymentIntent: stripeStore.skipPaymentIntent,
753
988
  varianceTestInput,
754
989
  },
@@ -888,4 +1123,4 @@ stripeStoreOnChange('clientSecret', clientSecret => {
888
1123
  sessionStorage.removeItem('zonos--client-secret');
889
1124
  }
890
1125
  });
891
- 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, };
@@ -34,7 +34,8 @@
34
34
  :host .zonos--title {
35
35
  margin-bottom: 16px;
36
36
  }
37
- :host .zonos--company-name-input {
37
+ :host .zonos--company-name-input,
38
+ :host .zonos--tax-id-input {
38
39
  margin-bottom: 16px;
39
40
  }
40
41
  :host zonos-banner {
@@ -1,5 +1,6 @@
1
1
  import { h, Host, } from "@stencil/core";
2
- import { stripeStore } from "../../store/checkout/stripe";
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: '6cb58defa44e55a88bdb8ad3b1b2e96033337fec', class: "zonos--address zonos--elements" }, h("zonos-text", { key: '2708affaeb700f6c256b38285696d3eaffa1d1ea', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderTaxIdInput(), h("div", { key: '290de47b8579a70f997ead2ab3ada123dfa4d204', class: "zonos--address-component" })));
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() {
@@ -34,7 +34,8 @@
34
34
  :host .zonos--title {
35
35
  margin-bottom: 16px;
36
36
  }
37
- :host .zonos--company-name-input {
37
+ :host .zonos--company-name-input,
38
+ :host .zonos--tax-id-input {
38
39
  margin-bottom: 8px;
39
40
  }
40
41
  :host zonos-banner {
@@ -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: 'd66b492bb6eb663ce3311012de3cc14e9848e41e', class: classes([
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: '4ab2a112115c951719063f94247d1d85f16faec8', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderCustomAddressForm()));
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';