@zonos/elements 1.3.171 → 1.3.173

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 (133) hide show
  1. package/dist/cjs/{CheckoutConfig-f5e68e14.js → CheckoutConfig-c5943bbf.js} +1 -1
  2. package/dist/cjs/{cart-36799bbe.js → cart-d9052930.js} +21 -8
  3. package/dist/cjs/{handleFetch-7b7f9f7c.js → handleFetch-ff25db40.js} +10 -6
  4. package/dist/cjs/index.cjs.js +9 -9
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/{paypal-3eae38bd.js → paypal-31477331.js} +6 -2
  7. package/dist/cjs/zonos-address_7.cjs.entry.js +61 -19
  8. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +20 -12
  9. package/dist/cjs/zonos-checkout.cjs.entry.js +106 -36
  10. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  11. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  12. package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
  13. package/dist/cjs/zonos-elements.cjs.js +1 -1
  14. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +20 -4
  15. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  17. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  18. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +10 -6
  19. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +114 -37
  20. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +10 -6
  21. package/dist/collection/components/store/checkout/cart.js +5 -0
  22. package/dist/collection/components/store/checkout/paypal.js +5 -0
  23. package/dist/collection/components/store/checkout/stripe.js +12 -7
  24. package/dist/collection/components/stripe/zonos-address/zonos-address.js +37 -16
  25. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +27 -4
  26. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +22 -2
  27. package/dist/collection/components/utils/api/trackConversionEvent.js +1 -0
  28. package/dist/collection/components/utils/handleFetch.js +9 -6
  29. package/dist/collection/components/utils/logging/getAdditionalLogMetadata.js +1 -0
  30. package/dist/collection/styles/stripe/defaultVariable.js +2 -0
  31. package/dist/collection/types/generated/graphql.frontend.types.js +9 -0
  32. package/dist/collection/types/generated/graphql.internal.types.js +16 -0
  33. package/dist/esm/{CheckoutConfig-2994efd9.js → CheckoutConfig-75af3742.js} +1 -1
  34. package/dist/esm/{cart-b2e57589.js → cart-fff4f4a4.js} +21 -8
  35. package/dist/esm/{handleFetch-8d72c8cd.js → handleFetch-0109fb78.js} +10 -6
  36. package/dist/esm/index.js +10 -10
  37. package/dist/esm/loader.js +1 -1
  38. package/dist/esm/{paypal-38da5d52.js → paypal-087fbd16.js} +6 -2
  39. package/dist/esm/zonos-address_7.entry.js +61 -19
  40. package/dist/esm/zonos-cart-items_13.entry.js +20 -12
  41. package/dist/esm/zonos-checkout.entry.js +106 -36
  42. package/dist/esm/zonos-controller.entry.js +2 -2
  43. package/dist/esm/zonos-country-flag.entry.js +2 -2
  44. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  45. package/dist/esm/zonos-elements.js +1 -1
  46. package/dist/esm/zonos-empty-state-payment_4.entry.js +20 -4
  47. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  48. package/dist/esm/zonos-hello.entry.js +2 -2
  49. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  50. package/dist/esm-es5/{CheckoutConfig-2994efd9.js → CheckoutConfig-75af3742.js} +1 -1
  51. package/dist/esm-es5/{cart-b2e57589.js → cart-fff4f4a4.js} +1 -1
  52. package/dist/esm-es5/handleFetch-0109fb78.js +1 -0
  53. package/dist/esm-es5/index.js +1 -1
  54. package/dist/esm-es5/loader.js +1 -1
  55. package/dist/esm-es5/{paypal-38da5d52.js → paypal-087fbd16.js} +2 -2
  56. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  57. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  58. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  59. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  60. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  61. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  62. package/dist/esm-es5/zonos-elements.js +1 -1
  63. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  64. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  65. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  66. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  67. package/dist/scripts/index.d.ts +26 -6
  68. package/dist/scripts/index.js +1 -1
  69. package/dist/scripts/loadZonos.js +1 -1
  70. package/dist/scripts/zonos.js +1 -1
  71. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +17 -3
  72. package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +1 -1
  73. package/dist/types/components/store/checkout/cart.d.ts +4 -0
  74. package/dist/types/components/store/checkout/stripe.d.ts +10 -1
  75. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +6 -2
  76. package/dist/types/components/stripe/zonos-link-authentication/zonos-link-authentication.d.ts +1 -1
  77. package/dist/types/components/stripe/zonos-payment/zonos-payment.d.ts +3 -0
  78. package/dist/types/components/utils/logging/getAdditionalLogMetadata.d.ts +1 -0
  79. package/dist/types/components.d.ts +8 -6
  80. package/dist/types/types/ConversionEvent.d.ts +2 -1
  81. package/dist/types/types/checkout/CheckoutConfig.d.ts +1 -0
  82. package/dist/types/types/checkout/api/CheckoutSession.d.ts +8 -0
  83. package/dist/types/types/generated/graphql.frontend.types.d.ts +92 -0
  84. package/dist/types/types/generated/graphql.frontend.types.ts +106 -0
  85. package/dist/types/types/generated/graphql.internal.types.d.ts +124 -0
  86. package/dist/types/types/generated/graphql.internal.types.ts +154 -0
  87. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  88. package/dist/zonos-elements/index.esm.js +1 -1
  89. package/dist/zonos-elements/{p-0bfca3a9.system.entry.js → p-0078362c.system.entry.js} +1 -1
  90. package/dist/zonos-elements/p-033817e3.system.entry.js +1 -0
  91. package/dist/zonos-elements/p-04c38987.system.js +1 -0
  92. package/dist/zonos-elements/{p-cb52cfdf.entry.js → p-0db19b02.entry.js} +1 -1
  93. package/dist/zonos-elements/p-1b5a2714.system.entry.js +1 -0
  94. package/dist/zonos-elements/{p-1edbfb1f.system.entry.js → p-1be7b435.system.entry.js} +1 -1
  95. package/dist/zonos-elements/{p-47f79a6d.js → p-1c488ecf.js} +1 -1
  96. package/dist/zonos-elements/{p-c5c2976f.system.js → p-2ebb4fa7.system.js} +1 -1
  97. package/dist/zonos-elements/{p-1a20922f.system.entry.js → p-31ce9143.system.entry.js} +1 -1
  98. package/dist/zonos-elements/{p-a3888f1d.system.js → p-38f6f6fd.system.js} +1 -1
  99. package/dist/zonos-elements/{p-b0c39400.entry.js → p-407a96d2.entry.js} +1 -1
  100. package/dist/zonos-elements/p-427c2766.entry.js +1 -0
  101. package/dist/zonos-elements/p-46f6e5e9.system.js +1 -1
  102. package/dist/zonos-elements/{p-0def1397.system.entry.js → p-514431e9.system.entry.js} +1 -1
  103. package/dist/zonos-elements/p-5275b7ca.system.entry.js +1 -0
  104. package/dist/zonos-elements/p-5edc11be.system.entry.js +1 -0
  105. package/dist/zonos-elements/{p-461ca324.entry.js → p-67ca7373.entry.js} +1 -1
  106. package/dist/zonos-elements/{p-864c7c7d.entry.js → p-73a7b89b.entry.js} +1 -1
  107. package/dist/zonos-elements/{p-ecd4ec15.system.js → p-759a654a.system.js} +1 -1
  108. package/dist/zonos-elements/{p-bfa028a2.entry.js → p-7862da71.entry.js} +1 -1
  109. package/dist/zonos-elements/p-78b81404.system.js +17 -0
  110. package/dist/zonos-elements/p-839448c3.js +1 -0
  111. package/dist/zonos-elements/p-8b33c3b7.entry.js +1 -0
  112. package/dist/zonos-elements/{p-56a8b1f6.system.entry.js → p-a83370c6.system.entry.js} +1 -1
  113. package/dist/zonos-elements/{p-ff1c6d9a.entry.js → p-a9d7746a.entry.js} +1 -1
  114. package/dist/zonos-elements/{p-c82f488b.system.entry.js → p-ada6e691.system.entry.js} +1 -1
  115. package/dist/zonos-elements/{p-dd0259f4.js → p-bfd6e156.js} +1 -1
  116. package/dist/zonos-elements/p-cbd2bd33.js +17 -0
  117. package/dist/zonos-elements/p-ef9fdf45.entry.js +1 -0
  118. package/dist/zonos-elements/p-f6c0da8b.entry.js +1 -0
  119. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  120. package/package.json +1 -1
  121. package/dist/esm-es5/handleFetch-8d72c8cd.js +0 -1
  122. package/dist/zonos-elements/p-00ad3c73.entry.js +0 -1
  123. package/dist/zonos-elements/p-173d1fcd.system.entry.js +0 -1
  124. package/dist/zonos-elements/p-48173901.js +0 -17
  125. package/dist/zonos-elements/p-53cb8867.system.entry.js +0 -1
  126. package/dist/zonos-elements/p-56758218.system.entry.js +0 -1
  127. package/dist/zonos-elements/p-71539c8a.js +0 -1
  128. package/dist/zonos-elements/p-9261869c.system.js +0 -1
  129. package/dist/zonos-elements/p-934164df.entry.js +0 -1
  130. package/dist/zonos-elements/p-9f9e4f74.entry.js +0 -1
  131. package/dist/zonos-elements/p-bf113a46.system.js +0 -17
  132. package/dist/zonos-elements/p-e09cea9c.entry.js +0 -1
  133. package/dist/zonos-elements/p-fd352222.system.entry.js +0 -1
@@ -180,13 +180,30 @@ export class ZonosCheckout {
180
180
  settlementAmount: total,
181
181
  };
182
182
  };
183
+ this.getDefaultAddress = () => {
184
+ // If checkout customer is authenticated, use the address from the customer profile
185
+ if (this.defaultCustomerProfileAddress.length) {
186
+ return this.defaultCustomerProfileAddress;
187
+ }
188
+ // If default address is provided directly from the component, use it
189
+ if (Array.isArray(this.defaultAddress) && this.defaultAddress.length) {
190
+ return this.defaultAddress;
191
+ }
192
+ if (!Array.isArray(this.defaultAddress) &&
193
+ typeof this.defaultAddress === 'object') {
194
+ return [this.defaultAddress];
195
+ }
196
+ return this.defaultAddressParams;
197
+ };
183
198
  this.appearanceSettingsOverride = undefined;
184
199
  this.preview = false;
185
200
  this.mobile = false;
186
201
  this.overrideStagingMode = undefined;
187
- this.defaultAddress = null;
202
+ this.defaultAddress = [];
188
203
  this.forceDialogOpen = false;
189
- this.defaultAddressParams = null;
204
+ this.defaultAddressParams = [];
205
+ this.defaultCustomerProfileAddress = [];
206
+ this.customerProfile = null;
190
207
  this.open = this.forceDialogOpen;
191
208
  this.stripe = window.Zonos.stripe;
192
209
  this.submitLoading = false;
@@ -203,6 +220,7 @@ export class ZonosCheckout {
203
220
  this.inventoryCheckErrorMessage = null;
204
221
  this.placedOrderInfo = null;
205
222
  this.clientSecret = stripeStore.clientSecret;
223
+ this.stripeCustomerSessionClientSecret = stripeStore.stripeCustomerSessionClientSecret;
206
224
  }
207
225
  /**
208
226
  * Init cart info handler event
@@ -263,6 +281,8 @@ export class ZonosCheckout {
263
281
  cartId = cartIdResult.cartId;
264
282
  // set prefill address if provided in createCartId callback result
265
283
  this.useShippingDataFromCreateCartId(cartIdResult.shippingData);
284
+ cartStore.customerAuthenticationToken =
285
+ cartIdResult.customerAuthenticationToken || null;
266
286
  }
267
287
  else {
268
288
  cartId = cartIdResult;
@@ -477,11 +497,11 @@ export class ZonosCheckout {
477
497
  isPreview: this.preview,
478
498
  sessionTimeout: CHECKOUT_SESSION_TIMEOUT,
479
499
  });
500
+ submitGtag('zonos-checkout-start');
501
+ void trackConversionEvent('checkout_open');
480
502
  const { enabled } = await isStoreDiscountEnabled();
481
503
  // Hide discount input if there's no active discount configured for the store
482
504
  cartStore.shouldHideDiscountInput = !enabled;
483
- submitGtag('zonos-checkout-start');
484
- void trackConversionEvent('checkout_open');
485
505
  this.handleOrderDuplication();
486
506
  if (window.Zonos.isLegacyCheckout) {
487
507
  void sendLoadCheckoutFacadeLog();
@@ -621,7 +641,6 @@ export class ZonosCheckout {
621
641
  const phone = address.customerPhone || '';
622
642
  const postal_code = address.customerZip || '';
623
643
  const state = address.customerState || '';
624
- const countryCode = country === 'UK' ? 'GB' : country;
625
644
  /**
626
645
  * If one of the value is null, no need to preset the default address.
627
646
  * City and state are optional (they are not always provided for example Puerto Rico)
@@ -637,19 +656,27 @@ export class ZonosCheckout {
637
656
  .join(', '));
638
657
  return;
639
658
  }
640
- this.defaultAddressParams = {
641
- address: {
642
- city: city || '',
643
- country: countryCode,
644
- line1,
645
- line2,
646
- postal_code,
647
- state,
659
+ if (country &&
660
+ localizationStore.shippingZoneCountries &&
661
+ !(country in localizationStore.shippingZoneCountries)) {
662
+ log(`Country "${country}" is not in the shipping zone, so it can not be prefilled`, 'warn');
663
+ return;
664
+ }
665
+ this.defaultAddressParams = [
666
+ {
667
+ address: {
668
+ city: city || '',
669
+ country,
670
+ line1,
671
+ line2,
672
+ postal_code,
673
+ state,
674
+ },
675
+ email,
676
+ name,
677
+ phone,
648
678
  },
649
- email,
650
- name,
651
- phone,
652
- };
679
+ ];
653
680
  log('Prefill address applied', 'info', {
654
681
  prefillAddress: this.defaultAddressParams,
655
682
  providedAddress: address,
@@ -675,19 +702,21 @@ export class ZonosCheckout {
675
702
  domesticRedirectedBtnSelector: domesticRedirectedBtnSelector,
676
703
  onShippingAddressSessionFound: shippingAddressSession => {
677
704
  // prefilled the default address if shipping address session is found for checkout on open
678
- this.defaultAddress = {
679
- address: {
680
- city: shippingAddressSession.city,
681
- country: shippingAddressSession.countryCode,
682
- line1: shippingAddressSession.address1,
683
- line2: shippingAddressSession.address2,
684
- postal_code: shippingAddressSession.postalCode,
685
- state: shippingAddressSession.state,
705
+ this.defaultAddress = [
706
+ {
707
+ address: {
708
+ city: shippingAddressSession.city,
709
+ country: shippingAddressSession.countryCode,
710
+ line1: shippingAddressSession.address1,
711
+ line2: shippingAddressSession.address2,
712
+ postal_code: shippingAddressSession.postalCode,
713
+ state: shippingAddressSession.state,
714
+ },
715
+ email: '',
716
+ name: `${shippingAddressSession.firstName} ${shippingAddressSession.lastName}`,
717
+ phone: shippingAddressSession.phone,
686
718
  },
687
- email: '',
688
- name: `${shippingAddressSession.firstName} ${shippingAddressSession.lastName}`,
689
- phone: shippingAddressSession.phone,
690
- };
719
+ ];
691
720
  },
692
721
  });
693
722
  /**
@@ -930,9 +959,39 @@ export class ZonosCheckout {
930
959
  handleAddressChange() {
931
960
  stripeStoreReset();
932
961
  }
962
+ handleCustomerProfileChange() {
963
+ var _a, _b;
964
+ if (!this.customerProfile) {
965
+ log('No customer profile', 'info');
966
+ this.defaultCustomerProfileAddress = [];
967
+ return;
968
+ }
969
+ log('Customer profile found', 'info', {
970
+ customerProfile: this.customerProfile,
971
+ });
972
+ // Build and set saved locations from checkout customers
973
+ this.defaultCustomerProfileAddress =
974
+ ((_b = (_a = stripeStore.customerProfile) === null || _a === void 0 ? void 0 : _a.locations) === null || _b === void 0 ? void 0 : _b.map(location => {
975
+ var _a;
976
+ return {
977
+ address: {
978
+ city: location.locality,
979
+ country: location.countryCode,
980
+ line1: location.line1,
981
+ line2: location.line2 || '',
982
+ postal_code: location.postalCode,
983
+ state: location.administrativeArea,
984
+ },
985
+ email: location.email || ((_a = stripeStore.customerProfile) === null || _a === void 0 ? void 0 : _a.email) || '',
986
+ name: location.name || '',
987
+ phone: location.phone || '',
988
+ };
989
+ })) || [];
990
+ }
933
991
  handleClientSecretChange() {
934
- log('=== Client secret changed', 'info', {
935
- clientSecret: stripeStore.clientSecret,
992
+ log('==== Client secret changed', 'info', {
993
+ clientSecret: this.clientSecret,
994
+ stripeCustomerSessionClientSecret: this.stripeCustomerSessionClientSecret,
936
995
  });
937
996
  // apply theme to stripe elements
938
997
  void this.applyStripeTheme();
@@ -954,6 +1013,8 @@ export class ZonosCheckout {
954
1013
  html.style.overflow = 'hidden';
955
1014
  }
956
1015
  else {
1016
+ // Should reset stripeCustomerSessionClientSecret state when dialog is closed since merchant would need to re-authenticate, get an OTP again and we will get a new customer session.
1017
+ this.stripeCustomerSessionClientSecret = null;
957
1018
  const bodyOverflow = body.getAttribute(overflowAttrKey);
958
1019
  const htmlOverflow = html.getAttribute(overflowAttrKey);
959
1020
  // reset overflow state to original state
@@ -1001,8 +1062,15 @@ export class ZonosCheckout {
1001
1062
  }
1002
1063
  render() {
1003
1064
  var _a, _b, _c, _d;
1065
+ this.customerProfile = stripeStore.customerProfile;
1004
1066
  // Set client secret so that we can add this to @Watch listener
1005
1067
  this.clientSecret = stripeStore.clientSecret;
1068
+ // Only set and update stripeCustomerSession state if it's available, since it would only be available at the time checkout session is created, afterward access checkout session the value would be `null`.
1069
+ if (stripeStore.stripeCustomerSessionClientSecret) {
1070
+ // Set stripe customer session client secret so that we can add this to @Watch listener
1071
+ this.stripeCustomerSessionClientSecret =
1072
+ stripeStore.stripeCustomerSessionClientSecret;
1073
+ }
1006
1074
  const dialogLoading =
1007
1075
  // if it's last step, don't need to check stripe elements
1008
1076
  (cartStore.step !== 'finish' &&
@@ -1055,7 +1123,7 @@ export class ZonosCheckout {
1055
1123
  '--zonos--primary-color': !this.isMobile
1056
1124
  ? colorPrimary
1057
1125
  : undefined,
1058
- }) }, !this.isMobile && renderTopHeader(), cartStore.step === 'customer-info' && (h("zonos-customer-info", { continueLoading: this.submitLoading, defaultAddress: this.defaultAddress || this.defaultAddressParams, isMobile: this.isMobile, onContinueClicked: () => this.handleCustomerInfoContinue(), submitBtnColor: submitButtonColor })), cartStore.step === 'shipping' && (h("zonos-shipping", { continueLoading: this.submitLoading, onContinueClicked: () => this.handleShippingContinue(), submitBtnColor: submitButtonColor })), cartStore.step === 'payment' && (h("zonos-checkout-payment", { continueLoading: this.submitLoading, isMobile: this.isMobile, onContinueClicked: async () => {
1126
+ }) }, !this.isMobile && renderTopHeader(), cartStore.step === 'customer-info' && (h("zonos-customer-info", { continueLoading: this.submitLoading, defaultAddress: this.getDefaultAddress(), isMobile: this.isMobile, onContinueClicked: () => this.handleCustomerInfoContinue(), submitBtnColor: submitButtonColor })), cartStore.step === 'shipping' && (h("zonos-shipping", { continueLoading: this.submitLoading, onContinueClicked: () => this.handleShippingContinue(), submitBtnColor: submitButtonColor })), cartStore.step === 'payment' && (h("zonos-checkout-payment", { continueLoading: this.submitLoading, isMobile: this.isMobile, onContinueClicked: async () => {
1059
1127
  await this.handleStripePaymentContinue();
1060
1128
  }, submitBtnColor: submitButtonColor }))), h("div", { class: "zonos--right", "data-theme": rightSideTheme }, this.isMobile && renderTopHeader(), h("div", { class: "zonos--right-actions" }, window.Zonos.showBaseForeign && (h("zonos-currency-toggle", null)), !this.isLegacyCheckout && (h("zonos-button", { class: "zonos--close-button", icon: h("zonos-icon", { "aria-label": "Close checkout dialog", content: RemoveIcon }), noBackground: true, onClick: () => this.closeDialogHandler() }))), h("div", { class: "flex--wrapper" }, h("div", { class: "zonos--wrapper" }, h("zonos-review", { collapsed: this.collapseReviewMobile, mobile: this.isMobile, onClick: () => {
1061
1129
  // do nothing if it's not mobile
@@ -1233,8 +1301,8 @@ export class ZonosCheckout {
1233
1301
  "type": "unknown",
1234
1302
  "mutable": false,
1235
1303
  "complexType": {
1236
- "original": "StripeStoreContactOption | null",
1237
- "resolved": "null | { address: { city: string; country: string; line1: string; line2?: string | undefined; postal_code: string; state: string; }; email: string; name: string; phone?: string | undefined; }",
1304
+ "original": "| StripeStoreContactOption[]\n | StripeStoreContactOption",
1305
+ "resolved": "StripeStoreContactOption[] | { address: { city: string; country: string; line1: string; line2?: string | undefined; postal_code: string; state: string; }; email: string; name: string; phone?: string | undefined; }",
1238
1306
  "references": {
1239
1307
  "StripeStoreContactOption": {
1240
1308
  "location": "import",
@@ -1251,7 +1319,7 @@ export class ZonosCheckout {
1251
1319
  },
1252
1320
  "getter": false,
1253
1321
  "setter": false,
1254
- "defaultValue": "null"
1322
+ "defaultValue": "[]"
1255
1323
  },
1256
1324
  "forceDialogOpen": {
1257
1325
  "type": "boolean",
@@ -1278,6 +1346,8 @@ export class ZonosCheckout {
1278
1346
  static get states() {
1279
1347
  return {
1280
1348
  "defaultAddressParams": {},
1349
+ "defaultCustomerProfileAddress": {},
1350
+ "customerProfile": {},
1281
1351
  "open": {},
1282
1352
  "stripe": {},
1283
1353
  "submitLoading": {},
@@ -1293,7 +1363,8 @@ export class ZonosCheckout {
1293
1363
  "payInUsdConfirmDialogOpen": {},
1294
1364
  "inventoryCheckErrorMessage": {},
1295
1365
  "placedOrderInfo": {},
1296
- "clientSecret": {}
1366
+ "clientSecret": {},
1367
+ "stripeCustomerSessionClientSecret": {}
1297
1368
  };
1298
1369
  }
1299
1370
  static get methods() {
@@ -1367,7 +1438,7 @@ export class ZonosCheckout {
1367
1438
  "signature": "(session: CheckoutSessionDetailsFragment) => Promise<void>",
1368
1439
  "parameters": [{
1369
1440
  "name": "session",
1370
- "type": "{ cartId: string | null; clientSecret: string; id: string; landedCost: { amountSubtotals: { discounts: number | null; duties: number; fees: number; items: number; landedCostTotal: number; shipping: number; taxes: number; } | null; id: string; landedCostGuaranteeCode: LandedCostGuaranteeCode; method: IncotermCode; shipmentRating: { displayName: string; }; } | null; metadata: ({ key: string; value: string; } | null)[] | null; organizationId: string; subtotals: { adjustments: number; duties: number; exchangeRate: { id: string; rate: number; sourceCurrencyCode: CurrencyCode; targetCurrencyCode: CurrencyCode; type: ExchangeRateType; }; fees: number; items: number; landedCostTotal: number; presentmentCurrencyCode: CurrencyCode; shipping: number; taxes: number; total: number; }; }",
1441
+ "type": "{ cartId: string | null; clientSecret: string; customerProfile: { email: string | null; locations: { administrativeArea: string; countryCode: CountryCode; email: string | null; line1: string; line2: string | null; locality: string; name: string | null; phone: string | null; postalCode: string; }[] | null; name: string | null; } | null; customerSessionClientSecret: string | null; id: string; landedCost: { amountSubtotals: { discounts: number | null; duties: number; fees: number; items: number; landedCostTotal: number; shipping: number; taxes: number; } | null; id: string; landedCostGuaranteeCode: LandedCostGuaranteeCode; method: IncotermCode; shipmentRating: { displayName: string; }; } | null; metadata: ({ key: string; value: string; } | null)[] | null; organizationId: string; subtotals: { adjustments: number; duties: number; exchangeRate: { id: string; rate: number; sourceCurrencyCode: CurrencyCode; targetCurrencyCode: CurrencyCode; type: ExchangeRateType; }; fees: number; items: number; landedCostTotal: number; presentmentCurrencyCode: CurrencyCode; shipping: number; taxes: number; total: number; }; }",
1371
1442
  "docs": ""
1372
1443
  }],
1373
1444
  "references": {
@@ -1406,9 +1477,15 @@ export class ZonosCheckout {
1406
1477
  }, {
1407
1478
  "propName": "defaultAddress",
1408
1479
  "methodName": "handleAddressChange"
1480
+ }, {
1481
+ "propName": "customerProfile",
1482
+ "methodName": "handleCustomerProfileChange"
1409
1483
  }, {
1410
1484
  "propName": "clientSecret",
1411
1485
  "methodName": "handleClientSecretChange"
1486
+ }, {
1487
+ "propName": "stripeCustomerSessionClientSecret",
1488
+ "methodName": "handleClientSecretChange"
1412
1489
  }, {
1413
1490
  "propName": "open",
1414
1491
  "methodName": "handleOpenChange"
@@ -148,7 +148,7 @@ export class ZonosCustomerInfo {
148
148
  this.submitBtnType = undefined;
149
149
  this.submitBtnColor = undefined;
150
150
  this.isMobile = false;
151
- this.defaultAddress = null;
151
+ this.defaultAddress = [];
152
152
  this.showErrorBanner = false;
153
153
  this.shippingCountry = '';
154
154
  this.isCheckingForRestrictedItems = false;
@@ -205,7 +205,7 @@ export class ZonosCustomerInfo {
205
205
  } }), this.isTaxIdError && (h("zonos-text", { textColor: 'red-600', type: "caption" }, translate('Tax id is required')))));
206
206
  }
207
207
  render() {
208
- var _a, _b;
208
+ var _a, _b, _c, _d, _e, _f;
209
209
  if (!stripeStore.stripeElements) {
210
210
  return null;
211
211
  }
@@ -224,11 +224,15 @@ export class ZonosCustomerInfo {
224
224
  const showBilling = !stripeStore.stripeShippingSameAsBilling;
225
225
  // Get theme for the update dialog, inherit from the theme, no from this component theme
226
226
  const theme = getZonosStoreTheme(zonosStore.appearance.theme);
227
+ // Attempt to get the email from email from customer profile's locations, if not provided, just use the email from root customer profile
228
+ const defaultEmail = ((_b = this.defaultAddress.find(Boolean)) === null || _b === void 0 ? void 0 : _b.email) ||
229
+ ((_e = (_d = (_c = stripeStore.customerProfile) === null || _c === void 0 ? void 0 : _c.locations) === null || _d === void 0 ? void 0 : _d.find(Boolean)) === null || _e === void 0 ? void 0 : _e.email) ||
230
+ ((_f = stripeStore.customerProfile) === null || _f === void 0 ? void 0 : _f.email);
227
231
  // start validate on typing after error banner is shown, and hide it if the form is complete
228
232
  if (this.showErrorBanner) {
229
233
  this.showErrorBanner = !this.handleValidate();
230
234
  }
231
- return (h(Host, { class: "zonos--customer-info zonos--elements" }, h("div", { class: "zonos--group" }, h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, translate('Customer information')), this.showErrorBanner && (h("zonos-banner", { class: "zonos--error-banner", intent: "error" }, translate('Missing required fields. Make sure all fields are completed.'))), h("zonos-link-authentication", { defaultEmail: (_b = this.defaultAddress) === null || _b === void 0 ? void 0 : _b.email, isEmailError: this.isEmailError, onLinkAuthenticationChange: this.handleEmailValidation, titleText: translate('Contact') }), h("zonos-address", { defaultAddress: this.defaultAddress, titleText: translate('Address'), type: "shipping" }), this.renderTaxIdInput(this.shippingCountry), h("zonos-checkbox", { class: "zonos--shipping-same-as-billing-cbx", isChecked: stripeStore.stripeShippingSameAsBilling, label: translate('Shipping address same as billing'), onCheckboxSelected: e => {
235
+ return (h(Host, { class: "zonos--customer-info zonos--elements" }, h("div", { class: "zonos--group" }, h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, translate('Customer information')), this.showErrorBanner && (h("zonos-banner", { class: "zonos--error-banner", intent: "error" }, translate('Missing required fields. Make sure all fields are completed.'))), h("zonos-link-authentication", { defaultEmail: defaultEmail, isEmailError: this.isEmailError, onLinkAuthenticationChange: this.handleEmailValidation, titleText: translate('Contact') }), h("zonos-address", { defaultAddress: this.defaultAddress, titleText: translate('Address'), type: "shipping" }), this.renderTaxIdInput(this.shippingCountry), h("zonos-checkbox", { class: "zonos--shipping-same-as-billing-cbx", isChecked: stripeStore.stripeShippingSameAsBilling, label: translate('Shipping address same as billing'), onCheckboxSelected: e => {
232
236
  stripeStore.stripeShippingSameAsBilling = e.detail;
233
237
  } }), h("zonos-collapse", { collapsed: !showBilling }, h("zonos-address", { defaultAddress: this.defaultAddress, titleText: translate('Billing address'), type: "billing" })), h("div", { class: "zonos--group-btn" }, h("zonos-button", { backgroundColor: this.submitBtnColor, bold: true, loading: this.continueLoading, onClick: () => this.continueClickHandler(), size: "lg",
234
238
  // use primary type when on mobile mode
@@ -348,8 +352,8 @@ export class ZonosCustomerInfo {
348
352
  "type": "unknown",
349
353
  "mutable": false,
350
354
  "complexType": {
351
- "original": "StripeStoreContactOption | null",
352
- "resolved": "null | { address: { city: string; country: string; line1: string; line2?: string | undefined; postal_code: string; state: string; }; email: string; name: string; phone?: string | undefined; }",
355
+ "original": "StripeStoreContactOption[]",
356
+ "resolved": "StripeStoreContactOption[]",
353
357
  "references": {
354
358
  "StripeStoreContactOption": {
355
359
  "location": "import",
@@ -366,7 +370,7 @@ export class ZonosCustomerInfo {
366
370
  },
367
371
  "getter": false,
368
372
  "setter": false,
369
- "defaultValue": "null"
373
+ "defaultValue": "[]"
370
374
  }
371
375
  };
372
376
  }
@@ -15,6 +15,7 @@ const { onChange, reset, state: cartStore, } = createStore(() => ({
15
15
  checkoutTimeoutInterval: null,
16
16
  currency: 'USD',
17
17
  customQuotingError: null,
18
+ customerAuthenticationToken: null,
18
19
  displayBaseCurrency: false,
19
20
  dutiesTaxesFees: null,
20
21
  dutiesTaxesFeesEstimate: null,
@@ -167,7 +168,11 @@ const cartStoreHasOneEligibleItem = () => {
167
168
  };
168
169
  const cartStoreSetCheckoutSession = (checkoutSession) => {
169
170
  var _a, _b, _c, _d, _e;
171
+ // update stripe store with updated information
170
172
  stripeStore.clientSecret = checkoutSession.clientSecret;
173
+ stripeStore.stripeCustomerSessionClientSecret =
174
+ checkoutSession.customerSessionClientSecret;
175
+ stripeStore.customerProfile = checkoutSession.customerProfile;
171
176
  cartStore.checkoutSession = checkoutSession;
172
177
  cartStore.checkoutSessionId = checkoutSession.id;
173
178
  // Check if there is a redirect URL in the metadata to override
@@ -6,6 +6,7 @@ import { translate } from "../translationStore";
6
6
  import { zonosStore } from "../zonosStore";
7
7
  import { paypalCaptureOrder } from "../../utils/api/paypalCaptureOrder";
8
8
  import { paypalCreateOrder } from "../../utils/api/paypalCreateOrder";
9
+ import { trackConversionEvent } from "../../utils/api/trackConversionEvent";
9
10
  import { isContrastColor } from "../../utils/isContrastColor";
10
11
  import { jsonParse } from "../../utils/jsonParse";
11
12
  import { log } from "../../utils/logging/log";
@@ -77,6 +78,10 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
77
78
  });
78
79
  return {
79
80
  createOrder: async () => {
81
+ // Clicking on the paypal button should trigger the paymentInfoCompleted event
82
+ void trackConversionEvent('checkout_paymentInfoCompleted', {
83
+ paymentMethod: 'paypal',
84
+ });
80
85
  const checkoutSessionStatus = await validateCheckoutSession();
81
86
  if (!checkoutSessionStatus.valid) {
82
87
  paypalStore.paypalErrorMessage = checkoutSessionStatus.errorMessage;
@@ -21,6 +21,7 @@ const { onChange, reset, state: stripeStore, } = createStore(() => ({
21
21
  clientSecret: sessionStorage.getItem('zonos--client-secret') || '',
22
22
  companyName: '',
23
23
  customErrorMessage: null,
24
+ customerProfile: null,
24
25
  fetchingLandedCostAbortController: null,
25
26
  hasPaymentError: false,
26
27
  isFetchingLandedCost: false,
@@ -43,6 +44,7 @@ const { onChange, reset, state: stripeStore, } = createStore(() => ({
43
44
  stripeBillingAddressEventData: null,
44
45
  stripeBillingAddressUsedWhenFetchingLC: null,
45
46
  stripeBillingAddressUsedWhenValidatingAddress: null,
47
+ stripeCustomerSessionClientSecret: null,
46
48
  stripeElements: null,
47
49
  stripeElementsForBillingAddress: null,
48
50
  stripeElementsOptions: null,
@@ -85,6 +87,7 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
85
87
  },
86
88
  // Client secret can be undefined since we will load other elements that doesn't require client secret first, then load client secret and render one that requires it later
87
89
  clientSecret: clientSecret || undefined,
90
+ customerSessionClientSecret: stripeStore.stripeCustomerSessionClientSecret || undefined,
88
91
  externalPaymentMethodTypes: [...paypalPaymentType],
89
92
  locale: localizationStore.selectedLocale,
90
93
  };
@@ -214,6 +217,10 @@ const stripeCalculateLandedCost = async () => {
214
217
  }
215
218
  return Object.assign(Object.assign({}, checkoutSession), { landedCost: foundLandedCost });
216
219
  }).filter(Boolean)) || [];
220
+ // Send event when we get the quote back after the customer clicked "Continue to shipping"
221
+ if (checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.length) {
222
+ void trackConversionEvent('checkout_quoteReceived');
223
+ }
217
224
  // update adjustmentTotal
218
225
  // highlight promocode input error if promocode is applied but no adjustment applied in landed cost
219
226
  const isInvalidPromoCode = cartStore.promoCodeApplied &&
@@ -514,6 +521,9 @@ const stripeStoreConfirmPayment = async () => {
514
521
  paymentMethod: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.payment_method,
515
522
  });
516
523
  log('Payment intent confirmed', 'info', { error, paymentIntent });
524
+ if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === 'requires_action') {
525
+ throw new Error(translate('Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.'));
526
+ }
517
527
  if (error) {
518
528
  if (error.type === 'card_error' || error.type === 'validation_error') {
519
529
  throw new Error(error.message);
@@ -540,6 +550,7 @@ export const getCheckoutSessionBody = () => {
540
550
  adjustmentsAmount: cartStore.adjustments.reduce((prev, adj) => prev + adj.amount, 0),
541
551
  cartId: window.Zonos.cartId,
542
552
  currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
553
+ customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
543
554
  itemsAmount: total,
544
555
  metadata: [
545
556
  {
@@ -566,10 +577,6 @@ export const getCheckoutSessionBody = () => {
566
577
  };
567
578
  const stripeStoreGetPaymentIntent = async () => {
568
579
  var _a;
569
- if (stripeStore.clientSecret) {
570
- log('Payment intent already exists, skipping fetching payment intent');
571
- return;
572
- }
573
580
  if (!cartStore.checkoutSessionId) {
574
581
  // We want to log the error anytime we fail to create a checkout session
575
582
  void sendErrorLog({
@@ -616,9 +623,6 @@ const stripeStoreGetPaymentIntent = async () => {
616
623
  });
617
624
  return;
618
625
  }
619
- // update stripe store with updated information
620
- stripeStore.clientSecret =
621
- json.checkoutSessionPaymentIntentCreate.clientSecret;
622
626
  // update cart store checkout session with updated from checkout session payment intent creation call so the checkout session and payment intent are in sync
623
627
  cartStoreSetCheckoutSession(json.checkoutSessionPaymentIntentCreate);
624
628
  };
@@ -695,6 +699,7 @@ const stripeStoreUpdateCheckoutSession = async ({ adjustmentsAmount, cartId, cur
695
699
  adjustmentsAmount,
696
700
  cartId,
697
701
  currency,
702
+ customerAuthenticationToken: cartStore.customerAuthenticationToken || undefined,
698
703
  id,
699
704
  itemsAmount,
700
705
  landedCostId,
@@ -3,6 +3,7 @@ import { stripeStore } from "../../store/checkout/stripe";
3
3
  import { getFallbackDefaultCountryCode, localizationStore, } from "../../store/hello/localization";
4
4
  import { translate } from "../../store/translationStore";
5
5
  import { zonosStore } from "../../store/zonosStore";
6
+ import { trackConversionEvent } from "../../utils/api/trackConversionEvent";
6
7
  import { isCheckoutMobile } from "../../utils/checkout/isCheckoutMobile";
7
8
  import { log } from "../../utils/logging/log";
8
9
  import { logError } from "../../utils/logging/logError";
@@ -15,9 +16,13 @@ export class ZonosAddress {
15
16
  * Google autocomplete overlay is conflict with our button, this is to adjust z index of the autocomplete
16
17
  */
17
18
  this.isAutoCompleteAdjusted = false;
19
+ /**
20
+ * Check if the tracking event is sent
21
+ */
22
+ this.trackingSent = false;
18
23
  this.type = undefined;
19
24
  this.titleText = undefined;
20
- this.defaultAddress = null;
25
+ this.defaultAddress = [];
21
26
  this.stripe = window.Zonos.stripe;
22
27
  this.isDirtyAddress = false;
23
28
  }
@@ -40,9 +45,14 @@ export class ZonosAddress {
40
45
  case 'billing':
41
46
  stripeStore.stripeBillingAddressEventData = event;
42
47
  break;
43
- default:
48
+ default: {
49
+ if (event.complete && !this.trackingSent) {
50
+ void trackConversionEvent('checkout_customerInfoFilled');
51
+ this.trackingSent = true;
52
+ }
44
53
  stripeStore.stripeAddressEventData = event;
45
54
  break;
55
+ }
46
56
  }
47
57
  }
48
58
  updateAddressElement({ stripeAddressElement, type, }) {
@@ -53,19 +63,15 @@ export class ZonosAddress {
53
63
  stripeStore.stripeBillingAddressElement = stripeAddressElement;
54
64
  }
55
65
  async watchInitStripe() {
56
- var _a, _b;
57
66
  this.stripe = window.Zonos.stripe;
58
67
  const { stripeAddressEventData, stripeElements } = this.getStripeAddressInstance();
59
68
  if (!this.stripe || !stripeElements) {
60
69
  logError("Stripe is not initialized. Couldn't load stripe element.");
61
70
  return;
62
71
  }
63
- const phone = (_a = this.defaultAddress) === null || _a === void 0 ? void 0 : _a.phone;
64
- if (!phone) {
65
- // remove phone from default address if it's not provided, stripe
66
- // will throw error if key phone exist and its value is empty or 'undefined'.
67
- (_b = this.defaultAddress) === null || _b === void 0 ? true : delete _b.phone;
68
- }
72
+ // remove phone from default address if it's not provided, stripe
73
+ // will throw error if key phone exist and its value is empty or 'undefined'.
74
+ const defaultAddress = this.defaultAddress.map(address => (Object.assign(Object.assign({}, address), { name: address.name, phone: address.phone || undefined })));
69
75
  const shippableCountries = localizationStore.shippingZoneCountries;
70
76
  const shippingZone = shippableCountries
71
77
  ? Object.values(shippableCountries).map(country => country.code)
@@ -79,8 +85,8 @@ export class ZonosAddress {
79
85
  const addressElement = stripeElements.create('address', {
80
86
  allowedCountries: checkoutAllCountries ? [] : allowedCountries,
81
87
  // only show the default address if stripeAddressEventData is not provided
82
- contacts: this.defaultAddress && !stripeAddressEventData
83
- ? [this.defaultAddress]
88
+ contacts: defaultAddress.length && !stripeAddressEventData
89
+ ? this.defaultAddress
84
90
  : [],
85
91
  defaultValues: {
86
92
  address: Object.assign(Object.assign({}, stripeAddressEventData === null || stripeAddressEventData === void 0 ? void 0 : stripeAddressEventData.value.address), { country: defaultAddressCountry }),
@@ -138,12 +144,27 @@ export class ZonosAddress {
138
144
  type: this.type,
139
145
  });
140
146
  }
141
- defaultAddressChanged() {
147
+ defaultAddressChanged(oldAddress, newAddress) {
148
+ // check if stringified json of oldAddress is different from newAddress
149
+ const oldAddressString = JSON.stringify(oldAddress);
150
+ const newAddressString = JSON.stringify(newAddress);
151
+ // No need to reset address element if the default address is the same
152
+ if (oldAddressString === newAddressString) {
153
+ return;
154
+ }
142
155
  log('Reset address element when default address property is changed', 'info', {
143
156
  defaultAddress: this.defaultAddress,
144
157
  });
145
158
  const stripeElement = this.getStripeAddressInstance().stripeAddressElement;
159
+ stripeElement === null || stripeElement === void 0 ? void 0 : stripeElement.clear();
146
160
  stripeElement === null || stripeElement === void 0 ? void 0 : stripeElement.destroy();
161
+ // Reset stripe address event data
162
+ if (this.type === 'shipping') {
163
+ stripeStore.stripeAddressEventData = null;
164
+ }
165
+ else {
166
+ stripeStore.stripeBillingAddressEventData = null;
167
+ }
147
168
  void this.watchInitStripe();
148
169
  }
149
170
  renderCompanyNameInput() {
@@ -177,7 +198,7 @@ export class ZonosAddress {
177
198
  }
178
199
  render() {
179
200
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
180
- return (h(Host, { key: '18d2602886588dfeb39c7c0386354671076dd9bf', class: "zonos--address zonos--elements" }, h("zonos-text", { key: '9c4f704259e307932930995b14a9f2edd51dd3e3', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), h("div", { key: '7b2031b0b29cc8153b9b6376f27ccd331cc46e7a', class: "zonos--address-component" })));
201
+ return (h(Host, { key: '9fd8e0ac4b86c10004c24e9d33f40ec577bd2a73', class: "zonos--address zonos--elements" }, h("zonos-text", { key: 'e7c3cbcab6f175354f26a8426d0dbf01afca736d', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), h("div", { key: '48ccbb019255c5362adf4c7954a7c2e3b015bfa5', class: "zonos--address-component" })));
181
202
  }
182
203
  static get is() { return "zonos-address"; }
183
204
  static get encapsulation() { return "scoped"; }
@@ -235,8 +256,8 @@ export class ZonosAddress {
235
256
  "type": "unknown",
236
257
  "mutable": false,
237
258
  "complexType": {
238
- "original": "ContactOption | null",
239
- "resolved": "ContactOption | null",
259
+ "original": "ContactOption[]",
260
+ "resolved": "ContactOption[]",
240
261
  "references": {
241
262
  "ContactOption": {
242
263
  "location": "import",
@@ -253,7 +274,7 @@ export class ZonosAddress {
253
274
  },
254
275
  "getter": false,
255
276
  "setter": false,
256
- "defaultValue": "null"
277
+ "defaultValue": "[]"
257
278
  }
258
279
  };
259
280
  }
@@ -4,6 +4,7 @@ import { cartStore } from "../../store/checkout/cart";
4
4
  import { stripeStore } from "../../store/checkout/stripe";
5
5
  import { translate } from "../../store/translationStore";
6
6
  import { getBorderRadius } from "../../utils/getBorderRadius";
7
+ import { log } from "../../utils/logging/log";
7
8
  import { logError } from "../../utils/logging/logError";
8
9
  import { validateEmailValue } from "../../utils/validateEmailValue";
9
10
  /**
@@ -59,7 +60,7 @@ export class ZonosLinkAuthentication {
59
60
  // Create and mount the Authentication Element in ${type} mode
60
61
  const linkAuthenticationElement = stripeStore.stripeLinkElement ||
61
62
  stripeStore.stripeElements.create('linkAuthentication', {
62
- defaultValues: defaultValues || undefined,
63
+ defaultValues: defaultValues,
63
64
  });
64
65
  const linkAuthenticationElementContainer = this.el.querySelector('.zonos--link-authentication-component');
65
66
  if (!linkAuthenticationElementContainer) {
@@ -74,11 +75,33 @@ export class ZonosLinkAuthentication {
74
75
  });
75
76
  stripeStore.stripeLinkElement = linkAuthenticationElement;
76
77
  }
77
- watchDefaultEmail() {
78
- if (!this.defaultEmail) {
78
+ watchDefaultEmail(newDefaultEmail, oldDefaultEmail) {
79
+ var _a, _b;
80
+ log('Default email is changed', 'info', {
81
+ newDefaultEmail,
82
+ oldDefaultEmail,
83
+ });
84
+ if (oldDefaultEmail === newDefaultEmail) {
79
85
  return;
80
86
  }
81
- this.setCustomEmailInputToLinkEvent(this.defaultEmail);
87
+ if (!newDefaultEmail) {
88
+ stripeStore.stripeLinkEventData = null;
89
+ }
90
+ // Only set value for Stripe input input to stripeLinkEventData when checkout is in staging mode
91
+ if (cartStore.isStagingMode) {
92
+ this.setCustomEmailInputToLinkEvent(newDefaultEmail || '');
93
+ return;
94
+ }
95
+ (_a = stripeStore.stripeLinkElement) === null || _a === void 0 ? void 0 : _a.clear();
96
+ (_b = stripeStore.stripeLinkElement) === null || _b === void 0 ? void 0 : _b.destroy();
97
+ stripeStore.stripeLinkElement = null;
98
+ stripeStore.stripeLinkEventData = null;
99
+ log('Reset stripe link element when default email is changed', 'info', {
100
+ defaultEmail: newDefaultEmail,
101
+ });
102
+ setTimeout(() => {
103
+ void this.watchInitStripe();
104
+ }, 5);
82
105
  }
83
106
  componentDidLoad() {
84
107
  // @Watch doesn't get trigger on initial load