@zonos/elements 1.3.139 → 1.3.141
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-0070bff2.js → cart-e1b59d03.js} +180 -1
- package/dist/cjs/index.cjs.js +41 -13
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{paypal-7c8a99b0.js → paypal-86cc51e4.js} +13 -1
- package/dist/cjs/zonos-address_7.cjs.entry.js +1 -1
- package/dist/cjs/zonos-cart-items_13.cjs.entry.js +49 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +5 -3
- package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
- 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-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
- 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-payment/zonos-checkout-payment.js +24 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -2
- package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +11 -4
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +1 -1
- package/dist/collection/components/store/checkout/paypal.js +14 -1
- package/dist/collection/components/store/checkout/stripe.js +9 -0
- package/dist/collection/components/store/hello/localization.js +3 -1
- package/dist/collection/components/store/translationStore/strings.arabic.js +6 -0
- package/dist/collection/components/store/translationStore/strings.base.js +6 -0
- package/dist/collection/components/store/translationStore/strings.chinese.js +6 -0
- package/dist/collection/components/store/translationStore/strings.danish.js +6 -0
- package/dist/collection/components/store/translationStore/strings.dutch.js +6 -0
- package/dist/collection/components/store/translationStore/strings.french.js +6 -0
- package/dist/collection/components/store/translationStore/strings.german.js +6 -0
- package/dist/collection/components/store/translationStore/strings.hebrew.js +6 -0
- package/dist/collection/components/store/translationStore/strings.indonesian.js +6 -0
- package/dist/collection/components/store/translationStore/strings.italian.js +6 -0
- package/dist/collection/components/store/translationStore/strings.japanese.js +6 -0
- package/dist/collection/components/store/translationStore/strings.korean.js +6 -0
- package/dist/collection/components/store/translationStore/strings.norwegian.js +6 -0
- package/dist/collection/components/store/translationStore/strings.polish.js +6 -0
- package/dist/collection/components/store/translationStore/strings.portuguese.js +6 -0
- package/dist/collection/components/store/translationStore/strings.russian.js +6 -0
- package/dist/collection/components/store/translationStore/strings.spanish.js +6 -0
- package/dist/collection/components/store/translationStore/strings.swedish.js +6 -0
- package/dist/collection/components/store/translationStore/strings.turkish.js +6 -0
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +6 -0
- package/dist/collection/components/utils/api/getCheckoutSession.js +14 -0
- package/dist/collection/components/utils/resetToSelectedTab.js +17 -0
- package/dist/collection/components/utils/validateCheckoutSession.js +39 -0
- package/dist/collection/scripts/_zonosBase.js +34 -6
- package/dist/esm/{cart-e5fb3abe.js → cart-709f053f.js} +181 -3
- package/dist/esm/index.js +41 -13
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{paypal-9636651e.js → paypal-77a60c44.js} +13 -1
- package/dist/esm/zonos-address_7.entry.js +1 -1
- package/dist/esm/zonos-cart-items_13.entry.js +49 -7
- package/dist/esm/zonos-checkout.entry.js +5 -3
- package/dist/esm/zonos-controller.entry.js +1 -1
- 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-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm/zonos-hello.entry.js +2 -2
- 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-709f053f.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/paypal-77a60c44.js +17 -0
- package/dist/esm-es5/zonos-address_7.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_13.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-elements.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 +1 -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/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.d.ts +6 -0
- package/dist/types/components/store/checkout/stripe.d.ts +4 -0
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.base.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.danish.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.french.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.german.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.italian.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.korean.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.polish.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.russian.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +6 -0
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +6 -0
- package/dist/types/components/store/translationStore.d.ts +1 -1
- package/dist/types/components/utils/api/getCheckoutSession.d.ts +9 -0
- package/dist/types/components/utils/resetToSelectedTab.d.ts +12 -0
- package/dist/types/components/utils/validateCheckoutSession.d.ts +9 -0
- package/dist/types/scripts/_zonosBase.d.ts +1 -0
- package/dist/types/types/checkout/api/CheckoutSession.d.ts +5 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +112 -0
- package/dist/types/types/generated/graphql.internal.types.ts +102 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-85545d0b.system.entry.js → p-01ad5be8.system.entry.js} +1 -1
- package/dist/zonos-elements/p-0c027d2e.entry.js +1 -0
- package/dist/zonos-elements/{p-d66cbed3.system.entry.js → p-1c4ff7b2.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-30f75fc0.system.entry.js → p-22d69480.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3316bcb0.system.entry.js → p-25c7e4fa.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-456d8ac3.system.entry.js → p-289ded20.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-f8d7bad6.entry.js → p-35b8dcde.entry.js} +1 -1
- package/dist/zonos-elements/{p-daf800c5.system.entry.js → p-49e4ca08.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d374ef35.system.entry.js → p-64a04391.system.entry.js} +1 -1
- package/dist/zonos-elements/p-6b0aa1bb.system.js +17 -0
- package/dist/zonos-elements/{p-59f7cc80.entry.js → p-8368a79e.entry.js} +1 -1
- package/dist/zonos-elements/{p-e176da08.system.entry.js → p-896d62a4.system.entry.js} +1 -1
- package/dist/zonos-elements/p-8f9affb3.system.entry.js +1 -0
- package/dist/zonos-elements/p-a58731ec.system.js +1 -0
- package/dist/zonos-elements/{p-9138a10d.entry.js → p-ad1d6ea2.entry.js} +1 -1
- package/dist/zonos-elements/p-afffdfc2.js +1 -0
- package/dist/zonos-elements/{p-3f71bac6.entry.js → p-b832ec52.entry.js} +1 -1
- package/dist/zonos-elements/{p-0931f518.entry.js → p-b9efc660.entry.js} +1 -1
- package/dist/zonos-elements/p-be2feba6.entry.js +1 -0
- package/dist/zonos-elements/p-c78dd680.system.js +1 -1
- package/dist/zonos-elements/{p-244fe3a1.system.entry.js → p-cf72603f.system.entry.js} +1 -1
- package/dist/zonos-elements/p-d35376d3.js +17 -0
- package/dist/zonos-elements/{p-035571bf.entry.js → p-e6c31531.entry.js} +1 -1
- package/dist/zonos-elements/{p-99190477.entry.js → p-f2867195.entry.js} +1 -1
- package/dist/zonos-elements/{p-d58b6247.entry.js → p-f8ca3e71.entry.js} +1 -1
- package/dist/zonos-elements/p-f8e8b50e.system.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +2 -1
- package/dist/esm-es5/cart-e5fb3abe.js +0 -1
- package/dist/esm-es5/paypal-9636651e.js +0 -17
- package/dist/zonos-elements/p-1037c75b.system.js +0 -1
- package/dist/zonos-elements/p-4e4a45cb.js +0 -17
- package/dist/zonos-elements/p-75048606.system.js +0 -1
- package/dist/zonos-elements/p-79a8c9ef.system.js +0 -17
- package/dist/zonos-elements/p-b7652a21.system.entry.js +0 -1
- package/dist/zonos-elements/p-e3112267.entry.js +0 -1
- package/dist/zonos-elements/p-f64e4276.js +0 -1
- package/dist/zonos-elements/p-f66fbfe8.entry.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadScript, } from "@paypal/paypal-js";
|
|
2
2
|
import { createStore } from "@stencil/store";
|
|
3
3
|
import { cartStore, cartStoreClearCheckoutInterval, cartStoreNextStep, } from "./cart";
|
|
4
|
-
import { stripeStoreHandleInventoryCheck } from "./stripe";
|
|
4
|
+
import { stripeStore, stripeStoreHandleInventoryCheck, } from "./stripe";
|
|
5
5
|
import { translate } from "../translationStore";
|
|
6
6
|
import { zonosStore } from "../zonosStore";
|
|
7
7
|
import { paypalCaptureOrder } from "../../utils/api/paypalCaptureOrder";
|
|
@@ -11,6 +11,7 @@ import { jsonParse } from "../../utils/jsonParse";
|
|
|
11
11
|
import { log } from "../../utils/logging/log";
|
|
12
12
|
import { logError } from "../../utils/logging/logError";
|
|
13
13
|
import { submitGtag } from "../../utils/submitGtag";
|
|
14
|
+
import { validateCheckoutSession } from "../../utils/validateCheckoutSession";
|
|
14
15
|
const { reset: paypalStoreReset, state: paypalStore } = createStore(() => ({
|
|
15
16
|
orderIdCreated: null,
|
|
16
17
|
paypalButtons: [],
|
|
@@ -73,6 +74,15 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
73
74
|
});
|
|
74
75
|
return {
|
|
75
76
|
createOrder: async () => {
|
|
77
|
+
const checkoutSessionStatus = await validateCheckoutSession();
|
|
78
|
+
if (!checkoutSessionStatus.valid) {
|
|
79
|
+
paypalStore.paypalErrorMessage = checkoutSessionStatus.errorMessage;
|
|
80
|
+
// reset stripe error message
|
|
81
|
+
stripeStore.hasPaymentError = false;
|
|
82
|
+
stripeStore.customErrorMessage = null;
|
|
83
|
+
onPaypalFail === null || onPaypalFail === void 0 ? void 0 : onPaypalFail();
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
76
86
|
try {
|
|
77
87
|
// reset paypal error banner
|
|
78
88
|
paypalStore.paypalErrorMessage = null;
|
|
@@ -99,6 +109,9 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
99
109
|
catch (err) {
|
|
100
110
|
logError('Failed to create paypal order', err);
|
|
101
111
|
paypalStore.paypalErrorMessage = translate('Failed to create PayPal order. Please try again, or consider using an alternative method.');
|
|
112
|
+
// reset stripe error message
|
|
113
|
+
stripeStore.hasPaymentError = false;
|
|
114
|
+
stripeStore.customErrorMessage = null;
|
|
102
115
|
// trigger fail event
|
|
103
116
|
onPaypalFail === null || onPaypalFail === void 0 ? void 0 : onPaypalFail();
|
|
104
117
|
return '';
|
|
@@ -13,10 +13,12 @@ import { jsonParse } from "../../utils/jsonParse";
|
|
|
13
13
|
import { log } from "../../utils/logging/log";
|
|
14
14
|
import { logError } from "../../utils/logging/logError";
|
|
15
15
|
import { sendErrorLog } from "../../utils/logging/sendErrorLog";
|
|
16
|
+
import { validateCheckoutSession } from "../../utils/validateCheckoutSession";
|
|
16
17
|
import { addressRuleStyle } from "../../../styles/stripe/addressRuleStyle";
|
|
17
18
|
import { defaultVariable } from "../../../styles/stripe/defaultVariable";
|
|
18
19
|
const { onChange, reset, state: stripeStore, } = createStore(() => ({
|
|
19
20
|
clientSecret: sessionStorage.getItem('zonos--client-secret') || null,
|
|
21
|
+
customErrorMessage: null,
|
|
20
22
|
fetchingLandedCostAbortController: null,
|
|
21
23
|
hasPaymentError: false,
|
|
22
24
|
isFetchingLandedCost: false,
|
|
@@ -464,9 +466,16 @@ const stripeStoreConfirmPayment = async () => {
|
|
|
464
466
|
const stripeElements = stripeStore.stripeElements;
|
|
465
467
|
const stripe = stripeStore.stripe;
|
|
466
468
|
const stripeClientSecret = stripeStore.clientSecret;
|
|
469
|
+
stripeStore.customErrorMessage = null;
|
|
467
470
|
if (!((_b = cartStore.selectedLandedCost) === null || _b === void 0 ? void 0 : _b.landedCost.id)) {
|
|
468
471
|
throw new Error('Attempted to confirm the payment when no landed cost is found in store');
|
|
469
472
|
}
|
|
473
|
+
// Check if the checkout session is valid before proceeding
|
|
474
|
+
const checkoutSessionStatus = await validateCheckoutSession();
|
|
475
|
+
if (!checkoutSessionStatus.valid) {
|
|
476
|
+
stripeStore.customErrorMessage = checkoutSessionStatus.errorMessage;
|
|
477
|
+
throw new Error(checkoutSessionStatus.errorMessage);
|
|
478
|
+
}
|
|
470
479
|
if (stripe &&
|
|
471
480
|
stripeElements &&
|
|
472
481
|
stripePaymentReady &&
|
|
@@ -95,6 +95,7 @@ const getNewLocalization = async () => {
|
|
|
95
95
|
startExchangeRateTimeout({ isGuaranteed, maxAge });
|
|
96
96
|
};
|
|
97
97
|
const getCustomMessages = async () => {
|
|
98
|
+
log(`Getting custom messages for ${localizationStore.selectedCountryCode}`);
|
|
98
99
|
if (!localizationStore.selectedCountryCode || !zonosStore.storeId) {
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
@@ -154,7 +155,6 @@ const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
|
|
|
154
155
|
}
|
|
155
156
|
localizationStore.targetCurrency = currencyCode;
|
|
156
157
|
void getNewLocalization();
|
|
157
|
-
void getCustomMessages();
|
|
158
158
|
// Save the country code to session storage for later use
|
|
159
159
|
window.sessionStorage.setItem('zonos--country', selectedCountryCode);
|
|
160
160
|
// Update the URL query param with the new country code
|
|
@@ -215,6 +215,7 @@ const localizationStoreUpdateSelectedLocale = (newSelectedLocale) => {
|
|
|
215
215
|
localizationStore.selectedLocale = newSelectedLocale;
|
|
216
216
|
translationStoreUpdateLanguage(newSelectedLocale);
|
|
217
217
|
void updateCheckoutSessionLanguage();
|
|
218
|
+
void getCustomMessages();
|
|
218
219
|
};
|
|
219
220
|
const initLocalizationStore = async () => {
|
|
220
221
|
// all countries from countries.json, shipping zone and localization
|
|
@@ -230,6 +231,7 @@ const initLocalizationStore = async () => {
|
|
|
230
231
|
initHelloCountryList(allCountries || {});
|
|
231
232
|
const { country, locale } = localization;
|
|
232
233
|
log(`Country code from localization: ${country}`);
|
|
234
|
+
log(`Locale from localization: ${locale}`);
|
|
233
235
|
// update selected country code in store
|
|
234
236
|
localizationStoreUpdateSelectedCountryCode(country);
|
|
235
237
|
// use locale from params if it exists, otherwise use locale from localization
|
|
@@ -170,6 +170,9 @@ export const stringsArabic = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'لم يتم العثور على دول',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'لم يتم اختيار تقييم الشحنة. يرجى العودة إلى خطوة "الشحن" واختيار تقييم الشحنة للمتابعة.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'لم يتم تحديد طريقة الشحن',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsArabic = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'تعذر التحقق من المخزون. حاول مرة أخرى.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'غير قادر على استرداد جلسة الدفع في الوقت الحالي. يرجى المحاولة مرة أخرى أو الاتصال بفريق الدعم لدينا.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'تحديث العنوان',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsBase = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'No countries found',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'No shipping method selected',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsBase = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Unable to check inventory. Please try again.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Update address',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsChinese = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: '未找到国家',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: '未选择运费评级。请返回到"运输"步骤并选择运费评级以继续。',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: '未选择运输方式',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsChinese = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: '无法检查库存。请再试一次。',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: '目前无法检索结账会话。请重试或联系我们的支持团队。',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: '更新地址',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsDanish = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Ingen lande fundet',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Ingen forsendelsesvurdering valgt. Gå venligst tilbage til "Forsendelse"-trinnet og vælg en forsendelsesvurdering for at fortsætte.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Ingen leveringsmetode valgt',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsDanish = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Kunne ikke tjekke lagerbeholdningen. Prøv venligst igen.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Kan ikke hente betalingssessionen i øjeblikket. Prøv venligst igen eller kontakt vores supportteam.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Opdater adresse',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsDutch = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Geen landen gevonden',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Geen verzendbeoordeling geselecteerd. Ga alstublieft terug naar de stap "Verzending" en selecteer een verzendbeoordeling om door te gaan.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Geen verzendmethode geselecteerd',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsDutch = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Kon de voorraad niet controleren. Probeer het opnieuw.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Kan de betaal sessie momenteel niet ophalen. Probeer het opnieuw of neem contact op met ons ondersteuningsteam.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Adres bijwerken',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsFrench = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Aucun pays trouvé',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: `Aucune évaluation d'expédition sélectionnée. Veuillez revenir à l'étape "Expédition" et sélectionner une évaluation d'expédition pour continuer.`,
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Aucune méthode de livraison sélectionnée',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsFrench = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: "Impossible de vérifier l'inventaire. Veuillez réessayer.",
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: "Impossible de récupérer la session de paiement pour le moment. Veuillez réessayer ou contacter notre équipe d'assistance.",
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: "Mettre à jour l'adresse",
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsGerman = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Keine Länder gefunden',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Keine Versandbewertung ausgewählt. Bitte gehen Sie zurück zum Schritt "Versand" und wählen Sie eine Versandbewertung aus, um fortzufahren.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Keine Versandart ausgewählt',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsGerman = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Inventar konnte nicht überprüft werden. Bitte versuchen Sie es erneut.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Die Checkout-Sitzung kann momentan nicht abgerufen werden. Bitte versuchen Sie es erneut oder kontaktieren Sie unser Support-Team.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Adresse aktualisieren',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsHebrew = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'לא נמצאו מדינות',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'לא נבחר דירוג משלוח. אנא חזור לשלב "משלוח" ובחר דירוג משלוח כדי להמשיך.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'לא נבחרה שיטת משלוח',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsHebrew = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'לא ניתן היה לבדוק את המלאי. אנא נסה שוב.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'לא ניתן לאחזר את מושב התשלום כרגע. אנא נסה שוב או צור קשר עם צוות התמיכה שלנו.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'עדכון כתובת',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsIndonesian = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Tidak ada negara yang ditemukan',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Tidak ada penilaian pengiriman yang dipilih. Silakan kembali ke langkah "Pengiriman" dan pilih penilaian pengiriman untuk melanjutkan.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Tidak ada metode pengiriman yang dipilih',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsIndonesian = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Tidak dapat memeriksa inventaris. Silakan coba lagi.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Tidak dapat mengambil sesi checkout saat ini. Silakan coba lagi atau hubungi tim dukungan kami.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Perbarui alamat',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsItalian = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Nessun paese trovato',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Nessuna valutazione di spedizione selezionata. Si prega di tornare al passaggio "Spedizione" e selezionare una valutazione di spedizione per procedere.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Nessun metodo di spedizione selezionato',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsItalian = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: "Impossibile verificare l'inventario. Si prega di riprovare.",
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Impossibile recuperare la sessione di pagamento al momento. Si prega di riprovare o contattare il nostro team di supporto.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Aggiorna indirizzo',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsJapanese = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: '国が見つかりません',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: '配送評価が選択されていません。「配送」ステップに戻り、配送評価を選択して続行してください。',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: '配送方法が選択されていません',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsJapanese = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: '在庫を確認できません。再試行してください。',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: '現在、チェックアウトセッションを取得できません。もう一度お試しいただくか、サポートチームにお問い合わせください。',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: '住所を更新',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsKorean = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: '국가를 찾을 수 없습니다',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: '배송 등급이 선택되지 않았습니다. "배송" 단계로 돌아가서 배송 등급을 선택하여 진행하세요.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: '선택된 배송 방법이 없습니다',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsKorean = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: '재고를 확인할 수 없습니다. 다시 시도해 주세요.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: '현재 결제 세션을 가져올 수 없습니다. 다시 시도하거나 지원 팀에 문의하십시오.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: '주소 업데이트',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsNorwegian = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Ingen land funnet',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Ingen forsendelsesvurdering valgt. Vennligst gå tilbake til "Frakt"-trinnet og velg en forsendelsesvurdering for å fortsette.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Ingen fraktmetode valgt',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsNorwegian = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Kunne ikke sjekke lagerbeholdningen. Vennligst prøv igjen.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Kan ikke hente utsjekkingsøkten for øyeblikket. Vennligst prøv igjen eller kontakt vårt supportteam.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Oppdater adresse',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsPolish = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Nie znaleziono krajów',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Nie wybrano oceny przesyłki. Proszę wrócić do kroku "Wysyłka" i wybrać ocenę przesyłki, aby kontynuować.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Nie wybrano metody wysyłki',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsPolish = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Nie można sprawdzić stanu magazynu. Spróbuj ponownie.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Nie można pobrać sesji kasy w tej chwili. Proszę spróbować ponownie lub skontaktować się z naszym zespołem wsparcia.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Zaktualizuj adres',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsPortuguese = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Nenhum país encontrado',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Nenhuma classificação de envio selecionada. Por favor, volte para a etapa de "Envio" e selecione uma classificação de envio para prosseguir.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Nenhum método de envio selecionado',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsPortuguese = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Não foi possível verificar o inventário. Por favor, tente novamente.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Não é possível recuperar a sessão de checkout no momento. Por favor, tente novamente ou entre em contato com nossa equipe de suporte.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Atualizar endereço',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsRussian = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Страны не найдены',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Не выбран рейтинг доставки. Пожалуйста, вернитесь к шагу "Доставка" и выберите рейтинг доставки, чтобы продолжить.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Метод доставки не выбран',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsRussian = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Не удалось проверить наличие на складе. Пожалуйста, попробуйте снова.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Не удается получить сеанс оформления заказа в данный момент. Пожалуйста, попробуйте еще раз или свяжитесь с нашей службой поддержки.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Обновить адрес',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsSpanish = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'No se encontraron países',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'No se ha seleccionado una calificación de envío. Por favor, regrese al paso de "Envío" y seleccione una calificación de envío para continuar.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'No se ha seleccionado un método de envío',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsSpanish = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'No se pudo verificar el inventario. Por favor, inténtelo de nuevo.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'No se puede recuperar la sesión de pago en este momento. Por favor, inténtelo de nuevo o contacte a nuestro equipo de soporte.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Actualizar dirección',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsSwedish = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Inga länder hittades',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Ingen fraktbedömning vald. Gå tillbaka till steget "Frakt" och välj en fraktbedömning för att fortsätta.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Ingen fraktmetod vald',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsSwedish = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Det gick inte att kontrollera lagret. Försök igen.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Kan inte hämta betalningssessionen just nu. Försök igen eller kontakta vårt supportteam.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Uppdatera adress',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsTurkish = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Ülke bulunamadı',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Gönderi derecelendirmesi seçilmedi. Lütfen "Kargo" adımına geri dönün ve devam etmek için bir gönderi derecelendirmesi seçin.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Kargo yöntemi seçilmedi',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsTurkish = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Envanter kontrol edilemedi. Lütfen tekrar deneyin.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Şu anda ödeme oturumunu alamıyoruz. Lütfen tekrar deneyin veya destek ekibimizle iletişime geçin.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Adresi güncelle',
|
|
370
376
|
},
|
|
@@ -170,6 +170,9 @@ export const stringsVietnamese = {
|
|
|
170
170
|
'No countries found': {
|
|
171
171
|
value: 'Không tìm thấy quốc gia nào',
|
|
172
172
|
},
|
|
173
|
+
'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
|
|
174
|
+
value: 'Chưa chọn đánh giá vận chuyển. Vui lòng quay lại bước "Vận chuyển" và chọn đánh giá vận chuyển để tiếp tục.',
|
|
175
|
+
},
|
|
173
176
|
'No shipping method selected': {
|
|
174
177
|
value: 'Chưa chọn phương thức vận chuyển',
|
|
175
178
|
},
|
|
@@ -365,6 +368,9 @@ export const stringsVietnamese = {
|
|
|
365
368
|
'Unable to check inventory. Please try again.': {
|
|
366
369
|
value: 'Không thể kiểm tra hàng tồn kho. Vui lòng thử lại.',
|
|
367
370
|
},
|
|
371
|
+
'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
|
|
372
|
+
value: 'Không thể truy xuất phiên thanh toán vào lúc này. Vui lòng thử lại hoặc liên hệ với đội ngũ hỗ trợ của chúng tôi.',
|
|
373
|
+
},
|
|
368
374
|
'Update address': {
|
|
369
375
|
value: 'Cập nhật địa chỉ',
|
|
370
376
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cartStore } from "../../store/checkout/cart";
|
|
2
|
+
import { handleFetch } from "../handleFetch";
|
|
3
|
+
export const getCheckoutSession = async () => {
|
|
4
|
+
if (!cartStore.checkoutSessionId) {
|
|
5
|
+
return {
|
|
6
|
+
errors: [{ message: 'No checkout session id found' }],
|
|
7
|
+
json: null,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
11
|
+
searchParams.set('checkoutSessionId', cartStore.checkoutSessionId);
|
|
12
|
+
const { errors, json } = await handleFetch(`/api/zonos-elements/get-checkout-session?${searchParams.toString()}`);
|
|
13
|
+
return { errors, json };
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reset any done tabs after selected tab to undone. This is to force user to go through all tabs again
|
|
3
|
+
*/
|
|
4
|
+
export const resetToSelectedTab = ({ selectedTab, tabList, }) => {
|
|
5
|
+
const selectedTabIndex = tabList[selectedTab].index;
|
|
6
|
+
// Any tab after the selected tab should be reset
|
|
7
|
+
const tabsToReset = Object.values(tabList)
|
|
8
|
+
.slice(selectedTabIndex - 1, Object.keys(tabList).length)
|
|
9
|
+
.map(tab => tab.value);
|
|
10
|
+
const newTabList = Object.assign({}, tabList);
|
|
11
|
+
Object.values(newTabList).forEach(tab => {
|
|
12
|
+
if (tabsToReset.includes(tab.value)) {
|
|
13
|
+
tab.isDone = false;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return newTabList;
|
|
17
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { translate } from "../store/translationStore";
|
|
2
|
+
import { getCheckoutSession } from "./api/getCheckoutSession";
|
|
3
|
+
import { allLogs } from "./logging/log";
|
|
4
|
+
import { logError } from "./logging/logError";
|
|
5
|
+
import { sendErrorLog } from "./logging/sendErrorLog";
|
|
6
|
+
/**
|
|
7
|
+
* Validate checkout session before confirming payment
|
|
8
|
+
*/
|
|
9
|
+
export const validateCheckoutSession = async () => {
|
|
10
|
+
var _a;
|
|
11
|
+
// get checkout session info
|
|
12
|
+
const { errors, json } = await getCheckoutSession();
|
|
13
|
+
if (errors.length || !json) {
|
|
14
|
+
logError('Failed to retrieve checkout session info before confirming payment ', errors);
|
|
15
|
+
void sendErrorLog({
|
|
16
|
+
endpoint: 'validateCheckoutSession',
|
|
17
|
+
errors: errors.map(error => error.message),
|
|
18
|
+
metadata: { allLogs },
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
errorMessage: translate('Unable to retrieve the checkout session at the moment. Please try again or contact our support team.'),
|
|
22
|
+
valid: false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Make sure landed cost is found in the checkout session
|
|
26
|
+
if (!((_a = json.checkoutSession.landedCost) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
27
|
+
logError('Landed cost is not found in the checkout session before confirming payment.');
|
|
28
|
+
void sendErrorLog({
|
|
29
|
+
endpoint: 'validateCheckoutSession',
|
|
30
|
+
errors: ['No landed cost found before confirming payment'],
|
|
31
|
+
metadata: { allLogs },
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
errorMessage: translate('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),
|
|
35
|
+
valid: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return { errorMessage: '', valid: true };
|
|
39
|
+
};
|