@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.
Files changed (239) hide show
  1. package/dist/cjs/{CheckoutConfig-4afc683b.js → CheckoutConfig-27c82f94.js} +19 -0
  2. package/dist/cjs/{cart-3d961c6e.js → cart-2ec8cac2.js} +285 -64
  3. package/dist/cjs/{debounce-0b9c0f8a.js → debounce-465a4328.js} +1 -1
  4. package/dist/cjs/{getBorderRadius-c424eb05.js → getBorderRadius-1b5e33cf.js} +1 -1
  5. package/dist/cjs/{handleFetch-969d05d8.js → handleFetch-05227713.js} +2 -6
  6. package/dist/cjs/index.cjs.js +29 -9
  7. package/dist/cjs/{isDarkColor-35e8daec.js → isDarkColor-428965f4.js} +1 -1
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/{localization-ff33875b.js → localization-9b43376c.js} +3 -2
  10. package/dist/cjs/{paypal-dee5c109.js → paypal-6449314e.js} +5 -5
  11. package/dist/cjs/updateCheckoutSessionAttributes-a31bb681.js +50 -0
  12. package/dist/cjs/zonos-address_11.cjs.entry.js +104 -84
  13. package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
  15. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  16. package/dist/cjs/zonos-card.cjs.entry.js +2 -2
  17. package/dist/cjs/zonos-cart-items_14.cjs.entry.js +98 -49
  18. package/dist/cjs/zonos-checkout.cjs.entry.js +87 -31
  19. package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
  20. package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
  21. package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
  22. package/dist/cjs/zonos-country-select_4.cjs.entry.js +13 -9
  23. package/dist/cjs/zonos-elements.cjs.js +1 -1
  24. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +7 -7
  25. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  26. package/dist/cjs/zonos-hello.cjs.entry.js +4 -4
  27. package/dist/cjs/zonos-input.cjs.entry.js +2 -2
  28. package/dist/cjs/zonos-language-select_2.cjs.entry.js +3 -3
  29. package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
  30. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
  31. package/dist/cjs/zonos-stripe-input.cjs.entry.js +3 -3
  32. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  33. package/dist/cjs/zonos-toggle.cjs.entry.js +1 -1
  34. package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
  35. package/dist/cjs/{zonosStore-7c1e1bc1.js → zonosStore-f8ee56aa.js} +1 -0
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +79 -24
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +71 -36
  38. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +33 -11
  39. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +2 -2
  40. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +9 -5
  41. package/dist/collection/components/store/checkout/cart.js +9 -2
  42. package/dist/collection/components/store/checkout/stripe.js +266 -55
  43. package/dist/collection/components/store/hello/localization.js +1 -0
  44. package/dist/collection/components/stripe/zonos-address/zonos-address.css +2 -1
  45. package/dist/collection/components/stripe/zonos-address/zonos-address.js +24 -3
  46. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +2 -1
  47. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +7 -5
  48. package/dist/collection/components/utils/api/cartCalculateLandedCost.js +3 -2
  49. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +2 -2
  50. package/dist/collection/components/utils/api/updateCheckoutSessionAttributes.js +46 -0
  51. package/dist/collection/components/utils/checkout/getAbandonedCartRenewTokenValue.js +17 -0
  52. package/dist/collection/components/utils/handleFetch.js +2 -1
  53. package/dist/collection/components/utils/logging/log.js +0 -5
  54. package/dist/collection/scripts/_getCartInfoById.js +3 -0
  55. package/dist/collection/types/checkout/api/CheckoutSession.js +14 -1
  56. package/dist/collection/types/checkout/api/CreateParty.js +1 -0
  57. package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
  58. package/dist/collection/types/generated/graphql.internal.types.js +15 -0
  59. package/dist/collection/types/index.js +1 -0
  60. package/dist/esm/{CheckoutConfig-eb7d6954.js → CheckoutConfig-724d7bae.js} +19 -1
  61. package/dist/esm/{cart-5835676d.js → cart-2f84f632.js} +284 -65
  62. package/dist/esm/{debounce-eaee3a94.js → debounce-0e42da22.js} +1 -1
  63. package/dist/esm/{getBorderRadius-b18c924f.js → getBorderRadius-71b3b8ab.js} +1 -1
  64. package/dist/esm/{handleFetch-621e45bc.js → handleFetch-7dd4622b.js} +2 -6
  65. package/dist/esm/index.js +28 -11
  66. package/dist/esm/{isDarkColor-d8bb8659.js → isDarkColor-3a9d6108.js} +1 -1
  67. package/dist/esm/loader.js +1 -1
  68. package/dist/esm/{localization-4c7f64e8.js → localization-e17c211b.js} +3 -2
  69. package/dist/esm/{paypal-b4f106be.js → paypal-1cf701aa.js} +6 -6
  70. package/dist/esm/updateCheckoutSessionAttributes-5097e715.js +48 -0
  71. package/dist/esm/zonos-address_11.entry.js +104 -84
  72. package/dist/esm/zonos-badge.entry.js +1 -1
  73. package/dist/esm/zonos-banner.entry.js +1 -1
  74. package/dist/esm/zonos-button_3.entry.js +3 -3
  75. package/dist/esm/zonos-card.entry.js +2 -2
  76. package/dist/esm/zonos-cart-items_14.entry.js +98 -49
  77. package/dist/esm/zonos-checkout.entry.js +87 -31
  78. package/dist/esm/zonos-collapse.entry.js +1 -1
  79. package/dist/esm/zonos-controller.entry.js +6 -6
  80. package/dist/esm/zonos-country-flag.entry.js +3 -3
  81. package/dist/esm/zonos-country-select_4.entry.js +13 -9
  82. package/dist/esm/zonos-elements.js +1 -1
  83. package/dist/esm/zonos-empty-state-payment_4.entry.js +7 -7
  84. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  85. package/dist/esm/zonos-hello.entry.js +4 -4
  86. package/dist/esm/zonos-input.entry.js +2 -2
  87. package/dist/esm/zonos-language-select_2.entry.js +3 -3
  88. package/dist/esm/zonos-logo.entry.js +1 -1
  89. package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
  90. package/dist/esm/zonos-stripe-input.entry.js +3 -3
  91. package/dist/esm/zonos-text.entry.js +1 -1
  92. package/dist/esm/zonos-toggle.entry.js +1 -1
  93. package/dist/esm/zonos-v-stack.entry.js +1 -1
  94. package/dist/esm/{zonosStore-1e015fa5.js → zonosStore-00975763.js} +1 -1
  95. package/dist/esm-es5/CheckoutConfig-724d7bae.js +1 -0
  96. package/dist/esm-es5/cart-2f84f632.js +1 -0
  97. package/dist/esm-es5/{debounce-eaee3a94.js → debounce-0e42da22.js} +1 -1
  98. package/dist/esm-es5/{getBorderRadius-b18c924f.js → getBorderRadius-71b3b8ab.js} +1 -1
  99. package/dist/esm-es5/handleFetch-7dd4622b.js +1 -0
  100. package/dist/esm-es5/index.js +1 -1
  101. package/dist/esm-es5/{isDarkColor-d8bb8659.js → isDarkColor-3a9d6108.js} +1 -1
  102. package/dist/esm-es5/loader.js +1 -1
  103. package/dist/esm-es5/{localization-4c7f64e8.js → localization-e17c211b.js} +1 -1
  104. package/dist/esm-es5/{paypal-b4f106be.js → paypal-1cf701aa.js} +2 -2
  105. package/dist/esm-es5/updateCheckoutSessionAttributes-5097e715.js +1 -0
  106. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  107. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  108. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  109. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  110. package/dist/esm-es5/zonos-card.entry.js +1 -1
  111. package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
  112. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  113. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  114. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  115. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  116. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  117. package/dist/esm-es5/zonos-elements.js +1 -1
  118. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  119. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  120. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  121. package/dist/esm-es5/zonos-input.entry.js +1 -1
  122. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  123. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  124. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  125. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  126. package/dist/esm-es5/zonos-text.entry.js +1 -1
  127. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  128. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  129. package/dist/esm-es5/{zonosStore-1e015fa5.js → zonosStore-00975763.js} +1 -1
  130. package/dist/scripts/index.d.ts +10 -0
  131. package/dist/scripts/index.js +1 -1
  132. package/dist/scripts/loadZonos.js +1 -1
  133. package/dist/scripts/zonos.js +1 -1
  134. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +2 -0
  135. package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +8 -4
  136. package/dist/types/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.d.ts +3 -0
  137. package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +1 -0
  138. package/dist/types/components/store/checkout/cart.d.ts +6 -2
  139. package/dist/types/components/store/checkout/stripe.d.ts +33 -6
  140. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +6 -0
  141. package/dist/types/components/utils/api/updateCheckoutSessionAttributes.d.ts +7 -0
  142. package/dist/types/components/utils/checkout/getAbandonedCartRenewTokenValue.d.ts +1 -0
  143. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +1 -0
  144. package/dist/types/types/checkout/api/CheckoutSession.d.ts +16 -0
  145. package/dist/types/types/checkout/api/CreateParty.d.ts +34 -0
  146. package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +2 -0
  147. package/dist/types/types/generated/graphql.frontend.types.d.ts +2 -0
  148. package/dist/types/types/generated/graphql.frontend.types.ts +2 -0
  149. package/dist/types/types/generated/graphql.internal.types.d.ts +61 -5
  150. package/dist/types/types/generated/graphql.internal.types.ts +105 -3
  151. package/dist/types/types/index.d.ts +1 -0
  152. package/dist/types/types/utils/ZonosSettings.d.ts +6 -0
  153. package/dist/zonos-elements/index.esm.js +1 -1
  154. package/dist/zonos-elements/{p-4e9c8f9e.system.js → p-0751b878.system.js} +1 -1
  155. package/dist/zonos-elements/{p-abe218ab.system.entry.js → p-08b29f73.system.entry.js} +1 -1
  156. package/dist/zonos-elements/{p-74bcb5cc.entry.js → p-0ca1d6dd.entry.js} +1 -1
  157. package/dist/zonos-elements/{p-12cd9d3a.entry.js → p-144b5006.entry.js} +1 -1
  158. package/dist/zonos-elements/{p-9e9ac7a2.system.js → p-19182dc7.system.js} +1 -1
  159. package/dist/zonos-elements/{p-eca09508.system.entry.js → p-1dc78af3.system.entry.js} +1 -1
  160. package/dist/zonos-elements/{p-e337fa88.js → p-207bd04a.js} +1 -1
  161. package/dist/zonos-elements/p-20839c46.js +1 -0
  162. package/dist/zonos-elements/{p-1aa24297.system.entry.js → p-2122d2cc.system.entry.js} +1 -1
  163. package/dist/zonos-elements/{p-4fb88ebc.system.entry.js → p-239695e8.system.entry.js} +1 -1
  164. package/dist/zonos-elements/{p-3196bf98.entry.js → p-23fe7661.entry.js} +1 -1
  165. package/dist/zonos-elements/p-2652198d.js +1 -0
  166. package/dist/zonos-elements/p-30a9f802.system.entry.js +1 -0
  167. package/dist/zonos-elements/{p-c666d557.system.js → p-3633a952.system.js} +1 -1
  168. package/dist/zonos-elements/{p-9b8a5372.entry.js → p-36b686b6.entry.js} +1 -1
  169. package/dist/zonos-elements/{p-658936c9.js → p-371d91d1.js} +2 -2
  170. package/dist/zonos-elements/{p-019f8637.entry.js → p-3934b38a.entry.js} +1 -1
  171. package/dist/zonos-elements/p-3c752420.system.js +1 -0
  172. package/dist/zonos-elements/p-3ee44728.system.js +1 -1
  173. package/dist/zonos-elements/p-40a4c8a2.system.js +1 -0
  174. package/dist/zonos-elements/{p-91c996d3.system.js → p-44c0a584.system.js} +2 -2
  175. package/dist/zonos-elements/{p-eb2560b6.system.entry.js → p-45a2f9b1.system.entry.js} +1 -1
  176. package/dist/zonos-elements/{p-1327b935.system.js → p-4a1b4a2d.system.js} +1 -1
  177. package/dist/zonos-elements/p-4c70fd75.entry.js +1 -0
  178. package/dist/zonos-elements/{p-bab19e2a.entry.js → p-4d62f3de.entry.js} +1 -1
  179. package/dist/zonos-elements/{p-848e08e8.entry.js → p-4dbaa2c2.entry.js} +1 -1
  180. package/dist/zonos-elements/p-4ed73ff8.entry.js +1 -0
  181. package/dist/zonos-elements/{p-47e2cd31.entry.js → p-4f5513dc.entry.js} +1 -1
  182. package/dist/zonos-elements/p-542acc2c.js +1 -0
  183. package/dist/zonos-elements/p-5711e187.system.js +1 -0
  184. package/dist/zonos-elements/{p-41c1d7c4.entry.js → p-5956a9e0.entry.js} +1 -1
  185. package/dist/zonos-elements/{p-5616b304.entry.js → p-5b7686f8.entry.js} +1 -1
  186. package/dist/zonos-elements/{p-0c4c8d63.entry.js → p-63a4dac5.entry.js} +1 -1
  187. package/dist/zonos-elements/{p-f4d741de.system.entry.js → p-695bf400.system.entry.js} +1 -1
  188. package/dist/zonos-elements/{p-9fa17353.js → p-6aa728f2.js} +1 -1
  189. package/dist/zonos-elements/{p-ed20f2f7.js → p-71c6bdc3.js} +1 -1
  190. package/dist/zonos-elements/p-738a49c0.system.js +1 -0
  191. package/dist/zonos-elements/{p-469ccc66.system.entry.js → p-74276b82.system.entry.js} +1 -1
  192. package/dist/zonos-elements/{p-e0587eeb.entry.js → p-77e22be4.entry.js} +1 -1
  193. package/dist/zonos-elements/{p-3afc27ef.entry.js → p-78dd1c53.entry.js} +1 -1
  194. package/dist/zonos-elements/{p-620deb03.system.entry.js → p-7f9bbbb3.system.entry.js} +1 -1
  195. package/dist/zonos-elements/p-896f2358.system.entry.js +1 -0
  196. package/dist/zonos-elements/{p-719e14a8.system.entry.js → p-8f41d864.system.entry.js} +1 -1
  197. package/dist/zonos-elements/{p-4cb8b87f.system.entry.js → p-964e2587.system.entry.js} +1 -1
  198. package/dist/zonos-elements/{p-93aeba62.system.entry.js → p-97831744.system.entry.js} +1 -1
  199. package/dist/zonos-elements/{p-2866fd29.system.entry.js → p-9d95c896.system.entry.js} +1 -1
  200. package/dist/zonos-elements/{p-abc83d01.entry.js → p-a24870af.entry.js} +1 -1
  201. package/dist/zonos-elements/p-a411ce2a.system.js +1 -0
  202. package/dist/zonos-elements/{p-1bc09abe.system.entry.js → p-a4686344.system.entry.js} +1 -1
  203. package/dist/zonos-elements/{p-edcfb3a3.js → p-a6f77d44.js} +1 -1
  204. package/dist/zonos-elements/{p-b21b0330.entry.js → p-a8f421ac.entry.js} +1 -1
  205. package/dist/zonos-elements/{p-18149db1.entry.js → p-aa40d402.entry.js} +1 -1
  206. package/dist/zonos-elements/{p-536f69eb.entry.js → p-ad1e1dbc.entry.js} +1 -1
  207. package/dist/zonos-elements/p-b1bfeec9.system.entry.js +1 -0
  208. package/dist/zonos-elements/p-b2d81c98.js +1 -0
  209. package/dist/zonos-elements/{p-7777d85f.system.entry.js → p-baa88176.system.entry.js} +1 -1
  210. package/dist/zonos-elements/{p-1ad099ec.system.entry.js → p-bf9cb85f.system.entry.js} +1 -1
  211. package/dist/zonos-elements/p-bfdb4e7a.entry.js +1 -0
  212. package/dist/zonos-elements/{p-858b7908.system.entry.js → p-c345b306.system.entry.js} +1 -1
  213. package/dist/zonos-elements/{p-22cb6880.system.entry.js → p-d1697144.system.entry.js} +1 -1
  214. package/dist/zonos-elements/p-d1c0bf92.entry.js +1 -0
  215. package/dist/zonos-elements/{p-16678764.js → p-d6a53ea6.js} +1 -1
  216. package/dist/zonos-elements/{p-265af369.system.entry.js → p-db424e02.system.entry.js} +1 -1
  217. package/dist/zonos-elements/p-eb77c0bf.system.js +1 -0
  218. package/dist/zonos-elements/{p-30778fde.system.entry.js → p-ef1ccec6.system.entry.js} +1 -1
  219. package/dist/zonos-elements/{p-42a9557f.entry.js → p-fdf5b8f4.entry.js} +1 -1
  220. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  221. package/package.json +1 -1
  222. package/dist/esm-es5/CheckoutConfig-eb7d6954.js +0 -1
  223. package/dist/esm-es5/cart-5835676d.js +0 -1
  224. package/dist/esm-es5/handleFetch-621e45bc.js +0 -1
  225. package/dist/zonos-elements/p-0de2c731.system.js +0 -1
  226. package/dist/zonos-elements/p-0fc02cde.js +0 -1
  227. package/dist/zonos-elements/p-1b75aa35.system.js +0 -1
  228. package/dist/zonos-elements/p-3a50124e.entry.js +0 -1
  229. package/dist/zonos-elements/p-3f1a2d31.js +0 -1
  230. package/dist/zonos-elements/p-5e1b2654.system.js +0 -1
  231. package/dist/zonos-elements/p-666164d9.system.js +0 -1
  232. package/dist/zonos-elements/p-9f78b79e.entry.js +0 -1
  233. package/dist/zonos-elements/p-a2b55d11.entry.js +0 -1
  234. package/dist/zonos-elements/p-aafcd40f.system.entry.js +0 -1
  235. package/dist/zonos-elements/p-b922c441.system.js +0 -1
  236. package/dist/zonos-elements/p-ba027b70.system.entry.js +0 -1
  237. package/dist/zonos-elements/p-c4e0f49a.system.entry.js +0 -1
  238. package/dist/zonos-elements/p-dbd23bea.entry.js +0 -1
  239. package/dist/zonos-elements/p-f9664811.js +0 -1
@@ -1,5 +1,23 @@
1
1
  'use strict';
2
2
 
3
+ const getAbandonedCartRenewTokenValue = () => {
4
+ const validityToken = new URLSearchParams(window.location.search).get('validityToken');
5
+ // check if validityToken length is base64 encoded
6
+ if (!validityToken ||
7
+ !/^[A-Za-z0-9+/]+={0,2}$/.test(validityToken) ||
8
+ validityToken.length % 4 !== 0) {
9
+ return null;
10
+ }
11
+ try {
12
+ // check if it can be decoded
13
+ atob(validityToken);
14
+ return validityToken;
15
+ }
16
+ catch (_a) {
17
+ return null;
18
+ }
19
+ };
20
+
3
21
  const baseRe = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
4
22
  const uuidRe = new RegExp(`^${baseRe.source}$`);
5
23
  const cartUuidRe = new RegExp(`^cart_${baseRe.source}$`);
@@ -35,3 +53,4 @@ exports._getIsValidCartId = _getIsValidCartId;
35
53
  exports.checkoutHiddenBtnSelector = checkoutHiddenBtnSelector;
36
54
  exports.checkoutHiddenInternationalBtnSelector = checkoutHiddenInternationalBtnSelector;
37
55
  exports.domesticRedirectedBtnSelector = domesticRedirectedBtnSelector;
56
+ exports.getAbandonedCartRenewTokenValue = getAbandonedCartRenewTokenValue;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const zonosStore = require('./zonosStore-7c1e1bc1.js');
4
- const localization = require('./localization-ff33875b.js');
5
- const handleFetch = require('./handleFetch-969d05d8.js');
6
- const isDarkColor = require('./isDarkColor-35e8daec.js');
7
- const getBorderRadius = require('./getBorderRadius-c424eb05.js');
3
+ const zonosStore = require('./zonosStore-f8ee56aa.js');
4
+ const localization = require('./localization-9b43376c.js');
5
+ const handleFetch = require('./handleFetch-05227713.js');
6
+ const isDarkColor = require('./isDarkColor-428965f4.js');
7
+ const getBorderRadius = require('./getBorderRadius-1b5e33cf.js');
8
8
 
9
9
  /**
10
10
  * Extract value from translated object
@@ -37,7 +37,7 @@ const prepCartCalculateLandedCost = (cartId) => {
37
37
  const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
38
38
  ? stripeStore.stripeAddressEventData
39
39
  : stripeStore.stripeBillingAddressEventData;
40
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
40
+ if (!stripeAddressData || !stripeBillingAddressData) {
41
41
  throw new Error('Missing stripe address data');
42
42
  }
43
43
  // Attempt to get translated address if available
@@ -114,7 +114,7 @@ const prepCalculateLandedCost = () => {
114
114
  ? stripeStore.stripeAddressEventData
115
115
  : stripeStore.stripeBillingAddressEventData;
116
116
  handleFetch.log({ stripeAddressData, stripeBillingAddressData }, 'info');
117
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
117
+ if (!stripeAddressData || !stripeBillingAddressData) {
118
118
  throw new Error('Missing stripe address data');
119
119
  }
120
120
  // Attempt to get translated address if available
@@ -256,7 +256,7 @@ const calculateLandedCost = async (abortController) => {
256
256
  };
257
257
 
258
258
  const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
259
- var _a;
259
+ var _a, _b;
260
260
  // request to get landed cost info
261
261
  const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/cart-calculate-landed-cost', {
262
262
  body: prepCartCalculateLandedCost(cartId),
@@ -264,7 +264,8 @@ const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
264
264
  signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
265
265
  });
266
266
  if (errors.length || !json) {
267
- const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.';
267
+ const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.' ||
268
+ ((_b = errors[0]) === null || _b === void 0 ? void 0 : _b.message.includes('signal is aborted'));
268
269
  const errorMessage = isAbortedRequest
269
270
  ? 'The landed cost calculation request was aborted to initiate a new one.'
270
271
  : 'Failed to calculate landed cost';
@@ -599,6 +600,7 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = z
599
600
  checkoutSettlementCurrency: 'USD',
600
601
  clientSecret: sessionStorage.getItem('zonos--client-secret') || '',
601
602
  companyName: '',
603
+ companyNameUsedWhenAsyncAddressUpdate: '',
602
604
  customAddressErrors: {
603
605
  city: '',
604
606
  firstName: '',
@@ -625,6 +627,8 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = z
625
627
  hasPaymentError: false,
626
628
  isFetchingLandedCost: false,
627
629
  isFetchingSession: false,
630
+ partyBillingId: null,
631
+ partyShippingId: null,
628
632
  shouldInventoryRefund: false,
629
633
  shouldRenderPayInUsdButton: false,
630
634
  /**
@@ -637,10 +641,12 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = z
637
641
  stripe: null,
638
642
  stripeAddressElement: null,
639
643
  stripeAddressEventData: null,
644
+ stripeAddressUsedWhenAsyncAddressUpdate: null,
640
645
  stripeAddressUsedWhenFetchingLC: null,
641
646
  stripeAddressUsedWhenValidatingAddress: null,
642
647
  stripeBillingAddressElement: null,
643
648
  stripeBillingAddressEventData: null,
649
+ stripeBillingAddressUsedWhenAsyncAddressUpdate: null,
644
650
  stripeBillingAddressUsedWhenFetchingLC: null,
645
651
  stripeBillingAddressUsedWhenValidatingAddress: null,
646
652
  stripeCustomerSessionClientSecret: null,
@@ -654,7 +660,7 @@ const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = z
654
660
  stripePaymentEventData: null,
655
661
  stripeShippingSameAsBilling: true,
656
662
  taxId: '',
657
- taxIdUsedWhenFetchingLC: '',
663
+ taxIdUsedWhenAsyncAddressUpdate: '',
658
664
  translatedAddress: {
659
665
  address: {},
660
666
  billingAddress: {},
@@ -759,15 +765,178 @@ const checkIsAddressOutdatedForValidation = () => {
759
765
  JSON.stringify((_d = stripeStore.stripeBillingAddressUsedWhenValidatingAddress) === null || _d === void 0 ? void 0 : _d.value);
760
766
  return isAddressDataDirty || isBillingAddressDataDirty;
761
767
  };
762
- const checkIsAddressOutdatedForLCPrefetch = () => {
768
+ const checkIsAddressOutdatedForAsyncAddressUpdate = () => {
763
769
  var _a, _b, _c, _d, _e, _f;
764
770
  const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
765
771
  JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
766
- const isAddressDataDirty = JSON.stringify((_c = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _c === void 0 ? void 0 : _c.value) !==
767
- JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
772
+ 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);
768
773
  const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
769
- JSON.stringify((_e = stripeStore.stripeBillingAddressEventData) === null || _e === void 0 ? void 0 : _e.value) !==
770
- JSON.stringify((_f = stripeStore.stripeBillingAddressUsedWhenFetchingLC) === null || _f === void 0 ? void 0 : _f.value);
774
+ 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);
775
+ const isTaxIdDirty = stripeStore.taxIdUsedWhenAsyncAddressUpdate !== stripeStore.taxId;
776
+ const isCompanyNameDirty = stripeStore.companyNameUsedWhenAsyncAddressUpdate !==
777
+ stripeStore.companyName;
778
+ return (isLinkDataDirty ||
779
+ isAddressDataDirty ||
780
+ isBillingAddressDataDirty ||
781
+ isTaxIdDirty ||
782
+ isCompanyNameDirty);
783
+ };
784
+ const buildAddressForPartyCreate = ({ address, firstName, lastName, name, phone, }) => {
785
+ const _firstName = (name === null || name === void 0 ? void 0 : name.split(' ')[0]) || firstName || '';
786
+ const _lastName = (name === null || name === void 0 ? void 0 : name.split(' ')[1]) || lastName || '';
787
+ if (!_firstName || !_lastName) {
788
+ void handleFetch.sendErrorLog({
789
+ endpoint: 'PARTY_CREATE_NO_NAME_FOUND',
790
+ errors: ['No name found'],
791
+ metadata: {
792
+ allLogs: handleFetch.allLogs,
793
+ cartId: window.Zonos.cartId,
794
+ checkoutSessionId: localization.storageStore.checkoutSessionId,
795
+ firstName,
796
+ lastName,
797
+ name,
798
+ },
799
+ });
800
+ }
801
+ if (!phone) {
802
+ void handleFetch.sendErrorLog({
803
+ endpoint: 'PARTY_CREATE_NO_PHONE_FOUND',
804
+ errors: ['No phone found'],
805
+ metadata: {
806
+ allLogs: handleFetch.allLogs,
807
+ cartId: window.Zonos.cartId,
808
+ checkoutSessionId: localization.storageStore.checkoutSessionId,
809
+ phone,
810
+ },
811
+ });
812
+ }
813
+ return {
814
+ city: address.city,
815
+ country: address.country,
816
+ firstName: _firstName,
817
+ lastName: _lastName,
818
+ line1: address.line1,
819
+ line2: address.line2,
820
+ phone: phone || '',
821
+ postal_code: address.postal_code,
822
+ state: address.state,
823
+ };
824
+ };
825
+ const stripeStoreAsyncAddressUpdate = async () => {
826
+ var _a, _b, _c, _d;
827
+ if (!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete) ||
828
+ (!stripeStore.stripeShippingSameAsBilling &&
829
+ !((_b = stripeStore.stripeBillingAddressEventData) === null || _b === void 0 ? void 0 : _b.complete)) ||
830
+ !stripeStore.stripeBillingAddressEventData) {
831
+ return {
832
+ partiesCreated: false,
833
+ };
834
+ }
835
+ // If there is no landed cost data, no need to create parties
836
+ if (!cartStore.landedCostData) {
837
+ return {
838
+ partiesCreated: false,
839
+ };
840
+ }
841
+ const firstLandedCostRootId = (_c = cartStore.landedCostData.find(Boolean)) === null || _c === void 0 ? void 0 : _c.landedCost.rootId;
842
+ if (!firstLandedCostRootId) {
843
+ // do nothing if we don't have selected landed cost
844
+ void handleFetch.sendErrorLog({
845
+ endpoint: 'PF_NO_SELECTED_LANDED_COST',
846
+ errors: ['No selected landed cost'],
847
+ metadata: {
848
+ allLogs: handleFetch.allLogs,
849
+ cartId: window.Zonos.cartId,
850
+ checkoutSessionId: localization.storageStore.checkoutSessionId,
851
+ },
852
+ });
853
+ return {
854
+ partiesCreated: false,
855
+ };
856
+ }
857
+ const isAddressOutdated = checkIsAddressOutdatedForAsyncAddressUpdate();
858
+ if (!isAddressOutdated) {
859
+ return {
860
+ partiesCreated: false,
861
+ };
862
+ }
863
+ const address = buildAddressForPartyCreate({
864
+ address: stripeStore.stripeAddressEventData.value.address,
865
+ firstName: stripeStore.stripeAddressEventData.value.firstName,
866
+ lastName: stripeStore.stripeAddressEventData.value.lastName,
867
+ name: stripeStore.stripeAddressEventData.value.name,
868
+ phone: stripeStore.stripeAddressEventData.value.phone,
869
+ });
870
+ const billingAddress = stripeStore.stripeShippingSameAsBilling
871
+ ? address
872
+ : buildAddressForPartyCreate({
873
+ address: stripeStore.stripeBillingAddressEventData.value.address,
874
+ firstName: stripeStore.stripeBillingAddressEventData.value.firstName,
875
+ lastName: stripeStore.stripeBillingAddressEventData.value.lastName,
876
+ name: stripeStore.stripeBillingAddressEventData.value.name,
877
+ phone: stripeStore.stripeBillingAddressEventData.value.phone,
878
+ });
879
+ const isE2ETest = new URLSearchParams(window.location.search).get('zonosE2ETest') === '1';
880
+ const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/create-parties', {
881
+ body: {
882
+ address,
883
+ billingAddress,
884
+ companyName: stripeStore.companyName,
885
+ email: ((_d = stripeStore.stripeLinkEventData) === null || _d === void 0 ? void 0 : _d.value.email) || '',
886
+ isTest: isE2ETest,
887
+ rootId: firstLandedCostRootId,
888
+ taxId: stripeStore.taxId,
889
+ },
890
+ method: 'POST',
891
+ });
892
+ if (errors.length || !json) {
893
+ handleFetch.logError('Error occurs when creating parties', JSON.stringify(errors, null, 2));
894
+ void handleFetch.sendErrorLog({
895
+ endpoint: 'PF_PARTY_CREATE_FAILED',
896
+ errors: ['Failed to create parties'],
897
+ metadata: {
898
+ allLogs: handleFetch.allLogs,
899
+ cartId: window.Zonos.cartId,
900
+ checkoutSessionId: localization.storageStore.checkoutSessionId,
901
+ errors,
902
+ json,
903
+ },
904
+ });
905
+ return {
906
+ partiesCreated: false,
907
+ };
908
+ }
909
+ stripeStore.companyNameUsedWhenAsyncAddressUpdate = stripeStore.companyName;
910
+ stripeStore.stripeAddressUsedWhenAsyncAddressUpdate =
911
+ stripeStore.stripeAddressEventData;
912
+ stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate =
913
+ stripeStore.stripeBillingAddressEventData;
914
+ stripeStore.taxIdUsedWhenAsyncAddressUpdate = stripeStore.taxId;
915
+ stripeStore.partyBillingId = json.billToPartyId;
916
+ stripeStore.partyShippingId = json.shipToPartyId;
917
+ return {
918
+ partiesCreated: true,
919
+ };
920
+ };
921
+ /**
922
+ * Extract only the necessary address info for landed cost prefetch
923
+ */
924
+ const buildAddressForLCPrefetch = (address) => {
925
+ return {
926
+ countryCode: address.address.country,
927
+ postalCode: address.address.postal_code,
928
+ state: address.address.state,
929
+ };
930
+ };
931
+ const checkIsAddressOutdatedForLCPrefetch = () => {
932
+ var _a, _b;
933
+ const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
934
+ JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
935
+ const isAddressDataDirty = stripeStore.stripeAddressEventData &&
936
+ JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeAddressEventData.value)) !== JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC);
937
+ const isBillingAddressDataDirty = !stripeStore.stripeShippingSameAsBilling &&
938
+ stripeStore.stripeBillingAddressEventData &&
939
+ JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeBillingAddressEventData.value)) !== JSON.stringify(stripeStore.stripeBillingAddressUsedWhenFetchingLC);
771
940
  return isLinkDataDirty || isAddressDataDirty || isBillingAddressDataDirty;
772
941
  };
773
942
  /**
@@ -781,14 +950,64 @@ const isPrefetchInfoOutdated = () => {
781
950
  ((_a = cartStore.landedCostData.find(Boolean)) === null || _a === void 0 ? void 0 : _a.subtotals.items) !==
782
951
  cartStore.subtotal;
783
952
  const isAddressOutdated = checkIsAddressOutdatedForLCPrefetch();
784
- // Auto prefetch landed cost if tax id is updated
785
- const isTaxIdDirty = stripeStore.taxIdUsedWhenFetchingLC !== stripeStore.taxId;
953
+ handleFetch.log('isPrefetchInfoOutdated', 'info', {
954
+ isAddressOutdated,
955
+ });
786
956
  return (
787
957
  // if landed cost data is not available, we need to fetch it
788
- !cartStore.landedCostData ||
958
+ (!cartStore.landedCostData && !stripeStore.isFetchingLandedCost) ||
789
959
  isAddressOutdated ||
790
- isTotalAmountChanged ||
791
- isTaxIdDirty);
960
+ isTotalAmountChanged);
961
+ };
962
+ const getCountryField = (country) => {
963
+ var _a, _b;
964
+ const countryFieldLabels = (_a = zonosStore.zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.countryFields;
965
+ const stripeCountryFieldLabels = (_b = zonosStore.zonosStore.genericSettings) === null || _b === void 0 ? void 0 : _b.stripeCountryFieldLabels;
966
+ const stripeFoundCountryField = stripeCountryFieldLabels && country in stripeCountryFieldLabels
967
+ ? stripeCountryFieldLabels[country]
968
+ : null;
969
+ const zonosFoundCountryField = countryFieldLabels && country in countryFieldLabels
970
+ ? countryFieldLabels[country]
971
+ : null;
972
+ /**
973
+ * 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
974
+ * 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
975
+ **/
976
+ if (cartStore.addressFormRenderType === 'stripe') {
977
+ return stripeFoundCountryField || zonosFoundCountryField;
978
+ }
979
+ return zonosFoundCountryField;
980
+ };
981
+ const isAddressReadyToRequestLandedCost = () => {
982
+ var _a, _b, _c, _d;
983
+ const linkReady = !!((_a = stripeStore.stripeLinkEventData) === null || _a === void 0 ? void 0 : _a.complete);
984
+ const shippingAddressReady = !!((_b = stripeStore.stripeAddressEventData) === null || _b === void 0 ? void 0 : _b.complete);
985
+ const billingAddressReady = stripeStore.stripeShippingSameAsBilling
986
+ ? shippingAddressReady
987
+ : !!((_c = stripeStore.stripeBillingAddressEventData) === null || _c === void 0 ? void 0 : _c.complete);
988
+ const shipToCountry = ((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value.address.country) || 'US';
989
+ const countryField = getCountryField(shipToCountry);
990
+ // Only send landed cost request if the address is complete when we can't get the country field
991
+ if (!countryField || !stripeStore.stripeAddressEventData) {
992
+ return shippingAddressReady && billingAddressReady && linkReady;
993
+ }
994
+ const isValidLine1 = stripeStore.stripeAddressEventData.value.address.line1.length > 0;
995
+ const isValidName = stripeStore.stripeAddressEventData.value.firstName &&
996
+ stripeStore.stripeAddressEventData.value.lastName;
997
+ const isStateValid = !countryField.stateRequired ||
998
+ (countryField.stateRequired &&
999
+ stripeStore.stripeAddressEventData.value.address.state.length > 0);
1000
+ const isPostalCodeValid = !countryField.zipRequired ||
1001
+ (countryField.zipRequired &&
1002
+ stripeStore.stripeAddressEventData.value.address.postal_code.length >= 3);
1003
+ const hasPhoneNumber = stripeStore.stripeAddressEventData.value.phone &&
1004
+ stripeStore.stripeAddressEventData.value.phone.length > 0;
1005
+ return (linkReady &&
1006
+ isValidName &&
1007
+ isValidLine1 &&
1008
+ isStateValid &&
1009
+ isPostalCodeValid &&
1010
+ hasPhoneNumber);
792
1011
  };
793
1012
  const stripeCalculateLandedCost = async () => {
794
1013
  var _a;
@@ -837,26 +1056,27 @@ const stripeCalculateLandedCost = async () => {
837
1056
  }
838
1057
  };
839
1058
  const stripeStorePrefetchLandedCost = async (params) => {
840
- var _a, _b, _c, _d, _e, _f, _g, _h;
1059
+ var _a, _b, _c, _d;
841
1060
  const retries = (params === null || params === void 0 ? void 0 : params.retries) || 0;
842
1061
  const applyingPromocode = !!(params === null || params === void 0 ? void 0 : params.applyingPromocode);
843
- const stripeAddressReady = !!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete);
844
- const stripeLinkReady = !!((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.complete);
845
- const stripeBillingAddressReady = stripeStore.stripeShippingSameAsBilling
846
- ? !!((_c = stripeStore.stripeLinkEventData) === null || _c === void 0 ? void 0 : _c.complete)
847
- : !!((_d = stripeStore.stripeBillingAddressEventData) === null || _d === void 0 ? void 0 : _d.complete);
848
1062
  const shouldRefetch = isPrefetchInfoOutdated();
1063
+ const isRequestReadyToPrefetch = isAddressReadyToRequestLandedCost();
1064
+ // Should not do anything if the address is not ready to request landed cost
1065
+ if (!isRequestReadyToPrefetch) {
1066
+ return {
1067
+ isRequestNotReady: true,
1068
+ };
1069
+ }
849
1070
  if (shouldRefetch) {
850
1071
  // if the info used when fetching landed cost is different from the current info, abort the previous request
851
- (_e = stripeStore.fetchingLandedCostAbortController) === null || _e === void 0 ? void 0 : _e.abort();
1072
+ (_a = stripeStore.fetchingLandedCostAbortController) === null || _a === void 0 ? void 0 : _a.abort();
852
1073
  stripeStore.fetchingLandedCostAbortController = null;
853
1074
  }
854
1075
  // Do not fetch if we are not ready or data is not outdated
855
- if ((!shouldRefetch && !applyingPromocode) ||
856
- !stripeAddressReady ||
857
- !stripeLinkReady ||
858
- !stripeBillingAddressReady) {
859
- return;
1076
+ if (!shouldRefetch && !applyingPromocode) {
1077
+ return {
1078
+ isRequestNotReady: false,
1079
+ };
860
1080
  }
861
1081
  // 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)
862
1082
  if (retries) {
@@ -869,24 +1089,31 @@ const stripeStorePrefetchLandedCost = async (params) => {
869
1089
  stripeStore.isFetchingLandedCost = true;
870
1090
  }
871
1091
  if (stripeStore.stripeAddressEventData) {
872
- stripeStore.stripeAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeAddressEventData);
1092
+ stripeStore.stripeAddressUsedWhenFetchingLC = {
1093
+ countryCode: stripeStore.stripeAddressEventData.value.address.country,
1094
+ postalCode: stripeStore.stripeAddressEventData.value.address.postal_code,
1095
+ state: stripeStore.stripeAddressEventData.value.address.state,
1096
+ };
873
1097
  }
874
1098
  if (stripeStore.stripeBillingAddressEventData) {
875
- stripeStore.stripeBillingAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeBillingAddressEventData);
1099
+ stripeStore.stripeBillingAddressUsedWhenFetchingLC = {
1100
+ countryCode: stripeStore.stripeBillingAddressEventData.value.address.country,
1101
+ postalCode: stripeStore.stripeBillingAddressEventData.value.address.postal_code,
1102
+ state: stripeStore.stripeBillingAddressEventData.value.address.state,
1103
+ };
876
1104
  }
877
1105
  if (stripeStore.stripeLinkEventData) {
878
1106
  stripeStore.stripeLinkUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeLinkEventData);
879
1107
  }
880
- stripeStore.taxIdUsedWhenFetchingLC = stripeStore.taxId;
881
1108
  try {
882
1109
  // Reset cart items to non-restricted state and restricted item list
883
1110
  cartStoreResetCartItems();
884
1111
  // fetch and apply landed cost
885
1112
  await stripeCalculateLandedCost();
886
1113
  // This is the cheapest service level since we already sorted them after fetching landed cost
887
- const cheapestServiceLevel = (_f = cartStore.shippingData) === null || _f === void 0 ? void 0 : _f.find(Boolean);
1114
+ const cheapestServiceLevel = (_b = cartStore.shippingData) === null || _b === void 0 ? void 0 : _b.find(Boolean);
888
1115
  // Landed cost that matches with service level
889
- 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));
1116
+ 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));
890
1117
  // apply new subtotal and total, this is mainly to show items in the presentment currency
891
1118
  const subtotals = !!matchLandedCost ? matchLandedCost.subtotals : null;
892
1119
  if (subtotals) {
@@ -910,9 +1137,11 @@ const stripeStorePrefetchLandedCost = async (params) => {
910
1137
  if (retries < 1) {
911
1138
  // retry fetching landed cost one more time
912
1139
  await stripeStorePrefetchLandedCost(Object.assign(Object.assign({}, params), { retries: (retries || 0) + 1 }));
913
- return;
1140
+ return {
1141
+ isRequestNotReady: false,
1142
+ };
914
1143
  }
915
- const shipToAddress = (_h = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _h === void 0 ? void 0 : _h.value;
1144
+ const shipToAddress = (_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value;
916
1145
  void handleFetch.sendErrorLog({
917
1146
  endpoint: `Failed to fetch landed cost (${retries} retries)`,
918
1147
  errors: [err.message],
@@ -925,6 +1154,9 @@ const stripeStorePrefetchLandedCost = async (params) => {
925
1154
  handleFetch.logError(err);
926
1155
  }
927
1156
  stripeStore.isFetchingLandedCost = false;
1157
+ return {
1158
+ isRequestNotReady: false,
1159
+ };
928
1160
  };
929
1161
  const stripeStoreApplyPromoCode = async () => {
930
1162
  var _a, _b;
@@ -935,6 +1167,8 @@ const stripeStoreApplyPromoCode = async () => {
935
1167
  if (cartStore.step === 'payment') {
936
1168
  cartStorePreviousStep();
937
1169
  }
1170
+ // async update address with new root id from the new quote
1171
+ await stripeStoreAsyncAddressUpdate();
938
1172
  // This is the cheapest service level since we already sorted them after fetching landed cost
939
1173
  const cheapestServiceLevel = (_a = cartStore.shippingData) === null || _a === void 0 ? void 0 : _a.find(Boolean);
940
1174
  // Landed cost that matches with service level
@@ -1177,18 +1411,6 @@ const getCheckoutSessionBody = () => {
1177
1411
  key: 'language',
1178
1412
  value: localization.localizationStore.selectedLocale,
1179
1413
  },
1180
- {
1181
- key: 'appVersion',
1182
- value: window.Zonos.version,
1183
- },
1184
- {
1185
- key: 'appVersionNpmIntegration',
1186
- value: window.Zonos.isNpm ? '1' : '0',
1187
- },
1188
- {
1189
- key: 'legacyCheckoutFacade',
1190
- value: window.Zonos.isLegacyCheckout ? '1' : '0',
1191
- },
1192
1414
  ],
1193
1415
  presentmentCountryCode: localization.localizationStore.selectedCountryCode,
1194
1416
  skipPaymentIntent: stripeStore.skipPaymentIntent,
@@ -1325,6 +1547,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
1325
1547
  const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/update-checkout-session', {
1326
1548
  body: {
1327
1549
  adjustmentsAmount,
1550
+ billToPartyId: stripeStore.partyBillingId,
1328
1551
  cartId,
1329
1552
  currency,
1330
1553
  customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
@@ -1336,20 +1559,9 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
1336
1559
  key: 'language',
1337
1560
  value: localization.localizationStore.selectedLocale,
1338
1561
  },
1339
- {
1340
- key: 'appVersion',
1341
- value: window.Zonos.version,
1342
- },
1343
- {
1344
- key: 'appVersionNpmIntegration',
1345
- value: window.Zonos.isNpm ? '1' : '0',
1346
- },
1347
- {
1348
- key: 'legacyCheckoutFacade',
1349
- value: window.Zonos.isLegacyCheckout ? '1' : '0',
1350
- },
1351
1562
  ],
1352
1563
  presentmentCountryCode,
1564
+ shipToPartyId: stripeStore.partyShippingId,
1353
1565
  skipPaymentIntent: stripeStore.skipPaymentIntent,
1354
1566
  varianceTestInput,
1355
1567
  },
@@ -1490,7 +1702,8 @@ stripeStoreOnChange('clientSecret', clientSecret => {
1490
1702
  }
1491
1703
  });
1492
1704
 
1493
- const { reset, state: cartStore } = zonosStore.createStore(() => ({
1705
+ const { onChange: cartStoreOnChange, reset, state: cartStore, } = zonosStore.createStore(() => ({
1706
+ addressFormRenderType: 'stripe',
1494
1707
  adjustmentTotal: 0,
1495
1708
  adjustments: [],
1496
1709
  checkoutSession: null,
@@ -1705,12 +1918,14 @@ const cartStoreReCalculateTotal = async ({ adjustmentsAmount, cartId, currency,
1705
1918
  }
1706
1919
  const { errors, json } = await stripeStoreUpdateCheckoutSession({
1707
1920
  adjustmentsAmount,
1921
+ billToPartyId: stripeStore.partyBillingId,
1708
1922
  cartId,
1709
1923
  currency,
1710
1924
  id: localization.storageStore.checkoutSessionId,
1711
1925
  itemsAmount,
1712
1926
  landedCostId,
1713
1927
  presentmentCountryCode: localization.localizationStore.selectedCountryCode,
1928
+ shipToPartyId: stripeStore.partyShippingId,
1714
1929
  varianceTestInput: localization.storageStore.enabledVariantTestKeys || [],
1715
1930
  });
1716
1931
  if (errors.length > 0 || !json) {
@@ -1794,9 +2009,11 @@ const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption, lan
1794
2009
  // update session with selected landed cost
1795
2010
  const updateCalculateStatus = await cartStoreReCalculateTotal({
1796
2011
  adjustmentsAmount: cartStore.adjustmentTotal,
2012
+ billToPartyId: stripeStore.partyBillingId,
1797
2013
  cartId: window.Zonos.cartId,
1798
2014
  dutiesTaxesFeesEstimate: dutiesTaxesFeesEstimate,
1799
2015
  landedCostId: (_f = selectedLandedCost.landedCost) === null || _f === void 0 ? void 0 : _f.id,
2016
+ shipToPartyId: stripeStore.partyShippingId,
1800
2017
  varianceTestInput: localization.storageStore.enabledVariantTestKeys || [],
1801
2018
  });
1802
2019
  // update conditionally render pay in USD button
@@ -1859,10 +2076,12 @@ const cartStoreUpdateItems = async ({ adjustments, cartItems, }) => {
1859
2076
  stripeStore.isFetchingSession = true;
1860
2077
  await cartStoreReCalculateTotal({
1861
2078
  adjustmentsAmount: adjustmentTotal,
2079
+ billToPartyId: stripeStore.partyBillingId,
1862
2080
  cartId: window.Zonos.cartId,
1863
2081
  currency: currency,
1864
2082
  dutiesTaxesFeesEstimate: 0,
1865
2083
  itemsAmount: total,
2084
+ shipToPartyId: stripeStore.partyShippingId,
1866
2085
  // attempt to init session on failure to update checkout session
1867
2086
  shouldInitSessionOnFailure: true,
1868
2087
  varianceTestInput: localization.storageStore.enabledVariantTestKeys || [],
@@ -1924,6 +2143,7 @@ exports.cartStoreGetMethod = cartStoreGetMethod;
1924
2143
  exports.cartStoreGetShippingTransitInfo = cartStoreGetShippingTransitInfo;
1925
2144
  exports.cartStoreHasOneEligibleItem = cartStoreHasOneEligibleItem;
1926
2145
  exports.cartStoreNextStep = cartStoreNextStep;
2146
+ exports.cartStoreOnChange = cartStoreOnChange;
1927
2147
  exports.cartStoreReset = cartStoreReset;
1928
2148
  exports.cartStoreResetTabItems = cartStoreResetTabItems;
1929
2149
  exports.cartStoreSetCheckoutSession = cartStoreSetCheckoutSession;
@@ -1936,6 +2156,7 @@ exports.initStripeElements = initStripeElements;
1936
2156
  exports.sortServiceLevelOptionsByAmount = sortServiceLevelOptionsByAmount;
1937
2157
  exports.stripeStore = stripeStore;
1938
2158
  exports.stripeStoreApplyPromoCode = stripeStoreApplyPromoCode;
2159
+ exports.stripeStoreAsyncAddressUpdate = stripeStoreAsyncAddressUpdate;
1939
2160
  exports.stripeStoreCleanupDomesticShippingSession = stripeStoreCleanupDomesticShippingSession;
1940
2161
  exports.stripeStoreConfirmPayment = stripeStoreConfirmPayment;
1941
2162
  exports.stripeStoreGetDomesticShippingSession = stripeStoreGetDomesticShippingSession;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const zonosStore = require('./zonosStore-7c1e1bc1.js');
3
+ const zonosStore = require('./zonosStore-f8ee56aa.js');
4
4
 
5
5
  var root = zonosStore._root;
6
6
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const zonosStore = require('./zonosStore-7c1e1bc1.js');
3
+ const zonosStore = require('./zonosStore-f8ee56aa.js');
4
4
 
5
5
  /**
6
6
  * Get the border radius for the elements based on the style
@@ -37,11 +37,6 @@ const log = (message, type, ..._additionalInfo) => {
37
37
  !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
38
38
  // if debug is false, do not log
39
39
  if (!isDebug) {
40
- // log errors to the console if the type is error
41
- if (type === 'error') {
42
- // eslint-disable-next-line no-console
43
- console.error(message, ...additionalInfo);
44
- }
45
40
  return;
46
41
  }
47
42
  let loggingIframe = document.querySelector('iframe#zonos---debug-logging-iframe');
@@ -434,12 +429,13 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
434
429
  }
435
430
  const nextFallbackApiType = getNextFallbackApiType(basePathType);
436
431
  const unknownError = errors.find(({ type }) => type === 'unknown');
432
+ const isAbortError = errors.find(({ message }) => message.includes('signal is aborted'));
437
433
  const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
438
434
  const shouldCallFallback =
439
435
  // If next fallback is available, and the error is unknown (Failed to fetch) or 404
440
436
  nextFallbackApiType && isUnknownError;
441
437
  // Should log the error if it's unknown error
442
- if (isUnknownError) {
438
+ if (isUnknownError || isAbortError) {
443
439
  void sendErrorLog({
444
440
  endpoint: fallbackApiList[basePathType] + path,
445
441
  errors: errors.map(({ message }) => `API: ${message}`),