@tagadapay/plugin-sdk 4.0.0 → 4.0.2
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/README.md +1129 -1129
- package/build-cdn.js +499 -499
- package/dist/external-tracker.js +156 -2
- package/dist/external-tracker.min.js +2 -2
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/tagada-react-sdk-minimal.min.js +2 -2
- package/dist/tagada-react-sdk-minimal.min.js.map +4 -4
- package/dist/tagada-react-sdk.js +696 -245
- package/dist/tagada-react-sdk.min.js +2 -2
- package/dist/tagada-react-sdk.min.js.map +4 -4
- package/dist/tagada-sdk.js +2908 -94
- package/dist/tagada-sdk.min.js +2 -2
- package/dist/tagada-sdk.min.js.map +4 -4
- package/dist/v2/core/funnelClient.d.ts +40 -0
- package/dist/v2/core/funnelClient.js +30 -0
- package/dist/v2/core/pixelTracker.d.ts +51 -0
- package/dist/v2/core/pixelTracker.js +425 -0
- package/dist/v2/core/resources/checkout.d.ts +45 -1
- package/dist/v2/core/resources/checkout.js +13 -3
- package/dist/v2/core/resources/offers.d.ts +1 -1
- package/dist/v2/core/resources/offers.js +3 -1
- package/dist/v2/core/resources/promotionEvents.d.ts +5 -0
- package/dist/v2/core/resources/promotionEvents.js +2 -0
- package/dist/v2/core/resources/promotions.d.ts +6 -1
- package/dist/v2/core/resources/promotions.js +6 -1
- package/dist/v2/core/resources/shippingRates.d.ts +18 -0
- package/dist/v2/core/resources/shippingRates.js +18 -0
- package/dist/v2/core/utils/clickIdResolver.d.ts +79 -0
- package/dist/v2/core/utils/clickIdResolver.js +169 -0
- package/dist/v2/core/utils/index.d.ts +2 -0
- package/dist/v2/core/utils/index.js +4 -0
- package/dist/v2/core/utils/metaEventId.d.ts +14 -0
- package/dist/v2/core/utils/metaEventId.js +16 -0
- package/dist/v2/core/utils/previewModeIndicator.js +101 -101
- package/dist/v2/index.d.ts +7 -0
- package/dist/v2/index.js +10 -0
- package/dist/v2/react/components/ApplePayButton.js +50 -0
- package/dist/v2/react/components/FunnelScriptInjector.js +9 -9
- package/dist/v2/react/components/GooglePayButton.js +39 -1
- package/dist/v2/react/components/StripeExpressButton.js +54 -2
- package/dist/v2/react/hooks/payment-actions/useNgeniusThreedsAction.js +11 -11
- package/dist/v2/react/hooks/useCheckoutQuery.js +41 -29
- package/dist/v2/react/hooks/useDiscountsQuery.js +4 -0
- package/dist/v2/react/hooks/useFunnel.d.ts +7 -0
- package/dist/v2/react/hooks/useFunnel.js +2 -1
- package/dist/v2/react/hooks/usePixelTracking.d.ts +10 -5
- package/dist/v2/react/hooks/usePixelTracking.js +32 -374
- package/dist/v2/react/hooks/usePreviewOffer.d.ts +3 -1
- package/dist/v2/react/hooks/usePreviewOffer.js +8 -2
- package/dist/v2/react/hooks/usePromotionsQuery.js +9 -3
- package/dist/v2/react/hooks/useShippingRatesQuery.js +36 -21
- package/dist/v2/react/hooks/useStepConfig.d.ts +9 -0
- package/dist/v2/react/hooks/useStepConfig.js +5 -1
- package/dist/v2/react/index.d.ts +4 -0
- package/dist/v2/react/index.js +8 -0
- package/dist/v2/react/providers/TagadaProvider.js +18 -5
- package/dist/v2/standalone/apple-pay-service.d.ts +1 -1
- package/dist/v2/standalone/index.d.ts +3 -0
- package/dist/v2/standalone/index.js +23 -0
- package/dist/v2/standalone/payment-service.d.ts +54 -1
- package/dist/v2/standalone/payment-service.js +228 -61
- package/package.json +115 -115
package/dist/tagada-react-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TagadaPay React SDK v4.0.
|
|
2
|
+
* TagadaPay React SDK v4.0.2
|
|
3
3
|
* CDN Bundle - React hooks and TagadaProvider (Debug Build)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -3391,6 +3391,26 @@ var TagadaReactSDKBundle = (() => {
|
|
|
3391
3391
|
"/api/v1/checkout-sessions/".concat(sessionId, "/shipping-rates/preview?").concat(queryParams.toString())
|
|
3392
3392
|
);
|
|
3393
3393
|
}
|
|
3394
|
+
/**
|
|
3395
|
+
* Preview shipping rates for a country AND persist the auto-selected rate on the session.
|
|
3396
|
+
*
|
|
3397
|
+
* Difference with `previewShippingRates` (which is read-only):
|
|
3398
|
+
* - the server picks the highlighted (or cheapest) rate for `countryCode`
|
|
3399
|
+
* - it writes `checkoutSession.shippingRateId` to the DB
|
|
3400
|
+
* - the next `getCheckout()` will return a summary that includes shipping cost
|
|
3401
|
+
*
|
|
3402
|
+
* Use this from the studio when geolocation (or any client-side hint) determines a country
|
|
3403
|
+
* BEFORE the user submits the full address. Otherwise the wallet sheet (Apple Pay, etc.) will
|
|
3404
|
+
* be opened with a stale total that doesn't include shipping fees.
|
|
3405
|
+
*/
|
|
3406
|
+
async selectPreviewShippingRate(sessionId, params) {
|
|
3407
|
+
return this.apiClient.post(
|
|
3408
|
+
"/api/v1/checkout-sessions/".concat(sessionId, "/shipping-rates/select-preview"),
|
|
3409
|
+
__spreadValues({
|
|
3410
|
+
countryCode: params.countryCode
|
|
3411
|
+
}, params.stateCode ? { stateCode: params.stateCode } : {})
|
|
3412
|
+
);
|
|
3413
|
+
}
|
|
3394
3414
|
};
|
|
3395
3415
|
}
|
|
3396
3416
|
});
|
|
@@ -9994,8 +10014,11 @@ var TagadaReactSDKBundle = (() => {
|
|
|
9994
10014
|
FunnelClient: () => FunnelClient,
|
|
9995
10015
|
TrackingProvider: () => TrackingProvider,
|
|
9996
10016
|
findMethod: () => findMethod,
|
|
10017
|
+
getAssignedCheckoutOfferDefault: () => getAssignedCheckoutOfferDefault,
|
|
10018
|
+
getAssignedCheckoutOfferIds: () => getAssignedCheckoutOfferIds,
|
|
9997
10019
|
getAssignedOrderBumpOfferIds: () => getAssignedOrderBumpOfferIds,
|
|
9998
10020
|
getAssignedPaymentFlowId: () => getAssignedPaymentFlowId,
|
|
10021
|
+
getAssignedPaymentInitiator: () => getAssignedPaymentInitiator,
|
|
9999
10022
|
getAssignedPixels: () => getAssignedPixels,
|
|
10000
10023
|
getAssignedResources: () => getAssignedResources,
|
|
10001
10024
|
getAssignedScripts: () => getAssignedScripts,
|
|
@@ -10140,7 +10163,8 @@ var TagadaReactSDKBundle = (() => {
|
|
|
10140
10163
|
scripts: local.scripts,
|
|
10141
10164
|
pixels: local.pixels,
|
|
10142
10165
|
orderBumps: local.orderBumps,
|
|
10143
|
-
upsellOffers: local.upsellOffers
|
|
10166
|
+
upsellOffers: local.upsellOffers,
|
|
10167
|
+
checkoutOffers: local.checkoutOffers
|
|
10144
10168
|
};
|
|
10145
10169
|
}
|
|
10146
10170
|
function getAssignedStepConfig() {
|
|
@@ -10186,6 +10210,10 @@ var TagadaReactSDKBundle = (() => {
|
|
|
10186
10210
|
}
|
|
10187
10211
|
return void 0;
|
|
10188
10212
|
}
|
|
10213
|
+
function getAssignedPaymentInitiator() {
|
|
10214
|
+
const stepConfig = getAssignedStepConfig();
|
|
10215
|
+
return stepConfig == null ? void 0 : stepConfig.paymentInitiator;
|
|
10216
|
+
}
|
|
10189
10217
|
function getAssignedResources() {
|
|
10190
10218
|
const stepConfig = getAssignedStepConfig();
|
|
10191
10219
|
const legacy = stepConfig == null ? void 0 : stepConfig.staticResources;
|
|
@@ -10240,6 +10268,17 @@ var TagadaReactSDKBundle = (() => {
|
|
|
10240
10268
|
if (stepConfig.upsellOffers.mode !== "custom") return void 0;
|
|
10241
10269
|
return stepConfig.upsellOffers.enabledUpsellIds;
|
|
10242
10270
|
}
|
|
10271
|
+
function getAssignedCheckoutOfferIds() {
|
|
10272
|
+
const stepConfig = getAssignedStepConfig();
|
|
10273
|
+
if (!(stepConfig == null ? void 0 : stepConfig.checkoutOffers)) return void 0;
|
|
10274
|
+
if (stepConfig.checkoutOffers.mode !== "custom") return void 0;
|
|
10275
|
+
return stepConfig.checkoutOffers.enabledOfferIds;
|
|
10276
|
+
}
|
|
10277
|
+
function getAssignedCheckoutOfferDefault() {
|
|
10278
|
+
var _a11;
|
|
10279
|
+
const stepConfig = getAssignedStepConfig();
|
|
10280
|
+
return (_a11 = stepConfig == null ? void 0 : stepConfig.checkoutOffers) == null ? void 0 : _a11.defaultOfferId;
|
|
10281
|
+
}
|
|
10243
10282
|
var lazyInjectPreviewIndicator, TrackingProvider, localFunnelConfigCache, localFunnelConfigLoading, FunnelClient;
|
|
10244
10283
|
var init_funnelClient = __esm({
|
|
10245
10284
|
"src/v2/core/funnelClient.ts"() {
|
|
@@ -12768,47 +12807,12 @@ var TagadaReactSDKBundle = (() => {
|
|
|
12768
12807
|
}
|
|
12769
12808
|
});
|
|
12770
12809
|
|
|
12771
|
-
// src/v2/
|
|
12772
|
-
function useStepConfig() {
|
|
12773
|
-
const stepConfig = (0, import_react3.useMemo)(() => getAssignedStepConfig(), []);
|
|
12774
|
-
const paymentFlowId = (0, import_react3.useMemo)(() => getAssignedPaymentFlowId(), []);
|
|
12775
|
-
const resources = (0, import_react3.useMemo)(() => getAssignedResources(), []);
|
|
12776
|
-
const pixels = (0, import_react3.useMemo)(() => getAssignedPixels(), []);
|
|
12777
|
-
const getScripts = (0, import_react3.useMemo)(() => {
|
|
12778
|
-
return (position) => {
|
|
12779
|
-
return getAssignedScripts(position);
|
|
12780
|
-
};
|
|
12781
|
-
}, []);
|
|
12782
|
-
const paymentSetupConfig = (0, import_react3.useMemo)(() => stepConfig == null ? void 0 : stepConfig.paymentSetupConfig, [stepConfig]);
|
|
12783
|
-
const orderBumpOfferIds = (0, import_react3.useMemo)(() => getAssignedOrderBumpOfferIds(), []);
|
|
12784
|
-
const upsellOfferIds = (0, import_react3.useMemo)(() => getAssignedUpsellOfferIds(), []);
|
|
12785
|
-
return {
|
|
12786
|
-
stepConfig,
|
|
12787
|
-
paymentFlowId,
|
|
12788
|
-
resources,
|
|
12789
|
-
staticResources: resources,
|
|
12790
|
-
getScripts,
|
|
12791
|
-
pixels,
|
|
12792
|
-
paymentSetupConfig,
|
|
12793
|
-
orderBumpOfferIds,
|
|
12794
|
-
upsellOfferIds
|
|
12795
|
-
};
|
|
12796
|
-
}
|
|
12797
|
-
var import_react3;
|
|
12798
|
-
var init_useStepConfig = __esm({
|
|
12799
|
-
"src/v2/react/hooks/useStepConfig.ts"() {
|
|
12800
|
-
"use strict";
|
|
12801
|
-
import_react3 = __require("react");
|
|
12802
|
-
init_funnelClient();
|
|
12803
|
-
}
|
|
12804
|
-
});
|
|
12805
|
-
|
|
12806
|
-
// src/v2/react/hooks/usePixelTracking.tsx
|
|
12810
|
+
// src/v2/core/pixelTracker.ts
|
|
12807
12811
|
function createDuplicateGuard(windowMs) {
|
|
12808
12812
|
const lastEvents = /* @__PURE__ */ new Map();
|
|
12809
|
-
return (eventName, parameters) => {
|
|
12813
|
+
return (eventName, parameters, eventId) => {
|
|
12810
12814
|
try {
|
|
12811
|
-
const key = JSON.stringify({ eventName, parameters });
|
|
12815
|
+
const key = JSON.stringify({ eventName, parameters, eventId });
|
|
12812
12816
|
const now = Date.now();
|
|
12813
12817
|
const last = lastEvents.get(key);
|
|
12814
12818
|
if (last && now - last < windowMs) return false;
|
|
@@ -12819,112 +12823,36 @@ var TagadaReactSDKBundle = (() => {
|
|
|
12819
12823
|
}
|
|
12820
12824
|
};
|
|
12821
12825
|
}
|
|
12822
|
-
function
|
|
12823
|
-
|
|
12824
|
-
const [pixelsInitialized, setPixelsInitialized] = (0, import_react4.useState)(false);
|
|
12825
|
-
const isMountedRef = (0, import_react4.useRef)(true);
|
|
12826
|
-
(0, import_react4.useEffect)(() => {
|
|
12827
|
-
isMountedRef.current = true;
|
|
12828
|
-
return () => {
|
|
12829
|
-
isMountedRef.current = false;
|
|
12830
|
-
};
|
|
12831
|
-
}, []);
|
|
12832
|
-
(0, import_react4.useEffect)(() => {
|
|
12833
|
-
var _a11, _b2, _c, _d, _e;
|
|
12834
|
-
if (!pixels || pixelsInitialized || !isMountedRef.current) return;
|
|
12835
|
-
const loadPromises = [];
|
|
12836
|
-
try {
|
|
12837
|
-
(_a11 = pixels.facebook) == null ? void 0 : _a11.forEach((px) => {
|
|
12838
|
-
if (px.enabled && px.pixelId) loadPromises.push(initMetaPixel(px.pixelId));
|
|
12839
|
-
});
|
|
12840
|
-
(_b2 = pixels.tiktok) == null ? void 0 : _b2.forEach((px) => {
|
|
12841
|
-
if (px.enabled && px.pixelId) loadPromises.push(initTikTokPixel(px.pixelId));
|
|
12842
|
-
});
|
|
12843
|
-
(_c = pixels.snapchat) == null ? void 0 : _c.forEach((px) => {
|
|
12844
|
-
if (px.enabled && px.pixelId) loadPromises.push(initSnapchatPixel(px.pixelId));
|
|
12845
|
-
});
|
|
12846
|
-
(_d = pixels.pinterest) == null ? void 0 : _d.forEach((px) => {
|
|
12847
|
-
if (px.enabled && px.pixelId) loadPromises.push(initPinterestPixel(px.pixelId));
|
|
12848
|
-
});
|
|
12849
|
-
(_e = pixels.gtm) == null ? void 0 : _e.forEach((px) => {
|
|
12850
|
-
if (px.enabled && px.containerId) loadPromises.push(initGTM(px.containerId));
|
|
12851
|
-
});
|
|
12852
|
-
Promise.all(loadPromises).then(() => {
|
|
12853
|
-
if (isMountedRef.current) setPixelsInitialized(true);
|
|
12854
|
-
});
|
|
12855
|
-
} catch (error) {
|
|
12856
|
-
console.error("[SDK Pixels] Initialization error:", error);
|
|
12857
|
-
}
|
|
12858
|
-
}, [pixels, pixelsInitialized]);
|
|
12859
|
-
const track = (0, import_react4.useCallback)(
|
|
12860
|
-
(eventName, parameters = {}) => {
|
|
12861
|
-
if (!pixels || !pixelsInitialized || !isMountedRef.current) return;
|
|
12862
|
-
if (!shouldTrackEvent(eventName, parameters)) return;
|
|
12863
|
-
try {
|
|
12864
|
-
const events = resolvePixelEvents(pixels, eventName, parameters);
|
|
12865
|
-
const firedProviders = /* @__PURE__ */ new Set();
|
|
12866
|
-
for (const { provider, mapped, pixel } of events) {
|
|
12867
|
-
if (provider === "gtm" || provider === "tiktok") {
|
|
12868
|
-
fire(provider, mapped.name, mapped.params, pixel);
|
|
12869
|
-
} else {
|
|
12870
|
-
if (!firedProviders.has(provider)) {
|
|
12871
|
-
fire(provider, mapped.name, mapped.params);
|
|
12872
|
-
firedProviders.add(provider);
|
|
12873
|
-
}
|
|
12874
|
-
}
|
|
12875
|
-
}
|
|
12876
|
-
} catch (error) {
|
|
12877
|
-
console.error("[SDK Pixels] Tracking error:", error);
|
|
12878
|
-
}
|
|
12879
|
-
},
|
|
12880
|
-
[pixels, pixelsInitialized]
|
|
12881
|
-
);
|
|
12882
|
-
(0, import_react4.useEffect)(() => {
|
|
12883
|
-
if (!pixelsInitialized || !isMountedRef.current) return;
|
|
12884
|
-
const id = setTimeout(() => {
|
|
12885
|
-
if (isMountedRef.current) {
|
|
12886
|
-
track("PageView", { path: typeof window !== "undefined" ? window.location.pathname : "" });
|
|
12887
|
-
}
|
|
12888
|
-
}, 0);
|
|
12889
|
-
return () => clearTimeout(id);
|
|
12890
|
-
}, [pixelsInitialized, track]);
|
|
12891
|
-
const value = (0, import_react4.useMemo)(
|
|
12892
|
-
() => ({ track, pixelsInitialized }),
|
|
12893
|
-
[track, pixelsInitialized]
|
|
12894
|
-
);
|
|
12895
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelTrackingContext.Provider, { value, children });
|
|
12896
|
-
}
|
|
12897
|
-
function usePixelTracking() {
|
|
12898
|
-
const context = (0, import_react4.useContext)(PixelTrackingContext);
|
|
12899
|
-
if (!context) throw new Error("usePixelTracking must be used within a PixelTrackingProvider");
|
|
12900
|
-
return context;
|
|
12901
|
-
}
|
|
12902
|
-
function fire(provider, name, params, pixel) {
|
|
12903
|
-
var _a11, _b2, _c, _d, _e, _f, _g;
|
|
12826
|
+
function fire(provider, name, params, pixel, options = {}) {
|
|
12827
|
+
var _a11, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
12904
12828
|
if (typeof window === "undefined") return;
|
|
12905
12829
|
const w2 = window;
|
|
12830
|
+
const eventId = options.eventId;
|
|
12906
12831
|
switch (provider) {
|
|
12907
12832
|
case "facebook":
|
|
12908
|
-
(_a11 = w2.fbq) == null ? void 0 : _a11.call(w2, "track", name, params);
|
|
12833
|
+
if (eventId) (_a11 = w2.fbq) == null ? void 0 : _a11.call(w2, "track", name, params, { eventID: eventId });
|
|
12834
|
+
else (_b2 = w2.fbq) == null ? void 0 : _b2.call(w2, "track", name, params);
|
|
12909
12835
|
break;
|
|
12910
12836
|
case "tiktok": {
|
|
12911
12837
|
const pixelId = pixel && "pixelId" in pixel ? pixel.pixelId : null;
|
|
12912
|
-
const target = pixelId && ((
|
|
12838
|
+
const target = pixelId && ((_c = w2.ttq) == null ? void 0 : _c.instance) ? w2.ttq.instance(pixelId) : w2.ttq;
|
|
12913
12839
|
if (name === "Pageview") {
|
|
12914
|
-
(
|
|
12840
|
+
(_d = target == null ? void 0 : target.page) == null ? void 0 : _d.call(target);
|
|
12841
|
+
} else if (eventId) {
|
|
12842
|
+
(_e = target == null ? void 0 : target.track) == null ? void 0 : _e.call(target, name, params, { event_id: eventId });
|
|
12915
12843
|
} else {
|
|
12916
|
-
(
|
|
12844
|
+
(_f = target == null ? void 0 : target.track) == null ? void 0 : _f.call(target, name, params);
|
|
12917
12845
|
}
|
|
12918
12846
|
break;
|
|
12919
12847
|
}
|
|
12920
12848
|
case "snapchat":
|
|
12921
|
-
(
|
|
12849
|
+
(_g = w2.snaptr) == null ? void 0 : _g.call(w2, "track", name, params);
|
|
12922
12850
|
break;
|
|
12923
12851
|
case "pinterest":
|
|
12924
12852
|
if (name === "pagevisit") {
|
|
12925
|
-
(
|
|
12853
|
+
(_h = w2.pintrk) == null ? void 0 : _h.call(w2, "page");
|
|
12926
12854
|
} else {
|
|
12927
|
-
(
|
|
12855
|
+
(_i = w2.pintrk) == null ? void 0 : _i.call(w2, "track", name, params);
|
|
12928
12856
|
}
|
|
12929
12857
|
break;
|
|
12930
12858
|
case "gtm":
|
|
@@ -13142,17 +13070,72 @@ var TagadaReactSDKBundle = (() => {
|
|
|
13142
13070
|
return waitForScriptLoad(script);
|
|
13143
13071
|
}
|
|
13144
13072
|
}
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
|
|
13073
|
+
function createPixelTracker(pixels) {
|
|
13074
|
+
const shouldTrackEvent = createDuplicateGuard(5e3);
|
|
13075
|
+
let pixelsInitialized = false;
|
|
13076
|
+
const initPromise = (async () => {
|
|
13077
|
+
var _a11, _b2, _c, _d, _e;
|
|
13078
|
+
if (!pixels || typeof window === "undefined") return;
|
|
13079
|
+
const loadPromises = [];
|
|
13080
|
+
try {
|
|
13081
|
+
(_a11 = pixels.facebook) == null ? void 0 : _a11.forEach((px) => {
|
|
13082
|
+
if (px.enabled && px.pixelId) loadPromises.push(initMetaPixel(px.pixelId));
|
|
13083
|
+
});
|
|
13084
|
+
(_b2 = pixels.tiktok) == null ? void 0 : _b2.forEach((px) => {
|
|
13085
|
+
if (px.enabled && px.pixelId) loadPromises.push(initTikTokPixel(px.pixelId));
|
|
13086
|
+
});
|
|
13087
|
+
(_c = pixels.snapchat) == null ? void 0 : _c.forEach((px) => {
|
|
13088
|
+
if (px.enabled && px.pixelId) loadPromises.push(initSnapchatPixel(px.pixelId));
|
|
13089
|
+
});
|
|
13090
|
+
(_d = pixels.pinterest) == null ? void 0 : _d.forEach((px) => {
|
|
13091
|
+
if (px.enabled && px.pixelId) loadPromises.push(initPinterestPixel(px.pixelId));
|
|
13092
|
+
});
|
|
13093
|
+
(_e = pixels.gtm) == null ? void 0 : _e.forEach((px) => {
|
|
13094
|
+
if (px.enabled && px.containerId) loadPromises.push(initGTM(px.containerId));
|
|
13095
|
+
});
|
|
13096
|
+
await Promise.all(loadPromises);
|
|
13097
|
+
} catch (error) {
|
|
13098
|
+
console.error("[SDK Pixels] Initialization error:", error);
|
|
13099
|
+
}
|
|
13100
|
+
pixelsInitialized = true;
|
|
13101
|
+
})();
|
|
13102
|
+
const track = (eventName, parameters = {}, options = {}) => {
|
|
13103
|
+
if (!pixels || !pixelsInitialized) return;
|
|
13104
|
+
if (!shouldTrackEvent(eventName, parameters, options.eventId)) return;
|
|
13105
|
+
try {
|
|
13106
|
+
const events = resolvePixelEvents(pixels, eventName, parameters);
|
|
13107
|
+
const firedProviders = /* @__PURE__ */ new Set();
|
|
13108
|
+
for (const { provider, mapped, pixel } of events) {
|
|
13109
|
+
if (provider === "gtm" || provider === "tiktok") {
|
|
13110
|
+
fire(provider, mapped.name, mapped.params, pixel, options);
|
|
13111
|
+
} else {
|
|
13112
|
+
if (!firedProviders.has(provider)) {
|
|
13113
|
+
fire(provider, mapped.name, mapped.params, void 0, options);
|
|
13114
|
+
firedProviders.add(provider);
|
|
13115
|
+
}
|
|
13116
|
+
}
|
|
13117
|
+
}
|
|
13118
|
+
} catch (error) {
|
|
13119
|
+
console.error("[SDK Pixels] Tracking error:", error);
|
|
13120
|
+
}
|
|
13121
|
+
};
|
|
13122
|
+
initPromise.then(() => {
|
|
13123
|
+
if (typeof window === "undefined") return;
|
|
13124
|
+
track("PageView", { path: window.location.pathname });
|
|
13125
|
+
});
|
|
13126
|
+
return {
|
|
13127
|
+
initPromise,
|
|
13128
|
+
get pixelsInitialized() {
|
|
13129
|
+
return pixelsInitialized;
|
|
13130
|
+
},
|
|
13131
|
+
track
|
|
13132
|
+
};
|
|
13133
|
+
}
|
|
13134
|
+
var win, SCRIPT_LOAD_TIMEOUT_MS, _metaScriptEl, _tiktokBaseInitialized, _snapchatScriptEl, _pinterestScriptEl;
|
|
13135
|
+
var init_pixelTracker = __esm({
|
|
13136
|
+
"src/v2/core/pixelTracker.ts"() {
|
|
13148
13137
|
"use strict";
|
|
13149
|
-
"use client";
|
|
13150
|
-
import_react4 = __require("react");
|
|
13151
13138
|
init_pixelMapping();
|
|
13152
|
-
init_useStepConfig();
|
|
13153
|
-
import_jsx_runtime4 = __require("react/jsx-runtime");
|
|
13154
|
-
PixelTrackingContext = (0, import_react4.createContext)(null);
|
|
13155
|
-
shouldTrackEvent = createDuplicateGuard(5e3);
|
|
13156
13139
|
win = typeof window !== "undefined" ? window : void 0;
|
|
13157
13140
|
SCRIPT_LOAD_TIMEOUT_MS = 5e3;
|
|
13158
13141
|
_metaScriptEl = null;
|
|
@@ -13162,6 +13145,228 @@ var TagadaReactSDKBundle = (() => {
|
|
|
13162
13145
|
}
|
|
13163
13146
|
});
|
|
13164
13147
|
|
|
13148
|
+
// src/v2/react/hooks/useStepConfig.ts
|
|
13149
|
+
function useStepConfig() {
|
|
13150
|
+
const stepConfig = (0, import_react3.useMemo)(() => getAssignedStepConfig(), []);
|
|
13151
|
+
const paymentFlowId = (0, import_react3.useMemo)(() => getAssignedPaymentFlowId(), []);
|
|
13152
|
+
const resources = (0, import_react3.useMemo)(() => getAssignedResources(), []);
|
|
13153
|
+
const pixels = (0, import_react3.useMemo)(() => getAssignedPixels(), []);
|
|
13154
|
+
const getScripts = (0, import_react3.useMemo)(() => {
|
|
13155
|
+
return (position) => {
|
|
13156
|
+
return getAssignedScripts(position);
|
|
13157
|
+
};
|
|
13158
|
+
}, []);
|
|
13159
|
+
const paymentSetupConfig = (0, import_react3.useMemo)(() => stepConfig == null ? void 0 : stepConfig.paymentSetupConfig, [stepConfig]);
|
|
13160
|
+
const orderBumpOfferIds = (0, import_react3.useMemo)(() => getAssignedOrderBumpOfferIds(), []);
|
|
13161
|
+
const upsellOfferIds = (0, import_react3.useMemo)(() => getAssignedUpsellOfferIds(), []);
|
|
13162
|
+
const checkoutOfferIds = (0, import_react3.useMemo)(() => getAssignedCheckoutOfferIds(), []);
|
|
13163
|
+
const checkoutOfferDefaultId = (0, import_react3.useMemo)(() => getAssignedCheckoutOfferDefault(), []);
|
|
13164
|
+
return {
|
|
13165
|
+
stepConfig,
|
|
13166
|
+
paymentFlowId,
|
|
13167
|
+
resources,
|
|
13168
|
+
staticResources: resources,
|
|
13169
|
+
getScripts,
|
|
13170
|
+
pixels,
|
|
13171
|
+
paymentSetupConfig,
|
|
13172
|
+
orderBumpOfferIds,
|
|
13173
|
+
upsellOfferIds,
|
|
13174
|
+
checkoutOfferIds,
|
|
13175
|
+
checkoutOfferDefaultId
|
|
13176
|
+
};
|
|
13177
|
+
}
|
|
13178
|
+
var import_react3;
|
|
13179
|
+
var init_useStepConfig = __esm({
|
|
13180
|
+
"src/v2/react/hooks/useStepConfig.ts"() {
|
|
13181
|
+
"use strict";
|
|
13182
|
+
import_react3 = __require("react");
|
|
13183
|
+
init_funnelClient();
|
|
13184
|
+
}
|
|
13185
|
+
});
|
|
13186
|
+
|
|
13187
|
+
// src/v2/react/hooks/usePixelTracking.tsx
|
|
13188
|
+
function PixelTrackingProvider({ children }) {
|
|
13189
|
+
const { pixels } = useStepConfig();
|
|
13190
|
+
const trackerRef = (0, import_react4.useRef)(null);
|
|
13191
|
+
const [pixelsInitialized, setPixelsInitialized] = (0, import_react4.useState)(false);
|
|
13192
|
+
(0, import_react4.useEffect)(() => {
|
|
13193
|
+
if (!pixels) return;
|
|
13194
|
+
const tracker = createPixelTracker(pixels);
|
|
13195
|
+
trackerRef.current = tracker;
|
|
13196
|
+
setPixelsInitialized(false);
|
|
13197
|
+
let cancelled = false;
|
|
13198
|
+
tracker.initPromise.then(() => {
|
|
13199
|
+
if (!cancelled) setPixelsInitialized(true);
|
|
13200
|
+
});
|
|
13201
|
+
return () => {
|
|
13202
|
+
cancelled = true;
|
|
13203
|
+
trackerRef.current = null;
|
|
13204
|
+
};
|
|
13205
|
+
}, [pixels]);
|
|
13206
|
+
const value = (0, import_react4.useMemo)(
|
|
13207
|
+
() => ({
|
|
13208
|
+
track: (eventName, parameters, options) => {
|
|
13209
|
+
var _a11;
|
|
13210
|
+
(_a11 = trackerRef.current) == null ? void 0 : _a11.track(eventName, parameters, options);
|
|
13211
|
+
},
|
|
13212
|
+
pixelsInitialized
|
|
13213
|
+
}),
|
|
13214
|
+
[pixelsInitialized]
|
|
13215
|
+
);
|
|
13216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PixelTrackingContext.Provider, { value, children });
|
|
13217
|
+
}
|
|
13218
|
+
function usePixelTracking() {
|
|
13219
|
+
const context = (0, import_react4.useContext)(PixelTrackingContext);
|
|
13220
|
+
if (!context) throw new Error("usePixelTracking must be used within a PixelTrackingProvider");
|
|
13221
|
+
return context;
|
|
13222
|
+
}
|
|
13223
|
+
var import_react4, import_jsx_runtime4, PixelTrackingContext;
|
|
13224
|
+
var init_usePixelTracking = __esm({
|
|
13225
|
+
"src/v2/react/hooks/usePixelTracking.tsx"() {
|
|
13226
|
+
"use strict";
|
|
13227
|
+
"use client";
|
|
13228
|
+
import_react4 = __require("react");
|
|
13229
|
+
init_pixelTracker();
|
|
13230
|
+
init_useStepConfig();
|
|
13231
|
+
import_jsx_runtime4 = __require("react/jsx-runtime");
|
|
13232
|
+
PixelTrackingContext = (0, import_react4.createContext)(null);
|
|
13233
|
+
}
|
|
13234
|
+
});
|
|
13235
|
+
|
|
13236
|
+
// src/v2/core/utils/clickIdResolver.ts
|
|
13237
|
+
function readCookie(name) {
|
|
13238
|
+
if (typeof document === "undefined" || !document.cookie) return null;
|
|
13239
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13240
|
+
const m3 = document.cookie.match(new RegExp("(?:^|; )" + escaped + "=([^;]*)"));
|
|
13241
|
+
if (!m3) return null;
|
|
13242
|
+
try {
|
|
13243
|
+
return decodeURIComponent(m3[1]);
|
|
13244
|
+
} catch (e3) {
|
|
13245
|
+
return m3[1];
|
|
13246
|
+
}
|
|
13247
|
+
}
|
|
13248
|
+
function readUrlParam(search, name) {
|
|
13249
|
+
if (!search) return null;
|
|
13250
|
+
try {
|
|
13251
|
+
return new URLSearchParams(search).get(name);
|
|
13252
|
+
} catch (e3) {
|
|
13253
|
+
return null;
|
|
13254
|
+
}
|
|
13255
|
+
}
|
|
13256
|
+
function resolveClickId() {
|
|
13257
|
+
var _a11, _b2;
|
|
13258
|
+
const all3 = {};
|
|
13259
|
+
let clickId = null;
|
|
13260
|
+
let source = null;
|
|
13261
|
+
let key = null;
|
|
13262
|
+
const search = typeof window !== "undefined" ? (_b2 = (_a11 = window.location) == null ? void 0 : _a11.search) != null ? _b2 : "" : "";
|
|
13263
|
+
for (const name of CLICK_ID_URL_PARAMS) {
|
|
13264
|
+
const v2 = readUrlParam(search, name);
|
|
13265
|
+
if (v2) {
|
|
13266
|
+
all3["url:".concat(name)] = v2;
|
|
13267
|
+
if (clickId === null) {
|
|
13268
|
+
clickId = v2;
|
|
13269
|
+
source = "url";
|
|
13270
|
+
key = name;
|
|
13271
|
+
}
|
|
13272
|
+
}
|
|
13273
|
+
}
|
|
13274
|
+
for (const name of CLICK_ID_COOKIES) {
|
|
13275
|
+
const v2 = readCookie(name);
|
|
13276
|
+
if (v2) {
|
|
13277
|
+
all3["cookie:".concat(name)] = v2;
|
|
13278
|
+
if (clickId === null) {
|
|
13279
|
+
clickId = v2;
|
|
13280
|
+
source = "cookie";
|
|
13281
|
+
key = name;
|
|
13282
|
+
}
|
|
13283
|
+
}
|
|
13284
|
+
}
|
|
13285
|
+
return { clickId, source, key, all: all3 };
|
|
13286
|
+
}
|
|
13287
|
+
function publishTrackingGlobal() {
|
|
13288
|
+
var _a11;
|
|
13289
|
+
if (typeof window === "undefined") return null;
|
|
13290
|
+
const resolved = resolveClickId();
|
|
13291
|
+
const tracking = __spreadProps(__spreadValues({}, resolved), { resolvedAt: Date.now() });
|
|
13292
|
+
window.TagadaPay = __spreadProps(__spreadValues({}, (_a11 = window.TagadaPay) != null ? _a11 : {}), { tracking });
|
|
13293
|
+
return tracking;
|
|
13294
|
+
}
|
|
13295
|
+
var CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES;
|
|
13296
|
+
var init_clickIdResolver = __esm({
|
|
13297
|
+
"src/v2/core/utils/clickIdResolver.ts"() {
|
|
13298
|
+
"use strict";
|
|
13299
|
+
CLICK_ID_URL_PARAMS = Object.freeze([
|
|
13300
|
+
// Postback ad-trackers (most specific first)
|
|
13301
|
+
"cf_click_id",
|
|
13302
|
+
// ClickFlare canonical
|
|
13303
|
+
"cid",
|
|
13304
|
+
// Voluum canonical (also: ClickFlare receiving-side)
|
|
13305
|
+
"rtkclickid",
|
|
13306
|
+
// RedTrack canonical
|
|
13307
|
+
"cmc_tid",
|
|
13308
|
+
// ClickMagick canonical (replaces legacy #S2#)
|
|
13309
|
+
"cmc_id",
|
|
13310
|
+
// ClickMagick legacy
|
|
13311
|
+
"cmcid",
|
|
13312
|
+
// ClickMagick alt
|
|
13313
|
+
"clickid",
|
|
13314
|
+
// Generic affiliate-network token (Binom, RedTrack, Voluum, …)
|
|
13315
|
+
"click_id",
|
|
13316
|
+
// Generic snake_case (ClickFlare, ClickMagick, …)
|
|
13317
|
+
// Ad-platform native click ids
|
|
13318
|
+
"gclid",
|
|
13319
|
+
// Google Ads
|
|
13320
|
+
"gbraid",
|
|
13321
|
+
// Google Ads (iOS app)
|
|
13322
|
+
"wbraid",
|
|
13323
|
+
// Google Ads (web→app)
|
|
13324
|
+
"fbclid",
|
|
13325
|
+
// Meta
|
|
13326
|
+
"msclkid",
|
|
13327
|
+
// Microsoft Ads
|
|
13328
|
+
"ttclid",
|
|
13329
|
+
// TikTok
|
|
13330
|
+
"twclid",
|
|
13331
|
+
// X / Twitter
|
|
13332
|
+
"li_fat_id",
|
|
13333
|
+
// LinkedIn
|
|
13334
|
+
"epik",
|
|
13335
|
+
// Pinterest
|
|
13336
|
+
"dclid",
|
|
13337
|
+
// Display & Video 360
|
|
13338
|
+
"yclid",
|
|
13339
|
+
// Yandex
|
|
13340
|
+
"irclickid"
|
|
13341
|
+
// Impact
|
|
13342
|
+
]);
|
|
13343
|
+
CLICK_ID_COOKIES = Object.freeze([
|
|
13344
|
+
// ClickFlare
|
|
13345
|
+
"cf_click_id",
|
|
13346
|
+
"cfclid",
|
|
13347
|
+
// RedTrack — `rtkclickid-store` is the canonical first-party cookie
|
|
13348
|
+
// set by RedTrack's Universal Tracking Script.
|
|
13349
|
+
"rtkclickid-store",
|
|
13350
|
+
"_rtkclickid",
|
|
13351
|
+
"rtkclickid",
|
|
13352
|
+
// Voluum
|
|
13353
|
+
"_voluum",
|
|
13354
|
+
"_voluumclickid",
|
|
13355
|
+
// Binom
|
|
13356
|
+
"_binom",
|
|
13357
|
+
"_binomclickid",
|
|
13358
|
+
// ClickMagick
|
|
13359
|
+
"_mck",
|
|
13360
|
+
"cmcid",
|
|
13361
|
+
// Other
|
|
13362
|
+
"skro-click-id",
|
|
13363
|
+
// Skro
|
|
13364
|
+
"click_id"
|
|
13365
|
+
// generic catch-all (last)
|
|
13366
|
+
]);
|
|
13367
|
+
}
|
|
13368
|
+
});
|
|
13369
|
+
|
|
13165
13370
|
// src/v2/core/utils/products.ts
|
|
13166
13371
|
var init_products = __esm({
|
|
13167
13372
|
"src/v2/core/utils/products.ts"() {
|
|
@@ -13520,6 +13725,16 @@ var TagadaReactSDKBundle = (() => {
|
|
|
13520
13725
|
}
|
|
13521
13726
|
});
|
|
13522
13727
|
|
|
13728
|
+
// src/v2/core/utils/metaEventId.ts
|
|
13729
|
+
function makeMetaEventId(eventName, entityId) {
|
|
13730
|
+
return "".concat(eventName, "_").concat(entityId);
|
|
13731
|
+
}
|
|
13732
|
+
var init_metaEventId = __esm({
|
|
13733
|
+
"src/v2/core/utils/metaEventId.ts"() {
|
|
13734
|
+
"use strict";
|
|
13735
|
+
}
|
|
13736
|
+
});
|
|
13737
|
+
|
|
13523
13738
|
// src/v2/core/utils/index.ts
|
|
13524
13739
|
var init_utils4 = __esm({
|
|
13525
13740
|
"src/v2/core/utils/index.ts"() {
|
|
@@ -13535,6 +13750,18 @@ var TagadaReactSDKBundle = (() => {
|
|
|
13535
13750
|
init_sessionStorage();
|
|
13536
13751
|
init_funnelQueryKeys();
|
|
13537
13752
|
init_configHotReload();
|
|
13753
|
+
init_metaEventId();
|
|
13754
|
+
init_clickIdResolver();
|
|
13755
|
+
}
|
|
13756
|
+
});
|
|
13757
|
+
|
|
13758
|
+
// src/v2/core/resources/promotionEvents.ts
|
|
13759
|
+
var PROMOTION_APPLIED, PROMOTION_REMOVED;
|
|
13760
|
+
var init_promotionEvents = __esm({
|
|
13761
|
+
"src/v2/core/resources/promotionEvents.ts"() {
|
|
13762
|
+
"use strict";
|
|
13763
|
+
PROMOTION_APPLIED = "PROMOTION_APPLIED";
|
|
13764
|
+
PROMOTION_REMOVED = "PROMOTION_REMOVED";
|
|
13538
13765
|
}
|
|
13539
13766
|
});
|
|
13540
13767
|
|
|
@@ -13543,9 +13770,11 @@ var TagadaReactSDKBundle = (() => {
|
|
|
13543
13770
|
var init_checkout2 = __esm({
|
|
13544
13771
|
"src/v2/core/resources/checkout.ts"() {
|
|
13545
13772
|
"use strict";
|
|
13773
|
+
init_promotionEvents();
|
|
13546
13774
|
CheckoutResource = class {
|
|
13547
|
-
constructor(apiClient) {
|
|
13775
|
+
constructor(apiClient, bus) {
|
|
13548
13776
|
this.apiClient = apiClient;
|
|
13777
|
+
this.bus = bus;
|
|
13549
13778
|
}
|
|
13550
13779
|
/**
|
|
13551
13780
|
* Initialize a new checkout session (sync mode)
|
|
@@ -13660,15 +13889,25 @@ var TagadaReactSDKBundle = (() => {
|
|
|
13660
13889
|
* Apply promotion code
|
|
13661
13890
|
*/
|
|
13662
13891
|
async applyPromotionCode(checkoutSessionId, code) {
|
|
13663
|
-
|
|
13892
|
+
var _a11;
|
|
13893
|
+
const result = await this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/apply"), {
|
|
13664
13894
|
code
|
|
13665
13895
|
});
|
|
13896
|
+
if (result.success) {
|
|
13897
|
+
void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_APPLIED, { checkoutSessionId }));
|
|
13898
|
+
}
|
|
13899
|
+
return result;
|
|
13666
13900
|
}
|
|
13667
13901
|
/**
|
|
13668
13902
|
* Remove promotion
|
|
13669
13903
|
*/
|
|
13670
13904
|
async removePromotion(checkoutSessionId, promotionId) {
|
|
13671
|
-
|
|
13905
|
+
var _a11;
|
|
13906
|
+
const result = await this.apiClient.delete("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/").concat(promotionId));
|
|
13907
|
+
if (result.success) {
|
|
13908
|
+
void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_REMOVED, { checkoutSessionId }));
|
|
13909
|
+
}
|
|
13910
|
+
return result;
|
|
13672
13911
|
}
|
|
13673
13912
|
/**
|
|
13674
13913
|
* Get applied promotions
|
|
@@ -13939,22 +14178,23 @@ var TagadaReactSDKBundle = (() => {
|
|
|
13939
14178
|
* @param returnUrl - Optional return URL for checkout
|
|
13940
14179
|
* @param mainOrderId - Optional main order ID (for upsells)
|
|
13941
14180
|
*/
|
|
13942
|
-
async payPreviewedOffer(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
|
|
14181
|
+
async payPreviewedOffer(offerId, currency = "", lineItems, returnUrl, mainOrderId, initiatedBy) {
|
|
13943
14182
|
console.log("\u{1F4B3} [OffersResource] Calling pay-preview API:", {
|
|
13944
14183
|
offerId,
|
|
13945
14184
|
currency,
|
|
13946
14185
|
lineItems,
|
|
13947
14186
|
returnUrl,
|
|
13948
14187
|
mainOrderId,
|
|
14188
|
+
initiatedBy,
|
|
13949
14189
|
endpoint: "/api/v1/offers/".concat(offerId, "/pay-preview")
|
|
13950
14190
|
});
|
|
13951
|
-
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay-preview"), {
|
|
14191
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay-preview"), __spreadValues({
|
|
13952
14192
|
offerId,
|
|
13953
14193
|
currency,
|
|
13954
14194
|
lineItems,
|
|
13955
14195
|
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.href : ""),
|
|
13956
14196
|
mainOrderId
|
|
13957
|
-
});
|
|
14197
|
+
}, initiatedBy ? { initiatedBy } : {}));
|
|
13958
14198
|
console.log("\u{1F4E5} [OffersResource] Pay-preview API response:", response);
|
|
13959
14199
|
return response;
|
|
13960
14200
|
}
|
|
@@ -14657,9 +14897,11 @@ var TagadaReactSDKBundle = (() => {
|
|
|
14657
14897
|
var init_promotions2 = __esm({
|
|
14658
14898
|
"src/v2/core/resources/promotions.ts"() {
|
|
14659
14899
|
"use strict";
|
|
14900
|
+
init_promotionEvents();
|
|
14660
14901
|
PromotionsResource = class {
|
|
14661
|
-
constructor(apiClient) {
|
|
14902
|
+
constructor(apiClient, bus) {
|
|
14662
14903
|
this.apiClient = apiClient;
|
|
14904
|
+
this.bus = bus;
|
|
14663
14905
|
}
|
|
14664
14906
|
/**
|
|
14665
14907
|
* Get applied promotions for a checkout session
|
|
@@ -14671,24 +14913,25 @@ var TagadaReactSDKBundle = (() => {
|
|
|
14671
14913
|
* Apply a promotion code to a checkout session
|
|
14672
14914
|
*/
|
|
14673
14915
|
async applyPromotionCode(checkoutSessionId, code) {
|
|
14674
|
-
var _a11, _b2, _c, _d, _e, _f;
|
|
14916
|
+
var _a11, _b2, _c, _d, _e, _f, _g;
|
|
14675
14917
|
try {
|
|
14676
14918
|
const response = await this.apiClient.post(
|
|
14677
14919
|
"/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/apply"),
|
|
14678
14920
|
{ code: code.trim() }
|
|
14679
14921
|
);
|
|
14680
14922
|
if (response.success) {
|
|
14923
|
+
void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_APPLIED, { checkoutSessionId }));
|
|
14681
14924
|
return { success: true, promotion: response.promotion };
|
|
14682
14925
|
} else {
|
|
14683
|
-
return { success: false, error: ((
|
|
14926
|
+
return { success: false, error: ((_b2 = response.error) == null ? void 0 : _b2.message) || "Failed to apply promotion code" };
|
|
14684
14927
|
}
|
|
14685
14928
|
} catch (err) {
|
|
14686
14929
|
let errorMessage = "Failed to apply promotion code";
|
|
14687
14930
|
if (err && typeof err === "object" && "response" in err) {
|
|
14688
14931
|
const apiError = err;
|
|
14689
|
-
if ((
|
|
14932
|
+
if ((_e = (_d = (_c = apiError.response) == null ? void 0 : _c.data) == null ? void 0 : _d.error) == null ? void 0 : _e.message) {
|
|
14690
14933
|
errorMessage = apiError.response.data.error.message;
|
|
14691
|
-
} else if ((
|
|
14934
|
+
} else if ((_g = (_f = apiError.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) {
|
|
14692
14935
|
errorMessage = apiError.response.data.message;
|
|
14693
14936
|
}
|
|
14694
14937
|
}
|
|
@@ -14699,23 +14942,24 @@ var TagadaReactSDKBundle = (() => {
|
|
|
14699
14942
|
* Remove a promotion from a checkout session
|
|
14700
14943
|
*/
|
|
14701
14944
|
async removePromotionCode(checkoutSessionId, promotionId) {
|
|
14702
|
-
var _a11, _b2, _c, _d, _e, _f;
|
|
14945
|
+
var _a11, _b2, _c, _d, _e, _f, _g;
|
|
14703
14946
|
try {
|
|
14704
14947
|
const response = await this.apiClient.delete(
|
|
14705
14948
|
"/api/v1/checkout-sessions/".concat(checkoutSessionId, "/promotions/").concat(promotionId)
|
|
14706
14949
|
);
|
|
14707
14950
|
if (response.success) {
|
|
14951
|
+
void ((_a11 = this.bus) == null ? void 0 : _a11.emit(PROMOTION_REMOVED, { checkoutSessionId }));
|
|
14708
14952
|
return { success: true };
|
|
14709
14953
|
} else {
|
|
14710
|
-
return { success: false, error: ((
|
|
14954
|
+
return { success: false, error: ((_b2 = response.error) == null ? void 0 : _b2.message) || "Failed to remove promotion" };
|
|
14711
14955
|
}
|
|
14712
14956
|
} catch (err) {
|
|
14713
14957
|
let errorMessage = "Failed to remove promotion";
|
|
14714
14958
|
if (err && typeof err === "object" && "response" in err) {
|
|
14715
14959
|
const apiError = err;
|
|
14716
|
-
if ((
|
|
14960
|
+
if ((_e = (_d = (_c = apiError.response) == null ? void 0 : _c.data) == null ? void 0 : _d.error) == null ? void 0 : _e.message) {
|
|
14717
14961
|
errorMessage = apiError.response.data.error.message;
|
|
14718
|
-
} else if ((
|
|
14962
|
+
} else if ((_g = (_f = apiError.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) {
|
|
14719
14963
|
errorMessage = apiError.response.data.message;
|
|
14720
14964
|
}
|
|
14721
14965
|
}
|
|
@@ -15739,7 +15983,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
15739
15983
|
const { storeId } = usePluginConfig();
|
|
15740
15984
|
const currency = useCurrency();
|
|
15741
15985
|
const queryClient = useQueryClient();
|
|
15742
|
-
const { isSessionInitialized, session } = useTagadaContext();
|
|
15986
|
+
const { isSessionInitialized, session, client } = useTagadaContext();
|
|
15743
15987
|
const pendingSessionPromise = (0, import_react7.useRef)(null);
|
|
15744
15988
|
const sessionResolvers = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
|
|
15745
15989
|
(0, import_react7.useEffect)(() => {
|
|
@@ -15774,11 +16018,11 @@ var TagadaReactSDKBundle = (() => {
|
|
|
15774
16018
|
}, [isSessionInitialized]);
|
|
15775
16019
|
const checkoutResource = (0, import_react7.useMemo)(() => {
|
|
15776
16020
|
try {
|
|
15777
|
-
return new CheckoutResource(getGlobalApiClient());
|
|
16021
|
+
return new CheckoutResource(getGlobalApiClient(), client.bus);
|
|
15778
16022
|
} catch (error2) {
|
|
15779
16023
|
throw new Error(messages.initFailed + ": " + (error2 instanceof Error ? error2.message : "Unknown error"));
|
|
15780
16024
|
}
|
|
15781
|
-
}, []);
|
|
16025
|
+
}, [client.bus]);
|
|
15782
16026
|
const [internalToken, setInternalToken] = (0, import_react7.useState)(providedToken);
|
|
15783
16027
|
(0, import_react7.useEffect)(() => {
|
|
15784
16028
|
if (providedToken && providedToken !== internalToken) {
|
|
@@ -16003,6 +16247,60 @@ var TagadaReactSDKBundle = (() => {
|
|
|
16003
16247
|
promotionIds
|
|
16004
16248
|
})
|
|
16005
16249
|
});
|
|
16250
|
+
const init = (0, import_react7.useCallback)(async (params) => {
|
|
16251
|
+
var _a11;
|
|
16252
|
+
await waitForSession();
|
|
16253
|
+
const result = await initMutation.mutateAsync(params);
|
|
16254
|
+
setInternalToken(result.checkoutToken);
|
|
16255
|
+
return {
|
|
16256
|
+
checkoutSession: (_a11 = checkout == null ? void 0 : checkout.checkoutSession) != null ? _a11 : {},
|
|
16257
|
+
checkoutToken: result.checkoutToken
|
|
16258
|
+
};
|
|
16259
|
+
}, [waitForSession, initMutation.mutateAsync, checkout == null ? void 0 : checkout.checkoutSession]);
|
|
16260
|
+
const replaceSessionLineItems = (0, import_react7.useCallback)(
|
|
16261
|
+
(lineItems) => replaceSessionLineItemsMutation.mutateAsync({ lineItems }),
|
|
16262
|
+
[replaceSessionLineItemsMutation.mutateAsync]
|
|
16263
|
+
);
|
|
16264
|
+
const updateLineItems = (0, import_react7.useCallback)(
|
|
16265
|
+
(lineItems) => lineItemsMutation.mutateAsync({ lineItems }),
|
|
16266
|
+
[lineItemsMutation.mutateAsync]
|
|
16267
|
+
);
|
|
16268
|
+
const updateLineItemsOptimistic = (0, import_react7.useCallback)(
|
|
16269
|
+
(lineItems) => lineItemsMutation.mutate({ lineItems }),
|
|
16270
|
+
[lineItemsMutation.mutate]
|
|
16271
|
+
);
|
|
16272
|
+
const addLineItems = (0, import_react7.useCallback)(
|
|
16273
|
+
(lineItems) => addLineItemsMutation.mutateAsync({ lineItems }),
|
|
16274
|
+
[addLineItemsMutation.mutateAsync]
|
|
16275
|
+
);
|
|
16276
|
+
const removeLineItems = (0, import_react7.useCallback)(
|
|
16277
|
+
(lineItems) => removeLineItemsMutation.mutateAsync({ lineItems }),
|
|
16278
|
+
[removeLineItemsMutation.mutateAsync]
|
|
16279
|
+
);
|
|
16280
|
+
const setItemQuantity = (0, import_react7.useCallback)(
|
|
16281
|
+
(variantId, quantity, priceId) => quantityMutation.mutateAsync({ variantId, quantity, priceId }),
|
|
16282
|
+
[quantityMutation.mutateAsync]
|
|
16283
|
+
);
|
|
16284
|
+
const updateCustomer = (0, import_react7.useCallback)(
|
|
16285
|
+
(data) => customerMutation.mutateAsync(data),
|
|
16286
|
+
[customerMutation.mutateAsync]
|
|
16287
|
+
);
|
|
16288
|
+
const updateCustomerAndSessionInfo = (0, import_react7.useCallback)(
|
|
16289
|
+
(data) => customerAndSessionMutation.mutateAsync(data),
|
|
16290
|
+
[customerAndSessionMutation.mutateAsync]
|
|
16291
|
+
);
|
|
16292
|
+
const applyPromotionCode = (0, import_react7.useCallback)(
|
|
16293
|
+
(code) => promotionMutation.mutateAsync({ code }),
|
|
16294
|
+
[promotionMutation.mutateAsync]
|
|
16295
|
+
);
|
|
16296
|
+
const removePromotion = (0, import_react7.useCallback)(
|
|
16297
|
+
(promotionId) => removePromotionMutation.mutateAsync({ promotionId }),
|
|
16298
|
+
[removePromotionMutation.mutateAsync]
|
|
16299
|
+
);
|
|
16300
|
+
const previewCheckoutSession = (0, import_react7.useCallback)(
|
|
16301
|
+
(lineItems, promotionIds) => previewCheckoutSessionMutation.mutateAsync({ lineItems, promotionIds }),
|
|
16302
|
+
[previewCheckoutSessionMutation.mutateAsync]
|
|
16303
|
+
);
|
|
16006
16304
|
return {
|
|
16007
16305
|
// Query data
|
|
16008
16306
|
checkout,
|
|
@@ -16010,29 +16308,20 @@ var TagadaReactSDKBundle = (() => {
|
|
|
16010
16308
|
error,
|
|
16011
16309
|
isSuccess,
|
|
16012
16310
|
// Actions
|
|
16013
|
-
init
|
|
16014
|
-
var _a11;
|
|
16015
|
-
await waitForSession();
|
|
16016
|
-
const result = await initMutation.mutateAsync(params);
|
|
16017
|
-
setInternalToken(result.checkoutToken);
|
|
16018
|
-
return {
|
|
16019
|
-
checkoutSession: (_a11 = checkout == null ? void 0 : checkout.checkoutSession) != null ? _a11 : {},
|
|
16020
|
-
checkoutToken: result.checkoutToken
|
|
16021
|
-
};
|
|
16022
|
-
},
|
|
16311
|
+
init,
|
|
16023
16312
|
refresh,
|
|
16024
16313
|
// Checkout operations
|
|
16025
|
-
replaceSessionLineItems
|
|
16026
|
-
updateLineItems
|
|
16027
|
-
updateLineItemsOptimistic
|
|
16028
|
-
addLineItems
|
|
16029
|
-
removeLineItems
|
|
16030
|
-
setItemQuantity
|
|
16031
|
-
updateCustomer
|
|
16032
|
-
updateCustomerAndSessionInfo
|
|
16033
|
-
applyPromotionCode
|
|
16034
|
-
removePromotion
|
|
16035
|
-
previewCheckoutSession
|
|
16314
|
+
replaceSessionLineItems,
|
|
16315
|
+
updateLineItems,
|
|
16316
|
+
updateLineItemsOptimistic,
|
|
16317
|
+
addLineItems,
|
|
16318
|
+
removeLineItems,
|
|
16319
|
+
setItemQuantity,
|
|
16320
|
+
updateCustomer,
|
|
16321
|
+
updateCustomerAndSessionInfo,
|
|
16322
|
+
applyPromotionCode,
|
|
16323
|
+
removePromotion,
|
|
16324
|
+
previewCheckoutSession
|
|
16036
16325
|
};
|
|
16037
16326
|
}
|
|
16038
16327
|
var import_react7, DEFAULT_MESSAGES;
|
|
@@ -18875,8 +19164,16 @@ var TagadaReactSDKBundle = (() => {
|
|
|
18875
19164
|
init_client();
|
|
18876
19165
|
init_useApiQuery();
|
|
18877
19166
|
init_usePixelTracking();
|
|
19167
|
+
init_clickIdResolver();
|
|
18878
19168
|
import_jsx_runtime6 = __require("react/jsx-runtime");
|
|
18879
19169
|
import_meta2 = {};
|
|
19170
|
+
if (typeof window !== "undefined") {
|
|
19171
|
+
try {
|
|
19172
|
+
publishTrackingGlobal();
|
|
19173
|
+
} catch (error) {
|
|
19174
|
+
console.error("[TagadaProvider] Failed to publish tracking global:", error);
|
|
19175
|
+
}
|
|
19176
|
+
}
|
|
18880
19177
|
FunnelScriptInjector2 = (0, import_react11.lazy)(() => Promise.resolve().then(() => (init_FunnelScriptInjector(), FunnelScriptInjector_exports)).then((m3) => ({ default: m3.FunnelScriptInjector })));
|
|
18881
19178
|
DebugDrawer2 = (0, import_react11.lazy)(() => Promise.resolve().then(() => (init_DebugDrawer(), DebugDrawer_exports)));
|
|
18882
19179
|
InitializationLoader = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
@@ -18924,9 +19221,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
18924
19221
|
}
|
|
18925
19222
|
});
|
|
18926
19223
|
|
|
18927
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
19224
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryProvider.js
|
|
18928
19225
|
var require_BasisTheoryProvider = __commonJS({
|
|
18929
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
19226
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryProvider.js"(exports) {
|
|
18930
19227
|
"use strict";
|
|
18931
19228
|
Object.defineProperty(exports, "__esModule", {
|
|
18932
19229
|
value: true
|
|
@@ -24787,9 +25084,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
24787
25084
|
}
|
|
24788
25085
|
});
|
|
24789
25086
|
|
|
24790
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25087
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryReact.js
|
|
24791
25088
|
var require_BasisTheoryReact = __commonJS({
|
|
24792
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25089
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/BasisTheoryReact.js"(exports) {
|
|
24793
25090
|
"use strict";
|
|
24794
25091
|
Object.defineProperty(exports, "__esModule", {
|
|
24795
25092
|
value: true
|
|
@@ -24848,9 +25145,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
24848
25145
|
}
|
|
24849
25146
|
});
|
|
24850
25147
|
|
|
24851
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25148
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/useBasisTheory.js
|
|
24852
25149
|
var require_useBasisTheory = __commonJS({
|
|
24853
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25150
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/useBasisTheory.js"(exports) {
|
|
24854
25151
|
"use strict";
|
|
24855
25152
|
Object.defineProperty(exports, "__esModule", {
|
|
24856
25153
|
value: true
|
|
@@ -25293,9 +25590,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25293
25590
|
}
|
|
25294
25591
|
});
|
|
25295
25592
|
|
|
25296
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25593
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/index.js
|
|
25297
25594
|
var require_core = __commonJS({
|
|
25298
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25595
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/core/index.js"(exports) {
|
|
25299
25596
|
"use strict";
|
|
25300
25597
|
Object.defineProperty(exports, "__esModule", {
|
|
25301
25598
|
value: true
|
|
@@ -25409,9 +25706,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25409
25706
|
}
|
|
25410
25707
|
});
|
|
25411
25708
|
|
|
25412
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25709
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useBasisTheoryValue.js
|
|
25413
25710
|
var require_useBasisTheoryValue = __commonJS({
|
|
25414
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25711
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useBasisTheoryValue.js"(exports) {
|
|
25415
25712
|
"use strict";
|
|
25416
25713
|
Object.defineProperty(exports, "__esModule", {
|
|
25417
25714
|
value: true
|
|
@@ -25428,9 +25725,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25428
25725
|
}
|
|
25429
25726
|
});
|
|
25430
25727
|
|
|
25431
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25728
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useElement.js
|
|
25432
25729
|
var require_useElement = __commonJS({
|
|
25433
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25730
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useElement.js"(exports) {
|
|
25434
25731
|
"use strict";
|
|
25435
25732
|
Object.defineProperty(exports, "__esModule", {
|
|
25436
25733
|
value: true
|
|
@@ -25496,9 +25793,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25496
25793
|
}
|
|
25497
25794
|
});
|
|
25498
25795
|
|
|
25499
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25796
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useListener.js
|
|
25500
25797
|
var require_useListener = __commonJS({
|
|
25501
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25798
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/useListener.js"(exports) {
|
|
25502
25799
|
"use strict";
|
|
25503
25800
|
Object.defineProperty(exports, "__esModule", {
|
|
25504
25801
|
value: true
|
|
@@ -25519,9 +25816,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25519
25816
|
}
|
|
25520
25817
|
});
|
|
25521
25818
|
|
|
25522
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25819
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardElement.js
|
|
25523
25820
|
var require_CardElement = __commonJS({
|
|
25524
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25821
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardElement.js"(exports) {
|
|
25525
25822
|
"use strict";
|
|
25526
25823
|
Object.defineProperty(exports, "__esModule", {
|
|
25527
25824
|
value: true
|
|
@@ -25640,9 +25937,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25640
25937
|
}
|
|
25641
25938
|
});
|
|
25642
25939
|
|
|
25643
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25940
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/TextElement.js
|
|
25644
25941
|
var require_TextElement = __commonJS({
|
|
25645
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
25942
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/TextElement.js"(exports) {
|
|
25646
25943
|
"use strict";
|
|
25647
25944
|
Object.defineProperty(exports, "__esModule", {
|
|
25648
25945
|
value: true
|
|
@@ -25767,9 +26064,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25767
26064
|
}
|
|
25768
26065
|
});
|
|
25769
26066
|
|
|
25770
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26067
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardNumberElement.js
|
|
25771
26068
|
var require_CardNumberElement = __commonJS({
|
|
25772
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26069
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardNumberElement.js"(exports) {
|
|
25773
26070
|
"use strict";
|
|
25774
26071
|
Object.defineProperty(exports, "__esModule", {
|
|
25775
26072
|
value: true
|
|
@@ -25891,9 +26188,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
25891
26188
|
}
|
|
25892
26189
|
});
|
|
25893
26190
|
|
|
25894
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26191
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardExpirationDateElement.js
|
|
25895
26192
|
var require_CardExpirationDateElement = __commonJS({
|
|
25896
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26193
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardExpirationDateElement.js"(exports) {
|
|
25897
26194
|
"use strict";
|
|
25898
26195
|
Object.defineProperty(exports, "__esModule", {
|
|
25899
26196
|
value: true
|
|
@@ -26009,9 +26306,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
26009
26306
|
}
|
|
26010
26307
|
});
|
|
26011
26308
|
|
|
26012
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26309
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardVerificationCodeElement.js
|
|
26013
26310
|
var require_CardVerificationCodeElement = __commonJS({
|
|
26014
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26311
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/CardVerificationCodeElement.js"(exports) {
|
|
26015
26312
|
"use strict";
|
|
26016
26313
|
Object.defineProperty(exports, "__esModule", {
|
|
26017
26314
|
value: true
|
|
@@ -26129,9 +26426,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
26129
26426
|
}
|
|
26130
26427
|
});
|
|
26131
26428
|
|
|
26132
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26429
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/index.js
|
|
26133
26430
|
var require_elements4 = __commonJS({
|
|
26134
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26431
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/elements/index.js"(exports) {
|
|
26135
26432
|
"use strict";
|
|
26136
26433
|
Object.defineProperty(exports, "__esModule", {
|
|
26137
26434
|
value: true
|
|
@@ -26174,9 +26471,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
26174
26471
|
}
|
|
26175
26472
|
});
|
|
26176
26473
|
|
|
26177
|
-
// ../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26474
|
+
// ../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/index.js
|
|
26178
26475
|
var require_basis_theory_react = __commonJS({
|
|
26179
|
-
"../../node_modules/.pnpm/@basis-theory+basis-theory-
|
|
26476
|
+
"../../node_modules/.pnpm/@basis-theory+basis-theory-_3594ba83d3352e06ac52ce79f5370123/node_modules/@basis-theory/basis-theory-react/index.js"(exports) {
|
|
26180
26477
|
"use strict";
|
|
26181
26478
|
Object.defineProperty(exports, "__esModule", {
|
|
26182
26479
|
value: true
|
|
@@ -27537,9 +27834,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
27537
27834
|
}
|
|
27538
27835
|
});
|
|
27539
27836
|
|
|
27540
|
-
// ../../node_modules/.pnpm/@google-pay+button-react@3.
|
|
27837
|
+
// ../../node_modules/.pnpm/@google-pay+button-react@3._bb72023390b4ccbcc01656d1bbc0eaa2/node_modules/@google-pay/button-react/dist/index.umd.min.js
|
|
27541
27838
|
var require_index_umd_min = __commonJS({
|
|
27542
|
-
"../../node_modules/.pnpm/@google-pay+button-react@3.
|
|
27839
|
+
"../../node_modules/.pnpm/@google-pay+button-react@3._bb72023390b4ccbcc01656d1bbc0eaa2/node_modules/@google-pay/button-react/dist/index.umd.min.js"(exports, module) {
|
|
27543
27840
|
!function(e3, t3) {
|
|
27544
27841
|
"object" == typeof exports && "undefined" != typeof module ? module.exports = t3(__require("react")) : "function" == typeof define && define.amd ? define(["react"], t3) : (e3 = "undefined" != typeof globalThis ? globalThis : e3 || self).GooglePayButton = t3(e3.React);
|
|
27545
27842
|
}(exports, function(e3) {
|
|
@@ -27739,6 +28036,8 @@ var TagadaReactSDKBundle = (() => {
|
|
|
27739
28036
|
var index_exports = {};
|
|
27740
28037
|
__export(index_exports, {
|
|
27741
28038
|
ApplePayButton: () => ApplePayButton,
|
|
28039
|
+
CLICK_ID_COOKIES: () => CLICK_ID_COOKIES,
|
|
28040
|
+
CLICK_ID_URL_PARAMS: () => CLICK_ID_URL_PARAMS,
|
|
27742
28041
|
ExpressPaymentMethodsProvider: () => ExpressPaymentMethodsProvider,
|
|
27743
28042
|
FunnelActionType: () => FunnelActionType,
|
|
27744
28043
|
GooglePayButton: () => GooglePayButton,
|
|
@@ -27761,7 +28060,10 @@ var TagadaReactSDKBundle = (() => {
|
|
|
27761
28060
|
getExpressMethods: () => getExpressMethods,
|
|
27762
28061
|
getExpressMethodsByProcessor: () => getExpressMethodsByProcessor,
|
|
27763
28062
|
isMethodEnabled: () => isMethodEnabled,
|
|
28063
|
+
makeMetaEventId: () => makeMetaEventId,
|
|
28064
|
+
publishTrackingGlobal: () => publishTrackingGlobal,
|
|
27764
28065
|
queryKeys: () => queryKeys,
|
|
28066
|
+
resolveClickId: () => resolveClickId,
|
|
27765
28067
|
useApiMutation: () => useApiMutation,
|
|
27766
28068
|
useApiQuery: () => useApiQuery,
|
|
27767
28069
|
useApplePayCheckout: () => useApplePayCheckout,
|
|
@@ -27867,8 +28169,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
27867
28169
|
}, []);
|
|
27868
28170
|
const effectiveSessionId = sessionId || ((_a11 = checkout == null ? void 0 : checkout.checkoutSession) == null ? void 0 : _a11.id);
|
|
27869
28171
|
const hasSyncedInitialSelectionRef = (0, import_react.useRef)(false);
|
|
27870
|
-
const [
|
|
27871
|
-
const [isPreviewLoading, setIsPreviewLoading] = (0, import_react.useState)(false);
|
|
28172
|
+
const [previewParams, setPreviewParams] = (0, import_react.useState)(null);
|
|
27872
28173
|
const {
|
|
27873
28174
|
data: shippingRatesData,
|
|
27874
28175
|
isLoading: isFetching,
|
|
@@ -27897,6 +28198,24 @@ var TagadaReactSDKBundle = (() => {
|
|
|
27897
28198
|
}
|
|
27898
28199
|
});
|
|
27899
28200
|
const shippingRates = shippingRatesData == null ? void 0 : shippingRatesData.rates;
|
|
28201
|
+
const {
|
|
28202
|
+
data: previewedRates,
|
|
28203
|
+
isLoading: isPreviewLoading
|
|
28204
|
+
} = useQuery({
|
|
28205
|
+
queryKey: ["shipping-rates-preview", effectiveSessionId, previewParams == null ? void 0 : previewParams.countryCode, previewParams == null ? void 0 : previewParams.stateCode],
|
|
28206
|
+
queryFn: async () => {
|
|
28207
|
+
const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, previewParams);
|
|
28208
|
+
return [...response.rates].sort((a3, b3) => {
|
|
28209
|
+
var _a12, _b3;
|
|
28210
|
+
if (a3.isFree && !b3.isFree) return -1;
|
|
28211
|
+
if (!a3.isFree && b3.isFree) return 1;
|
|
28212
|
+
return ((_a12 = a3.amount) != null ? _a12 : 0) - ((_b3 = b3.amount) != null ? _b3 : 0);
|
|
28213
|
+
});
|
|
28214
|
+
},
|
|
28215
|
+
enabled: !!effectiveSessionId && !!previewParams,
|
|
28216
|
+
staleTime: 3e4,
|
|
28217
|
+
refetchOnWindowFocus: false
|
|
28218
|
+
});
|
|
27900
28219
|
const checkoutSelectedRateId = (_c = (_b2 = checkout == null ? void 0 : checkout.checkoutSession) == null ? void 0 : _b2.shippingRate) == null ? void 0 : _c.id;
|
|
27901
28220
|
const setShippingRateMutation = useMutation({
|
|
27902
28221
|
mutationFn: ({ rateId }) => {
|
|
@@ -27952,27 +28271,28 @@ var TagadaReactSDKBundle = (() => {
|
|
|
27952
28271
|
}, [refetch]);
|
|
27953
28272
|
const previewRates = (0, import_react.useCallback)(async (countryCode, stateCode) => {
|
|
27954
28273
|
if (!enabled || !effectiveSessionId) return [];
|
|
28274
|
+
setPreviewParams({ countryCode, stateCode });
|
|
27955
28275
|
try {
|
|
27956
|
-
|
|
27957
|
-
|
|
27958
|
-
|
|
27959
|
-
|
|
27960
|
-
|
|
27961
|
-
|
|
27962
|
-
|
|
27963
|
-
|
|
27964
|
-
|
|
27965
|
-
|
|
28276
|
+
return await queryClient.fetchQuery({
|
|
28277
|
+
queryKey: ["shipping-rates-preview", effectiveSessionId, countryCode, stateCode],
|
|
28278
|
+
queryFn: async () => {
|
|
28279
|
+
const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, {
|
|
28280
|
+
countryCode,
|
|
28281
|
+
stateCode
|
|
28282
|
+
});
|
|
28283
|
+
return [...response.rates].sort((a3, b3) => {
|
|
28284
|
+
var _a12, _b3;
|
|
28285
|
+
if (a3.isFree && !b3.isFree) return -1;
|
|
28286
|
+
if (!a3.isFree && b3.isFree) return 1;
|
|
28287
|
+
return ((_a12 = a3.amount) != null ? _a12 : 0) - ((_b3 = b3.amount) != null ? _b3 : 0);
|
|
28288
|
+
});
|
|
28289
|
+
}
|
|
27966
28290
|
});
|
|
27967
|
-
setPreviewedRates(sortedRates);
|
|
27968
|
-
return sortedRates;
|
|
27969
28291
|
} catch (error) {
|
|
27970
28292
|
console.error("[useShippingRatesQuery] Error previewing shipping rates:", error);
|
|
27971
28293
|
return [];
|
|
27972
|
-
} finally {
|
|
27973
|
-
setIsPreviewLoading(false);
|
|
27974
28294
|
}
|
|
27975
|
-
}, [enabled, effectiveSessionId, shippingRatesResource]);
|
|
28295
|
+
}, [enabled, effectiveSessionId, queryClient, shippingRatesResource]);
|
|
27976
28296
|
return {
|
|
27977
28297
|
shippingRates,
|
|
27978
28298
|
selectedRate,
|
|
@@ -31049,6 +31369,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31049
31369
|
}
|
|
31050
31370
|
|
|
31051
31371
|
// src/v2/react/components/ApplePayButton.tsx
|
|
31372
|
+
init_useStepConfig();
|
|
31052
31373
|
var import_jsx_runtime7 = __require("react/jsx-runtime");
|
|
31053
31374
|
var applePayContactToAddress = (contact) => {
|
|
31054
31375
|
var _a11, _b2;
|
|
@@ -31101,6 +31422,13 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31101
31422
|
} = useExpressPaymentMethods();
|
|
31102
31423
|
const [processingPayment, setProcessingPayment] = (0, import_react34.useState)(false);
|
|
31103
31424
|
const [isApplePayAvailable, setIsApplePayAvailable] = (0, import_react34.useState)(false);
|
|
31425
|
+
const { stepConfig } = useStepConfig();
|
|
31426
|
+
const countryAllowlist = (0, import_react34.useMemo)(() => {
|
|
31427
|
+
var _a12;
|
|
31428
|
+
const list = (_a12 = stepConfig == null ? void 0 : stepConfig.addressSettings) == null ? void 0 : _a12.countryAllowlist;
|
|
31429
|
+
if (!list || list.length === 0) return void 0;
|
|
31430
|
+
return list.map((c3) => c3.toUpperCase());
|
|
31431
|
+
}, [stepConfig]);
|
|
31104
31432
|
const basistheoryPublicKey = (0, import_react34.useMemo)(() => getBasisTheoryApiKey(), []);
|
|
31105
31433
|
const { processApplePayPayment } = usePaymentQuery();
|
|
31106
31434
|
const { selectRate } = useShippingRatesQuery({ checkout });
|
|
@@ -31223,7 +31551,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31223
31551
|
amount: minorUnitsToCurrencyString(checkout.summary.totalAdjustedAmount, checkout.summary.currency),
|
|
31224
31552
|
type: "final"
|
|
31225
31553
|
};
|
|
31226
|
-
const request = {
|
|
31554
|
+
const request = __spreadValues({
|
|
31227
31555
|
countryCode: ((_b2 = applePayPaymentMethod == null ? void 0 : applePayPaymentMethod.metadata) == null ? void 0 : _b2.country) || "US",
|
|
31228
31556
|
currencyCode: checkout.summary.currency,
|
|
31229
31557
|
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
@@ -31233,7 +31561,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31233
31561
|
lineItems,
|
|
31234
31562
|
requiredShippingContactFields: ["name", "phone", "email", "postalAddress"],
|
|
31235
31563
|
requiredBillingContactFields: ["postalAddress"]
|
|
31236
|
-
};
|
|
31564
|
+
}, countryAllowlist ? { supportedCountries: countryAllowlist } : {});
|
|
31237
31565
|
try {
|
|
31238
31566
|
const session = new ApplePaySession(3, request);
|
|
31239
31567
|
session.onvalidatemerchant = (event) => {
|
|
@@ -31254,6 +31582,14 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31254
31582
|
const billingContact = event.payment.billingContact;
|
|
31255
31583
|
const shippingAddress = applePayContactToAddress(shippingContact);
|
|
31256
31584
|
const billingAddress = applePayContactToAddress(billingContact);
|
|
31585
|
+
if (countryAllowlist && shippingAddress.country && !countryAllowlist.includes(shippingAddress.country.toUpperCase())) {
|
|
31586
|
+
console.error("[ApplePay] Shipping country not in allowlist:", shippingAddress.country);
|
|
31587
|
+
session.completePayment(ApplePaySession.STATUS_FAILURE);
|
|
31588
|
+
const errorMessage = "Shipping to this country is not supported";
|
|
31589
|
+
setContextError(errorMessage);
|
|
31590
|
+
if (onError3) onError3(errorMessage);
|
|
31591
|
+
return;
|
|
31592
|
+
}
|
|
31257
31593
|
await updateCheckoutSessionValues({
|
|
31258
31594
|
data: {
|
|
31259
31595
|
shippingAddress,
|
|
@@ -31314,7 +31650,37 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31314
31650
|
};
|
|
31315
31651
|
session.onshippingcontactselected = (event) => {
|
|
31316
31652
|
void (async () => {
|
|
31653
|
+
var _a13, _b3, _c, _d;
|
|
31317
31654
|
const shippingContact = event.shippingContact;
|
|
31655
|
+
const contactCountry = ((shippingContact == null ? void 0 : shippingContact.countryCode) || "").toUpperCase();
|
|
31656
|
+
if (countryAllowlist && contactCountry && !countryAllowlist.includes(contactCountry)) {
|
|
31657
|
+
console.warn("[ApplePay] Selected shipping country not in allowlist:", contactCountry);
|
|
31658
|
+
const ApplePayErrorCtor = window.ApplePayError;
|
|
31659
|
+
const currentTotal = {
|
|
31660
|
+
label: ((_a13 = checkout.checkoutSession.store) == null ? void 0 : _a13.name) || "Store",
|
|
31661
|
+
amount: minorUnitsToCurrencyString(
|
|
31662
|
+
(_c = (_b3 = checkout.summary) == null ? void 0 : _b3.totalAdjustedAmount) != null ? _c : 0,
|
|
31663
|
+
(_d = checkout.summary) == null ? void 0 : _d.currency
|
|
31664
|
+
),
|
|
31665
|
+
type: "final"
|
|
31666
|
+
};
|
|
31667
|
+
const errors = ApplePayErrorCtor ? [new ApplePayErrorCtor(
|
|
31668
|
+
"shippingContactInvalid",
|
|
31669
|
+
"country",
|
|
31670
|
+
"Shipping to this country is not supported"
|
|
31671
|
+
)] : [{
|
|
31672
|
+
code: "shippingContactInvalid",
|
|
31673
|
+
contactField: "country",
|
|
31674
|
+
message: "Shipping to this country is not supported"
|
|
31675
|
+
}];
|
|
31676
|
+
session.completeShippingContactSelection({
|
|
31677
|
+
newTotal: currentTotal,
|
|
31678
|
+
newLineItems: lineItems,
|
|
31679
|
+
newShippingMethods: [],
|
|
31680
|
+
errors
|
|
31681
|
+
});
|
|
31682
|
+
return;
|
|
31683
|
+
}
|
|
31318
31684
|
try {
|
|
31319
31685
|
await updateCheckoutSessionValues({
|
|
31320
31686
|
data: {
|
|
@@ -31370,6 +31736,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31370
31736
|
shippingMethods,
|
|
31371
31737
|
lineItems,
|
|
31372
31738
|
applePayPaymentMethod,
|
|
31739
|
+
countryAllowlist,
|
|
31373
31740
|
minorUnitsToCurrencyString,
|
|
31374
31741
|
validateMerchant,
|
|
31375
31742
|
tokenizeApplePay,
|
|
@@ -31416,7 +31783,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
31416
31783
|
);
|
|
31417
31784
|
};
|
|
31418
31785
|
|
|
31419
|
-
// ../../node_modules/.pnpm/@stripe+react-stripe-js@5.
|
|
31786
|
+
// ../../node_modules/.pnpm/@stripe+react-stripe-js@5.6_b5ce487d3341346f9e43c58fb3ea9d2c/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs
|
|
31420
31787
|
var import_react35 = __toESM(__require("react"), 1);
|
|
31421
31788
|
var import_prop_types = __toESM(require_prop_types(), 1);
|
|
31422
31789
|
function ownKeys2(object, enumerableOnly) {
|
|
@@ -32128,6 +32495,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32128
32495
|
// src/v2/react/components/StripeExpressButton.tsx
|
|
32129
32496
|
var import_react36 = __require("react");
|
|
32130
32497
|
init_payments();
|
|
32498
|
+
init_useStepConfig();
|
|
32131
32499
|
init_useApiQuery();
|
|
32132
32500
|
var import_jsx_runtime8 = __require("react/jsx-runtime");
|
|
32133
32501
|
var EXPRESS_METHOD_KEYS = ["apple_pay", "google_pay", "link", "klarna_express"];
|
|
@@ -32146,6 +32514,13 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32146
32514
|
const { startPolling } = usePaymentPolling();
|
|
32147
32515
|
const isProcessingRef = (0, import_react36.useRef)(false);
|
|
32148
32516
|
const [visible, setVisible] = (0, import_react36.useState)(false);
|
|
32517
|
+
const { stepConfig } = useStepConfig();
|
|
32518
|
+
const countryAllowlist = (0, import_react36.useMemo)(() => {
|
|
32519
|
+
var _a12;
|
|
32520
|
+
const list = (_a12 = stepConfig == null ? void 0 : stepConfig.addressSettings) == null ? void 0 : _a12.countryAllowlist;
|
|
32521
|
+
if (!list || list.length === 0) return void 0;
|
|
32522
|
+
return list.map((c3) => c3.toUpperCase());
|
|
32523
|
+
}, [stepConfig]);
|
|
32149
32524
|
const paymentsResource = (0, import_react36.useMemo)(() => new PaymentsResource(getGlobalApiClient()), []);
|
|
32150
32525
|
const liveAmount = Math.round((_b2 = (_a11 = checkout.summary) == null ? void 0 : _a11.totalAdjustedAmount) != null ? _b2 : 0);
|
|
32151
32526
|
const liveCurrency = (((_c = checkout.summary) == null ? void 0 : _c.currency) || "usd").toLowerCase();
|
|
@@ -32154,12 +32529,13 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32154
32529
|
elements.update({ amount: liveAmount, currency: liveCurrency });
|
|
32155
32530
|
}, [elements, liveAmount, liveCurrency]);
|
|
32156
32531
|
const onConfirm = async (event) => {
|
|
32157
|
-
var _a12, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
32532
|
+
var _a12, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
|
|
32158
32533
|
if (!stripe || !elements || isProcessingRef.current) return;
|
|
32159
32534
|
isProcessingRef.current = true;
|
|
32160
32535
|
const paymentMethod = event.expressPaymentType;
|
|
32161
32536
|
try {
|
|
32162
32537
|
const billing = event.billingDetails;
|
|
32538
|
+
const eventShipping = event.shippingAddress;
|
|
32163
32539
|
if (billing) {
|
|
32164
32540
|
const nameParts = ((_a12 = billing.name) != null ? _a12 : "").trim().split(/\s+/);
|
|
32165
32541
|
const firstName = (_b3 = nameParts[0]) != null ? _b3 : "";
|
|
@@ -32176,9 +32552,28 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32176
32552
|
phone: (_o = billing.phone) != null ? _o : "",
|
|
32177
32553
|
email: (_p = billing.email) != null ? _p : ""
|
|
32178
32554
|
};
|
|
32555
|
+
const shippingFromEvent = (eventShipping == null ? void 0 : eventShipping.address) ? {
|
|
32556
|
+
firstName: (_r = ((_q = eventShipping.name) != null ? _q : "").trim().split(/\s+/)[0]) != null ? _r : "",
|
|
32557
|
+
lastName: ((_s = eventShipping.name) != null ? _s : "").trim().split(/\s+/).slice(1).join(" "),
|
|
32558
|
+
address1: (_t = eventShipping.address.line1) != null ? _t : "",
|
|
32559
|
+
address2: (_u = eventShipping.address.line2) != null ? _u : "",
|
|
32560
|
+
city: (_v = eventShipping.address.city) != null ? _v : "",
|
|
32561
|
+
state: (_w = eventShipping.address.state) != null ? _w : "",
|
|
32562
|
+
country: (_x = eventShipping.address.country) != null ? _x : "",
|
|
32563
|
+
postal: (_y = eventShipping.address.postal_code) != null ? _y : "",
|
|
32564
|
+
phone: (_z = billing.phone) != null ? _z : "",
|
|
32565
|
+
email: (_A = billing.email) != null ? _A : ""
|
|
32566
|
+
} : billingAddress;
|
|
32567
|
+
const shippingCountry = shippingFromEvent.country.toUpperCase();
|
|
32568
|
+
if (countryAllowlist && shippingCountry && !countryAllowlist.includes(shippingCountry)) {
|
|
32569
|
+
console.error("[StripeExpress] Shipping country not in allowlist:", shippingCountry);
|
|
32570
|
+
onError3 == null ? void 0 : onError3("Shipping to this country is not supported");
|
|
32571
|
+
isProcessingRef.current = false;
|
|
32572
|
+
return;
|
|
32573
|
+
}
|
|
32179
32574
|
await updateCheckoutSessionValues({
|
|
32180
32575
|
data: {
|
|
32181
|
-
shippingAddress:
|
|
32576
|
+
shippingAddress: shippingFromEvent,
|
|
32182
32577
|
billingAddress
|
|
32183
32578
|
}
|
|
32184
32579
|
});
|
|
@@ -32188,11 +32583,11 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32188
32583
|
}
|
|
32189
32584
|
const { error: submitError } = await elements.submit();
|
|
32190
32585
|
if (submitError) {
|
|
32191
|
-
onError3 == null ? void 0 : onError3((
|
|
32586
|
+
onError3 == null ? void 0 : onError3((_B = submitError.message) != null ? _B : "Validation failed");
|
|
32192
32587
|
isProcessingRef.current = false;
|
|
32193
32588
|
return;
|
|
32194
32589
|
}
|
|
32195
|
-
const shippingRateId = checkout.checkoutSession.shippingRateId || ((
|
|
32590
|
+
const shippingRateId = checkout.checkoutSession.shippingRateId || ((_C = checkout.checkoutSession.shippingRate) == null ? void 0 : _C.id);
|
|
32196
32591
|
const response = await paymentsResource.processPaymentDirect(
|
|
32197
32592
|
checkout.checkoutSession.id,
|
|
32198
32593
|
"",
|
|
@@ -32205,7 +32600,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32205
32600
|
shippingRateId
|
|
32206
32601
|
}
|
|
32207
32602
|
);
|
|
32208
|
-
const clientSecret = (
|
|
32603
|
+
const clientSecret = (_G = (_F = (_E = (_D = response == null ? void 0 : response.payment) == null ? void 0 : _D.requireActionData) == null ? void 0 : _E.metadata) == null ? void 0 : _F.stripeExpressCheckout) == null ? void 0 : _G.clientSecret;
|
|
32209
32604
|
if (!clientSecret) {
|
|
32210
32605
|
onError3 == null ? void 0 : onError3("Express checkout configuration missing \u2014 no client secret returned");
|
|
32211
32606
|
isProcessingRef.current = false;
|
|
@@ -32221,7 +32616,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32221
32616
|
redirect: "if_required"
|
|
32222
32617
|
});
|
|
32223
32618
|
if (confirmError) {
|
|
32224
|
-
onError3 == null ? void 0 : onError3((
|
|
32619
|
+
onError3 == null ? void 0 : onError3((_H = confirmError.message) != null ? _H : "Payment confirmation failed");
|
|
32225
32620
|
isProcessingRef.current = false;
|
|
32226
32621
|
return;
|
|
32227
32622
|
}
|
|
@@ -32250,7 +32645,13 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32250
32645
|
onError3 == null ? void 0 : onError3(msg);
|
|
32251
32646
|
}
|
|
32252
32647
|
};
|
|
32253
|
-
|
|
32648
|
+
const hiddenStyle = {
|
|
32649
|
+
position: "absolute",
|
|
32650
|
+
left: "-9999px",
|
|
32651
|
+
top: "-9999px",
|
|
32652
|
+
pointerEvents: "none"
|
|
32653
|
+
};
|
|
32654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: visible ? void 0 : hiddenStyle, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
32254
32655
|
ExpressCheckoutElement,
|
|
32255
32656
|
{
|
|
32256
32657
|
onReady: ({ availablePaymentMethods }) => {
|
|
@@ -32264,7 +32665,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32264
32665
|
isProcessingRef.current = false;
|
|
32265
32666
|
onCancel == null ? void 0 : onCancel();
|
|
32266
32667
|
},
|
|
32267
|
-
options: {
|
|
32668
|
+
options: __spreadValues({
|
|
32268
32669
|
buttonType: {
|
|
32269
32670
|
applePay: "buy",
|
|
32270
32671
|
googlePay: "buy"
|
|
@@ -32278,7 +32679,10 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32278
32679
|
},
|
|
32279
32680
|
emailRequired: true,
|
|
32280
32681
|
billingAddressRequired: true
|
|
32281
|
-
}
|
|
32682
|
+
}, countryAllowlist ? {
|
|
32683
|
+
shippingAddressRequired: true,
|
|
32684
|
+
allowedShippingCountries: countryAllowlist
|
|
32685
|
+
} : {})
|
|
32282
32686
|
}
|
|
32283
32687
|
) });
|
|
32284
32688
|
}
|
|
@@ -32322,6 +32726,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32322
32726
|
// src/v2/react/components/GooglePayButton.tsx
|
|
32323
32727
|
var import_button_react = __toESM(require_index_umd_min());
|
|
32324
32728
|
var import_react37 = __require("react");
|
|
32729
|
+
init_useStepConfig();
|
|
32325
32730
|
var import_jsx_runtime9 = __require("react/jsx-runtime");
|
|
32326
32731
|
var GooglePayButton = ({
|
|
32327
32732
|
className = "",
|
|
@@ -32365,6 +32770,13 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32365
32770
|
const [processingPayment, setProcessingPayment] = (0, import_react37.useState)(false);
|
|
32366
32771
|
const [pendingPaymentData, setPendingPaymentData] = (0, import_react37.useState)(null);
|
|
32367
32772
|
const [googlePayError, setGooglePayError] = (0, import_react37.useState)(null);
|
|
32773
|
+
const { stepConfig } = useStepConfig();
|
|
32774
|
+
const countryAllowlist = (0, import_react37.useMemo)(() => {
|
|
32775
|
+
var _a12;
|
|
32776
|
+
const list = (_a12 = stepConfig == null ? void 0 : stepConfig.addressSettings) == null ? void 0 : _a12.countryAllowlist;
|
|
32777
|
+
if (!list || list.length === 0) return void 0;
|
|
32778
|
+
return list.map((c3) => c3.toUpperCase());
|
|
32779
|
+
}, [stepConfig]);
|
|
32368
32780
|
if (!googlePayPaymentMethod) {
|
|
32369
32781
|
return null;
|
|
32370
32782
|
}
|
|
@@ -32454,6 +32866,15 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32454
32866
|
if (paymentData.shippingAddress) {
|
|
32455
32867
|
shippingAddress = googlePayAddressToAddress(paymentData.shippingAddress);
|
|
32456
32868
|
}
|
|
32869
|
+
if (countryAllowlist && (shippingAddress == null ? void 0 : shippingAddress.country) && !countryAllowlist.includes(shippingAddress.country.toUpperCase())) {
|
|
32870
|
+
const msg = "Shipping to this country is not supported";
|
|
32871
|
+
console.error("[GooglePay] Shipping country not in allowlist:", shippingAddress.country);
|
|
32872
|
+
setProcessingPayment(false);
|
|
32873
|
+
setGooglePayError(msg);
|
|
32874
|
+
setContextError(msg);
|
|
32875
|
+
if (onError3) onError3(msg);
|
|
32876
|
+
return;
|
|
32877
|
+
}
|
|
32457
32878
|
if (shippingAddress) {
|
|
32458
32879
|
await updateCheckoutSessionValues({
|
|
32459
32880
|
data: {
|
|
@@ -32491,6 +32912,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32491
32912
|
updateCustomerEmail,
|
|
32492
32913
|
tokenizeGooglePayTokenWithBasisTheory,
|
|
32493
32914
|
handleGooglePayPayment,
|
|
32915
|
+
countryAllowlist,
|
|
32494
32916
|
onSuccess,
|
|
32495
32917
|
onError3,
|
|
32496
32918
|
setContextError
|
|
@@ -32519,6 +32941,17 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32519
32941
|
const paymentDataRequestUpdate = {};
|
|
32520
32942
|
if (intermediatePaymentData.callbackTrigger === "SHIPPING_ADDRESS") {
|
|
32521
32943
|
const address = intermediatePaymentData.shippingAddress;
|
|
32944
|
+
const addressCountry = ((address == null ? void 0 : address.countryCode) || "").toUpperCase();
|
|
32945
|
+
if (countryAllowlist && addressCountry && !countryAllowlist.includes(addressCountry)) {
|
|
32946
|
+
resolve({
|
|
32947
|
+
error: {
|
|
32948
|
+
reason: "SHIPPING_ADDRESS_UNSERVICEABLE",
|
|
32949
|
+
message: "Shipping to this country is not supported",
|
|
32950
|
+
intent: "SHIPPING_ADDRESS"
|
|
32951
|
+
}
|
|
32952
|
+
});
|
|
32953
|
+
return;
|
|
32954
|
+
}
|
|
32522
32955
|
const shippingAddress = {
|
|
32523
32956
|
address1: ((_a12 = address == null ? void 0 : address.addressLines) == null ? void 0 : _a12[0]) || "",
|
|
32524
32957
|
address2: ((_b3 = address == null ? void 0 : address.addressLines) == null ? void 0 : _b3[1]) || "",
|
|
@@ -32586,7 +33019,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32586
33019
|
void processCallback();
|
|
32587
33020
|
});
|
|
32588
33021
|
},
|
|
32589
|
-
[updateCheckoutSessionValues, reComputeOrderSummary, checkout, selectRate]
|
|
33022
|
+
[updateCheckoutSessionValues, reComputeOrderSummary, checkout, selectRate, countryAllowlist]
|
|
32590
33023
|
);
|
|
32591
33024
|
const handleGooglePayAuthorized = (0, import_react37.useCallback)(
|
|
32592
33025
|
(paymentData) => {
|
|
@@ -32646,6 +33079,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
32646
33079
|
emailRequired: true,
|
|
32647
33080
|
callbackIntents: requiresShipping ? ["SHIPPING_OPTION", "SHIPPING_ADDRESS", "PAYMENT_AUTHORIZATION"] : ["PAYMENT_AUTHORIZATION"]
|
|
32648
33081
|
}, requiresShipping && {
|
|
33082
|
+
shippingAddressParameters: countryAllowlist ? { allowedCountryCodes: countryAllowlist } : void 0,
|
|
32649
33083
|
shippingOptionParameters: {
|
|
32650
33084
|
defaultSelectedOptionId: ((_h = (_g = checkout.checkoutSession) == null ? void 0 : _g.shippingRate) == null ? void 0 : _h.id) || (shippingMethods.length > 0 ? shippingMethods[0].identifier : ""),
|
|
32651
33085
|
shippingOptions: shippingMethods.map((method) => ({
|
|
@@ -35774,7 +36208,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
35774
36208
|
if (sessionId) {
|
|
35775
36209
|
await Promise.all([
|
|
35776
36210
|
queryClient.invalidateQueries({ queryKey: ["discounts", sessionId] }),
|
|
35777
|
-
queryClient.invalidateQueries({ queryKey: ["checkout"] })
|
|
36211
|
+
queryClient.invalidateQueries({ queryKey: ["checkout"] }),
|
|
36212
|
+
queryClient.invalidateQueries({ queryKey: ["shipping-rates", sessionId] }),
|
|
36213
|
+
queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", sessionId] })
|
|
35778
36214
|
]);
|
|
35779
36215
|
}
|
|
35780
36216
|
if (onApplySuccess) {
|
|
@@ -35798,7 +36234,9 @@ var TagadaReactSDKBundle = (() => {
|
|
|
35798
36234
|
if (sessionId) {
|
|
35799
36235
|
await Promise.all([
|
|
35800
36236
|
queryClient.invalidateQueries({ queryKey: ["discounts", sessionId] }),
|
|
35801
|
-
queryClient.invalidateQueries({ queryKey: ["checkout"] })
|
|
36237
|
+
queryClient.invalidateQueries({ queryKey: ["checkout"] }),
|
|
36238
|
+
queryClient.invalidateQueries({ queryKey: ["shipping-rates", sessionId] }),
|
|
36239
|
+
queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", sessionId] })
|
|
35802
36240
|
]);
|
|
35803
36241
|
}
|
|
35804
36242
|
if (onRemoveSuccess) {
|
|
@@ -36953,6 +37391,7 @@ var TagadaReactSDKBundle = (() => {
|
|
|
36953
37391
|
init_modern2();
|
|
36954
37392
|
var import_react65 = __require("react");
|
|
36955
37393
|
init_offers();
|
|
37394
|
+
init_funnelClient();
|
|
36956
37395
|
init_useApiQuery();
|
|
36957
37396
|
function usePreviewOffer(options) {
|
|
36958
37397
|
const { offerId, currency: requestedCurrency = "", initialSelections = {} } = options;
|
|
@@ -37157,18 +37596,21 @@ var TagadaReactSDKBundle = (() => {
|
|
|
37157
37596
|
};
|
|
37158
37597
|
});
|
|
37159
37598
|
}, [summary, effectiveCurrency]);
|
|
37160
|
-
const pay = (0, import_react65.useCallback)(async (mainOrderId) => {
|
|
37599
|
+
const pay = (0, import_react65.useCallback)(async (mainOrderId, payOptions) => {
|
|
37600
|
+
var _a11;
|
|
37161
37601
|
if (isPaying) {
|
|
37162
37602
|
throw new Error("Payment already in progress");
|
|
37163
37603
|
}
|
|
37164
37604
|
setIsPaying(true);
|
|
37165
37605
|
try {
|
|
37606
|
+
const initiatedBy = (_a11 = payOptions == null ? void 0 : payOptions.initiatedBy) != null ? _a11 : getAssignedPaymentInitiator();
|
|
37166
37607
|
const result = await offersResource.payPreviewedOffer(
|
|
37167
37608
|
offerId,
|
|
37168
37609
|
effectiveCurrency,
|
|
37169
37610
|
lineItemsForPreview,
|
|
37170
37611
|
typeof window !== "undefined" ? window.location.href : void 0,
|
|
37171
|
-
mainOrderId
|
|
37612
|
+
mainOrderId,
|
|
37613
|
+
initiatedBy
|
|
37172
37614
|
);
|
|
37173
37615
|
console.log("[usePreviewOffer] Payment initiated:", result);
|
|
37174
37616
|
return {
|
|
@@ -37340,17 +37782,19 @@ var TagadaReactSDKBundle = (() => {
|
|
|
37340
37782
|
init_modern2();
|
|
37341
37783
|
init_promotions2();
|
|
37342
37784
|
init_useApiQuery();
|
|
37785
|
+
init_TagadaProvider();
|
|
37343
37786
|
function usePromotionsQuery(options = {}) {
|
|
37344
37787
|
const { checkoutSessionId, enabled = true } = options;
|
|
37345
37788
|
const queryClient = useQueryClient();
|
|
37346
|
-
const
|
|
37789
|
+
const apiClient = getGlobalApiClient();
|
|
37790
|
+
const { client } = useTagadaContext();
|
|
37347
37791
|
const promotionsResource = (0, import_react67.useMemo)(() => {
|
|
37348
37792
|
try {
|
|
37349
|
-
return new PromotionsResource(client);
|
|
37793
|
+
return new PromotionsResource(apiClient, client.bus);
|
|
37350
37794
|
} catch (error2) {
|
|
37351
37795
|
throw new Error("Failed to initialize promotions resource: " + (error2 instanceof Error ? error2.message : "Unknown error"));
|
|
37352
37796
|
}
|
|
37353
|
-
}, [client]);
|
|
37797
|
+
}, [apiClient, client.bus]);
|
|
37354
37798
|
const {
|
|
37355
37799
|
data: appliedPromotions = [],
|
|
37356
37800
|
isLoading,
|
|
@@ -37375,6 +37819,8 @@ var TagadaReactSDKBundle = (() => {
|
|
|
37375
37819
|
if (checkoutSessionId) {
|
|
37376
37820
|
void queryClient.invalidateQueries({ queryKey: ["promotions", checkoutSessionId] });
|
|
37377
37821
|
void queryClient.invalidateQueries({ queryKey: ["checkout", checkoutSessionId] });
|
|
37822
|
+
void queryClient.invalidateQueries({ queryKey: ["shipping-rates", checkoutSessionId] });
|
|
37823
|
+
void queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", checkoutSessionId] });
|
|
37378
37824
|
}
|
|
37379
37825
|
}
|
|
37380
37826
|
});
|
|
@@ -37389,6 +37835,8 @@ var TagadaReactSDKBundle = (() => {
|
|
|
37389
37835
|
if (checkoutSessionId) {
|
|
37390
37836
|
void queryClient.invalidateQueries({ queryKey: ["promotions", checkoutSessionId] });
|
|
37391
37837
|
void queryClient.invalidateQueries({ queryKey: ["checkout", checkoutSessionId] });
|
|
37838
|
+
void queryClient.invalidateQueries({ queryKey: ["shipping-rates", checkoutSessionId] });
|
|
37839
|
+
void queryClient.invalidateQueries({ queryKey: ["shipping-rates-preview", checkoutSessionId] });
|
|
37392
37840
|
}
|
|
37393
37841
|
}
|
|
37394
37842
|
});
|
|
@@ -37606,7 +38054,8 @@ var TagadaReactSDKBundle = (() => {
|
|
|
37606
38054
|
pixels: getAssignedPixels(),
|
|
37607
38055
|
getScripts: (position) => getAssignedScripts(position),
|
|
37608
38056
|
orderBumpOfferIds: getAssignedOrderBumpOfferIds(),
|
|
37609
|
-
upsellOfferIds: getAssignedUpsellOfferIds()
|
|
38057
|
+
upsellOfferIds: getAssignedUpsellOfferIds(),
|
|
38058
|
+
paymentInitiator: getAssignedPaymentInitiator()
|
|
37610
38059
|
};
|
|
37611
38060
|
}, []);
|
|
37612
38061
|
return __spreadProps(__spreadValues({}, funnel), {
|
|
@@ -38247,6 +38696,8 @@ var TagadaReactSDKBundle = (() => {
|
|
|
38247
38696
|
init_funnel();
|
|
38248
38697
|
init_funnelClient();
|
|
38249
38698
|
init_money();
|
|
38699
|
+
init_metaEventId();
|
|
38700
|
+
init_clickIdResolver();
|
|
38250
38701
|
init_errors();
|
|
38251
38702
|
return __toCommonJS(index_exports);
|
|
38252
38703
|
})();
|