@zonos/elements 1.3.188 → 1.3.190
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/{CheckoutConfig-f1442a60.js → CheckoutConfig-4afc683b.js} +2 -0
- package/dist/cjs/TaxId-12acedde.js +94 -0
- package/dist/cjs/{cart-f9df3ac8.js → cart-27f6c7a4.js} +60 -0
- package/dist/cjs/index.cjs.js +35 -9
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{paypal-5e73c8f5.js → paypal-84d83a76.js} +1 -1
- package/dist/cjs/zonos-address_11.cjs.entry.js +61 -4
- package/dist/cjs/zonos-cart-items_13.cjs.entry.js +37 -31
- package/dist/cjs/zonos-checkout.cjs.entry.js +16 -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-empty-state-payment_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +1 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +31 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +14 -28
- package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.js +1 -1
- package/dist/collection/components/store/translationStore/strings.arabic.js +3 -0
- package/dist/collection/components/store/translationStore/strings.base.js +3 -0
- package/dist/collection/components/store/translationStore/strings.chinese.js +3 -0
- package/dist/collection/components/store/translationStore/strings.danish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.dutch.js +3 -0
- package/dist/collection/components/store/translationStore/strings.french.js +3 -0
- package/dist/collection/components/store/translationStore/strings.german.js +3 -0
- package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -0
- package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.italian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.japanese.js +3 -0
- package/dist/collection/components/store/translationStore/strings.korean.js +3 -0
- package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.polish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -0
- package/dist/collection/components/store/translationStore/strings.russian.js +3 -0
- package/dist/collection/components/store/translationStore/strings.spanish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.swedish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.turkish.js +3 -0
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -0
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +65 -1
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +50 -2
- package/dist/collection/components/utils/taxIdValidationResult.js +23 -2
- package/dist/collection/scripts/_zonosBase.js +25 -1
- package/dist/collection/types/checkout/CheckoutConfig.js +1 -0
- package/dist/collection/types/checkout/TaxId.js +64 -0
- package/dist/esm/{CheckoutConfig-5479d192.js → CheckoutConfig-eb7d6954.js} +2 -1
- package/dist/esm/TaxId-50d72254.js +90 -0
- package/dist/esm/{cart-4725a63b.js → cart-f5c12be6.js} +60 -0
- package/dist/esm/index.js +34 -10
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{paypal-a09943f4.js → paypal-594f49e9.js} +1 -1
- package/dist/esm/zonos-address_11.entry.js +61 -4
- package/dist/esm/zonos-cart-items_13.entry.js +37 -31
- package/dist/esm/zonos-checkout.entry.js +16 -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-empty-state-payment_4.entry.js +2 -2
- package/dist/esm/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-stripe-input.entry.js +1 -1
- package/dist/esm-es5/{CheckoutConfig-5479d192.js → CheckoutConfig-eb7d6954.js} +1 -1
- package/dist/esm-es5/TaxId-50d72254.js +1 -0
- package/dist/esm-es5/cart-f5c12be6.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{paypal-a09943f4.js → paypal-594f49e9.js} +1 -1
- package/dist/esm-es5/zonos-address_11.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-empty-state-payment_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-stripe-input.entry.js +1 -1
- package/dist/scripts/index.d.ts +34 -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.d.ts +4 -0
- package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +4 -5
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.base.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.french.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.german.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -0
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -0
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +13 -0
- package/dist/types/components/stripe/zonos-custom-address/zonos-custom-address.d.ts +9 -0
- package/dist/types/components/utils/taxIdValidationResult.d.ts +2 -1
- package/dist/types/components.d.ts +25 -0
- package/dist/types/scripts/_zonosBase.d.ts +9 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +1 -0
- package/dist/types/types/checkout/TaxId.d.ts +123 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-01eda7f2.entry.js +1 -0
- package/dist/zonos-elements/p-03bbd1af.entry.js +1 -0
- package/dist/zonos-elements/p-04a0e38b.system.entry.js +1 -0
- package/dist/zonos-elements/{p-e90cb997.entry.js → p-0dae66d2.entry.js} +1 -1
- package/dist/zonos-elements/{p-aaff5dcc.entry.js → p-1146b6e0.entry.js} +1 -1
- package/dist/zonos-elements/{p-8721bd47.system.entry.js → p-23975acb.system.entry.js} +1 -1
- package/dist/zonos-elements/p-2b8345d8.system.js +1 -0
- package/dist/zonos-elements/{p-04303b56.system.entry.js → p-315d8e78.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-175e242e.entry.js → p-3707564c.entry.js} +1 -1
- package/dist/zonos-elements/p-3831dab5.system.js +1 -0
- package/dist/zonos-elements/{p-341f40c2.system.entry.js → p-3d130579.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3f1a2d31.js +1 -0
- package/dist/zonos-elements/{p-0104d3ba.entry.js → p-4d1269a7.entry.js} +1 -1
- package/dist/zonos-elements/p-54fdf40b.entry.js +1 -0
- package/dist/zonos-elements/{p-8ee34712.system.js → p-5e1b2654.system.js} +1 -1
- package/dist/zonos-elements/{p-de462b9b.js → p-657390e6.js} +2 -2
- package/dist/zonos-elements/p-682e09fc.system.entry.js +1 -0
- package/dist/zonos-elements/p-6b361d2b.js +1 -0
- package/dist/zonos-elements/{p-fd348fd4.system.entry.js → p-751bfce8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9a7a9b1c.entry.js → p-77654589.entry.js} +1 -1
- package/dist/zonos-elements/{p-e5d081d8.entry.js → p-7bed199d.entry.js} +1 -1
- package/dist/zonos-elements/{p-995761ea.system.entry.js → p-83a7ece6.system.entry.js} +1 -1
- package/dist/zonos-elements/p-86d29d50.system.entry.js +1 -0
- package/dist/zonos-elements/p-97e330cd.entry.js +1 -0
- package/dist/zonos-elements/{p-98e4a965.system.entry.js → p-9aa94d71.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-818d6f17.entry.js → p-a09f64e1.entry.js} +1 -1
- package/dist/zonos-elements/p-c1458d16.system.js +1 -0
- package/dist/zonos-elements/p-d7b5b237.js +1 -0
- package/dist/zonos-elements/{p-6fd6af48.system.entry.js → p-db3f6d6e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9913c186.system.js → p-e2d45b2e.system.js} +1 -1
- package/dist/zonos-elements/p-ea6d87a1.system.js +1 -1
- package/dist/zonos-elements/{p-9f7b9d66.system.entry.js → p-eeaff898.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/TaxId-4632639d.js +0 -29
- package/dist/esm/TaxId-915ef042.js +0 -26
- package/dist/esm-es5/TaxId-915ef042.js +0 -1
- package/dist/esm-es5/cart-4725a63b.js +0 -1
- package/dist/zonos-elements/p-12a6b7bd.system.js +0 -1
- package/dist/zonos-elements/p-25c47bf9.system.entry.js +0 -1
- package/dist/zonos-elements/p-33bdbcfd.entry.js +0 -1
- package/dist/zonos-elements/p-36bb3cbb.entry.js +0 -1
- package/dist/zonos-elements/p-5bd927f2.js +0 -1
- package/dist/zonos-elements/p-64ea232c.system.entry.js +0 -1
- package/dist/zonos-elements/p-6b40da70.system.js +0 -1
- package/dist/zonos-elements/p-70d4d436.entry.js +0 -1
- package/dist/zonos-elements/p-92d83e23.system.entry.js +0 -1
- package/dist/zonos-elements/p-f6038af5.entry.js +0 -1
- package/dist/zonos-elements/p-f927fd7a.system.js +0 -1
- package/dist/zonos-elements/p-fa6de0f3.js +0 -1
- package/dist/zonos-elements/p-fe253cc1.js +0 -1
|
@@ -8,6 +8,7 @@ import { trackConversionEvent } from "../../utils/api/trackConversionEvent";
|
|
|
8
8
|
import { isCheckoutMobile } from "../../utils/checkout/isCheckoutMobile";
|
|
9
9
|
import { log } from "../../utils/logging/log";
|
|
10
10
|
import { logError } from "../../utils/logging/logError";
|
|
11
|
+
import { countryRequireTaxId, shipToTaxIdLabels, } from "../../../types/checkout/Tax";
|
|
11
12
|
/**
|
|
12
13
|
* This component is a wrapper for the stripe address element that would render default style object
|
|
13
14
|
*/
|
|
@@ -24,6 +25,7 @@ export class ZonosAddress {
|
|
|
24
25
|
this.type = undefined;
|
|
25
26
|
this.titleText = undefined;
|
|
26
27
|
this.defaultAddress = [];
|
|
28
|
+
this.taxIdErrorMessage = '';
|
|
27
29
|
this.stripe = window.Zonos.stripe;
|
|
28
30
|
this.isDirtyAddress = false;
|
|
29
31
|
this.isAddressFilled = false;
|
|
@@ -183,6 +185,33 @@ export class ZonosAddress {
|
|
|
183
185
|
}
|
|
184
186
|
void this.watchInitStripe();
|
|
185
187
|
}
|
|
188
|
+
isInTaxIdCountry(countryCode) {
|
|
189
|
+
return countryRequireTaxId.includes(countryCode);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Render tax id input based on ship to country code
|
|
193
|
+
*/
|
|
194
|
+
renderTaxIdInput() {
|
|
195
|
+
var _a;
|
|
196
|
+
// No need to render tax id input for billing address
|
|
197
|
+
if (this.type === 'billing') {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const countryCode = (_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.value.address.country;
|
|
201
|
+
// Don't render tax id input if the country is not provided
|
|
202
|
+
if (!countryCode) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
const isCountryRequireTaxId = this.isInTaxIdCountry(countryCode);
|
|
206
|
+
if (!isCountryRequireTaxId) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const taxIdInputInfo = shipToTaxIdLabels[countryCode];
|
|
210
|
+
return (h("div", { class: "zonos--tax-id-input" }, h("zonos-stripe-input", { inputLabel: translate(taxIdInputInfo.friendlyName), inputPlaceholder: taxIdInputInfo.placeholder, inputValue: stripeStore.taxId || '', isError: !!this.taxIdErrorMessage, onInputChange: (event) => {
|
|
211
|
+
stripeStore.taxId = event.detail;
|
|
212
|
+
this.taxIdChanged.emit(event.detail);
|
|
213
|
+
} }), this.taxIdErrorMessage && (h("zonos-text", { textColor: 'red-600', type: "caption" }, this.taxIdErrorMessage))));
|
|
214
|
+
}
|
|
186
215
|
renderCompanyNameInput() {
|
|
187
216
|
var _a;
|
|
188
217
|
// No need to render company name for billing address
|
|
@@ -219,7 +248,7 @@ export class ZonosAddress {
|
|
|
219
248
|
this.isAddressFilled = true;
|
|
220
249
|
}
|
|
221
250
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
222
|
-
return (h(Host, { key: '
|
|
251
|
+
return (h(Host, { key: '603d9b20415c68a3337316d5882b931870546b91', class: "zonos--address zonos--elements" }, h("zonos-text", { key: 'bf50ebdb5d923bb0f394d021cd1bc4efbde0137e', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderTaxIdInput(), h("div", { key: '8712b6649822782ec450fe040acc29eb4ca21ed3', class: "zonos--address-component" })));
|
|
223
252
|
}
|
|
224
253
|
static get is() { return "zonos-address"; }
|
|
225
254
|
static get encapsulation() { return "scoped"; }
|
|
@@ -296,6 +325,26 @@ export class ZonosAddress {
|
|
|
296
325
|
"getter": false,
|
|
297
326
|
"setter": false,
|
|
298
327
|
"defaultValue": "[]"
|
|
328
|
+
},
|
|
329
|
+
"taxIdErrorMessage": {
|
|
330
|
+
"type": "string",
|
|
331
|
+
"mutable": false,
|
|
332
|
+
"complexType": {
|
|
333
|
+
"original": "string",
|
|
334
|
+
"resolved": "string",
|
|
335
|
+
"references": {}
|
|
336
|
+
},
|
|
337
|
+
"required": false,
|
|
338
|
+
"optional": false,
|
|
339
|
+
"docs": {
|
|
340
|
+
"tags": [],
|
|
341
|
+
"text": "Error message for tax id input"
|
|
342
|
+
},
|
|
343
|
+
"getter": false,
|
|
344
|
+
"setter": false,
|
|
345
|
+
"attribute": "tax-id-error-message",
|
|
346
|
+
"reflect": false,
|
|
347
|
+
"defaultValue": "''"
|
|
299
348
|
}
|
|
300
349
|
};
|
|
301
350
|
}
|
|
@@ -323,6 +372,21 @@ export class ZonosAddress {
|
|
|
323
372
|
"resolved": "boolean",
|
|
324
373
|
"references": {}
|
|
325
374
|
}
|
|
375
|
+
}, {
|
|
376
|
+
"method": "taxIdChanged",
|
|
377
|
+
"name": "taxIdChanged",
|
|
378
|
+
"bubbles": true,
|
|
379
|
+
"cancelable": true,
|
|
380
|
+
"composed": true,
|
|
381
|
+
"docs": {
|
|
382
|
+
"tags": [],
|
|
383
|
+
"text": "Event to emit when tax id is changed"
|
|
384
|
+
},
|
|
385
|
+
"complexType": {
|
|
386
|
+
"original": "string",
|
|
387
|
+
"resolved": "string",
|
|
388
|
+
"references": {}
|
|
389
|
+
}
|
|
326
390
|
}];
|
|
327
391
|
}
|
|
328
392
|
static get elementRef() { return "el"; }
|
|
@@ -23,6 +23,7 @@ import { isCheckoutMobile } from "../../utils/checkout/isCheckoutMobile";
|
|
|
23
23
|
import { classes } from "../../utils/classes";
|
|
24
24
|
import { log } from "../../utils/logging/log";
|
|
25
25
|
import { mergeAddress } from "../../utils/mergeAddress";
|
|
26
|
+
import { countryRequireTaxId, shipToTaxIdLabels, } from "../../../types/checkout/Tax";
|
|
26
27
|
/**
|
|
27
28
|
* This component is a wrapper for the stripe address element that would render default style object
|
|
28
29
|
*/
|
|
@@ -185,6 +186,7 @@ export class ZonosAddress {
|
|
|
185
186
|
this.type = undefined;
|
|
186
187
|
this.titleText = undefined;
|
|
187
188
|
this.defaultAddress = [];
|
|
189
|
+
this.taxIdErrorMessage = '';
|
|
188
190
|
this.stripe = window.Zonos.stripe;
|
|
189
191
|
this.isDirtyAddress = false;
|
|
190
192
|
this.isAddressFilled = false;
|
|
@@ -289,6 +291,32 @@ export class ZonosAddress {
|
|
|
289
291
|
const hasErrors = line1 || postalCode || state || city || firstName || lastName || phone;
|
|
290
292
|
return !hasErrors;
|
|
291
293
|
}
|
|
294
|
+
isInTaxIdCountry(countryCode) {
|
|
295
|
+
return countryRequireTaxId.includes(countryCode);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Render tax id input based on ship to country code
|
|
299
|
+
*/
|
|
300
|
+
renderTaxIdInput() {
|
|
301
|
+
var _a;
|
|
302
|
+
// No need to render tax id input for billing address
|
|
303
|
+
if (this.type === 'billing') {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
const countryCode = (_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.value.address.country;
|
|
307
|
+
// Don't render tax id input if the country is not provided
|
|
308
|
+
if (!countryCode) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
const isCountryRequireTaxId = this.isInTaxIdCountry(countryCode);
|
|
312
|
+
if (!isCountryRequireTaxId) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
const taxIdInputInfo = shipToTaxIdLabels[countryCode];
|
|
316
|
+
return (h("div", { class: "zonos--tax-id-input" }, h("zonos-stripe-input", { error: this.taxIdErrorMessage, inputLabel: translate(taxIdInputInfo.friendlyName), inputPlaceholder: taxIdInputInfo.placeholder, inputValue: stripeStore.taxId || '', isError: !!this.taxIdErrorMessage, onInputChange: (event) => {
|
|
317
|
+
stripeStore.taxId = event.detail;
|
|
318
|
+
} })));
|
|
319
|
+
}
|
|
292
320
|
renderCompanyNameInput() {
|
|
293
321
|
var _a;
|
|
294
322
|
// No need to render company name for billing address
|
|
@@ -774,10 +802,10 @@ export class ZonosAddress {
|
|
|
774
802
|
this.country = localizationStore.selectedCountryCode;
|
|
775
803
|
}
|
|
776
804
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
777
|
-
return (h(Host, { key: '
|
|
805
|
+
return (h(Host, { key: '1d80f8ffc85a27a7630fcc883d0bd9e8b7973d95', class: classes([
|
|
778
806
|
'zonos--address zonos--elements',
|
|
779
807
|
`zonos--${this.type}-address`,
|
|
780
|
-
]) }, h("zonos-text", { key: '
|
|
808
|
+
]) }, h("zonos-text", { key: '6f0bde17ecda83d01cdb8576df4a03a226921db8', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), this.renderCompanyNameInput(), this.renderTaxIdInput(), this.renderCustomAddressForm()));
|
|
781
809
|
}
|
|
782
810
|
static get is() { return "zonos-custom-address"; }
|
|
783
811
|
static get encapsulation() { return "scoped"; }
|
|
@@ -854,6 +882,26 @@ export class ZonosAddress {
|
|
|
854
882
|
"getter": false,
|
|
855
883
|
"setter": false,
|
|
856
884
|
"defaultValue": "[]"
|
|
885
|
+
},
|
|
886
|
+
"taxIdErrorMessage": {
|
|
887
|
+
"type": "string",
|
|
888
|
+
"mutable": false,
|
|
889
|
+
"complexType": {
|
|
890
|
+
"original": "string",
|
|
891
|
+
"resolved": "string",
|
|
892
|
+
"references": {}
|
|
893
|
+
},
|
|
894
|
+
"required": false,
|
|
895
|
+
"optional": false,
|
|
896
|
+
"docs": {
|
|
897
|
+
"tags": [],
|
|
898
|
+
"text": "Error message for tax id input"
|
|
899
|
+
},
|
|
900
|
+
"getter": false,
|
|
901
|
+
"setter": false,
|
|
902
|
+
"attribute": "tax-id-error-message",
|
|
903
|
+
"reflect": false,
|
|
904
|
+
"defaultValue": "''"
|
|
857
905
|
}
|
|
858
906
|
};
|
|
859
907
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { euCountryCodes } from "../../types/index";
|
|
1
2
|
const isTaxIdRequired = (shippingCountry) => {
|
|
2
|
-
const requireTaxIdCountry = ['MX'];
|
|
3
|
+
const requireTaxIdCountry = ['MX', ...euCountryCodes];
|
|
3
4
|
return requireTaxIdCountry.includes(shippingCountry);
|
|
4
5
|
};
|
|
5
|
-
export const taxIdValidationResult = ({ shippingCountry, taxId, }) => {
|
|
6
|
+
export const taxIdValidationResult = ({ companyName, shippingCountry, taxId, }) => {
|
|
7
|
+
// Check to see if we are required to collect tax id for the shipping country or not
|
|
6
8
|
const taxRequired = isTaxIdRequired(shippingCountry);
|
|
7
9
|
if (!taxRequired) {
|
|
8
10
|
return {
|
|
@@ -10,6 +12,25 @@ export const taxIdValidationResult = ({ shippingCountry, taxId, }) => {
|
|
|
10
12
|
valid: true,
|
|
11
13
|
};
|
|
12
14
|
}
|
|
15
|
+
// For GB, tax id is not required if company name is not filled (not business address)
|
|
16
|
+
if (shippingCountry === 'GB') {
|
|
17
|
+
if (!companyName) {
|
|
18
|
+
return {
|
|
19
|
+
error: null,
|
|
20
|
+
valid: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!taxId) {
|
|
24
|
+
return {
|
|
25
|
+
error: 'Tax id is required',
|
|
26
|
+
valid: false,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
error: null,
|
|
31
|
+
valid: true,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
13
34
|
if (!taxId) {
|
|
14
35
|
return {
|
|
15
36
|
error: 'Tax id is required',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import { createCustomEvent } from "../components/utils/createCustomEvent";
|
|
2
3
|
import { IframeService } from "../components/utils/iframe/IframeHelpers";
|
|
3
4
|
import { log } from "../components/utils/logging/log";
|
|
4
5
|
import { logError } from "../components/utils/logging/logError";
|
|
@@ -9,7 +10,7 @@ import { getZonosQaUrl } from "./_getZonosQaUrl";
|
|
|
9
10
|
import { zonosLoadStripe } from "./_loadStripe";
|
|
10
11
|
import { getCartIdFromQueryParam } from "./cart/_getCartIdFromParam";
|
|
11
12
|
import { setupCartDataWithSettings } from "./cart/_setupCartDataWithSettings";
|
|
12
|
-
import { checkoutHiddenBtnSelector, } from "../types/checkout/CheckoutConfig";
|
|
13
|
+
import { checkoutHiddenBtnSelector, checkoutHiddenInternationalBtnSelector, } from "../types/checkout/CheckoutConfig";
|
|
13
14
|
/**
|
|
14
15
|
* Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
|
|
15
16
|
*/
|
|
@@ -156,6 +157,8 @@ Zonos.init = async (params) => {
|
|
|
156
157
|
_a.injectZonosCss();
|
|
157
158
|
// inject fonts for zonos elements
|
|
158
159
|
_a.injectFonts();
|
|
160
|
+
// inject checkout international button
|
|
161
|
+
_a.injectCheckoutInternationalButton();
|
|
159
162
|
// init zonos controller
|
|
160
163
|
_a.injectController({
|
|
161
164
|
config: {
|
|
@@ -169,6 +172,18 @@ Zonos.init = async (params) => {
|
|
|
169
172
|
});
|
|
170
173
|
_a.doneInit = true;
|
|
171
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* Inject the hidden international checkout button to trigger checkout regardless of shipping zones
|
|
177
|
+
*/
|
|
178
|
+
Zonos.injectCheckoutInternationalButton = () => {
|
|
179
|
+
if (!document.querySelector(`#${checkoutHiddenInternationalBtnSelector}`)) {
|
|
180
|
+
// inject the hidden international checkout button
|
|
181
|
+
const checkoutInternationalBtn = document.createElement('button');
|
|
182
|
+
checkoutInternationalBtn.id = checkoutHiddenInternationalBtnSelector;
|
|
183
|
+
checkoutInternationalBtn.style.display = 'none';
|
|
184
|
+
document.body.appendChild(checkoutInternationalBtn);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
172
187
|
Zonos.injectCustomScriptForHostedCheckout = () => {
|
|
173
188
|
const cartData = _a.cartData;
|
|
174
189
|
const metadata = (cartData === null || cartData === void 0 ? void 0 : cartData.metadata) || [];
|
|
@@ -202,6 +217,15 @@ Zonos.displayCurrency = () => {
|
|
|
202
217
|
void zonosHello.displayCurrency();
|
|
203
218
|
}
|
|
204
219
|
};
|
|
220
|
+
Zonos.triggerCheckoutInternational = async () => {
|
|
221
|
+
// wait for the button to be visible and attached to the event
|
|
222
|
+
const checkoutInternationalBtn = document.querySelector(`#${checkoutHiddenInternationalBtnSelector}`);
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
if (checkoutInternationalBtn) {
|
|
225
|
+
checkoutInternationalBtn.dispatchEvent(createCustomEvent('click'));
|
|
226
|
+
}
|
|
227
|
+
}, 10);
|
|
228
|
+
};
|
|
205
229
|
// Called openHelloDialog because the main use case is to simply open the dialog
|
|
206
230
|
Zonos.openHelloDialog = (value) => {
|
|
207
231
|
const zonosHello = document.querySelector('zonos-hello');
|
|
@@ -1,24 +1,88 @@
|
|
|
1
|
+
export const euCountryCodes = [
|
|
2
|
+
'AT',
|
|
3
|
+
'BE',
|
|
4
|
+
'BG',
|
|
5
|
+
'CY',
|
|
6
|
+
'CZ',
|
|
7
|
+
'DE',
|
|
8
|
+
'DK',
|
|
9
|
+
'EE',
|
|
10
|
+
'ES',
|
|
11
|
+
'FI',
|
|
12
|
+
'FR',
|
|
13
|
+
'GR',
|
|
14
|
+
'HR',
|
|
15
|
+
'HU',
|
|
16
|
+
'IE',
|
|
17
|
+
'IT',
|
|
18
|
+
'LT',
|
|
19
|
+
'LU',
|
|
20
|
+
'LV',
|
|
21
|
+
'MT',
|
|
22
|
+
'NL',
|
|
23
|
+
'PL',
|
|
24
|
+
'PT',
|
|
25
|
+
'RO',
|
|
26
|
+
'SE',
|
|
27
|
+
'SI',
|
|
28
|
+
'SK',
|
|
29
|
+
'CH',
|
|
30
|
+
'NO',
|
|
31
|
+
'GB',
|
|
32
|
+
];
|
|
1
33
|
export const countryRequireTaxId = [
|
|
2
34
|
'AR',
|
|
3
35
|
'BR',
|
|
4
36
|
'KR',
|
|
5
37
|
'MX',
|
|
38
|
+
// EU countries
|
|
39
|
+
...euCountryCodes,
|
|
6
40
|
];
|
|
7
41
|
export const shipToTaxIdLabels = {
|
|
8
42
|
AR: {
|
|
9
43
|
friendlyName: 'Unique Labor Identification Code',
|
|
10
44
|
placeholder: '00-00000000-0',
|
|
11
45
|
},
|
|
46
|
+
AT: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
47
|
+
BE: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
48
|
+
BG: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
12
49
|
BR: {
|
|
13
50
|
friendlyName: 'CPF/CNPJ number',
|
|
14
51
|
placeholder: '000.000.000-00',
|
|
15
52
|
},
|
|
53
|
+
CH: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
54
|
+
CY: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
55
|
+
CZ: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
56
|
+
DE: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
57
|
+
DK: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
58
|
+
EE: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
59
|
+
ES: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
60
|
+
FI: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
61
|
+
FR: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
62
|
+
GB: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
63
|
+
GR: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
64
|
+
HR: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
65
|
+
HU: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
66
|
+
IE: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
67
|
+
IT: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
16
68
|
KR: {
|
|
17
69
|
friendlyName: 'Personal Customers Clearance Code',
|
|
18
70
|
placeholder: '000-00-00000',
|
|
19
71
|
},
|
|
72
|
+
LT: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
73
|
+
LU: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
74
|
+
LV: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
75
|
+
MT: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
20
76
|
MX: {
|
|
21
77
|
friendlyName: 'RFC number',
|
|
22
78
|
placeholder: 'XAXX010101000',
|
|
23
79
|
},
|
|
80
|
+
NL: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
81
|
+
NO: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
82
|
+
PL: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
83
|
+
PT: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
84
|
+
RO: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
85
|
+
SE: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
86
|
+
SI: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
87
|
+
SK: { friendlyName: 'EORI number', placeholder: 'DE123456789' },
|
|
24
88
|
};
|
|
@@ -26,6 +26,7 @@ const _getIsValidCartId = (cartId) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const checkoutHiddenBtnSelector = 'zonos--checkout-hidden-button';
|
|
29
|
+
const checkoutHiddenInternationalBtnSelector = 'zonos--checkout-hidden-international-button';
|
|
29
30
|
const domesticRedirectedBtnSelector = 'zonos--domestic-redirected-checkout-button';
|
|
30
31
|
|
|
31
|
-
export { _getIsValidCartId as _, checkoutHiddenBtnSelector as c, domesticRedirectedBtnSelector as d };
|
|
32
|
+
export { _getIsValidCartId as _, checkoutHiddenInternationalBtnSelector as a, checkoutHiddenBtnSelector as c, domesticRedirectedBtnSelector as d };
|