@zonos/elements 1.2.4-alpha.6 → 1.2.4-alpha.7
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-7ad04cdb.js → cart-90f7c8c0.js} +36 -8
- package/dist/cjs/{getBorderRadius-a97a5f75.js → getBorderRadius-bf4a4276.js} +1 -1
- package/dist/cjs/{index-20cb112f.js → index-0dcccc22.js} +27 -16
- package/dist/cjs/index.cjs.js +6 -6
- package/dist/cjs/{isDarkColor-261fcf3d.js → isDarkColor-ff6ff183.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{localization-5069ab0b.js → localization-9caf3397.js} +7 -7
- package/dist/cjs/{submitGtag-44e938ff.js → submitGtag-b141b45d.js} +2 -2
- package/dist/cjs/zonos-address_2.cjs.entry.js +6 -6
- package/dist/cjs/zonos-badge.cjs.entry.js +2 -2
- package/dist/cjs/zonos-banner.cjs.entry.js +2 -2
- package/dist/cjs/zonos-button_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-card_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-cart-items_10.cjs.entry.js +50 -8
- package/dist/cjs/zonos-checkout.cjs.entry.js +9 -7
- package/dist/cjs/zonos-component.cjs.entry.js +1 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +8 -8
- package/dist/cjs/zonos-country-flag_4.cjs.entry.js +4 -4
- package/dist/cjs/zonos-elements.cjs.js +3 -3
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
- package/dist/cjs/zonos-hello.cjs.entry.js +4 -4
- package/dist/cjs/zonos-icon.cjs.entry.js +2 -2
- package/dist/cjs/zonos-notification.cjs.entry.js +2 -2
- package/dist/cjs/zonos-payment.cjs.entry.js +6 -6
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +3 -3
- package/dist/cjs/zonos-text.cjs.entry.js +2 -2
- package/dist/cjs/{zonosStore-a0fa5b77.js → zonosStore-b43ef5db.js} +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +48 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +5 -2
- package/dist/collection/components/common/zonos-notification/zonos-notification.js +3 -2
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +9 -6
- package/dist/collection/components/main/zonos-controller.js +16 -14
- package/dist/collection/components/store/checkout/cart.js +1 -1
- package/dist/collection/components/store/checkout/stripe.js +3 -2
- package/dist/collection/components/utils/api/calculateLandedCost.js +9 -1
- package/dist/collection/components/utils/api/checkItemRestrictions.js +1 -1
- 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 +1 -1
- package/dist/collection/components/utils/api/getLocaleMessages.js +1 -1
- package/dist/collection/components/utils/api/getLocalization.js +1 -1
- package/dist/collection/components/utils/api/getShippingZones.js +1 -1
- package/dist/collection/components/utils/api/getZonosSetting.js +1 -1
- package/dist/collection/components/utils/api/triggerBuildLandedCost.js +22 -0
- package/dist/collection/types/generated/graphql.customer.types.js +72 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +83 -6
- package/dist/components/cart.js +33 -5
- package/dist/components/localization.js +6 -6
- package/dist/components/zonos-checkout-finish2.js +47 -4
- package/dist/components/zonos-checkout.js +2 -0
- package/dist/components/zonos-controller.js +2 -2
- package/dist/components/zonos-hello.js +1 -1
- package/dist/esm/{cart-face98c8.js → cart-b439be00.js} +36 -8
- package/dist/esm/{getBorderRadius-35e8acce.js → getBorderRadius-178a0a05.js} +1 -1
- package/dist/esm/{index-3617e24c.js → index-36ff6342.js} +27 -16
- package/dist/esm/index.js +6 -6
- package/dist/esm/{isDarkColor-44e9e451.js → isDarkColor-416d6047.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{localization-ed07b7f0.js → localization-a51ccbc2.js} +7 -7
- package/dist/esm/{submitGtag-5b553683.js → submitGtag-521826a2.js} +2 -2
- package/dist/esm/zonos-address_2.entry.js +6 -6
- package/dist/esm/zonos-badge.entry.js +2 -2
- package/dist/esm/zonos-banner.entry.js +2 -2
- package/dist/esm/zonos-button_2.entry.js +4 -4
- package/dist/esm/zonos-card_2.entry.js +2 -2
- package/dist/esm/zonos-cart-items_10.entry.js +50 -8
- package/dist/esm/zonos-checkout.entry.js +9 -7
- package/dist/esm/zonos-component.entry.js +1 -1
- package/dist/esm/zonos-controller.entry.js +8 -8
- package/dist/esm/zonos-country-flag_4.entry.js +4 -4
- package/dist/esm/zonos-elements.js +4 -4
- package/dist/esm/zonos-hello-dialog.entry.js +3 -3
- package/dist/esm/zonos-hello.entry.js +4 -4
- package/dist/esm/zonos-icon.entry.js +2 -2
- package/dist/esm/zonos-notification.entry.js +2 -2
- package/dist/esm/zonos-payment.entry.js +6 -6
- package/dist/esm/zonos-shipping-rich-radio.entry.js +3 -3
- package/dist/esm/zonos-text.entry.js +2 -2
- package/dist/esm/{zonosStore-e0b7a5cf.js → zonosStore-61e74f58.js} +1 -1
- package/dist/esm-es5/cart-b439be00.js +1 -0
- package/dist/esm-es5/{getBorderRadius-35e8acce.js → getBorderRadius-178a0a05.js} +1 -1
- package/dist/esm-es5/index-36ff6342.js +2 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{isDarkColor-44e9e451.js → isDarkColor-416d6047.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{localization-ed07b7f0.js → localization-a51ccbc2.js} +1 -1
- package/dist/esm-es5/{submitGtag-5b553683.js → submitGtag-521826a2.js} +1 -1
- package/dist/esm-es5/zonos-address_2.entry.js +1 -1
- package/dist/esm-es5/zonos-badge.entry.js +1 -1
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_2.entry.js +1 -1
- package/dist/esm-es5/zonos-card_2.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-component.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag_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-icon.entry.js +1 -1
- package/dist/esm-es5/zonos-notification.entry.js +1 -1
- package/dist/esm-es5/zonos-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-e0b7a5cf.js → zonosStore-61e74f58.js} +1 -1
- package/dist/scripts/loadZonos.js +3 -3
- package/dist/scripts/zonos.js +3 -3
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +5 -1
- package/dist/types/components/store/checkout/stripe.d.ts +1 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/api/triggerBuildLandedCost.d.ts +5 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +3 -1
- package/dist/types/types/generated/graphql.customer.types.d.ts +230 -7
- package/dist/types/types/generated/graphql.customer.types.ts +281 -7
- package/dist/types/types/generated/graphql.frontend.types.d.ts +222 -11
- package/dist/types/types/generated/graphql.frontend.types.ts +377 -11
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-d8daeec4.system.entry.js → p-06fb9d1f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-77a7929b.js → p-089ba905.js} +1 -1
- package/dist/zonos-elements/{p-f0f9c43a.js → p-1685c8df.js} +1 -1
- package/dist/zonos-elements/p-18904b7c.system.js +2 -0
- package/dist/zonos-elements/{p-b8d11094.entry.js → p-1d4a970b.entry.js} +1 -1
- package/dist/zonos-elements/{p-80ba24a8.system.js → p-24eed2a8.system.js} +1 -1
- package/dist/zonos-elements/{p-bec21999.system.js → p-24fbe845.system.js} +1 -1
- package/dist/zonos-elements/{p-55f1da18.entry.js → p-2801d868.entry.js} +1 -1
- package/dist/zonos-elements/{p-1dbaf24b.system.entry.js → p-2f43da39.system.entry.js} +1 -1
- package/dist/zonos-elements/p-33137e7d.system.entry.js +1 -0
- package/dist/zonos-elements/{p-99c9bd01.js → p-3c6988d7.js} +1 -1
- package/dist/zonos-elements/p-3cea383b.system.entry.js +1 -0
- package/dist/zonos-elements/{p-86580e70.system.entry.js → p-47390db7.system.entry.js} +1 -1
- package/dist/zonos-elements/p-4846796a.js +1 -0
- package/dist/zonos-elements/p-494c77a7.entry.js +1 -0
- package/dist/zonos-elements/{p-00c99619.entry.js → p-49f09b91.entry.js} +1 -1
- package/dist/zonos-elements/{p-9e396855.system.entry.js → p-4a15c5c7.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-507e1954.system.entry.js → p-4bee0bff.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3eb33ba6.entry.js → p-4d93275c.entry.js} +1 -1
- package/dist/zonos-elements/{p-f09eb5c5.entry.js → p-4ed71bd7.entry.js} +1 -1
- package/dist/zonos-elements/{p-8bbad467.js → p-55f49f1e.js} +1 -1
- package/dist/zonos-elements/{p-114d8a14.system.entry.js → p-560aa686.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-03df1466.entry.js → p-639396bb.entry.js} +1 -1
- package/dist/zonos-elements/{p-3c64448f.system.entry.js → p-67154df2.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9dbbacd9.entry.js → p-684ed483.entry.js} +1 -1
- package/dist/zonos-elements/{p-c743e43f.entry.js → p-89c210d6.entry.js} +1 -1
- package/dist/zonos-elements/{p-5aefdcdc.system.js → p-8c48b75e.system.js} +1 -1
- package/dist/zonos-elements/{p-4138e220.system.entry.js → p-8c5595d9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-263c1639.entry.js → p-938803f4.entry.js} +1 -1
- package/dist/zonos-elements/p-956efa27.js +2 -0
- package/dist/zonos-elements/{p-bca3d02f.entry.js → p-a0e36ed3.entry.js} +1 -1
- package/dist/zonos-elements/{p-b5bc4851.entry.js → p-a376a37f.entry.js} +1 -1
- package/dist/zonos-elements/{p-94f03799.system.js → p-a504f64f.system.js} +1 -1
- package/dist/zonos-elements/p-afe26069.entry.js +1 -0
- package/dist/zonos-elements/{p-f2ed98bb.system.entry.js → p-b4601210.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4db8bd2e.system.js → p-b51de536.system.js} +1 -1
- package/dist/zonos-elements/{p-9fa111f1.entry.js → p-b6148206.entry.js} +1 -1
- package/dist/zonos-elements/{p-643eeb24.system.js → p-b85be1ab.system.js} +1 -1
- package/dist/zonos-elements/{p-06ec9556.system.entry.js → p-c9348bb0.system.entry.js} +1 -1
- package/dist/zonos-elements/p-d2217f09.system.js +1 -0
- package/dist/zonos-elements/{p-7bd0ab43.system.entry.js → p-d856a200.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-754bdfdb.system.js → p-da060b1c.system.js} +1 -1
- package/dist/zonos-elements/{p-6f6d24da.entry.js → p-e1f6ab97.entry.js} +1 -1
- package/dist/zonos-elements/{p-3a7546f0.system.entry.js → p-e5ae22a9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4c0f4461.system.entry.js → p-e98be2d0.system.entry.js} +1 -1
- package/dist/zonos-elements/p-e9b832c5.entry.js +1 -0
- package/dist/zonos-elements/p-eb392924.entry.js +1 -0
- package/dist/zonos-elements/{p-b2984730.system.entry.js → p-f141519c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-39ae023c.system.entry.js → p-f367f2fe.system.entry.js} +1 -1
- package/dist/zonos-elements/p-ff95f098.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/dist/zonos-elements/zonos-elements.js +1 -1
- package/package.json +7 -6
- package/dist/esm-es5/cart-face98c8.js +0 -1
- package/dist/esm-es5/index-3617e24c.js +0 -2
- package/dist/zonos-elements/p-39dfc72b.entry.js +0 -1
- package/dist/zonos-elements/p-3c40bb08.entry.js +0 -1
- package/dist/zonos-elements/p-47c110a4.system.js +0 -1
- package/dist/zonos-elements/p-5e6be2a3.entry.js +0 -1
- package/dist/zonos-elements/p-aeeaaa7a.system.entry.js +0 -1
- package/dist/zonos-elements/p-b944303a.system.entry.js +0 -1
- package/dist/zonos-elements/p-bec05c21.system.js +0 -2
- package/dist/zonos-elements/p-c6ed3777.js +0 -1
- package/dist/zonos-elements/p-cf8aaa17.js +0 -2
- package/dist/zonos-elements/p-d9ed23ec.entry.js +0 -1
- package/dist/zonos-elements/p-e1de2a1f.js +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { prepCalculateLandedCost } from "./prepCalculateLandedCost";
|
|
2
|
+
import { handleFetch } from "../handleFetch";
|
|
3
|
+
export const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
4
|
+
var _a;
|
|
5
|
+
const data = prepCalculateLandedCost();
|
|
6
|
+
const landedCost = await buildLandedCost(data.checkoutSessionId, data.contact, data.shippingAddress);
|
|
7
|
+
if (!landedCost) {
|
|
8
|
+
throw new Error('Failed to build landed cost');
|
|
9
|
+
}
|
|
10
|
+
// Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
|
|
11
|
+
const { errors, json } = await handleFetch(`${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/validate-landed-cost`, {
|
|
12
|
+
body: landedCost,
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
},
|
|
16
|
+
method: 'POST',
|
|
17
|
+
});
|
|
18
|
+
if (!json || errors.length) {
|
|
19
|
+
throw new Error(`Invalid landed cost object: ${((_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
|
|
20
|
+
}
|
|
21
|
+
return landedCost;
|
|
22
|
+
};
|
|
@@ -58,6 +58,10 @@ export const carrierAccountRateType = {
|
|
|
58
58
|
export const carrierAccountUsageCategoryCode = {
|
|
59
59
|
Shipping: 'SHIPPING',
|
|
60
60
|
};
|
|
61
|
+
export const carrierApiAccountProvider = {
|
|
62
|
+
General: 'GENERAL',
|
|
63
|
+
Organization: 'ORGANIZATION',
|
|
64
|
+
};
|
|
61
65
|
export const carrierApiRateTypeCode = {
|
|
62
66
|
Negotiated: 'NEGOTIATED',
|
|
63
67
|
Retail: 'RETAIL',
|
|
@@ -140,6 +144,11 @@ export const classificationBulkJobStatus = {
|
|
|
140
144
|
Initialized: 'INITIALIZED',
|
|
141
145
|
Processing: 'PROCESSING',
|
|
142
146
|
};
|
|
147
|
+
export const classificationCalculateSource = {
|
|
148
|
+
External: 'EXTERNAL',
|
|
149
|
+
Internal: 'INTERNAL',
|
|
150
|
+
Legacy: 'LEGACY',
|
|
151
|
+
};
|
|
143
152
|
export const clearanceType = {
|
|
144
153
|
Commercial: 'COMMERCIAL',
|
|
145
154
|
Postal: 'POSTAL',
|
|
@@ -862,6 +871,15 @@ export const currencySymbolLocation = {
|
|
|
862
871
|
After: 'AFTER',
|
|
863
872
|
Before: 'BEFORE',
|
|
864
873
|
};
|
|
874
|
+
export const customsDocumentFileType = {
|
|
875
|
+
Pdf: 'PDF',
|
|
876
|
+
Txt: 'TXT',
|
|
877
|
+
};
|
|
878
|
+
export const customsDocumentType = {
|
|
879
|
+
CertificateOfOrigin: 'CERTIFICATE_OF_ORIGIN',
|
|
880
|
+
CommercialInvoice: 'COMMERCIAL_INVOICE',
|
|
881
|
+
Other: 'OTHER',
|
|
882
|
+
};
|
|
865
883
|
export const customsSpecAttributeType = {
|
|
866
884
|
AccountNumber: 'ACCOUNT_NUMBER',
|
|
867
885
|
B13A: 'B13A',
|
|
@@ -1207,6 +1225,11 @@ export const labelStatusType = {
|
|
|
1207
1225
|
Created: 'CREATED',
|
|
1208
1226
|
Voided: 'VOIDED',
|
|
1209
1227
|
};
|
|
1228
|
+
export const landedCostAdjustmentType = {
|
|
1229
|
+
CartTotal: 'CART_TOTAL',
|
|
1230
|
+
Item: 'ITEM',
|
|
1231
|
+
Shipping: 'SHIPPING',
|
|
1232
|
+
};
|
|
1210
1233
|
export const landedCostCalculationMethod = {
|
|
1211
1234
|
Dap: 'DAP',
|
|
1212
1235
|
Ddp: 'DDP',
|
|
@@ -1235,6 +1258,7 @@ export const landedCostFeeType = {
|
|
|
1235
1258
|
ZonosLandedCostGuarantee: 'ZONOS_LANDED_COST_GUARANTEE',
|
|
1236
1259
|
};
|
|
1237
1260
|
export const landedCostGuaranteeCode = {
|
|
1261
|
+
InclusivePrice: 'INCLUSIVE_PRICE',
|
|
1238
1262
|
NotApplicable: 'NOT_APPLICABLE',
|
|
1239
1263
|
Zonos: 'ZONOS',
|
|
1240
1264
|
};
|
|
@@ -1248,6 +1272,11 @@ export const landedCostMethod = {
|
|
|
1248
1272
|
DdpForced: 'DDP_FORCED',
|
|
1249
1273
|
DdpPreferred: 'DDP_PREFERRED',
|
|
1250
1274
|
};
|
|
1275
|
+
export const landedCostQuoteType = {
|
|
1276
|
+
Auditing: 'AUDITING',
|
|
1277
|
+
Checkout: 'CHECKOUT',
|
|
1278
|
+
InclusivePrice: 'INCLUSIVE_PRICE',
|
|
1279
|
+
};
|
|
1251
1280
|
export const landedCostTariffRate = {
|
|
1252
1281
|
Exact: 'EXACT',
|
|
1253
1282
|
Maximum: 'MAXIMUM',
|
|
@@ -1397,6 +1426,10 @@ export const notificationActiveStatus = {
|
|
|
1397
1426
|
Disabled: 'DISABLED',
|
|
1398
1427
|
Enabled: 'ENABLED',
|
|
1399
1428
|
};
|
|
1429
|
+
export const orderCompleteBillingMethod = {
|
|
1430
|
+
BillingDgs: 'BILLING_DGS',
|
|
1431
|
+
Legacy: 'LEGACY',
|
|
1432
|
+
};
|
|
1400
1433
|
export const orderStatus = {
|
|
1401
1434
|
Canceled: 'CANCELED',
|
|
1402
1435
|
Completed: 'COMPLETED',
|
|
@@ -1409,6 +1442,10 @@ export const orderTransactionBillingMethod = {
|
|
|
1409
1442
|
BillingDgs: 'BILLING_DGS',
|
|
1410
1443
|
Legacy: 'LEGACY',
|
|
1411
1444
|
};
|
|
1445
|
+
export const organizationBusinessUnit = {
|
|
1446
|
+
Ecommerce: 'ECOMMERCE',
|
|
1447
|
+
SupplyChain: 'SUPPLY_CHAIN',
|
|
1448
|
+
};
|
|
1412
1449
|
export const organizationStatus = {
|
|
1413
1450
|
Active: 'ACTIVE',
|
|
1414
1451
|
Churned: 'CHURNED',
|
|
@@ -1436,6 +1473,10 @@ export const packageLocation = {
|
|
|
1436
1473
|
Rear: 'REAR',
|
|
1437
1474
|
Side: 'SIDE',
|
|
1438
1475
|
};
|
|
1476
|
+
export const packagingOptionDeleteAction = {
|
|
1477
|
+
Delete: 'DELETE',
|
|
1478
|
+
Disable: 'DISABLE',
|
|
1479
|
+
};
|
|
1439
1480
|
export const packagingOptionSource = {
|
|
1440
1481
|
Default: 'DEFAULT',
|
|
1441
1482
|
Dynamic: 'DYNAMIC',
|
|
@@ -1527,6 +1568,10 @@ export const shipmentAmountType = {
|
|
|
1527
1568
|
PublishedRate: 'PUBLISHED_RATE',
|
|
1528
1569
|
Surcharge: 'SURCHARGE',
|
|
1529
1570
|
};
|
|
1571
|
+
export const shipmentBatchStatus = {
|
|
1572
|
+
Closed: 'CLOSED',
|
|
1573
|
+
Open: 'OPEN',
|
|
1574
|
+
};
|
|
1530
1575
|
export const shipmentCartonSpecialService = {
|
|
1531
1576
|
Alcohol: 'ALCOHOL',
|
|
1532
1577
|
BatteryInsideEquipment: 'BATTERY_INSIDE_EQUIPMENT',
|
|
@@ -1569,6 +1614,20 @@ export const stripeBillingFrequency = {
|
|
|
1569
1614
|
Week: 'WEEK',
|
|
1570
1615
|
Year: 'YEAR',
|
|
1571
1616
|
};
|
|
1617
|
+
export const stripeChargeStatus = {
|
|
1618
|
+
Failed: 'FAILED',
|
|
1619
|
+
Pending: 'PENDING',
|
|
1620
|
+
Succeeded: 'SUCCEEDED',
|
|
1621
|
+
};
|
|
1622
|
+
export const stripePaymentIntentStatus = {
|
|
1623
|
+
Canceled: 'CANCELED',
|
|
1624
|
+
Processing: 'PROCESSING',
|
|
1625
|
+
RequiresAction: 'REQUIRES_ACTION',
|
|
1626
|
+
RequiresCapture: 'REQUIRES_CAPTURE',
|
|
1627
|
+
RequiresConfirmation: 'REQUIRES_CONFIRMATION',
|
|
1628
|
+
RequiresPaymentMethod: 'REQUIRES_PAYMENT_METHOD',
|
|
1629
|
+
Succeeded: 'SUCCEEDED',
|
|
1630
|
+
};
|
|
1572
1631
|
export const stripePriceBillingScheme = {
|
|
1573
1632
|
PerUnit: 'PER_UNIT',
|
|
1574
1633
|
Tiered: 'TIERED',
|
|
@@ -1679,8 +1738,12 @@ export const volumeUnitCode = {
|
|
|
1679
1738
|
QuartUsDry: 'QUART_US_DRY',
|
|
1680
1739
|
};
|
|
1681
1740
|
export const wcoVersion = {
|
|
1741
|
+
Wco_1997: 'WCO_1997',
|
|
1742
|
+
Wco_2002: 'WCO_2002',
|
|
1743
|
+
Wco_2007: 'WCO_2007',
|
|
1682
1744
|
Wco_2017: 'WCO_2017',
|
|
1683
1745
|
Wco_2022: 'WCO_2022',
|
|
1746
|
+
Wco_2027: 'WCO_2027',
|
|
1684
1747
|
};
|
|
1685
1748
|
export const weightUnitCode = {
|
|
1686
1749
|
Gram: 'GRAM',
|
|
@@ -1720,9 +1783,18 @@ export function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
1720
1783
|
FulfillmentCenter(variables, requestHeaders) {
|
|
1721
1784
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'FulfillmentCenter', 'query');
|
|
1722
1785
|
},
|
|
1786
|
+
GetCheckoutSession(variables, requestHeaders) {
|
|
1787
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetCheckoutSession', 'query');
|
|
1788
|
+
},
|
|
1789
|
+
GetOrder(variables, requestHeaders) {
|
|
1790
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetOrder', 'query');
|
|
1791
|
+
},
|
|
1723
1792
|
OnlineStoreSettings(variables, requestHeaders) {
|
|
1724
1793
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'OnlineStoreSettings', 'query');
|
|
1725
1794
|
},
|
|
1795
|
+
OrderUpdateAccountOrderNumber(variables, requestHeaders) {
|
|
1796
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'OrderUpdateAccountOrderNumber', 'mutation');
|
|
1797
|
+
},
|
|
1726
1798
|
ShippingZones(variables, requestHeaders) {
|
|
1727
1799
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'ShippingZones', 'query');
|
|
1728
1800
|
},
|
|
@@ -2,6 +2,44 @@ export const cursorOrdering = {
|
|
|
2
2
|
Asc: 'ASC',
|
|
3
3
|
Desc: 'DESC',
|
|
4
4
|
};
|
|
5
|
+
export const featureAspectKeyEnum = {
|
|
6
|
+
Checkout_2_0: 'checkout_2_0',
|
|
7
|
+
ClassifySingleRequest: 'classify_single_request',
|
|
8
|
+
ComConsolidation: 'com_consolidation',
|
|
9
|
+
DashboardCheckout_2Settings: 'dashboard_checkout_2_settings',
|
|
10
|
+
DashboardHello_2Settings: 'dashboard_hello_2_settings',
|
|
11
|
+
DashboardOrderApprove: 'dashboard_order_approve',
|
|
12
|
+
DashboardOrderApproveNoCapture: 'dashboard_order_approve_no_capture',
|
|
13
|
+
Dashboard_909Settings: 'dashboard_909_settings',
|
|
14
|
+
DocsSearchOpenAiQa: 'docs_search_open_ai_qa',
|
|
15
|
+
ExploreFrontendMutation: 'explore_frontend_mutation',
|
|
16
|
+
ExploreWeaviateMutation: 'explore_weaviate_mutation',
|
|
17
|
+
FeatureAspect: 'feature_aspect',
|
|
18
|
+
LocaleMessage: 'locale_message',
|
|
19
|
+
NewCheckoutBeta: 'new_checkout_beta',
|
|
20
|
+
PageAuditor: 'page_auditor',
|
|
21
|
+
PromptExplorer: 'prompt_explorer',
|
|
22
|
+
TeamAuditor: 'team_auditor',
|
|
23
|
+
};
|
|
24
|
+
export const featureAudienceNameEnum = {
|
|
25
|
+
AccountsReceivable: 'accounts_receivable',
|
|
26
|
+
CheckoutSales: 'checkout_sales',
|
|
27
|
+
CustomerSuccess: 'customer_success',
|
|
28
|
+
Designer: 'designer',
|
|
29
|
+
DocsContributor: 'docs_contributor',
|
|
30
|
+
Executive: 'executive',
|
|
31
|
+
ExecutiveAssistant: 'executive_assistant',
|
|
32
|
+
Finance: 'finance',
|
|
33
|
+
FrontendEngineer: 'frontend_engineer',
|
|
34
|
+
I18nKnownLanguage: 'i18n_known_language',
|
|
35
|
+
I18nSales: 'i18n_sales',
|
|
36
|
+
NewCheckoutMerchant: 'new_checkout_merchant',
|
|
37
|
+
Onboarding: 'onboarding',
|
|
38
|
+
PrincipalEngineer: 'principal_engineer',
|
|
39
|
+
ProServeHead: 'pro_serve_head',
|
|
40
|
+
ProductManager: 'product_manager',
|
|
41
|
+
TechLead: 'tech_lead',
|
|
42
|
+
};
|
|
5
43
|
export const localeElementsSupportedLocationCodeEnum = {
|
|
6
44
|
Ar: 'ar',
|
|
7
45
|
Da: 'da',
|
|
@@ -376,20 +414,59 @@ export const promptBulkJobStatusEnum = {
|
|
|
376
414
|
InProgress: 'in_progress',
|
|
377
415
|
Queued: 'queued',
|
|
378
416
|
};
|
|
379
|
-
export const promptCategoryCodeEnum = {
|
|
380
|
-
SeoMetaDescription: 'seo_meta_description',
|
|
381
|
-
SeoMetaTitle: 'seo_meta_title',
|
|
382
|
-
SeoStructuredData: 'seo_structured_data',
|
|
383
|
-
SeoSummary: 'seo_summary',
|
|
384
|
-
};
|
|
385
417
|
const defaultWrapper = (action, _operationName, _operationType) => action();
|
|
386
418
|
export function getSdk(client, withWrapper = defaultWrapper) {
|
|
387
419
|
return {
|
|
420
|
+
Cart(variables, requestHeaders) {
|
|
421
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'Cart', 'query');
|
|
422
|
+
},
|
|
388
423
|
CreateErrorEvent(variables, requestHeaders) {
|
|
389
424
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'CreateErrorEvent', 'mutation');
|
|
390
425
|
},
|
|
426
|
+
DeleteAllStoreReserveOrders(variables, requestHeaders) {
|
|
427
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'DeleteAllStoreReserveOrders', 'mutation');
|
|
428
|
+
},
|
|
429
|
+
DeleteBigCommerceCheckout(variables, requestHeaders) {
|
|
430
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'DeleteBigCommerceCheckout', 'mutation');
|
|
431
|
+
},
|
|
432
|
+
DeleteOrderImportLock(variables, requestHeaders) {
|
|
433
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'DeleteOrderImportLock', 'mutation');
|
|
434
|
+
},
|
|
435
|
+
DeleteReserveOrders(variables, requestHeaders) {
|
|
436
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'DeleteReserveOrders', 'mutation');
|
|
437
|
+
},
|
|
438
|
+
GetAudienceByAspectKey(variables, requestHeaders) {
|
|
439
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetAudienceByAspectKey', 'query');
|
|
440
|
+
},
|
|
441
|
+
GetBigCommerceCheckout(variables, requestHeaders) {
|
|
442
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetBigCommerceCheckout', 'query');
|
|
443
|
+
},
|
|
444
|
+
GetCheckoutReserveOrders(variables, requestHeaders) {
|
|
445
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetCheckoutReserveOrders', 'query');
|
|
446
|
+
},
|
|
447
|
+
GetReserveOrder(variables, requestHeaders) {
|
|
448
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetReserveOrder', 'query');
|
|
449
|
+
},
|
|
450
|
+
InsertCheckoutLog(variables, requestHeaders) {
|
|
451
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'InsertCheckoutLog', 'mutation');
|
|
452
|
+
},
|
|
453
|
+
InsertOrderImportLock(variables, requestHeaders) {
|
|
454
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'InsertOrderImportLock', 'mutation');
|
|
455
|
+
},
|
|
456
|
+
InsertReserveOrder(variables, requestHeaders) {
|
|
457
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'InsertReserveOrder', 'mutation');
|
|
458
|
+
},
|
|
459
|
+
InsertReserveOrderLog(variables, requestHeaders) {
|
|
460
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'InsertReserveOrderLog', 'mutation');
|
|
461
|
+
},
|
|
391
462
|
LocaleCountryMessages(variables, requestHeaders) {
|
|
392
463
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'LocaleCountryMessages', 'query');
|
|
393
464
|
},
|
|
465
|
+
UpdateReserveOrder(variables, requestHeaders) {
|
|
466
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'UpdateReserveOrder', 'mutation');
|
|
467
|
+
},
|
|
468
|
+
UpsertBigCommerceCheckout(variables, requestHeaders) {
|
|
469
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'UpsertBigCommerceCheckout', 'mutation');
|
|
470
|
+
},
|
|
394
471
|
};
|
|
395
472
|
}
|
package/dist/components/cart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z as zonosStore, c as createStore } from './zonosStore.js';
|
|
2
2
|
import { h as handleFetch, l as logError, a as log, b as localizationStore, t as translate } from './localization.js';
|
|
3
3
|
import { i as isDarkColor } from './isDarkColor.js';
|
|
4
4
|
import { g as getBorderRadius } from './getBorderRadius.js';
|
|
@@ -32,9 +32,36 @@ const prepCalculateLandedCost = () => {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const data = prepCalculateLandedCost();
|
|
38
|
+
const landedCost = await buildLandedCost(data.checkoutSessionId, data.contact, data.shippingAddress);
|
|
39
|
+
if (!landedCost) {
|
|
40
|
+
throw new Error('Failed to build landed cost');
|
|
41
|
+
}
|
|
42
|
+
// Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
|
|
43
|
+
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/validate-landed-cost`, {
|
|
44
|
+
body: landedCost,
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
method: 'POST',
|
|
49
|
+
});
|
|
50
|
+
if (!json || errors.length) {
|
|
51
|
+
throw new Error(`Invalid landed cost object: ${((_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
|
|
52
|
+
}
|
|
53
|
+
return landedCost;
|
|
54
|
+
};
|
|
55
|
+
|
|
35
56
|
const calculateLandedCost = async (abortController) => {
|
|
57
|
+
// If buildLandedCost callback is supplied, use that instead of our regular request to '/calculate-landed-cost'
|
|
58
|
+
const buildLandedCost = zonosStore.checkoutSettings.buildLandedCost;
|
|
59
|
+
if (buildLandedCost) {
|
|
60
|
+
const json = await triggerBuildLandedCost(buildLandedCost);
|
|
61
|
+
return json;
|
|
62
|
+
}
|
|
36
63
|
// request to get landed cost info
|
|
37
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/calculate-landed-cost`;
|
|
64
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/calculate-landed-cost`;
|
|
38
65
|
const { errors, json } = await handleFetch(url, {
|
|
39
66
|
body: prepCalculateLandedCost(),
|
|
40
67
|
method: 'POST',
|
|
@@ -89,6 +116,7 @@ const { onChange: onChange$1, reset: reset$1, state: stripeStore, } = createStor
|
|
|
89
116
|
stripeAddressElement: null,
|
|
90
117
|
stripeAddressEventData: null,
|
|
91
118
|
stripeAddressUsedWhenFetchingLC: null,
|
|
119
|
+
stripeBillingAddressElement: null,
|
|
92
120
|
stripeElements: null,
|
|
93
121
|
stripeElementsOptions: null,
|
|
94
122
|
stripeLinkElement: null,
|
|
@@ -334,7 +362,7 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
334
362
|
return false;
|
|
335
363
|
}
|
|
336
364
|
stripeStore.isFetchingSession = true;
|
|
337
|
-
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/create-checkout-session`, {
|
|
365
|
+
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/create-checkout-session`, {
|
|
338
366
|
body: {
|
|
339
367
|
currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
|
|
340
368
|
itemsAmount: total,
|
|
@@ -362,7 +390,7 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
362
390
|
const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
|
|
363
391
|
// No need to set loading state here because this function will be called under the hood to update
|
|
364
392
|
// landed cost id for the section.
|
|
365
|
-
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/update-checkout-session`, {
|
|
393
|
+
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/update-checkout-session`, {
|
|
366
394
|
body: {
|
|
367
395
|
currency,
|
|
368
396
|
id,
|
|
@@ -474,7 +502,7 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
|
|
|
474
502
|
}
|
|
475
503
|
// update checkout session
|
|
476
504
|
if (!cartStore.checkoutSessionId) {
|
|
477
|
-
logError('Could update cart total without checkout session id');
|
|
505
|
+
logError('Could not update cart total without checkout session id');
|
|
478
506
|
return false;
|
|
479
507
|
}
|
|
480
508
|
const { json } = await stripeStoreUpdateCheckoutSession({
|
|
@@ -3192,7 +3192,7 @@ const handleFetch = async (url, _opts) => {
|
|
|
3192
3192
|
|
|
3193
3193
|
const getCountries = async () => {
|
|
3194
3194
|
try {
|
|
3195
|
-
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/get-countries`, {
|
|
3195
|
+
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/get-countries`, {
|
|
3196
3196
|
method: 'GET',
|
|
3197
3197
|
});
|
|
3198
3198
|
if (errors.length || !json) {
|
|
@@ -3215,7 +3215,7 @@ const getCountryLandedCost = async (countryCode) => {
|
|
|
3215
3215
|
if (!countryCode) {
|
|
3216
3216
|
return null;
|
|
3217
3217
|
}
|
|
3218
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/country-landed-cost/${countryCode}`;
|
|
3218
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/country-landed-cost/${countryCode}`;
|
|
3219
3219
|
const { errors, json } = await handleFetch(url);
|
|
3220
3220
|
if (errors.length || !json) {
|
|
3221
3221
|
logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
@@ -3230,7 +3230,7 @@ const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCu
|
|
|
3230
3230
|
if (sourceCurrency === targetCurrency && !isGuaranteed) {
|
|
3231
3231
|
return { exchangeRate: null, maxAge: null };
|
|
3232
3232
|
}
|
|
3233
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/exchange-rates?sourceCurrency=${sourceCurrency}&targetCurrency=${targetCurrency}&isGuaranteed=${isGuaranteed}&country=${country}
|
|
3233
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/exchange-rates?sourceCurrency=${sourceCurrency}&targetCurrency=${targetCurrency}&isGuaranteed=${isGuaranteed}&country=${country}`;
|
|
3234
3234
|
const { errors, json } = await handleFetch(url);
|
|
3235
3235
|
if (errors.length || !json) {
|
|
3236
3236
|
logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
@@ -3247,7 +3247,7 @@ const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCu
|
|
|
3247
3247
|
|
|
3248
3248
|
const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
|
|
3249
3249
|
var _a;
|
|
3250
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/locale-messages?countryCode=${countryCode}&storeId=${storeId}&localeTo=${localeTo}`;
|
|
3250
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/locale-messages?countryCode=${countryCode}&storeId=${storeId}&localeTo=${localeTo}`;
|
|
3251
3251
|
const { errors, json } = await handleFetch(url);
|
|
3252
3252
|
if (errors.length || !json) {
|
|
3253
3253
|
// eslint-disable-next-line no-console
|
|
@@ -3269,7 +3269,7 @@ const getLocalization = async () => {
|
|
|
3269
3269
|
// load and use country from session storage when zCountry query param is not present
|
|
3270
3270
|
const countryLoadedSession = window.sessionStorage.getItem('zonos--country');
|
|
3271
3271
|
const zCountry = getZCountryUrlParam(currentUrl.searchParams) || countryLoadedSession;
|
|
3272
|
-
const localizationUrl = new URL(`${"https://v1.route.js.zonos.com"}/api/localization`);
|
|
3272
|
+
const localizationUrl = new URL(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/localization`);
|
|
3273
3273
|
if (zCountry) {
|
|
3274
3274
|
localizationUrl.searchParams.set('zCountry', zCountry);
|
|
3275
3275
|
}
|
|
@@ -3292,7 +3292,7 @@ const getLocalization = async () => {
|
|
|
3292
3292
|
|
|
3293
3293
|
const getShippingZones = async () => {
|
|
3294
3294
|
var _a, _b;
|
|
3295
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/shipping-zones`;
|
|
3295
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/shipping-zones`;
|
|
3296
3296
|
const { errors, json } = await handleFetch(url);
|
|
3297
3297
|
if (errors.length || !json) {
|
|
3298
3298
|
logError(`Error fetching shipping zones: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host, Fragment } from '@stencil/core/internal/client';
|
|
2
|
-
import { s as stripeStore, p as stripeStoreRetrievePayment, o as stripeStoreReset } from './cart.js';
|
|
3
|
-
import { t as translate } from './localization.js';
|
|
2
|
+
import { s as stripeStore, p as stripeStoreRetrievePayment, o as stripeStoreReset, c as cartStore } from './cart.js';
|
|
3
|
+
import { h as handleFetch, l as logError, t as translate } from './localization.js';
|
|
4
4
|
import { g as getBorderRadius } from './getBorderRadius.js';
|
|
5
5
|
import { s as submitGtag } from './submitGtag.js';
|
|
6
6
|
import { d as defineCustomElement$4 } from './zonos-button2.js';
|
|
@@ -20,6 +20,36 @@ const ZonosCheckoutFinish = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout
|
|
|
20
20
|
this.__registerHost();
|
|
21
21
|
this.__attachShadow();
|
|
22
22
|
this.closeClick = createEvent(this, "closeClick", 7);
|
|
23
|
+
this.pullOrder = async () => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const baseUrl = "https://v1.route.js.zonos.com";
|
|
26
|
+
const checkoutSessionId = cartStore.checkoutSessionId;
|
|
27
|
+
const { errors, json } = await handleFetch(`${baseUrl}/api/zonos-elements/get-order?checkoutSessionId=${checkoutSessionId}`);
|
|
28
|
+
if (errors.length || !(json === null || json === void 0 ? void 0 : json.id)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
// TODO: This method of triggering /success for BigCommerce is for MVP. Remove when eventRegistry is fixed to handle by webhooks
|
|
32
|
+
if (window.Zonos.isBigCommerce) {
|
|
33
|
+
const orderId = json === null || json === void 0 ? void 0 : json.id;
|
|
34
|
+
const storeHash = (_b = (_a = json === null || json === void 0 ? void 0 : json.metadata) === null || _a === void 0 ? void 0 : _a.find(x => (x === null || x === void 0 ? void 0 : x.key) === 'storeHash')) === null || _b === void 0 ? void 0 : _b.value;
|
|
35
|
+
if (!orderId || !storeHash) {
|
|
36
|
+
return logError('Unable to trigger BigCommerce /success: Missing orderId or storeHash');
|
|
37
|
+
}
|
|
38
|
+
void handleFetch(`${baseUrl}/api/bigcommerce/success?orderId=${orderId}&storeHash=${storeHash}`);
|
|
39
|
+
}
|
|
40
|
+
return json;
|
|
41
|
+
};
|
|
42
|
+
this.getPullOrder = async (attempts = 0) => {
|
|
43
|
+
const order = await this.pullOrder();
|
|
44
|
+
if (order) {
|
|
45
|
+
this.order = order;
|
|
46
|
+
}
|
|
47
|
+
else if (!order && attempts < 5) {
|
|
48
|
+
// Wait for 1 second before the next attempt
|
|
49
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
50
|
+
await this.getPullOrder(attempts + 1);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
23
53
|
this.checkPaymentStatus = async () => {
|
|
24
54
|
this.isLoading = true;
|
|
25
55
|
const clientSecret = new URLSearchParams(window.location.search).get('payment_intent_client_secret') || stripeStore.clientSecret;
|
|
@@ -45,6 +75,10 @@ const ZonosCheckoutFinish = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout
|
|
|
45
75
|
});
|
|
46
76
|
document.dispatchEvent(successEvent);
|
|
47
77
|
}
|
|
78
|
+
// Attempt to pull the order details from the graph every second on 5 attempts
|
|
79
|
+
if (this.notificationType === 'success') {
|
|
80
|
+
void this.getPullOrder();
|
|
81
|
+
}
|
|
48
82
|
}
|
|
49
83
|
stripeStoreReset();
|
|
50
84
|
this.isLoading = false;
|
|
@@ -59,6 +93,7 @@ const ZonosCheckoutFinish = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout
|
|
|
59
93
|
this.notificationType = 'success';
|
|
60
94
|
this.notificationTitle = '';
|
|
61
95
|
this.notificationMessages = [];
|
|
96
|
+
this.order = null;
|
|
62
97
|
}
|
|
63
98
|
componentDidLoad() {
|
|
64
99
|
if (this.overrideNotification) {
|
|
@@ -72,9 +107,16 @@ const ZonosCheckoutFinish = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout
|
|
|
72
107
|
void this.checkPaymentStatus();
|
|
73
108
|
}
|
|
74
109
|
render() {
|
|
110
|
+
// TODO: Keeping this code for when we have a UI for order details
|
|
111
|
+
// const orderTotal = this.order?.amountSubtotals
|
|
112
|
+
// ? Object.values(this.order.amountSubtotals).reduce((a, b) => a + b, 0)
|
|
113
|
+
// : 0;
|
|
114
|
+
// const totalItems = this.order?.items?.reduce((acc, item) => {
|
|
115
|
+
// return acc + item.quantity;
|
|
116
|
+
// }, 0);
|
|
75
117
|
return (h(Host, { class: "zonos--checkout-finish zonos--elements", style: {
|
|
76
118
|
'--border-radius': getBorderRadius(this.borderRadius),
|
|
77
|
-
} }, this.isLoading && (h("div", { class: "loading-wrapper" }, h("zonos-spinner", null))), !this.isLoading && (h("div", { class: "zonos--group" }, this.notificationType === 'success' ? (h("zonos-icon", { color: 'blue-800', content: SuccessIcon, size: 50 })) : (h("zonos-icon", { color: 'red-800', content: RemoveIcon, size: 50 })), h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), h("zonos-text", null, this.notificationMessages.map(message => (h(Fragment, null, message, h("br", null))))), h("zonos-button", { onClick: () => this.closeClickHandler(), size: "md", variant: "primary" }, translate('Keep shopping'))))));
|
|
119
|
+
} }, this.isLoading && (h("div", { class: "loading-wrapper" }, h("zonos-spinner", null))), !this.isLoading && (h(Fragment, null, h("div", { class: "zonos--group" }, this.notificationType === 'success' ? (h("zonos-icon", { color: 'blue-800', content: SuccessIcon, size: 50 })) : (h("zonos-icon", { color: 'red-800', content: RemoveIcon, size: 50 })), h("zonos-text", { class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), h("zonos-text", null, this.notificationMessages.map(message => (h(Fragment, null, message, h("br", null))))), h("zonos-button", { onClick: () => this.closeClickHandler(), size: "md", variant: "primary" }, translate('Keep shopping')))))));
|
|
78
120
|
}
|
|
79
121
|
static get assetsDirs() { return ["assets"]; }
|
|
80
122
|
static get style() { return zonosCheckoutFinishCss; }
|
|
@@ -85,7 +127,8 @@ const ZonosCheckoutFinish = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout
|
|
|
85
127
|
"isLoading": [32],
|
|
86
128
|
"notificationType": [32],
|
|
87
129
|
"notificationTitle": [32],
|
|
88
|
-
"notificationMessages": [32]
|
|
130
|
+
"notificationMessages": [32],
|
|
131
|
+
"order": [32]
|
|
89
132
|
}]);
|
|
90
133
|
function defineCustomElement() {
|
|
91
134
|
if (typeof customElements === "undefined") {
|
|
@@ -315,6 +315,8 @@ const ZonosCheckout$1 = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout ext
|
|
|
315
315
|
// Update the URL without query parameters
|
|
316
316
|
window.history.replaceState({}, document.title, cleanUrl);
|
|
317
317
|
this.open = false;
|
|
318
|
+
// Reload the page
|
|
319
|
+
window.location.reload();
|
|
318
320
|
}
|
|
319
321
|
async handleBackClick() {
|
|
320
322
|
// close the modal if back button is clicked on customer info step
|
|
@@ -6,7 +6,7 @@ import { d as defineCustomElement$3 } from './zonos-notification2.js';
|
|
|
6
6
|
import { d as defineCustomElement$2 } from './zonos-text2.js';
|
|
7
7
|
|
|
8
8
|
const getZonosSetting = async () => {
|
|
9
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-setting`;
|
|
9
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/zonos-setting`;
|
|
10
10
|
const { errors, json } = await handleFetch(url);
|
|
11
11
|
if (errors.length) {
|
|
12
12
|
logError(`Error occurs when getting zonos settings. If this is not an unauthorized error, it will use user setting or default setting`);
|
|
@@ -149,7 +149,7 @@ const ZonosController$1 = /*@__PURE__*/ proxyCustomElement(class ZonosController
|
|
|
149
149
|
zonosStore.appearance = Object.assign(Object.assign({}, zonosStore.appearance), { fontFamily: overrideFont });
|
|
150
150
|
}
|
|
151
151
|
const routeUrl = "https://v1.route.js.zonos.com";
|
|
152
|
-
const { errors, json } = await handleFetch(`${routeUrl}/api/get-font-detail?family=${fontSelected}`);
|
|
152
|
+
const { errors, json } = await handleFetch(`${routeUrl}/api/zonos-elements/get-font-detail?family=${fontSelected}`);
|
|
153
153
|
if (errors.length > 0 || !json) {
|
|
154
154
|
log(`Failed to load font ${fontSelected}`, 'warn');
|
|
155
155
|
return;
|
|
@@ -353,7 +353,7 @@ var debounce_1 = debounce;
|
|
|
353
353
|
|
|
354
354
|
const checkItemRestrictions = async ({ items, shipFrom, shipTo, }) => {
|
|
355
355
|
var _a;
|
|
356
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/check-item-restrictions`;
|
|
356
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/check-item-restrictions`;
|
|
357
357
|
const body = {
|
|
358
358
|
items,
|
|
359
359
|
shipFrom,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { h as handleFetch, l as log, a as localizationStore, b as logError, t as translate } from './localization-
|
|
3
|
-
import { i as isDarkColor } from './isDarkColor-
|
|
4
|
-
import { g as getBorderRadius } from './getBorderRadius-
|
|
1
|
+
import { z as zonosStore, c as createStore } from './zonosStore-61e74f58.js';
|
|
2
|
+
import { h as handleFetch, l as log, a as localizationStore, b as logError, t as translate } from './localization-a51ccbc2.js';
|
|
3
|
+
import { i as isDarkColor } from './isDarkColor-416d6047.js';
|
|
4
|
+
import { g as getBorderRadius } from './getBorderRadius-178a0a05.js';
|
|
5
5
|
|
|
6
6
|
const prepCalculateLandedCost = () => {
|
|
7
7
|
// maybe we don't need email now for prefetch the landed cost
|
|
@@ -32,9 +32,36 @@ const prepCalculateLandedCost = () => {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const data = prepCalculateLandedCost();
|
|
38
|
+
const landedCost = await buildLandedCost(data.checkoutSessionId, data.contact, data.shippingAddress);
|
|
39
|
+
if (!landedCost) {
|
|
40
|
+
throw new Error('Failed to build landed cost');
|
|
41
|
+
}
|
|
42
|
+
// Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
|
|
43
|
+
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/validate-landed-cost`, {
|
|
44
|
+
body: landedCost,
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
method: 'POST',
|
|
49
|
+
});
|
|
50
|
+
if (!json || errors.length) {
|
|
51
|
+
throw new Error(`Invalid landed cost object: ${((_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
|
|
52
|
+
}
|
|
53
|
+
return landedCost;
|
|
54
|
+
};
|
|
55
|
+
|
|
35
56
|
const calculateLandedCost = async (abortController) => {
|
|
57
|
+
// If buildLandedCost callback is supplied, use that instead of our regular request to '/calculate-landed-cost'
|
|
58
|
+
const buildLandedCost = zonosStore.checkoutSettings.buildLandedCost;
|
|
59
|
+
if (buildLandedCost) {
|
|
60
|
+
const json = await triggerBuildLandedCost(buildLandedCost);
|
|
61
|
+
return json;
|
|
62
|
+
}
|
|
36
63
|
// request to get landed cost info
|
|
37
|
-
const url = `${"https://v1.route.js.zonos.com"}/api/calculate-landed-cost`;
|
|
64
|
+
const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/calculate-landed-cost`;
|
|
38
65
|
const { errors, json } = await handleFetch(url, {
|
|
39
66
|
body: prepCalculateLandedCost(),
|
|
40
67
|
method: 'POST',
|
|
@@ -89,6 +116,7 @@ const { onChange: onChange$1, reset: reset$1, state: stripeStore, } = createStor
|
|
|
89
116
|
stripeAddressElement: null,
|
|
90
117
|
stripeAddressEventData: null,
|
|
91
118
|
stripeAddressUsedWhenFetchingLC: null,
|
|
119
|
+
stripeBillingAddressElement: null,
|
|
92
120
|
stripeElements: null,
|
|
93
121
|
stripeElementsOptions: null,
|
|
94
122
|
stripeLinkElement: null,
|
|
@@ -334,7 +362,7 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
334
362
|
return false;
|
|
335
363
|
}
|
|
336
364
|
stripeStore.isFetchingSession = true;
|
|
337
|
-
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/create-checkout-session`, {
|
|
365
|
+
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/create-checkout-session`, {
|
|
338
366
|
body: {
|
|
339
367
|
currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
|
|
340
368
|
itemsAmount: total,
|
|
@@ -362,7 +390,7 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
362
390
|
const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
|
|
363
391
|
// No need to set loading state here because this function will be called under the hood to update
|
|
364
392
|
// landed cost id for the section.
|
|
365
|
-
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/update-checkout-session`, {
|
|
393
|
+
const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/update-checkout-session`, {
|
|
366
394
|
body: {
|
|
367
395
|
currency,
|
|
368
396
|
id,
|
|
@@ -474,7 +502,7 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
|
|
|
474
502
|
}
|
|
475
503
|
// update checkout session
|
|
476
504
|
if (!cartStore.checkoutSessionId) {
|
|
477
|
-
logError('Could update cart total without checkout session id');
|
|
505
|
+
logError('Could not update cart total without checkout session id');
|
|
478
506
|
return false;
|
|
479
507
|
}
|
|
480
508
|
const { json } = await stripeStoreUpdateCheckoutSession({
|