@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
|
@@ -7173,6 +7173,57 @@ const translate = (...[key, replacement]) => {
|
|
|
7173
7173
|
return ((_b = translationStore.translatedChunks[key]) === null || _b === void 0 ? void 0 : _b.value) || key;
|
|
7174
7174
|
};
|
|
7175
7175
|
|
|
7176
|
+
const fallbackApiType = ['vercel', 'cloudflare'];
|
|
7177
|
+
const MAIN_BASE_API_TYPE = fallbackApiType[0];
|
|
7178
|
+
const fallbackApiList = {
|
|
7179
|
+
cloudflare: "https://route.elements.zonos.com",
|
|
7180
|
+
vercel: "https://v1.route.js.zonos.com",
|
|
7181
|
+
};
|
|
7182
|
+
const MAIN_BASE_API = fallbackApiList[MAIN_BASE_API_TYPE];
|
|
7183
|
+
/**
|
|
7184
|
+
* Next available fallback api type
|
|
7185
|
+
*/
|
|
7186
|
+
const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
|
|
7187
|
+
const currentIndex = fallbackApiType.indexOf(currentApiType);
|
|
7188
|
+
const nextFallbackApiType = fallbackApiType[currentIndex + 1];
|
|
7189
|
+
if (!nextFallbackApiType) {
|
|
7190
|
+
return null;
|
|
7191
|
+
}
|
|
7192
|
+
return nextFallbackApiType;
|
|
7193
|
+
};
|
|
7194
|
+
|
|
7195
|
+
const sendErrorLog = async ({ endpoint, errors, metadata }) => {
|
|
7196
|
+
const userAgentData = 'userAgentData' in window.navigator
|
|
7197
|
+
? // userAgentData is not yet supported in all browsers
|
|
7198
|
+
window.navigator.userAgentData
|
|
7199
|
+
: null;
|
|
7200
|
+
const errorObject = {
|
|
7201
|
+
endpoint,
|
|
7202
|
+
errors,
|
|
7203
|
+
metadata: Object.assign({ href: window.location.href, userAgent: userAgentData && userAgentData.brands.length > 0
|
|
7204
|
+
? userAgentData
|
|
7205
|
+
: window.navigator.userAgent }, metadata),
|
|
7206
|
+
};
|
|
7207
|
+
try {
|
|
7208
|
+
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
7209
|
+
void fetch(`${MAIN_BASE_API}/api/zonos-elements/log-error`, {
|
|
7210
|
+
body: JSON.stringify(errorObject),
|
|
7211
|
+
method: 'POST',
|
|
7212
|
+
});
|
|
7213
|
+
}
|
|
7214
|
+
catch (_err) {
|
|
7215
|
+
const nextFallbackApi = getNextFallbackApiType();
|
|
7216
|
+
if (!nextFallbackApi) {
|
|
7217
|
+
return;
|
|
7218
|
+
}
|
|
7219
|
+
// request to the fallback API if the first one fails
|
|
7220
|
+
void fetch(`${fallbackApiList[nextFallbackApi]}/api/zonos-elements/log-error`, {
|
|
7221
|
+
body: JSON.stringify(errorObject),
|
|
7222
|
+
method: 'POST',
|
|
7223
|
+
});
|
|
7224
|
+
}
|
|
7225
|
+
};
|
|
7226
|
+
|
|
7176
7227
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
7177
7228
|
var t = {};
|
|
7178
7229
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -7200,14 +7251,36 @@ const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false
|
|
|
7200
7251
|
return null;
|
|
7201
7252
|
}
|
|
7202
7253
|
};
|
|
7203
|
-
const
|
|
7254
|
+
const encodeString = (text) => {
|
|
7255
|
+
try {
|
|
7256
|
+
// encode the string, remove the "=" at the end of the encoded string
|
|
7257
|
+
const encodedString = btoa(text).replace(/=/g, '');
|
|
7258
|
+
return encodedString;
|
|
7259
|
+
}
|
|
7260
|
+
catch (error) {
|
|
7261
|
+
// return the reverse string if the encoding failed
|
|
7262
|
+
return text
|
|
7263
|
+
.replace(/[^A-Za-z0-9]/g, '')
|
|
7264
|
+
.split('')
|
|
7265
|
+
.reverse()
|
|
7266
|
+
.join('');
|
|
7267
|
+
}
|
|
7268
|
+
};
|
|
7269
|
+
const handleRequest = async ({ basePathType, options, path, }) => {
|
|
7204
7270
|
let response;
|
|
7271
|
+
// fallback to the main base API if the passed in base path is not available
|
|
7272
|
+
const baseUrl = fallbackApiList[basePathType] || MAIN_BASE_API_TYPE;
|
|
7273
|
+
const url = baseUrl + path;
|
|
7274
|
+
// adding random encoded token to the url so that the request will be cached differently for each store
|
|
7275
|
+
const modifiedUrl = new URL(url);
|
|
7276
|
+
modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
|
|
7205
7277
|
try {
|
|
7206
|
-
response = await fetch(
|
|
7278
|
+
response = await fetch(modifiedUrl.toString(), options);
|
|
7207
7279
|
}
|
|
7208
7280
|
catch (e) {
|
|
7209
7281
|
if (e instanceof Error) {
|
|
7210
7282
|
return {
|
|
7283
|
+
baseUrl,
|
|
7211
7284
|
errors: [{ message: e.message, type: 'unknown' }],
|
|
7212
7285
|
json: null,
|
|
7213
7286
|
response: null,
|
|
@@ -7216,6 +7289,7 @@ const handleRequest = async (url, options) => {
|
|
|
7216
7289
|
}
|
|
7217
7290
|
const message = 'Fail to fetch';
|
|
7218
7291
|
return {
|
|
7292
|
+
baseUrl,
|
|
7219
7293
|
errors: [{ message, type: 'unknown' }],
|
|
7220
7294
|
json: null,
|
|
7221
7295
|
response: null,
|
|
@@ -7231,6 +7305,7 @@ const handleRequest = async (url, options) => {
|
|
|
7231
7305
|
if (response.ok) {
|
|
7232
7306
|
const data = await getResponseBody({ response });
|
|
7233
7307
|
return {
|
|
7308
|
+
baseUrl,
|
|
7234
7309
|
errors: [],
|
|
7235
7310
|
json: data,
|
|
7236
7311
|
response,
|
|
@@ -7245,6 +7320,7 @@ const handleRequest = async (url, options) => {
|
|
|
7245
7320
|
});
|
|
7246
7321
|
const message = JSON.stringify(data);
|
|
7247
7322
|
return {
|
|
7323
|
+
baseUrl,
|
|
7248
7324
|
errors: [{ message, type: status }],
|
|
7249
7325
|
json: null,
|
|
7250
7326
|
response,
|
|
@@ -7254,6 +7330,7 @@ const handleRequest = async (url, options) => {
|
|
|
7254
7330
|
catch (e) {
|
|
7255
7331
|
const message = 'Unknown error';
|
|
7256
7332
|
return {
|
|
7333
|
+
baseUrl,
|
|
7257
7334
|
errors: [{ message: `${status}: ${message}`, type: status }],
|
|
7258
7335
|
json: null,
|
|
7259
7336
|
response: null,
|
|
@@ -7261,38 +7338,63 @@ const handleRequest = async (url, options) => {
|
|
|
7261
7338
|
};
|
|
7262
7339
|
}
|
|
7263
7340
|
};
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
}
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7341
|
+
const handleRequestWithFallback = async ({ basePathType, options, path, }) => {
|
|
7342
|
+
const _a = await handleRequest({
|
|
7343
|
+
basePathType,
|
|
7344
|
+
options,
|
|
7345
|
+
path,
|
|
7346
|
+
}), { errors, response } = _a, rest = __rest(_a, ["errors", "response"]);
|
|
7347
|
+
const nextFallbackApiType = getNextFallbackApiType(basePathType);
|
|
7348
|
+
const unknownError = errors.find(({ type }) => type === 'unknown');
|
|
7349
|
+
const shouldCallFallback =
|
|
7350
|
+
// If next fallback is available, and the error is unknown (fail to fetch) or 404
|
|
7351
|
+
nextFallbackApiType && (!!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404);
|
|
7352
|
+
if (shouldCallFallback) {
|
|
7353
|
+
void sendErrorLog({
|
|
7354
|
+
endpoint: fallbackApiList[basePathType] + path,
|
|
7355
|
+
errors: errors.map(({ message }) => message),
|
|
7356
|
+
metadata: {
|
|
7357
|
+
currentBasePath: basePathType,
|
|
7358
|
+
nextFallbackApiType,
|
|
7359
|
+
status: response === null || response === void 0 ? void 0 : response.status,
|
|
7360
|
+
statusText: response === null || response === void 0 ? void 0 : response.statusText,
|
|
7361
|
+
},
|
|
7362
|
+
});
|
|
7363
|
+
logError.log(`=== "${path}" failed to fetch, trying next fallback ${nextFallbackApiType}`);
|
|
7364
|
+
return handleRequestWithFallback({
|
|
7365
|
+
basePathType: nextFallbackApiType,
|
|
7366
|
+
options,
|
|
7367
|
+
path,
|
|
7368
|
+
});
|
|
7277
7369
|
}
|
|
7278
|
-
|
|
7279
|
-
|
|
7370
|
+
// No more fallbacks, just return the result
|
|
7371
|
+
return Object.assign({ errors, response }, rest);
|
|
7372
|
+
};
|
|
7373
|
+
/**
|
|
7374
|
+
* Fetch request and will request to fallback API when the first one fails
|
|
7375
|
+
* @param path Path name of the request (e.g. /api/something/com).
|
|
7376
|
+
* @param _opts fetch options
|
|
7377
|
+
*/
|
|
7378
|
+
const handleFetch = async (path, _opts) => {
|
|
7280
7379
|
const opts = __rest(_opts || {}, []);
|
|
7281
7380
|
const body = opts.body ? JSON.stringify(opts.body) : undefined;
|
|
7282
7381
|
const method = opts.method || 'GET';
|
|
7283
|
-
// adding random encoded token to the url so that the request will be cached differently for each store
|
|
7284
|
-
const modifiedUrl = new URL(url);
|
|
7285
|
-
modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
|
|
7286
7382
|
// headers content type
|
|
7287
7383
|
const headers = Object.assign({ 'Content-Type': 'application/json', 'Zonos-Is-BigCommerce': window.Zonos.isBigCommerce.toString(), 'Zonos-Referer': window.location.hostname, 'Zonos-Version': window.Zonos.version, credentialtoken: window.Zonos.zonosApiKey || 'Empty credential token from zonos-elements' }, opts.headers);
|
|
7288
7384
|
const options = Object.assign(Object.assign({}, opts), { body: method === 'GET' ? undefined : body, headers,
|
|
7289
7385
|
method });
|
|
7290
|
-
|
|
7386
|
+
// This is for testing fallback API, set fallback API type to start with
|
|
7387
|
+
const useFallbackApi = new URLSearchParams(window.location.search).get('useFallbackApi');
|
|
7388
|
+
return handleRequestWithFallback({
|
|
7389
|
+
basePathType: useFallbackApi || MAIN_BASE_API_TYPE,
|
|
7390
|
+
options,
|
|
7391
|
+
path,
|
|
7392
|
+
});
|
|
7291
7393
|
};
|
|
7292
7394
|
|
|
7293
7395
|
const getCountries = async () => {
|
|
7294
7396
|
try {
|
|
7295
|
-
const { errors, json } = await handleFetch(
|
|
7397
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/get-countries', {
|
|
7296
7398
|
method: 'GET',
|
|
7297
7399
|
});
|
|
7298
7400
|
if (errors.length || !json) {
|
|
@@ -7310,7 +7412,7 @@ const getCountryLandedCost = async (countryCode) => {
|
|
|
7310
7412
|
if (!countryCode) {
|
|
7311
7413
|
return null;
|
|
7312
7414
|
}
|
|
7313
|
-
const url =
|
|
7415
|
+
const url = `/api/zonos-elements/country-landed-cost/${countryCode}`;
|
|
7314
7416
|
const { errors, json } = await handleFetch(url);
|
|
7315
7417
|
if (errors.length || !json) {
|
|
7316
7418
|
logError.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
@@ -7339,8 +7441,12 @@ const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCu
|
|
|
7339
7441
|
if (sourceCurrency === targetCurrency && !isGuaranteed) {
|
|
7340
7442
|
return defaultUsExchangeRate;
|
|
7341
7443
|
}
|
|
7342
|
-
const
|
|
7343
|
-
|
|
7444
|
+
const searchParams = new URLSearchParams();
|
|
7445
|
+
searchParams.set('sourceCurrency', sourceCurrency);
|
|
7446
|
+
searchParams.set('targetCurrency', targetCurrency);
|
|
7447
|
+
searchParams.set('isGuaranteed', String(isGuaranteed));
|
|
7448
|
+
searchParams.set('country', country || '');
|
|
7449
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
|
|
7344
7450
|
if (errors.length || !json) {
|
|
7345
7451
|
logError.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
7346
7452
|
return defaultUsExchangeRate;
|
|
@@ -7360,8 +7466,7 @@ const getInclusivePricing = async (countryCode) => {
|
|
|
7360
7466
|
if (!countryCode) {
|
|
7361
7467
|
return null;
|
|
7362
7468
|
}
|
|
7363
|
-
const
|
|
7364
|
-
const { errors, json } = await handleFetch(url);
|
|
7469
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
|
|
7365
7470
|
if (errors.length || !json) {
|
|
7366
7471
|
logError.logError(`Error fetching country inclusive price setting: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
7367
7472
|
return null;
|
|
@@ -7371,8 +7476,13 @@ const getInclusivePricing = async (countryCode) => {
|
|
|
7371
7476
|
|
|
7372
7477
|
const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
|
|
7373
7478
|
var _a;
|
|
7374
|
-
const
|
|
7375
|
-
|
|
7479
|
+
const searchParams = new URLSearchParams();
|
|
7480
|
+
searchParams.set('countryCode', countryCode);
|
|
7481
|
+
searchParams.set('storeId', storeId.toString());
|
|
7482
|
+
if (localeTo) {
|
|
7483
|
+
searchParams.set('localeTo', localeTo);
|
|
7484
|
+
}
|
|
7485
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
|
|
7376
7486
|
if (errors.length || !json) {
|
|
7377
7487
|
logError.logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
|
|
7378
7488
|
return [];
|
|
@@ -7392,14 +7502,11 @@ const getLocalization = async () => {
|
|
|
7392
7502
|
// load and use country from session storage when zCountry query param is not present
|
|
7393
7503
|
const countryLoadedSession = window.sessionStorage.getItem('zonos--country');
|
|
7394
7504
|
const zCountry = getZCountryUrlParam(currentUrl.searchParams) || countryLoadedSession;
|
|
7395
|
-
const
|
|
7505
|
+
const searchParams = new URLSearchParams();
|
|
7396
7506
|
if (zCountry) {
|
|
7397
|
-
|
|
7507
|
+
searchParams.set('zCountry', zCountry);
|
|
7398
7508
|
}
|
|
7399
|
-
const
|
|
7400
|
-
const { errors, json } = await handleFetch(fetchUrl, {
|
|
7401
|
-
method: 'GET',
|
|
7402
|
-
});
|
|
7509
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
|
|
7403
7510
|
if (errors.length || !json) {
|
|
7404
7511
|
return { country: null, locale: null };
|
|
7405
7512
|
}
|
|
@@ -7415,8 +7522,7 @@ const getLocalization = async () => {
|
|
|
7415
7522
|
|
|
7416
7523
|
const getShippingZones = async () => {
|
|
7417
7524
|
var _a, _b;
|
|
7418
|
-
const
|
|
7419
|
-
const { errors, json } = await handleFetch(url);
|
|
7525
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/shipping-zones');
|
|
7420
7526
|
if (errors.length || !json) {
|
|
7421
7527
|
logError.logError(`Error fetching shipping zones: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
7422
7528
|
return null;
|
|
@@ -7823,7 +7929,7 @@ const updateCheckoutSessionLanguage = async () => {
|
|
|
7823
7929
|
if (!cartStore.checkoutSessionId) {
|
|
7824
7930
|
return null;
|
|
7825
7931
|
}
|
|
7826
|
-
const { errors, json } = await handleFetch(
|
|
7932
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
|
|
7827
7933
|
body: {
|
|
7828
7934
|
id: cartStore.checkoutSessionId,
|
|
7829
7935
|
metadata: [
|
|
@@ -7935,13 +8041,13 @@ const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
|
7935
8041
|
checkoutSessionId: data.checkoutSessionId,
|
|
7936
8042
|
contact: data.contact,
|
|
7937
8043
|
shippingAddress: data.shippingAddress,
|
|
7938
|
-
zonosApiRoute:
|
|
8044
|
+
zonosApiRoute: MAIN_BASE_API,
|
|
7939
8045
|
});
|
|
7940
8046
|
if (!landedCost || ((_a = landedCost.errors) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
7941
8047
|
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'}`);
|
|
7942
8048
|
}
|
|
7943
8049
|
// Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
|
|
7944
|
-
const { errors, json } = await handleFetch(
|
|
8050
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/validate-landed-cost', {
|
|
7945
8051
|
body: landedCost,
|
|
7946
8052
|
headers: {
|
|
7947
8053
|
'Content-Type': 'application/json',
|
|
@@ -7963,8 +8069,7 @@ const calculateLandedCost = async (abortController) => {
|
|
|
7963
8069
|
return json;
|
|
7964
8070
|
}
|
|
7965
8071
|
// request to get landed cost info
|
|
7966
|
-
const
|
|
7967
|
-
const { errors, json } = await handleFetch(url, {
|
|
8072
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/calculate-landed-cost', {
|
|
7968
8073
|
body: prepCalculateLandedCost(),
|
|
7969
8074
|
method: 'POST',
|
|
7970
8075
|
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
@@ -8495,13 +8600,11 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
8495
8600
|
return false;
|
|
8496
8601
|
}
|
|
8497
8602
|
stripeStore.isFetchingSession = true;
|
|
8498
|
-
const { errors, json } = await handleFetch(
|
|
8603
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/create-checkout-session', {
|
|
8499
8604
|
body: {
|
|
8500
8605
|
currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
|
|
8501
8606
|
itemsAmount: total,
|
|
8502
|
-
metadata: [
|
|
8503
|
-
{ key: 'language', value: localizationStore.selectedLocale },
|
|
8504
|
-
],
|
|
8607
|
+
metadata: [{ key: 'language', value: localizationStore.selectedLocale }],
|
|
8505
8608
|
presentmentCountryCode: localizationStore.selectedCountryCode || null,
|
|
8506
8609
|
},
|
|
8507
8610
|
method: 'POST',
|
|
@@ -8526,7 +8629,7 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
8526
8629
|
const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
|
|
8527
8630
|
// No need to set loading state here because this function will be called under the hood to update
|
|
8528
8631
|
// landed cost id for the section.
|
|
8529
|
-
const { errors, json } = await handleFetch(
|
|
8632
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
|
|
8530
8633
|
body: {
|
|
8531
8634
|
currency,
|
|
8532
8635
|
id,
|
|
@@ -8625,8 +8728,7 @@ const stripeStoreTranslateAddressToLatin = async ({ addressInvalidCharactersList
|
|
|
8625
8728
|
if (!isAddressOutdated) {
|
|
8626
8729
|
return;
|
|
8627
8730
|
}
|
|
8628
|
-
const
|
|
8629
|
-
const { errors, json } = await handleFetch(`${routeUrl}/api/zonos-elements/validate-address`, {
|
|
8731
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/validate-address', {
|
|
8630
8732
|
body: requestBody,
|
|
8631
8733
|
method: 'POST',
|
|
8632
8734
|
});
|
|
@@ -9009,6 +9111,7 @@ exports.localizationStore = localizationStore;
|
|
|
9009
9111
|
exports.localizationStoreOnUpdate = localizationStoreOnUpdate;
|
|
9010
9112
|
exports.localizationStoreUpdateSelectedCountryCode = localizationStoreUpdateSelectedCountryCode;
|
|
9011
9113
|
exports.localizationStoreUpdateSelectedLocale = localizationStoreUpdateSelectedLocale;
|
|
9114
|
+
exports.sendErrorLog = sendErrorLog;
|
|
9012
9115
|
exports.setZCountryUrlParam = setZCountryUrlParam;
|
|
9013
9116
|
exports.stripeStore = stripeStore;
|
|
9014
9117
|
exports.stripeStoreCleanupDomesticShippingSession = stripeStoreCleanupDomesticShippingSession;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const cart = require('./cart-
|
|
3
|
+
const cart = require('./cart-7a79bccc.js');
|
|
4
4
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
5
5
|
|
|
6
6
|
const trackConversionEvent = async (eventName, metadata) => {
|
|
@@ -15,7 +15,6 @@ const trackConversionEvent = async (eventName, metadata) => {
|
|
|
15
15
|
!window.Zonos.zonosConversionTest) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/track-conversion-event`;
|
|
19
18
|
const countryCode = cart.localizationStore.selectedCountryCode;
|
|
20
19
|
const organizationId = zonosStore.zonosStore.organizationId;
|
|
21
20
|
const checkoutSessionId = cart.cartStore.checkoutSessionId;
|
|
@@ -30,7 +29,7 @@ const trackConversionEvent = async (eventName, metadata) => {
|
|
|
30
29
|
metadata,
|
|
31
30
|
organizationId,
|
|
32
31
|
};
|
|
33
|
-
await cart.handleFetch(
|
|
32
|
+
await cart.handleFetch('/api/zonos-elements/track-conversion-event', {
|
|
34
33
|
body,
|
|
35
34
|
method: 'POST',
|
|
36
35
|
});
|
|
@@ -48,25 +47,6 @@ const createCustomEvent = (eventName, detail) => {
|
|
|
48
47
|
});
|
|
49
48
|
};
|
|
50
49
|
|
|
51
|
-
const sendErrorLog = async ({ endpoint, errors, metadata }) => {
|
|
52
|
-
const userAgentData = 'userAgentData' in window.navigator
|
|
53
|
-
? // userAgentData is not yet supported in all browsers
|
|
54
|
-
window.navigator.userAgentData
|
|
55
|
-
: null;
|
|
56
|
-
const errorObject = {
|
|
57
|
-
endpoint,
|
|
58
|
-
errors,
|
|
59
|
-
metadata: Object.assign({ href: window.location.href, userAgent: userAgentData && userAgentData.brands.length > 0
|
|
60
|
-
? userAgentData
|
|
61
|
-
: window.navigator.userAgent }, metadata),
|
|
62
|
-
};
|
|
63
|
-
void cart.handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/log-error`, {
|
|
64
|
-
body: errorObject,
|
|
65
|
-
method: 'POST',
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
50
|
exports.createCustomEvent = createCustomEvent;
|
|
70
51
|
exports.getIsTestMode = getIsTestMode;
|
|
71
|
-
exports.sendErrorLog = sendErrorLog;
|
|
72
52
|
exports.trackConversionEvent = trackConversionEvent;
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -94,13 +94,17 @@ const getZonosQaUrl = () => {
|
|
|
94
94
|
return null;
|
|
95
95
|
}
|
|
96
96
|
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
97
|
-
const cdnUrl = "https://v1.3.
|
|
97
|
+
const cdnUrl = "https://v1.3.46.js.zonos.com";
|
|
98
98
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
99
|
-
if (!qaUrl &&
|
|
99
|
+
if (!qaUrl &&
|
|
100
|
+
(cdnUrl.includes('test.') ||
|
|
101
|
+
// Vercel git domain
|
|
102
|
+
cdnUrl.includes('test-'))) {
|
|
100
103
|
return cdnUrl;
|
|
101
104
|
}
|
|
102
105
|
// when local demo app is running, it needs to use the local dev script unless the qaUrl is set
|
|
103
|
-
if (!qaUrl &&
|
|
106
|
+
if (!qaUrl &&
|
|
107
|
+
['dev.demo.elements.zonos.com'].includes(window.location.hostname)) {
|
|
104
108
|
return 'https://dev.elements.zonos.com';
|
|
105
109
|
}
|
|
106
110
|
if (!qaUrl) {
|
|
@@ -264,10 +268,10 @@ const zonosLoadUrl = (() => {
|
|
|
264
268
|
}
|
|
265
269
|
return null;
|
|
266
270
|
})();
|
|
267
|
-
const ZONOS_URL = "https://v1.3.
|
|
268
|
-
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.
|
|
269
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.
|
|
270
|
-
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.
|
|
271
|
+
const ZONOS_URL = "https://v1.3.46.js.zonos.com";
|
|
272
|
+
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.46";
|
|
273
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.46";
|
|
274
|
+
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.46";
|
|
271
275
|
const MAIN_LOAD_CDN_TYPE = 'jsdelivr';
|
|
272
276
|
const INTER_FONT_URL = 'https://rsms.me';
|
|
273
277
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
@@ -288,7 +292,7 @@ Zonos.isBigCommerce = false;
|
|
|
288
292
|
*/
|
|
289
293
|
Zonos.isNpm = true;
|
|
290
294
|
Zonos.zonosQaUrl = null;
|
|
291
|
-
Zonos.version = `v${"1.3.
|
|
295
|
+
Zonos.version = `v${"1.3.46"}`;
|
|
292
296
|
Zonos.modeAlerted = false;
|
|
293
297
|
Zonos.tempCartData = null;
|
|
294
298
|
Zonos.paypal = null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
4
|
-
const cart = require('./cart-
|
|
4
|
+
const cart = require('./cart-7a79bccc.js');
|
|
5
5
|
const isDarkColor = require('./isDarkColor-4eb96a1e.js');
|
|
6
6
|
const logError = require('./logError-4e2f2020.js');
|
|
7
7
|
|
|
@@ -209,7 +209,7 @@ function validateArguments(options, PromisePonyfill) {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
const paypalCaptureOrder = async ({ checkoutSessionId, paypalMockResponse, }) => {
|
|
212
|
-
const { errors, json } = await cart.handleFetch(
|
|
212
|
+
const { errors, json } = await cart.handleFetch('/api/zonos-elements/capture-paypal-order', {
|
|
213
213
|
body: { checkoutSessionId, paypalMockResponse },
|
|
214
214
|
method: 'POST',
|
|
215
215
|
});
|
|
@@ -217,7 +217,7 @@ const paypalCaptureOrder = async ({ checkoutSessionId, paypalMockResponse, }) =>
|
|
|
217
217
|
};
|
|
218
218
|
|
|
219
219
|
const paypalCreateOrder = async ({ checkoutSessionId, }) => {
|
|
220
|
-
const { errors, json } = await cart.handleFetch(
|
|
220
|
+
const { errors, json } = await cart.handleFetch('/api/zonos-elements/create-paypal-order', {
|
|
221
221
|
body: { checkoutSessionId },
|
|
222
222
|
method: 'POST',
|
|
223
223
|
});
|
|
@@ -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 isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
|
|
8
8
|
const logError = require('./logError-4e2f2020.js');
|
|
9
9
|
const containsNonLatinChars = require('./containsNonLatinChars-2be5129b.js');
|
|
@@ -3,11 +3,11 @@
|
|
|
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 classes = require('./classes-b7918f56.js');
|
|
8
|
-
const paypal = require('./paypal-
|
|
8
|
+
const paypal = require('./paypal-eb07e9f5.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
10
|
-
const
|
|
10
|
+
const createCustomEvent = require('./createCustomEvent-2fe80338.js');
|
|
11
11
|
const getBorderRadius = require('./getBorderRadius-4413e191.js');
|
|
12
12
|
const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
|
|
13
13
|
const ILanguage = require('./ILanguage-98b04442.js');
|
|
@@ -190,18 +190,25 @@ const ZonosCheckoutFinish = class {
|
|
|
190
190
|
this.closeClick = index.createEvent(this, "closeClick", 7);
|
|
191
191
|
this.pullOrder = async () => {
|
|
192
192
|
var _a, _b;
|
|
193
|
-
const baseUrl = "https://v1.route.js.zonos.com";
|
|
194
193
|
const checkoutSessionId = cart.cartStore.checkoutSessionId;
|
|
195
|
-
const
|
|
194
|
+
const searchParams = new URLSearchParams();
|
|
195
|
+
searchParams.set('checkoutSessionId', checkoutSessionId || '');
|
|
196
|
+
const { baseUrl, errors, json } = await cart.handleFetch(`/api/zonos-elements/get-order?${searchParams.toString()}`);
|
|
196
197
|
if (errors.length || !(json === null || json === void 0 ? void 0 : json.id)) {
|
|
197
|
-
return
|
|
198
|
+
return {
|
|
199
|
+
baseUrl,
|
|
200
|
+
order: null,
|
|
201
|
+
};
|
|
198
202
|
}
|
|
199
203
|
// onOrderSuccess callback may be provided on Zonos.init
|
|
200
204
|
await ((_b = (_a = zonosStore.zonosStore.checkoutSettings).onOrderSuccess) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
201
205
|
zonosApiRoute: baseUrl,
|
|
202
206
|
zonosOrder: json,
|
|
203
207
|
}));
|
|
204
|
-
return
|
|
208
|
+
return {
|
|
209
|
+
baseUrl,
|
|
210
|
+
order: json,
|
|
211
|
+
};
|
|
205
212
|
};
|
|
206
213
|
this.redirectToUrl = (url) => {
|
|
207
214
|
// reset store and checkout session id before redirecting
|
|
@@ -233,9 +240,9 @@ const ZonosCheckoutFinish = class {
|
|
|
233
240
|
};
|
|
234
241
|
// 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
|
|
235
242
|
this.getPullOrder = async (attempts = 0) => {
|
|
236
|
-
const order = await this.pullOrder();
|
|
243
|
+
const { baseUrl, order } = await this.pullOrder();
|
|
237
244
|
if (order) {
|
|
238
|
-
void
|
|
245
|
+
void createCustomEvent.trackConversionEvent('checkout_orderCompleted');
|
|
239
246
|
this.order = order;
|
|
240
247
|
this.handleSuccessBehavior();
|
|
241
248
|
}
|
|
@@ -247,9 +254,8 @@ const ZonosCheckoutFinish = class {
|
|
|
247
254
|
else {
|
|
248
255
|
// Set loading to false to display generic success page and log error
|
|
249
256
|
this.isLoading = false;
|
|
250
|
-
const baseUrl = "https://v1.route.js.zonos.com";
|
|
251
257
|
const checkoutSessionId = cart.cartStore.checkoutSessionId;
|
|
252
|
-
void
|
|
258
|
+
void cart.sendErrorLog({
|
|
253
259
|
endpoint: `${baseUrl}/api/zonos-elements/get-order?checkoutSessionId=${checkoutSessionId}`,
|
|
254
260
|
errors: ['Order not found after multiple attempts'],
|
|
255
261
|
metadata: {
|
|
@@ -291,10 +297,10 @@ const ZonosCheckoutFinish = class {
|
|
|
291
297
|
}
|
|
292
298
|
else {
|
|
293
299
|
paypal.submitGtag('zonos-checkout-success');
|
|
294
|
-
void
|
|
300
|
+
void createCustomEvent.trackConversionEvent('checkout_paymentInfoCompleted', {
|
|
295
301
|
paymentMethod,
|
|
296
302
|
});
|
|
297
|
-
const successEvent =
|
|
303
|
+
const successEvent = createCustomEvent.createCustomEvent('zonos-checkout-success', {
|
|
298
304
|
message: 'Zonos Checkout successfully processed order',
|
|
299
305
|
});
|
|
300
306
|
document.dispatchEvent(successEvent);
|
|
@@ -373,12 +379,12 @@ const ZonosCheckoutFinish = class {
|
|
|
373
379
|
render() {
|
|
374
380
|
var _a, _b;
|
|
375
381
|
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);
|
|
376
|
-
const isTestMode =
|
|
377
|
-
return (index.h(index.Host, { key: '
|
|
382
|
+
const isTestMode = createCustomEvent.getIsTestMode();
|
|
383
|
+
return (index.h(index.Host, { key: 'ac24d728b66f975dc5f4abcc0e019577b92b5265', class: "zonos--checkout-finish zonos--elements", style: {
|
|
378
384
|
'--border-radius': getBorderRadius.getBorderRadius({
|
|
379
385
|
overrideBorderStyle: this.borderRadius,
|
|
380
386
|
}),
|
|
381
|
-
} }, this.isLoading && (index.h("div", { key: '
|
|
387
|
+
} }, this.isLoading && (index.h("div", { key: '5e445cb54f5a22f59823d502d6d20679568ccad9', class: "loading-wrapper" }, index.h("zonos-spinner", { key: 'c96e41437570caa001f3f5b8841a02d3896c2142' }))), !this.isLoading && (index.h("div", { key: '4a3f1cd814fa7d0bee7193d9ae3a39d170826944', class: "zonos--finish-details" }, index.h("div", { key: 'abc20383d6ddcfbe1833e8e846d629dcbabc83f9', class: "zonos--group" }, this.notificationType === 'success' ? (index.h("zonos-icon", { "aria-label": "Order success", content: SuccessIcon, iconColor: 'blue-800', size: 50 })) : (index.h("zonos-icon", { "aria-label": "Order failed", content: RemoveIcon, iconColor: 'red-800', size: 50 })), index.h("zonos-text", { key: 'ea5344bba3f55d026bf6f25a624f5bf94045f581', class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), orderId && (index.h("div", { key: '7622b546b79aefb379b70c1505b20a5c9926fc4d', class: "zonos--order-number" }, "Order #", orderId)), index.h("zonos-text", { key: '5748732fc28167b733ed917645db52b88522238f', textColor: "gray-600" }, this.notificationMessages.map(message => (index.h(index.Fragment, null, message, index.h("br", null))))), index.h("zonos-button", { key: 'd83ebfc701253978240eeccf685f4ea03ce1e25a', onClick: () => this.closeClickHandler(), size: "md", variant: "primary" }, this.notificationActionText)), isTestMode && cart.cartStore.step === 'finish' && (index.h("div", { key: '5c08c8322043cde4c7ad687cc53d6b4ad9f94233', class: "zonos--finish-button-wrapper" }, index.h("zonos-button", { key: '8e69a15a544893304d143071e1321c6a4cd455c3', backgroundColor: "gray-0", buttonColor: "gray-1200", onClick: () => this.closeClickHandler(), size: "lg", variant: "outline" }, "New test cart"), index.h("zonos-button", { key: '132b343fef61cea8063dca9afc55e708226fa166', onClick: () => this.redirectToUrl(`/orders/all`), size: "lg", variant: "primary" }, "View order in Dashboard")))))));
|
|
382
388
|
}
|
|
383
389
|
static get assetsDirs() { return ["assets"]; }
|
|
384
390
|
};
|
|
@@ -488,7 +494,7 @@ const ZonosCheckoutPayment = class {
|
|
|
488
494
|
if (this.showErrorBanner) {
|
|
489
495
|
this.showErrorBanner = !this.handleValidate();
|
|
490
496
|
}
|
|
491
|
-
const isTestMode =
|
|
497
|
+
const isTestMode = createCustomEvent.getIsTestMode();
|
|
492
498
|
const hasPaypalEnabled = paypal.paypalStoreHasPaypalEnabled();
|
|
493
499
|
return (index.h(index.Host, { class: "zonos--checkout-payment zonos--elements" }, index.h("div", { class: "zonos--group" }, index.h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, cart.translate('Payment method')), this.showErrorBanner && (index.h("zonos-banner", { class: "zonos--error-banner", intent: "error" }, cart.translate('Missing required fields. Make sure all fields are completed.'))), cart.stripeStore.hasPaymentError && (index.h("zonos-banner", { class: "zonos--payment-error-banner", intent: "error" }, cart.translate("We couldn't complete your payment. Please verify the payment details and try again."))), paypal.paypalStore.paypalErrorMessage && (index.h("zonos-banner", { class: "zonos--payment-error-banner", intent: "error" }, paypal.paypalStore.paypalErrorMessage)), index.h("zonos-payment", null), index.h("div", { class: "zonos--group-btn" }, index.h("zonos-button", { backgroundColor: this.submitBtnColor, loading: this.continueLoading, onClick: () => this.continueClickHandler(), size: "lg",
|
|
494
500
|
// use primary type when on mobile mode
|
|
@@ -789,7 +795,7 @@ const ZonosCustomerInfo = class {
|
|
|
789
795
|
this.continueClicked.emit();
|
|
790
796
|
// submit google tag when the form is complete
|
|
791
797
|
paypal.submitGtag('zonos-checkout-customer-info');
|
|
792
|
-
void
|
|
798
|
+
void createCustomEvent.trackConversionEvent('checkout_customerInfoCompleted');
|
|
793
799
|
};
|
|
794
800
|
this.handleValidate = () => {
|
|
795
801
|
const stripeShippingAddressEventData = cart.stripeStore.stripeAddressEventData;
|
|
@@ -1036,7 +1042,7 @@ const ZonosShipping = class {
|
|
|
1036
1042
|
this.continueClicked.emit();
|
|
1037
1043
|
// submit google tag when the form is complete
|
|
1038
1044
|
paypal.submitGtag('zonos-checkout-shipping-info');
|
|
1039
|
-
void
|
|
1045
|
+
void createCustomEvent.trackConversionEvent('checkout_shippingInfoCompleted', {
|
|
1040
1046
|
serviceLevelId: (_a = this.selectedShippingMethod) === null || _a === void 0 ? void 0 : _a.value,
|
|
1041
1047
|
});
|
|
1042
1048
|
};
|