@zonos/elements 1.3.45 → 1.3.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cart-89b4f62d.js → cart-7a79bccc.js} +152 -49
- package/dist/cjs/{sendErrorLog-a966a8c1.js → createCustomEvent-2fe80338.js} +2 -22
- package/dist/cjs/index.cjs.js +12 -8
- package/dist/cjs/{paypal-1a1882c4.js → paypal-eb07e9f5.js} +3 -3
- package/dist/cjs/zonos-address_8.cjs.entry.js +1 -1
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +25 -19
- package/dist/cjs/zonos-checkout.cjs.entry.js +10 -10
- package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -3
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-notification_3.cjs.entry.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +14 -8
- package/dist/collection/components/main/zonos-controller.js +4 -3
- package/dist/collection/components/store/checkout/stripe.js +4 -7
- package/dist/collection/components/store/hello/localization.js +1 -1
- package/dist/collection/components/utils/api/calculateLandedCost.js +1 -2
- package/dist/collection/components/utils/api/checkItemRestrictions.js +1 -2
- package/dist/collection/components/utils/api/getCountries.js +1 -1
- package/dist/collection/components/utils/api/getCountryLandedCost.js +1 -1
- package/dist/collection/components/utils/api/getExchangeRate.js +6 -2
- package/dist/collection/components/utils/api/getInclusivePricing.js +1 -2
- package/dist/collection/components/utils/api/getLocaleMessages.js +7 -2
- package/dist/collection/components/utils/api/getLocalization.js +3 -6
- package/dist/collection/components/utils/api/getShippingZones.js +1 -2
- package/dist/collection/components/utils/api/getZonosSettings.js +1 -2
- package/dist/collection/components/utils/api/paypalCaptureOrder.js +1 -1
- package/dist/collection/components/utils/api/paypalCreateOrder.js +1 -1
- package/dist/collection/components/utils/api/trackConversionEvent.js +1 -2
- package/dist/collection/components/utils/api/triggerBuildLandedCost.js +3 -2
- package/dist/collection/components/utils/getNextFallbackApi.js +18 -0
- package/dist/collection/components/utils/handleFetch.js +75 -21
- package/dist/collection/components/utils/logging/sendErrorLog.js +19 -5
- package/dist/collection/components/utils/logging/sendLoadScriptLog.js +1 -1
- package/dist/collection/environment.js +13 -78
- package/dist/collection/scripts/_getZonosQaUrl.js +6 -2
- package/dist/collection/utils/formattedCloudflareApiUrl.js +43 -0
- package/dist/collection/utils/formattedUrl.js +80 -0
- package/dist/collection/utils/generateCloudflareDeployUrl.js +21 -0
- package/dist/esm/{cart-9f40efd7.js → cart-2198741e.js} +153 -51
- package/dist/esm/{sendErrorLog-aea606c0.js → createCustomEvent-451d7879.js} +3 -22
- package/dist/esm/index.js +12 -8
- package/dist/esm/{paypal-f4bb6ce7.js → paypal-2890968d.js} +3 -3
- package/dist/esm/zonos-address_8.entry.js +1 -1
- package/dist/esm/zonos-cart-items_12.entry.js +17 -11
- package/dist/esm/zonos-checkout.entry.js +3 -3
- package/dist/esm/zonos-controller.entry.js +6 -6
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm/zonos-hello.entry.js +2 -3
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-notification_3.entry.js +2 -2
- package/dist/esm-es5/{cart-9f40efd7.js → cart-2198741e.js} +1 -1
- package/dist/esm-es5/createCustomEvent-451d7879.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/paypal-2890968d.js +17 -0
- package/dist/esm-es5/zonos-address_8.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
- package/dist/scripts/index.d.ts +3 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/utils/getNextFallbackApi.d.ts +10 -0
- package/dist/types/components/utils/handleFetch.d.ts +10 -1
- package/dist/types/environment.d.ts +4 -9
- package/dist/types/scripts/_getNextFallbackUrl.d.ts +1 -1
- package/dist/types/utils/formattedCloudflareApiUrl.d.ts +20 -0
- package/dist/types/utils/formattedUrl.d.ts +9 -0
- package/dist/types/utils/generateCloudflareDeployUrl.d.ts +10 -0
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-18f46c3f.entry.js +1 -0
- package/dist/zonos-elements/p-2b25ac5e.system.js +1 -0
- package/dist/zonos-elements/p-2f24a1f7.system.js +17 -0
- package/dist/zonos-elements/p-3b116246.system.entry.js +1 -0
- package/dist/zonos-elements/{p-578f42c1.entry.js → p-40e8f3bd.entry.js} +1 -1
- package/dist/zonos-elements/p-467cdce8.system.entry.js +1 -0
- package/dist/zonos-elements/p-52c2fb9d.entry.js +1 -0
- package/dist/zonos-elements/{p-5845029a.system.entry.js → p-65efc406.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8618e185.entry.js → p-6b868590.entry.js} +1 -1
- package/dist/zonos-elements/{p-f9754e48.entry.js → p-791d240f.entry.js} +1 -1
- package/dist/zonos-elements/{p-acf9a97e.system.entry.js → p-7b9ed9ed.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7b8099ed.js → p-84e5636c.js} +1 -1
- package/dist/zonos-elements/{p-8630168f.system.entry.js → p-85b297d3.system.entry.js} +1 -1
- package/dist/zonos-elements/p-8b2486b7.system.entry.js +1 -0
- package/dist/zonos-elements/{p-7bd28076.system.entry.js → p-a28492ca.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-43d3cafd.system.js → p-ac01a4fe.system.js} +1 -1
- package/dist/zonos-elements/{p-4204ccf9.system.entry.js → p-b066612a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-b06704a9.js +17 -0
- package/dist/zonos-elements/{p-37c9fdd2.system.entry.js → p-bfe85ef2.system.entry.js} +1 -1
- package/dist/zonos-elements/p-c3bb224b.entry.js +1 -0
- package/dist/zonos-elements/p-c78dd680.system.js +1 -1
- package/dist/zonos-elements/{p-d014791e.entry.js → p-cfbcfd4b.entry.js} +1 -1
- package/dist/zonos-elements/{p-c7952400.entry.js → p-e43bbfe1.entry.js} +1 -1
- package/dist/zonos-elements/{p-567b457b.entry.js → p-e69e429d.entry.js} +1 -1
- package/dist/zonos-elements/p-f12c159e.js +1 -0
- package/dist/zonos-elements/p-f9aa9bd8.system.js +1 -0
- package/dist/zonos-elements/{p-8bf1af28.entry.js → p-fb6c529a.entry.js} +1 -1
- package/dist/zonos-elements/{p-ca0a5c22.system.entry.js → p-ff10609a.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/paypal-f4bb6ce7.js +0 -17
- package/dist/esm-es5/sendErrorLog-aea606c0.js +0 -1
- package/dist/zonos-elements/p-0bfe455c.system.entry.js +0 -1
- package/dist/zonos-elements/p-13618b27.system.entry.js +0 -1
- package/dist/zonos-elements/p-29f4cce5.system.js +0 -17
- package/dist/zonos-elements/p-2d01b8e6.system.entry.js +0 -1
- package/dist/zonos-elements/p-3490d40f.js +0 -17
- package/dist/zonos-elements/p-5b9f2535.system.js +0 -1
- package/dist/zonos-elements/p-6f759c76.system.js +0 -1
- package/dist/zonos-elements/p-757166b8.entry.js +0 -1
- package/dist/zonos-elements/p-76291114.entry.js +0 -1
- package/dist/zonos-elements/p-9aef3a35.entry.js +0 -1
- package/dist/zonos-elements/p-d99e58f2.js +0 -1
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const paypal = require('./paypal-
|
|
6
|
+
const cart = require('./cart-7a79bccc.js');
|
|
7
|
+
const paypal = require('./paypal-eb07e9f5.js');
|
|
8
8
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
9
|
-
const
|
|
9
|
+
const createCustomEvent = require('./createCustomEvent-2fe80338.js');
|
|
10
10
|
const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
|
|
11
11
|
const logError = require('./logError-4e2f2020.js');
|
|
12
12
|
const classes = require('./classes-b7918f56.js');
|
|
@@ -169,7 +169,7 @@ const isShippableCountry = (showLog = true) => {
|
|
|
169
169
|
}
|
|
170
170
|
// if localization is loaded and the localization is not a shippable country, keep the original click event
|
|
171
171
|
if (!cart.localizationStore.isShippableCountry) {
|
|
172
|
-
document.dispatchEvent(
|
|
172
|
+
document.dispatchEvent(createCustomEvent.createCustomEvent('legacyCheckoutError', 'Unable to initiate checkout process in a country where shipping is not available'));
|
|
173
173
|
if (showLog) {
|
|
174
174
|
logError.log(`Checkout: not shippable country`);
|
|
175
175
|
}
|
|
@@ -247,7 +247,7 @@ const watchBigcommerceDomesticCheckout = ({ domesticRedirectedBtnSelector, onShi
|
|
|
247
247
|
};
|
|
248
248
|
if (Object.values(shippingAddress).some(value => value === undefined || value === null)) {
|
|
249
249
|
logError.logError('One or more shipping address field is missing', Object.entries(shippingAddress));
|
|
250
|
-
void
|
|
250
|
+
void cart.sendErrorLog({
|
|
251
251
|
endpoint: 'No endpoint, domestic checkout form missing fields',
|
|
252
252
|
errors: [
|
|
253
253
|
'Bigcommerce: One or more shipping address field is missing in the domestic checkout form',
|
|
@@ -460,7 +460,7 @@ const ZonosCheckout = class {
|
|
|
460
460
|
sessionTimeout: CHECKOUT_SESSION_TIMEOUT,
|
|
461
461
|
});
|
|
462
462
|
paypal.submitGtag('zonos-checkout-start');
|
|
463
|
-
void
|
|
463
|
+
void createCustomEvent.trackConversionEvent('checkout_open');
|
|
464
464
|
}
|
|
465
465
|
catch (err) {
|
|
466
466
|
// stop loading
|
|
@@ -483,7 +483,7 @@ const ZonosCheckout = class {
|
|
|
483
483
|
button.setAttribute('data-zonos-checkout-attached', 'true');
|
|
484
484
|
// if this button is the hidden button, trigger the click event
|
|
485
485
|
if (button.matches(this.domesticRedirectedBtnSelector)) {
|
|
486
|
-
button.dispatchEvent(
|
|
486
|
+
button.dispatchEvent(createCustomEvent.createCustomEvent('click'));
|
|
487
487
|
// cleanup shipping session after button is clicked
|
|
488
488
|
cart.stripeStoreCleanupDomesticShippingSession();
|
|
489
489
|
// remove the button after it's clicked
|
|
@@ -492,7 +492,7 @@ const ZonosCheckout = class {
|
|
|
492
492
|
if (button.matches(this.legacyCheckoutHiddenBtnSelector)) {
|
|
493
493
|
this.isLegacyCheckout = true;
|
|
494
494
|
// trigger the click event on the button
|
|
495
|
-
button.dispatchEvent(
|
|
495
|
+
button.dispatchEvent(createCustomEvent.createCustomEvent('click'));
|
|
496
496
|
button.remove();
|
|
497
497
|
}
|
|
498
498
|
});
|
|
@@ -708,7 +708,7 @@ const ZonosCheckout = class {
|
|
|
708
708
|
const url = window.location.href;
|
|
709
709
|
// Remove query parameters
|
|
710
710
|
const cleanUrl = url.split('?')[0];
|
|
711
|
-
const isTestMode =
|
|
711
|
+
const isTestMode = createCustomEvent.getIsTestMode();
|
|
712
712
|
this.open = false;
|
|
713
713
|
// Update the URL without query parameters only if it's not in test mode
|
|
714
714
|
/**
|
|
@@ -793,7 +793,7 @@ const ZonosCheckout = class {
|
|
|
793
793
|
: logoUrl;
|
|
794
794
|
return (index.h("div", { class: "zonos--logo" }, logo && (index.h("img", { alt: `${zonosStore.zonosStore.organizationName} logo`, src: logo, width: 100 }))));
|
|
795
795
|
};
|
|
796
|
-
const isTestMode =
|
|
796
|
+
const isTestMode = createCustomEvent.getIsTestMode();
|
|
797
797
|
const renderTopHeader = () => {
|
|
798
798
|
return (index.h("zonos-v-stack", null, index.h("div", { class: "zonos--logo-wrapper" }, renderLogo(), isTestMode && (index.h("zonos-badge", { badgeColor: "orange", size: "small" }, cart.translate('Test mode')))), index.h("zonos-checkout-progress-tabs", { backgroundColor:
|
|
799
799
|
// only use different contrast color when the secondary color is too off with the background in mobile
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-7a79bccc.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
8
8
|
const logError = require('./logError-4e2f2020.js');
|
|
9
9
|
require('./isDarkColor-4eb96a1e.js');
|
|
10
10
|
require('./getBorderRadius-4413e191.js');
|
|
11
11
|
|
|
12
12
|
const getZonosSettings = async () => {
|
|
13
|
-
const
|
|
14
|
-
const { errors, json, zonosMode } = await cart.handleFetch(url);
|
|
13
|
+
const { errors, json, zonosMode } = await cart.handleFetch('/api/zonos-elements/zonos-settings');
|
|
15
14
|
if (errors.length) {
|
|
16
15
|
logError.logError(`Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings`);
|
|
17
16
|
return { errors, json: null, zonosMode };
|
|
@@ -169,8 +168,9 @@ const ZonosController = class {
|
|
|
169
168
|
logError.log(`[FONT] Just applied Inter , but no need to inject since we already inject Inter on start`, 'warn');
|
|
170
169
|
zonosStore.zonosStore.appearance = Object.assign(Object.assign({}, zonosStore.zonosStore.appearance), { fontFamily: overrideFont });
|
|
171
170
|
}
|
|
172
|
-
const
|
|
173
|
-
|
|
171
|
+
const searchParams = new URLSearchParams();
|
|
172
|
+
searchParams.set('family', fontSelected);
|
|
173
|
+
const { errors, json } = await cart.handleFetch(`/api/zonos-elements/get-font-detail?${searchParams.toString()}`);
|
|
174
174
|
if (errors.length > 0 || !json) {
|
|
175
175
|
logError.log(`Failed to load font ${fontSelected}`, 'warn');
|
|
176
176
|
return;
|
|
@@ -304,7 +304,7 @@ const ZonosController = class {
|
|
|
304
304
|
zonosStore.zonosStore.organizationName = organizationName;
|
|
305
305
|
}
|
|
306
306
|
render() {
|
|
307
|
-
return index.h(index.Host, { key: '
|
|
307
|
+
return index.h(index.Host, { key: 'b8a056dc3bbd14495e048a89a11f27a6fb3fdb10', class: "zonos--elements" });
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
ZonosController.style = ZonosControllerStyle0;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-7a79bccc.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
8
8
|
const classes = require('./classes-b7918f56.js');
|
|
9
9
|
require('./logError-4e2f2020.js');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-7a79bccc.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
8
8
|
const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
|
|
9
9
|
const isDarkColor = require('./isDarkColor-4eb96a1e.js');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-7a79bccc.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
8
8
|
const classes = require('./classes-b7918f56.js');
|
|
9
9
|
const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
6
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
7
|
-
const cart = require('./cart-
|
|
7
|
+
const cart = require('./cart-7a79bccc.js');
|
|
8
8
|
const classes = require('./classes-b7918f56.js');
|
|
9
9
|
const logError = require('./logError-4e2f2020.js');
|
|
10
10
|
const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-4c94667f.js');
|
|
@@ -365,13 +365,12 @@ var debounce_1 = debounce;
|
|
|
365
365
|
|
|
366
366
|
const checkItemRestrictions = async ({ items, shipFrom, shipTo, }) => {
|
|
367
367
|
var _a;
|
|
368
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/check-item-restrictions`;
|
|
369
368
|
const body = {
|
|
370
369
|
items,
|
|
371
370
|
shipFrom,
|
|
372
371
|
shipTo,
|
|
373
372
|
};
|
|
374
|
-
const { errors, json } = await cart.handleFetch(
|
|
373
|
+
const { errors, json } = await cart.handleFetch('/api/zonos-elements/check-item-restrictions', { body, method: 'POST' });
|
|
375
374
|
if (errors.length || !json) {
|
|
376
375
|
logError.logError(`Error fetching item restrictions: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
377
376
|
return [];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-7a79bccc.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
8
8
|
const ILanguage = require('./ILanguage-98b04442.js');
|
|
9
9
|
require('./logError-4e2f2020.js');
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const index = require('./index-d56e0a8b.js');
|
|
6
6
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
7
7
|
const classes = require('./classes-b7918f56.js');
|
|
8
|
-
const cart = require('./cart-
|
|
8
|
+
const cart = require('./cart-7a79bccc.js');
|
|
9
9
|
const logError = require('./logError-4e2f2020.js');
|
|
10
|
-
const paypal = require('./paypal-
|
|
10
|
+
const paypal = require('./paypal-eb07e9f5.js');
|
|
11
11
|
require('./isDarkColor-4eb96a1e.js');
|
|
12
12
|
require('./getBorderRadius-4413e191.js');
|
|
13
13
|
|
|
@@ -21,18 +21,25 @@ export class ZonosCheckoutFinish {
|
|
|
21
21
|
constructor() {
|
|
22
22
|
this.pullOrder = async () => {
|
|
23
23
|
var _a, _b;
|
|
24
|
-
const baseUrl = process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL;
|
|
25
24
|
const checkoutSessionId = cartStore.checkoutSessionId;
|
|
26
|
-
const
|
|
25
|
+
const searchParams = new URLSearchParams();
|
|
26
|
+
searchParams.set('checkoutSessionId', checkoutSessionId || '');
|
|
27
|
+
const { baseUrl, errors, json } = await handleFetch(`/api/zonos-elements/get-order?${searchParams.toString()}`);
|
|
27
28
|
if (errors.length || !(json === null || json === void 0 ? void 0 : json.id)) {
|
|
28
|
-
return
|
|
29
|
+
return {
|
|
30
|
+
baseUrl,
|
|
31
|
+
order: null,
|
|
32
|
+
};
|
|
29
33
|
}
|
|
30
34
|
// onOrderSuccess callback may be provided on Zonos.init
|
|
31
35
|
await ((_b = (_a = zonosStore.checkoutSettings).onOrderSuccess) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
32
36
|
zonosApiRoute: baseUrl,
|
|
33
37
|
zonosOrder: json,
|
|
34
38
|
}));
|
|
35
|
-
return
|
|
39
|
+
return {
|
|
40
|
+
baseUrl,
|
|
41
|
+
order: json,
|
|
42
|
+
};
|
|
36
43
|
};
|
|
37
44
|
this.redirectToUrl = (url) => {
|
|
38
45
|
// reset store and checkout session id before redirecting
|
|
@@ -64,7 +71,7 @@ export class ZonosCheckoutFinish {
|
|
|
64
71
|
};
|
|
65
72
|
// TODO: This method of pulling orders is temporary. Once we have a working event registry system, we will rely on that to tell us when the order is ready to trigger onOrderSuccess
|
|
66
73
|
this.getPullOrder = async (attempts = 0) => {
|
|
67
|
-
const order = await this.pullOrder();
|
|
74
|
+
const { baseUrl, order } = await this.pullOrder();
|
|
68
75
|
if (order) {
|
|
69
76
|
void trackConversionEvent('checkout_orderCompleted');
|
|
70
77
|
this.order = order;
|
|
@@ -78,7 +85,6 @@ export class ZonosCheckoutFinish {
|
|
|
78
85
|
else {
|
|
79
86
|
// Set loading to false to display generic success page and log error
|
|
80
87
|
this.isLoading = false;
|
|
81
|
-
const baseUrl = process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL;
|
|
82
88
|
const checkoutSessionId = cartStore.checkoutSessionId;
|
|
83
89
|
void sendErrorLog({
|
|
84
90
|
endpoint: `${baseUrl}/api/zonos-elements/get-order?checkoutSessionId=${checkoutSessionId}`,
|
|
@@ -205,11 +211,11 @@ export class ZonosCheckoutFinish {
|
|
|
205
211
|
var _a, _b;
|
|
206
212
|
const orderId = ((_a = this.order) === null || _a === void 0 ? void 0 : _a.accountOrderNumber) || getGraphQlShortId((_b = this.order) === null || _b === void 0 ? void 0 : _b.id);
|
|
207
213
|
const isTestMode = getIsTestMode();
|
|
208
|
-
return (h(Host, { key: '
|
|
214
|
+
return (h(Host, { key: 'ac24d728b66f975dc5f4abcc0e019577b92b5265', class: "zonos--checkout-finish zonos--elements", style: {
|
|
209
215
|
'--border-radius': getBorderRadius({
|
|
210
216
|
overrideBorderStyle: this.borderRadius,
|
|
211
217
|
}),
|
|
212
|
-
} }, this.isLoading && (h("div", { key: '
|
|
218
|
+
} }, this.isLoading && (h("div", { key: '5e445cb54f5a22f59823d502d6d20679568ccad9', class: "loading-wrapper" }, h("zonos-spinner", { key: 'c96e41437570caa001f3f5b8841a02d3896c2142' }))), !this.isLoading && (h("div", { key: '4a3f1cd814fa7d0bee7193d9ae3a39d170826944', class: "zonos--finish-details" }, h("div", { key: 'abc20383d6ddcfbe1833e8e846d629dcbabc83f9', class: "zonos--group" }, this.notificationType === 'success' ? (h("zonos-icon", { "aria-label": "Order success", content: SuccessIcon, iconColor: 'blue-800', size: 50 })) : (h("zonos-icon", { "aria-label": "Order failed", content: RemoveIcon, iconColor: 'red-800', size: 50 })), h("zonos-text", { key: 'ea5344bba3f55d026bf6f25a624f5bf94045f581', class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), orderId && (h("div", { key: '7622b546b79aefb379b70c1505b20a5c9926fc4d', class: "zonos--order-number" }, "Order #", orderId)), h("zonos-text", { key: '5748732fc28167b733ed917645db52b88522238f', textColor: "gray-600" }, this.notificationMessages.map(message => (h(Fragment, null, message, h("br", null))))), h("zonos-button", { key: 'd83ebfc701253978240eeccf685f4ea03ce1e25a', onClick: () => this.closeClickHandler(), size: "md", variant: "primary" }, this.notificationActionText)), isTestMode && cartStore.step === 'finish' && (h("div", { key: '5c08c8322043cde4c7ad687cc53d6b4ad9f94233', class: "zonos--finish-button-wrapper" }, h("zonos-button", { key: '8e69a15a544893304d143071e1321c6a4cd455c3', backgroundColor: "gray-0", buttonColor: "gray-1200", onClick: () => this.closeClickHandler(), size: "lg", variant: "outline" }, "New test cart"), h("zonos-button", { key: '132b343fef61cea8063dca9afc55e708226fa166', onClick: () => this.redirectToUrl(`/orders/all`), size: "lg", variant: "primary" }, "View order in Dashboard")))))));
|
|
213
219
|
}
|
|
214
220
|
static get is() { return "zonos-checkout-finish"; }
|
|
215
221
|
static get encapsulation() { return "shadow"; }
|
|
@@ -51,8 +51,9 @@ export class ZonosController {
|
|
|
51
51
|
log(`[FONT] Just applied Inter , but no need to inject since we already inject Inter on start`, 'warn');
|
|
52
52
|
zonosStore.appearance = Object.assign(Object.assign({}, zonosStore.appearance), { fontFamily: overrideFont });
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const searchParams = new URLSearchParams();
|
|
55
|
+
searchParams.set('family', fontSelected);
|
|
56
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/get-font-detail?${searchParams.toString()}`);
|
|
56
57
|
if (errors.length > 0 || !json) {
|
|
57
58
|
log(`Failed to load font ${fontSelected}`, 'warn');
|
|
58
59
|
return;
|
|
@@ -186,7 +187,7 @@ export class ZonosController {
|
|
|
186
187
|
zonosStore.organizationName = organizationName;
|
|
187
188
|
}
|
|
188
189
|
render() {
|
|
189
|
-
return h(Host, { key: '
|
|
190
|
+
return h(Host, { key: 'b8a056dc3bbd14495e048a89a11f27a6fb3fdb10', class: "zonos--elements" });
|
|
190
191
|
}
|
|
191
192
|
static get is() { return "zonos-controller"; }
|
|
192
193
|
static get encapsulation() { return "shadow"; }
|
|
@@ -358,13 +358,11 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
358
358
|
return false;
|
|
359
359
|
}
|
|
360
360
|
stripeStore.isFetchingSession = true;
|
|
361
|
-
const { errors, json } = await handleFetch(
|
|
361
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/create-checkout-session', {
|
|
362
362
|
body: {
|
|
363
363
|
currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
|
|
364
364
|
itemsAmount: total,
|
|
365
|
-
metadata: [
|
|
366
|
-
{ key: 'language', value: localizationStore.selectedLocale },
|
|
367
|
-
],
|
|
365
|
+
metadata: [{ key: 'language', value: localizationStore.selectedLocale }],
|
|
368
366
|
presentmentCountryCode: localizationStore.selectedCountryCode || null,
|
|
369
367
|
},
|
|
370
368
|
method: 'POST',
|
|
@@ -389,7 +387,7 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
389
387
|
const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
|
|
390
388
|
// No need to set loading state here because this function will be called under the hood to update
|
|
391
389
|
// landed cost id for the section.
|
|
392
|
-
const { errors, json } = await handleFetch(
|
|
390
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
|
|
393
391
|
body: {
|
|
394
392
|
currency,
|
|
395
393
|
id,
|
|
@@ -488,8 +486,7 @@ const stripeStoreTranslateAddressToLatin = async ({ addressInvalidCharactersList
|
|
|
488
486
|
if (!isAddressOutdated) {
|
|
489
487
|
return;
|
|
490
488
|
}
|
|
491
|
-
const
|
|
492
|
-
const { errors, json } = await handleFetch(`${routeUrl}/api/zonos-elements/validate-address`, {
|
|
489
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/validate-address', {
|
|
493
490
|
body: requestBody,
|
|
494
491
|
method: 'POST',
|
|
495
492
|
});
|
|
@@ -201,7 +201,7 @@ const updateCheckoutSessionLanguage = async () => {
|
|
|
201
201
|
if (!cartStore.checkoutSessionId) {
|
|
202
202
|
return null;
|
|
203
203
|
}
|
|
204
|
-
const { errors, json } = await handleFetch(
|
|
204
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
|
|
205
205
|
body: {
|
|
206
206
|
id: cartStore.checkoutSessionId,
|
|
207
207
|
metadata: [
|
|
@@ -11,8 +11,7 @@ export const calculateLandedCost = async (abortController) => {
|
|
|
11
11
|
return json;
|
|
12
12
|
}
|
|
13
13
|
// request to get landed cost info
|
|
14
|
-
const
|
|
15
|
-
const { errors, json } = await handleFetch(url, {
|
|
14
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/calculate-landed-cost', {
|
|
16
15
|
body: prepCalculateLandedCost(),
|
|
17
16
|
method: 'POST',
|
|
18
17
|
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
@@ -2,13 +2,12 @@ import { handleFetch } from "../handleFetch";
|
|
|
2
2
|
import { logError } from "../logging/logError";
|
|
3
3
|
export const checkItemRestrictions = async ({ items, shipFrom, shipTo, }) => {
|
|
4
4
|
var _a;
|
|
5
|
-
const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/check-item-restrictions`;
|
|
6
5
|
const body = {
|
|
7
6
|
items,
|
|
8
7
|
shipFrom,
|
|
9
8
|
shipTo,
|
|
10
9
|
};
|
|
11
|
-
const { errors, json } = await handleFetch(
|
|
10
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/check-item-restrictions', { body, method: 'POST' });
|
|
12
11
|
if (errors.length || !json) {
|
|
13
12
|
logError(`Error fetching item restrictions: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
14
13
|
return [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { handleFetch } from "../handleFetch";
|
|
2
2
|
export const getCountries = async () => {
|
|
3
3
|
try {
|
|
4
|
-
const { errors, json } = await handleFetch(
|
|
4
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/get-countries', {
|
|
5
5
|
method: 'GET',
|
|
6
6
|
});
|
|
7
7
|
if (errors.length || !json) {
|
|
@@ -5,7 +5,7 @@ export const getCountryLandedCost = async (countryCode) => {
|
|
|
5
5
|
if (!countryCode) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
|
-
const url =
|
|
8
|
+
const url = `/api/zonos-elements/country-landed-cost/${countryCode}`;
|
|
9
9
|
const { errors, json } = await handleFetch(url);
|
|
10
10
|
if (errors.length || !json) {
|
|
11
11
|
logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
@@ -20,8 +20,12 @@ export const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, t
|
|
|
20
20
|
if (sourceCurrency === targetCurrency && !isGuaranteed) {
|
|
21
21
|
return defaultUsExchangeRate;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const searchParams = new URLSearchParams();
|
|
24
|
+
searchParams.set('sourceCurrency', sourceCurrency);
|
|
25
|
+
searchParams.set('targetCurrency', targetCurrency);
|
|
26
|
+
searchParams.set('isGuaranteed', String(isGuaranteed));
|
|
27
|
+
searchParams.set('country', country || '');
|
|
28
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
|
|
25
29
|
if (errors.length || !json) {
|
|
26
30
|
logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
27
31
|
return defaultUsExchangeRate;
|
|
@@ -5,8 +5,7 @@ export const getInclusivePricing = async (countryCode) => {
|
|
|
5
5
|
if (!countryCode) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
const { errors, json } = await handleFetch(url);
|
|
8
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
|
|
10
9
|
if (errors.length || !json) {
|
|
11
10
|
logError(`Error fetching country inclusive price setting: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
12
11
|
return null;
|
|
@@ -2,8 +2,13 @@ import { handleFetch } from "../handleFetch";
|
|
|
2
2
|
import { logError } from "../logging/logError";
|
|
3
3
|
export const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
|
|
4
4
|
var _a;
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const searchParams = new URLSearchParams();
|
|
6
|
+
searchParams.set('countryCode', countryCode);
|
|
7
|
+
searchParams.set('storeId', storeId.toString());
|
|
8
|
+
if (localeTo) {
|
|
9
|
+
searchParams.set('localeTo', localeTo);
|
|
10
|
+
}
|
|
11
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
|
|
7
12
|
if (errors.length || !json) {
|
|
8
13
|
logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
|
|
9
14
|
return [];
|
|
@@ -6,14 +6,11 @@ export const getLocalization = async () => {
|
|
|
6
6
|
// load and use country from session storage when zCountry query param is not present
|
|
7
7
|
const countryLoadedSession = window.sessionStorage.getItem('zonos--country');
|
|
8
8
|
const zCountry = getZCountryUrlParam(currentUrl.searchParams) || countryLoadedSession;
|
|
9
|
-
const
|
|
9
|
+
const searchParams = new URLSearchParams();
|
|
10
10
|
if (zCountry) {
|
|
11
|
-
|
|
11
|
+
searchParams.set('zCountry', zCountry);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
const { errors, json } = await handleFetch(fetchUrl, {
|
|
15
|
-
method: 'GET',
|
|
16
|
-
});
|
|
13
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
|
|
17
14
|
if (errors.length || !json) {
|
|
18
15
|
return { country: null, locale: null };
|
|
19
16
|
}
|
|
@@ -2,8 +2,7 @@ import { handleFetch } from "../handleFetch";
|
|
|
2
2
|
import { logError } from "../logging/logError";
|
|
3
3
|
export const getShippingZones = async () => {
|
|
4
4
|
var _a, _b;
|
|
5
|
-
const
|
|
6
|
-
const { errors, json } = await handleFetch(url);
|
|
5
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/shipping-zones');
|
|
7
6
|
if (errors.length || !json) {
|
|
8
7
|
logError(`Error fetching shipping zones: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
9
8
|
return null;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { handleFetch } from "../handleFetch";
|
|
2
2
|
import { logError } from "../logging/logError";
|
|
3
3
|
export const getZonosSettings = async () => {
|
|
4
|
-
const
|
|
5
|
-
const { errors, json, zonosMode } = await handleFetch(url);
|
|
4
|
+
const { errors, json, zonosMode } = await handleFetch('/api/zonos-elements/zonos-settings');
|
|
6
5
|
if (errors.length) {
|
|
7
6
|
logError(`Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings`);
|
|
8
7
|
return { errors, json: null, zonosMode };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { handleFetch } from "../handleFetch";
|
|
2
2
|
export const paypalCaptureOrder = async ({ checkoutSessionId, paypalMockResponse, }) => {
|
|
3
|
-
const { errors, json } = await handleFetch(
|
|
3
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/capture-paypal-order', {
|
|
4
4
|
body: { checkoutSessionId, paypalMockResponse },
|
|
5
5
|
method: 'POST',
|
|
6
6
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { handleFetch } from "../handleFetch";
|
|
2
2
|
export const paypalCreateOrder = async ({ checkoutSessionId, }) => {
|
|
3
|
-
const { errors, json } = await handleFetch(
|
|
3
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/create-paypal-order', {
|
|
4
4
|
body: { checkoutSessionId },
|
|
5
5
|
method: 'POST',
|
|
6
6
|
});
|
|
@@ -14,7 +14,6 @@ export const trackConversionEvent = async (eventName, metadata) => {
|
|
|
14
14
|
!window.Zonos.zonosConversionTest) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/track-conversion-event`;
|
|
18
17
|
const countryCode = localizationStore.selectedCountryCode;
|
|
19
18
|
const organizationId = zonosStore.organizationId;
|
|
20
19
|
const checkoutSessionId = cartStore.checkoutSessionId;
|
|
@@ -29,7 +28,7 @@ export const trackConversionEvent = async (eventName, metadata) => {
|
|
|
29
28
|
metadata,
|
|
30
29
|
organizationId,
|
|
31
30
|
};
|
|
32
|
-
await handleFetch(
|
|
31
|
+
await handleFetch('/api/zonos-elements/track-conversion-event', {
|
|
33
32
|
body,
|
|
34
33
|
method: 'POST',
|
|
35
34
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { prepCalculateLandedCost } from "./prepCalculateLandedCost";
|
|
2
|
+
import { MAIN_BASE_API } from "../getNextFallbackApi";
|
|
2
3
|
import { handleFetch } from "../handleFetch";
|
|
3
4
|
export const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
4
5
|
var _a, _b, _c, _d;
|
|
@@ -9,13 +10,13 @@ export const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
|
9
10
|
checkoutSessionId: data.checkoutSessionId,
|
|
10
11
|
contact: data.contact,
|
|
11
12
|
shippingAddress: data.shippingAddress,
|
|
12
|
-
zonosApiRoute:
|
|
13
|
+
zonosApiRoute: MAIN_BASE_API,
|
|
13
14
|
});
|
|
14
15
|
if (!landedCost || ((_a = landedCost.errors) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
15
16
|
throw new Error(`Failed to build landed cost: ${((_c = (_b = landedCost === null || landedCost === void 0 ? void 0 : landedCost.errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) || 'Unknown error'}`);
|
|
16
17
|
}
|
|
17
18
|
// Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
|
|
18
|
-
const { errors, json } = await handleFetch(
|
|
19
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/validate-landed-cost', {
|
|
19
20
|
body: landedCost,
|
|
20
21
|
headers: {
|
|
21
22
|
'Content-Type': 'application/json',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const fallbackApiType = ['vercel', 'cloudflare'];
|
|
2
|
+
export const MAIN_BASE_API_TYPE = fallbackApiType[0];
|
|
3
|
+
export const fallbackApiList = {
|
|
4
|
+
cloudflare: process.env.NEXT_PUBLIC_ZONOS_CLOUDFLARE_URL,
|
|
5
|
+
vercel: process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL,
|
|
6
|
+
};
|
|
7
|
+
export const MAIN_BASE_API = fallbackApiList[MAIN_BASE_API_TYPE];
|
|
8
|
+
/**
|
|
9
|
+
* Next available fallback api type
|
|
10
|
+
*/
|
|
11
|
+
export const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
|
|
12
|
+
const currentIndex = fallbackApiType.indexOf(currentApiType);
|
|
13
|
+
const nextFallbackApiType = fallbackApiType[currentIndex + 1];
|
|
14
|
+
if (!nextFallbackApiType) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return nextFallbackApiType;
|
|
18
|
+
};
|