@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
@@ -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
@@ -600,18 +833,6 @@ export const getCheckoutSessionBody = () => {
600
833
  key: 'language',
601
834
  value: localizationStore.selectedLocale,
602
835
  },
603
- {
604
- key: 'appVersion',
605
- value: window.Zonos.version,
606
- },
607
- {
608
- key: 'appVersionNpmIntegration',
609
- value: window.Zonos.isNpm ? '1' : '0',
610
- },
611
- {
612
- key: 'legacyCheckoutFacade',
613
- value: window.Zonos.isLegacyCheckout ? '1' : '0',
614
- },
615
836
  ],
616
837
  presentmentCountryCode: localizationStore.selectedCountryCode,
617
838
  skipPaymentIntent: stripeStore.skipPaymentIntent,
@@ -748,6 +969,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
748
969
  const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
749
970
  body: {
750
971
  adjustmentsAmount,
972
+ billToPartyId: stripeStore.partyBillingId,
751
973
  cartId,
752
974
  currency,
753
975
  customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
@@ -759,20 +981,9 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
759
981
  key: 'language',
760
982
  value: localizationStore.selectedLocale,
761
983
  },
762
- {
763
- key: 'appVersion',
764
- value: window.Zonos.version,
765
- },
766
- {
767
- key: 'appVersionNpmIntegration',
768
- value: window.Zonos.isNpm ? '1' : '0',
769
- },
770
- {
771
- key: 'legacyCheckoutFacade',
772
- value: window.Zonos.isLegacyCheckout ? '1' : '0',
773
- },
774
984
  ],
775
985
  presentmentCountryCode,
986
+ shipToPartyId: stripeStore.partyShippingId,
776
987
  skipPaymentIntent: stripeStore.skipPaymentIntent,
777
988
  varianceTestInput,
778
989
  },
@@ -912,4 +1123,4 @@ stripeStoreOnChange('clientSecret', clientSecret => {
912
1123
  sessionStorage.removeItem('zonos--client-secret');
913
1124
  }
914
1125
  });
915
- export { initStripeElements, stripeCalculateLandedCost, stripeStore, stripeStoreApplyPromoCode, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreGetDomesticShippingSession, stripeStoreGetPaymentIntent, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreInitCheckoutSession, stripeStoreMessageBasedOnStatus, stripeStoreOnChange, stripeStorePrefetchLandedCost, stripeStoreRemovePromoCode, stripeStoreReset, stripeStoreResetPromoCode, stripeStoreRetrievePayment, stripeStoreSaveDomesticShippingSession, stripeStoreTranslateAddressToLatin, stripeStoreUpdateCheckoutSession, stripeStoreUpdateCheckoutSessionBaseCurrency, };
1126
+ export { initStripeElements, stripeCalculateLandedCost, stripeStore, stripeStoreApplyPromoCode, stripeStoreAsyncAddressUpdate, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreGetDomesticShippingSession, stripeStoreGetPaymentIntent, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreInitCheckoutSession, stripeStoreMessageBasedOnStatus, stripeStoreOnChange, stripeStorePrefetchLandedCost, stripeStoreRemovePromoCode, stripeStoreReset, stripeStoreResetPromoCode, stripeStoreRetrievePayment, stripeStoreSaveDomesticShippingSession, stripeStoreTranslateAddressToLatin, stripeStoreUpdateCheckoutSession, stripeStoreUpdateCheckoutSessionBaseCurrency, };
@@ -203,6 +203,7 @@ const updateCheckoutSessionLanguage = async () => {
203
203
  body: {
204
204
  id: storageStore.checkoutSessionId,
205
205
  metadata: [
206
+ // This is being used from the backend to determine the language of the checkout session
206
207
  {
207
208
  key: 'language',
208
209
  value: localizationStore.selectedLocale,
@@ -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';
@@ -33,7 +33,7 @@ export const prepCartCalculateLandedCost = (cartId) => {
33
33
  const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
34
34
  ? stripeStore.stripeAddressEventData
35
35
  : stripeStore.stripeBillingAddressEventData;
36
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
36
+ if (!stripeAddressData || !stripeBillingAddressData) {
37
37
  throw new Error('Missing stripe address data');
38
38
  }
39
39
  // Attempt to get translated address if available
@@ -110,7 +110,7 @@ export const prepCalculateLandedCost = () => {
110
110
  ? stripeStore.stripeAddressEventData
111
111
  : stripeStore.stripeBillingAddressEventData;
112
112
  log({ stripeAddressData, stripeBillingAddressData }, 'info');
113
- if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
113
+ if (!stripeAddressData || !stripeBillingAddressData) {
114
114
  throw new Error('Missing stripe address data');
115
115
  }
116
116
  // Attempt to get translated address if available