@zonos/elements 1.3.45 → 1.3.47
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-85870c2e.js} +187 -62
- package/dist/cjs/{sendErrorLog-a966a8c1.js → createCustomEvent-aacc2833.js} +2 -22
- package/dist/cjs/index.cjs.js +13 -8
- package/dist/cjs/{paypal-1a1882c4.js → paypal-e4428dbf.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 +84 -20
- package/dist/collection/components/utils/logging/sendErrorLog.js +33 -6
- package/dist/collection/components/utils/logging/sendLoadScriptLog.js +1 -1
- package/dist/collection/environment.js +15 -78
- package/dist/collection/scripts/_getZonosQaUrl.js +6 -2
- package/dist/collection/scripts/_zonosBase.js +1 -0
- 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-3aae6236.js} +188 -64
- package/dist/esm/{sendErrorLog-aea606c0.js → createCustomEvent-ccb20b48.js} +3 -22
- package/dist/esm/index.js +13 -8
- package/dist/esm/{paypal-f4bb6ce7.js → paypal-b1589e7b.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-3aae6236.js} +1 -1
- package/dist/esm-es5/createCustomEvent-ccb20b48.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/paypal-b1589e7b.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 +11 -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/components/utils/logging/sendErrorLog.d.ts +7 -1
- package/dist/types/environment.d.ts +8 -9
- package/dist/types/scripts/_getNextFallbackUrl.d.ts +1 -1
- package/dist/types/scripts/_zonosBase.d.ts +5 -0
- 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-7b8099ed.js → p-08a43211.js} +1 -1
- package/dist/zonos-elements/p-1738fe3f.entry.js +1 -0
- package/dist/zonos-elements/p-284520ae.js +17 -0
- package/dist/zonos-elements/{p-578f42c1.entry.js → p-3225705b.entry.js} +1 -1
- package/dist/zonos-elements/{p-8630168f.system.entry.js → p-3403a81a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3fb9e320.system.js +17 -0
- package/dist/zonos-elements/{p-acf9a97e.system.entry.js → p-3fd66f5b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8bf1af28.entry.js → p-57c67bbf.entry.js} +1 -1
- package/dist/zonos-elements/{p-4204ccf9.system.entry.js → p-6d613cee.system.entry.js} +1 -1
- package/dist/zonos-elements/p-7d0663ab.system.entry.js +1 -0
- package/dist/zonos-elements/{p-7bd28076.system.entry.js → p-8949d4a2.system.entry.js} +1 -1
- package/dist/zonos-elements/p-8b02985f.entry.js +1 -0
- package/dist/zonos-elements/p-90935326.system.entry.js +1 -0
- package/dist/zonos-elements/{p-c7952400.entry.js → p-9c9e8288.entry.js} +1 -1
- package/dist/zonos-elements/{p-43d3cafd.system.js → p-a576cbb8.system.js} +1 -1
- package/dist/zonos-elements/p-aa0127b3.system.js +1 -0
- package/dist/zonos-elements/{p-d014791e.entry.js → p-b9815df4.entry.js} +1 -1
- package/dist/zonos-elements/{p-ca0a5c22.system.entry.js → p-c035c64f.system.entry.js} +1 -1
- package/dist/zonos-elements/p-c3ca9e48.system.entry.js +1 -0
- package/dist/zonos-elements/p-c78dd680.system.js +1 -1
- package/dist/zonos-elements/{p-5845029a.system.entry.js → p-d5741e4e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8618e185.entry.js → p-d5b21512.entry.js} +1 -1
- package/dist/zonos-elements/{p-37c9fdd2.system.entry.js → p-e4033aa7.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-567b457b.entry.js → p-ea58a4a6.entry.js} +1 -1
- package/dist/zonos-elements/{p-f9754e48.entry.js → p-ed496e98.entry.js} +1 -1
- package/dist/zonos-elements/p-eefeab02.js +1 -0
- package/dist/zonos-elements/p-f25559fd.entry.js +1 -0
- package/dist/zonos-elements/p-f9b50965.system.js +1 -0
- 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,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-85870c2e.js');
|
|
7
7
|
const classes = require('./classes-b7918f56.js');
|
|
8
|
-
const paypal = require('./paypal-
|
|
8
|
+
const paypal = require('./paypal-e4428dbf.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
10
|
-
const
|
|
10
|
+
const createCustomEvent = require('./createCustomEvent-aacc2833.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
|
};
|
|
@@ -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-85870c2e.js');
|
|
7
|
+
const paypal = require('./paypal-e4428dbf.js');
|
|
8
8
|
const zonosStore = require('./zonosStore-56401fdb.js');
|
|
9
|
-
const
|
|
9
|
+
const createCustomEvent = require('./createCustomEvent-aacc2833.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-85870c2e.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-85870c2e.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-85870c2e.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-85870c2e.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-85870c2e.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-85870c2e.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-85870c2e.js');
|
|
9
9
|
const logError = require('./logError-4e2f2020.js');
|
|
10
|
-
const paypal = require('./paypal-
|
|
10
|
+
const paypal = require('./paypal-e4428dbf.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
|
});
|