@tagadapay/plugin-sdk 4.0.0 → 4.0.4
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 +707 -253
- package/dist/tagada-react-sdk.min.js +2 -2
- package/dist/tagada-react-sdk.min.js.map +4 -4
- package/dist/tagada-sdk.js +2922 -102
- 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 +3 -3
- package/dist/v2/core/resources/offers.js +11 -3
- 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/useOfferQuery.d.ts +11 -0
- package/dist/v2/react/hooks/useOfferQuery.js +11 -0
- 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 +4 -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 +5 -0
- package/dist/v2/react/index.js +9 -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
|
@@ -228,13 +228,15 @@ export function usePreviewOffer(options) {
|
|
|
228
228
|
});
|
|
229
229
|
}, [summary, effectiveCurrency]);
|
|
230
230
|
// Pay for the offer with current selections
|
|
231
|
-
const pay = useCallback(async (mainOrderId) => {
|
|
231
|
+
const pay = useCallback(async (mainOrderId, payOptions) => {
|
|
232
232
|
if (isPaying) {
|
|
233
233
|
throw new Error('Payment already in progress');
|
|
234
234
|
}
|
|
235
235
|
setIsPaying(true);
|
|
236
236
|
try {
|
|
237
|
-
|
|
237
|
+
// initiatedBy auto-picks from stepConfig.paymentInitiator inside
|
|
238
|
+
// OffersResource.payPreviewedOffer when not supplied here.
|
|
239
|
+
const result = await offersResource.payPreviewedOffer(offerId, effectiveCurrency, lineItemsForPreview, typeof window !== 'undefined' ? window.location.href : undefined, mainOrderId, payOptions?.initiatedBy);
|
|
238
240
|
console.log('[usePreviewOffer] Payment initiated:', result);
|
|
239
241
|
return {
|
|
240
242
|
checkoutUrl: result.checkout.checkoutUrl,
|
|
@@ -6,19 +6,21 @@ import { useMemo } from 'react';
|
|
|
6
6
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
7
7
|
import { PromotionsResource } from '../../core/resources/promotions';
|
|
8
8
|
import { getGlobalApiClient } from './useApiQuery';
|
|
9
|
+
import { useTagadaContext } from '../providers/TagadaProvider';
|
|
9
10
|
export function usePromotionsQuery(options = {}) {
|
|
10
11
|
const { checkoutSessionId, enabled = true } = options;
|
|
11
12
|
const queryClient = useQueryClient();
|
|
12
|
-
const
|
|
13
|
+
const apiClient = getGlobalApiClient();
|
|
14
|
+
const { client } = useTagadaContext();
|
|
13
15
|
// Create resource client
|
|
14
16
|
const promotionsResource = useMemo(() => {
|
|
15
17
|
try {
|
|
16
|
-
return new PromotionsResource(client);
|
|
18
|
+
return new PromotionsResource(apiClient, client.bus);
|
|
17
19
|
}
|
|
18
20
|
catch (error) {
|
|
19
21
|
throw new Error('Failed to initialize promotions resource: ' + (error instanceof Error ? error.message : 'Unknown error'));
|
|
20
22
|
}
|
|
21
|
-
}, [client]);
|
|
23
|
+
}, [apiClient, client.bus]);
|
|
22
24
|
// Main promotions query
|
|
23
25
|
const { data: appliedPromotions = [], isLoading, error, refetch, } = useQuery({
|
|
24
26
|
queryKey: ['promotions', checkoutSessionId],
|
|
@@ -40,6 +42,8 @@ export function usePromotionsQuery(options = {}) {
|
|
|
40
42
|
if (checkoutSessionId) {
|
|
41
43
|
void queryClient.invalidateQueries({ queryKey: ['promotions', checkoutSessionId] });
|
|
42
44
|
void queryClient.invalidateQueries({ queryKey: ['checkout', checkoutSessionId] });
|
|
45
|
+
void queryClient.invalidateQueries({ queryKey: ['shipping-rates', checkoutSessionId] });
|
|
46
|
+
void queryClient.invalidateQueries({ queryKey: ['shipping-rates-preview', checkoutSessionId] });
|
|
43
47
|
}
|
|
44
48
|
},
|
|
45
49
|
});
|
|
@@ -56,6 +60,8 @@ export function usePromotionsQuery(options = {}) {
|
|
|
56
60
|
if (checkoutSessionId) {
|
|
57
61
|
void queryClient.invalidateQueries({ queryKey: ['promotions', checkoutSessionId] });
|
|
58
62
|
void queryClient.invalidateQueries({ queryKey: ['checkout', checkoutSessionId] });
|
|
63
|
+
void queryClient.invalidateQueries({ queryKey: ['shipping-rates', checkoutSessionId] });
|
|
64
|
+
void queryClient.invalidateQueries({ queryKey: ['shipping-rates-preview', checkoutSessionId] });
|
|
59
65
|
}
|
|
60
66
|
},
|
|
61
67
|
});
|
|
@@ -23,9 +23,8 @@ export function useShippingRatesQuery(options = {}) {
|
|
|
23
23
|
const effectiveSessionId = sessionId || checkout?.checkoutSession?.id;
|
|
24
24
|
// Track if we've synced the initial selection from checkout
|
|
25
25
|
const hasSyncedInitialSelectionRef = useRef(false);
|
|
26
|
-
// Preview rates
|
|
27
|
-
const [
|
|
28
|
-
const [isPreviewLoading, setIsPreviewLoading] = useState(false);
|
|
26
|
+
// Preview rates params - triggers preview query when set
|
|
27
|
+
const [previewParams, setPreviewParams] = useState(null);
|
|
29
28
|
// Main shipping rates query
|
|
30
29
|
const { data: shippingRatesData, isLoading: isFetching, error: fetchError, refetch: refetchRates, } = useQuery({
|
|
31
30
|
queryKey: ['shipping-rates', effectiveSessionId],
|
|
@@ -54,6 +53,23 @@ export function useShippingRatesQuery(options = {}) {
|
|
|
54
53
|
});
|
|
55
54
|
// Get sorted shipping rates from query data
|
|
56
55
|
const shippingRates = shippingRatesData?.rates;
|
|
56
|
+
// Preview shipping rates query - invalidated by promotions mutations
|
|
57
|
+
const { data: previewedRates, isLoading: isPreviewLoading, } = useQuery({
|
|
58
|
+
queryKey: ['shipping-rates-preview', effectiveSessionId, previewParams?.countryCode, previewParams?.stateCode],
|
|
59
|
+
queryFn: async () => {
|
|
60
|
+
const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, previewParams);
|
|
61
|
+
return [...response.rates].sort((a, b) => {
|
|
62
|
+
if (a.isFree && !b.isFree)
|
|
63
|
+
return -1;
|
|
64
|
+
if (!a.isFree && b.isFree)
|
|
65
|
+
return 1;
|
|
66
|
+
return (a.amount ?? 0) - (b.amount ?? 0);
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
enabled: !!effectiveSessionId && !!previewParams,
|
|
70
|
+
staleTime: 30000,
|
|
71
|
+
refetchOnWindowFocus: false,
|
|
72
|
+
});
|
|
57
73
|
// Get selected rate from checkout data
|
|
58
74
|
const checkoutSelectedRateId = checkout?.checkoutSession?.shippingRate?.id;
|
|
59
75
|
// Set shipping rate mutation
|
|
@@ -137,31 +153,30 @@ export function useShippingRatesQuery(options = {}) {
|
|
|
137
153
|
const previewRates = useCallback(async (countryCode, stateCode) => {
|
|
138
154
|
if (!enabled || !effectiveSessionId)
|
|
139
155
|
return [];
|
|
156
|
+
setPreviewParams({ countryCode, stateCode });
|
|
140
157
|
try {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
158
|
+
return await queryClient.fetchQuery({
|
|
159
|
+
queryKey: ['shipping-rates-preview', effectiveSessionId, countryCode, stateCode],
|
|
160
|
+
queryFn: async () => {
|
|
161
|
+
const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, {
|
|
162
|
+
countryCode,
|
|
163
|
+
stateCode,
|
|
164
|
+
});
|
|
165
|
+
return [...response.rates].sort((a, b) => {
|
|
166
|
+
if (a.isFree && !b.isFree)
|
|
167
|
+
return -1;
|
|
168
|
+
if (!a.isFree && b.isFree)
|
|
169
|
+
return 1;
|
|
170
|
+
return (a.amount ?? 0) - (b.amount ?? 0);
|
|
171
|
+
});
|
|
172
|
+
},
|
|
153
173
|
});
|
|
154
|
-
setPreviewedRates(sortedRates);
|
|
155
|
-
return sortedRates;
|
|
156
174
|
}
|
|
157
175
|
catch (error) {
|
|
158
176
|
console.error('[useShippingRatesQuery] Error previewing shipping rates:', error);
|
|
159
177
|
return [];
|
|
160
178
|
}
|
|
161
|
-
|
|
162
|
-
setIsPreviewLoading(false);
|
|
163
|
-
}
|
|
164
|
-
}, [enabled, effectiveSessionId, shippingRatesResource]);
|
|
179
|
+
}, [enabled, effectiveSessionId, queryClient, shippingRatesResource]);
|
|
165
180
|
return {
|
|
166
181
|
shippingRates,
|
|
167
182
|
selectedRate,
|
|
@@ -63,6 +63,15 @@ export interface UseStepConfigResult {
|
|
|
63
63
|
* undefined = inherit all store upsells, string[] = only these IDs.
|
|
64
64
|
*/
|
|
65
65
|
upsellOfferIds: string[] | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Enabled in-step checkout-offer upsell IDs (tiered selector).
|
|
68
|
+
* undefined = inherit all store upsells of type='upsell'.
|
|
69
|
+
*/
|
|
70
|
+
checkoutOfferIds: string[] | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Default checkout-offer upsell ID configured for this step (if any).
|
|
73
|
+
*/
|
|
74
|
+
checkoutOfferDefaultId: string | undefined;
|
|
66
75
|
}
|
|
67
76
|
/**
|
|
68
77
|
* Hook to access runtime step configuration injected via HTML
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
import { useMemo } from 'react';
|
|
25
|
-
import { getAssignedOrderBumpOfferIds, getAssignedPaymentFlowId, getAssignedPixels, getAssignedResources, getAssignedScripts, getAssignedStepConfig, getAssignedUpsellOfferIds, } from '../../core/funnelClient';
|
|
25
|
+
import { getAssignedCheckoutOfferDefault, getAssignedCheckoutOfferIds, getAssignedOrderBumpOfferIds, getAssignedPaymentFlowId, getAssignedPixels, getAssignedResources, getAssignedScripts, getAssignedStepConfig, getAssignedUpsellOfferIds, } from '../../core/funnelClient';
|
|
26
26
|
/**
|
|
27
27
|
* Hook to access runtime step configuration injected via HTML
|
|
28
28
|
*
|
|
@@ -46,6 +46,8 @@ export function useStepConfig() {
|
|
|
46
46
|
const paymentSetupConfig = useMemo(() => stepConfig?.paymentSetupConfig, [stepConfig]);
|
|
47
47
|
const orderBumpOfferIds = useMemo(() => getAssignedOrderBumpOfferIds(), []);
|
|
48
48
|
const upsellOfferIds = useMemo(() => getAssignedUpsellOfferIds(), []);
|
|
49
|
+
const checkoutOfferIds = useMemo(() => getAssignedCheckoutOfferIds(), []);
|
|
50
|
+
const checkoutOfferDefaultId = useMemo(() => getAssignedCheckoutOfferDefault(), []);
|
|
49
51
|
return {
|
|
50
52
|
stepConfig,
|
|
51
53
|
paymentFlowId,
|
|
@@ -56,5 +58,7 @@ export function useStepConfig() {
|
|
|
56
58
|
paymentSetupConfig,
|
|
57
59
|
orderBumpOfferIds,
|
|
58
60
|
upsellOfferIds,
|
|
61
|
+
checkoutOfferIds,
|
|
62
|
+
checkoutOfferDefaultId,
|
|
59
63
|
};
|
|
60
64
|
}
|
package/dist/v2/react/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQ
|
|
|
33
33
|
export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
34
34
|
export { useCurrency } from './hooks/useCurrency';
|
|
35
35
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
36
|
+
/** @deprecated Use `usePreviewOffer` instead. */
|
|
36
37
|
export { useOfferQuery as useOffer } from './hooks/useOfferQuery';
|
|
37
38
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
38
39
|
export { useOrderQuery as useOrder } from './hooks/useOrderQuery';
|
|
@@ -99,6 +100,10 @@ export type { UseStoreConfigQueryOptions as UseStoreConfigOptions, UseStoreConfi
|
|
|
99
100
|
export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession } from './hooks/useThreeds';
|
|
100
101
|
export type { UseVipOffersQueryOptions as UseVipOffersOptions, UseVipOffersQueryResult as UseVipOffersResult } from './hooks/useVipOffersQuery';
|
|
101
102
|
export { formatMoney } from '../../react/utils/money';
|
|
103
|
+
export { makeMetaEventId } from '../core/utils/metaEventId';
|
|
104
|
+
export type { TrackOptions } from './hooks/usePixelTracking';
|
|
105
|
+
export { resolveClickId, publishTrackingGlobal, CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES, } from '../core/utils/clickIdResolver';
|
|
106
|
+
export type { ResolvedClickId, TagadaTrackingGlobal, ClickIdSource, } from '../core/utils/clickIdResolver';
|
|
102
107
|
export { TagadaError, TagadaApiError, TagadaNetworkError, TagadaAuthError, TagadaValidationError, TagadaCircuitBreakerError, TagadaErrorCode, } from '../core/errors';
|
|
103
108
|
export type { TagadaErrorOptions, TagadaErrorCodeValue } from '../core/errors';
|
|
104
109
|
export type { PaymentMethodName } from '../core/resources/checkout';
|
package/dist/v2/react/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQ
|
|
|
35
35
|
export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
36
36
|
export { useCurrency } from './hooks/useCurrency';
|
|
37
37
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
38
|
+
/** @deprecated Use `usePreviewOffer` instead. */
|
|
38
39
|
export { useOfferQuery as useOffer } from './hooks/useOfferQuery';
|
|
39
40
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
40
41
|
export { useOrderQuery as useOrder } from './hooks/useOrderQuery';
|
|
@@ -63,5 +64,13 @@ export { FunnelActionType } from '../core/resources/funnel';
|
|
|
63
64
|
export { getEnabledMethods, getExpressMethods, getExpressMethodsByProcessor, findMethod, isMethodEnabled } from '../core/funnelClient';
|
|
64
65
|
// Re-export utilities from main react
|
|
65
66
|
export { formatMoney } from '../../react/utils/money';
|
|
67
|
+
// Meta CAPI / browser pixel deduplication helper.
|
|
68
|
+
// Use this to build a stable `eventId` shared between the browser pixel
|
|
69
|
+
// (`track('Purchase', params, { eventId })`) and the server-side Meta CAPI
|
|
70
|
+
// `ServerEvent.setEventId(...)`. Both sides must agree on the formula.
|
|
71
|
+
export { makeMetaEventId } from '../core/utils/metaEventId';
|
|
72
|
+
// Click-id resolver (ad-tracker integrations: ClickFlare, Voluum, Binom, RedTrack, ClickMagick, …)
|
|
73
|
+
// Lives in core (runtime-agnostic) so the standalone SDK / studio builder can use it too.
|
|
74
|
+
export { resolveClickId, publishTrackingGlobal, CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES, } from '../core/utils/clickIdResolver';
|
|
66
75
|
// Error types
|
|
67
76
|
export { TagadaError, TagadaApiError, TagadaNetworkError, TagadaAuthError, TagadaValidationError, TagadaCircuitBreakerError, TagadaErrorCode, } from '../core/errors';
|
|
@@ -10,6 +10,19 @@ import { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMon
|
|
|
10
10
|
import { TagadaClient } from '../../core/client';
|
|
11
11
|
import { setGlobalApiClient } from '../hooks/useApiQuery';
|
|
12
12
|
import { PixelTrackingProvider } from '../hooks/usePixelTracking';
|
|
13
|
+
import { publishTrackingGlobal } from '../../core/utils/clickIdResolver';
|
|
14
|
+
// Publish window.TagadaPay.tracking eagerly at module-load time so merchant
|
|
15
|
+
// postback scripts injected by <FunnelScriptInjector /> (which run from child
|
|
16
|
+
// useEffects, BEFORE the parent provider's useEffects) can read it. Idempotent
|
|
17
|
+
// — safe if standalone SDK already published.
|
|
18
|
+
if (typeof window !== 'undefined') {
|
|
19
|
+
try {
|
|
20
|
+
publishTrackingGlobal();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error('[TagadaProvider] Failed to publish tracking global:', error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
13
26
|
const FunnelScriptInjector = lazy(() => import('../components/FunnelScriptInjector').then(m => ({ default: m.FunnelScriptInjector })));
|
|
14
27
|
const DebugDrawer = lazy(() => import('../components/DebugDrawer'));
|
|
15
28
|
// Professional, subtle loading component for initialization
|
|
@@ -38,11 +51,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
38
51
|
borderTop: '1.5px solid #9ca3af',
|
|
39
52
|
borderRadius: '50%',
|
|
40
53
|
animation: 'tagada-spin 1s linear infinite',
|
|
41
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
-
@keyframes tagada-spin {
|
|
43
|
-
0% { transform: rotate(0deg); }
|
|
44
|
-
100% { transform: rotate(360deg); }
|
|
45
|
-
}
|
|
54
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
55
|
+
@keyframes tagada-spin {
|
|
56
|
+
0% { transform: rotate(0deg); }
|
|
57
|
+
100% { transform: rotate(360deg); }
|
|
58
|
+
}
|
|
46
59
|
` })] }));
|
|
47
60
|
const TagadaContext = createContext(null);
|
|
48
61
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, localConfig, blockUntilSessionReady = false, rawPluginConfig, features, funnelId, autoInitializeFunnel = true, onNavigate, onFunnelError, debugScripts = [], }) {
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* (studio-app, vanilla-checkout templates, …) keep working without
|
|
10
10
|
* code changes.
|
|
11
11
|
*/
|
|
12
|
-
export { isApplePayAvailable, startApplePaySession, type ApplePayServiceConfig, type ApplePayPaymentRequest, type ApplePayTokenResult, type ApplePayShippingContact, type ApplePayCallbacks, } from '@tagadapay/core-js';
|
|
12
|
+
export { isApplePayAvailable, startApplePaySession, type ApplePayServiceConfig, type ApplePayPaymentRequest, type ApplePayTokenResult, type ApplePayShippingContact, type ApplePayCallbacks, type ApplePayInlineError, } from '@tagadapay/core-js';
|
|
@@ -57,6 +57,7 @@ export { isApplePayAvailable, startApplePaySession } from './apple-pay-service';
|
|
|
57
57
|
export type { ApplePayServiceConfig, ApplePayPaymentRequest, ApplePayTokenResult, ApplePayShippingContact, ApplePayCallbacks, } from './apple-pay-service';
|
|
58
58
|
export { isGooglePayAvailable, startGooglePaySession } from './google-pay-service';
|
|
59
59
|
export type { GooglePayServiceConfig, GooglePayPaymentRequest, GooglePayTokenResult, GooglePayAddress, GooglePayCallbacks, } from './google-pay-service';
|
|
60
|
+
export { formatMoney, getCurrencyInfo, moneyStringOrNumberToMinorUnits, minorUnitsToMajorUnits, } from '../../react/utils/money';
|
|
60
61
|
/**
|
|
61
62
|
* Get BasisTheory public API key based on hostname detection.
|
|
62
63
|
* Delegates to the centralized isProductionBasisTheory() logic.
|
|
@@ -68,3 +69,5 @@ export declare function getBasisTheoryApiKey(): string;
|
|
|
68
69
|
export declare function getBasisTheoryTenantId(): string;
|
|
69
70
|
export { TagadaTracker, TagadaExternalTracker, } from './external-tracker';
|
|
70
71
|
export type { TagadaTrackerConfig, ExternalTrackerSession, NavigateOptions, } from './external-tracker';
|
|
72
|
+
export { resolveClickId, publishTrackingGlobal, CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES, } from '../core/utils/clickIdResolver';
|
|
73
|
+
export type { ResolvedClickId, TagadaTrackingGlobal, ClickIdSource, } from '../core/utils/clickIdResolver';
|
|
@@ -11,6 +11,7 @@ import { ApiClient } from '../core/resources/apiClient';
|
|
|
11
11
|
import { CheckoutResource } from '../core/resources/checkout';
|
|
12
12
|
import { getAssignedStepConfig, getAssignedPaymentFlowId } from '../core/funnelClient';
|
|
13
13
|
import { getBasisTheoryApiKey as _getBtApiKey, getBasisTheoryTenantId as _getBtTenantId } from '../../react/config/payment';
|
|
14
|
+
import { publishTrackingGlobal } from '../core/utils/clickIdResolver';
|
|
14
15
|
/**
|
|
15
16
|
* Parse step config from window variable or meta tag
|
|
16
17
|
*/
|
|
@@ -103,6 +104,16 @@ export function injectStepConfigScripts() {
|
|
|
103
104
|
// Auto-run script injection when SDK loads
|
|
104
105
|
// Uses requestIdleCallback or setTimeout fallback for non-blocking execution
|
|
105
106
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
107
|
+
// Publish click_id (URL > cookie) to window.TagadaPay.tracking IMMEDIATELY
|
|
108
|
+
// — synchronously, before any merchant stepConfig.scripts run. This is what
|
|
109
|
+
// ad-tracker postback snippets read, so it must exist before they execute.
|
|
110
|
+
// No DOM dependencies, safe to call right now.
|
|
111
|
+
try {
|
|
112
|
+
publishTrackingGlobal();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error('[TagadaPay] Failed to publish tracking global:', error);
|
|
116
|
+
}
|
|
106
117
|
const runInjection = () => {
|
|
107
118
|
// Wait for body to be available
|
|
108
119
|
if (document.body) {
|
|
@@ -162,6 +173,11 @@ export { PaymentService } from './payment-service';
|
|
|
162
173
|
export { isApplePayAvailable, startApplePaySession } from './apple-pay-service';
|
|
163
174
|
// Re-export Google Pay Service (standalone native Google Pay — no React)
|
|
164
175
|
export { isGooglePayAvailable, startGooglePaySession } from './google-pay-service';
|
|
176
|
+
// Re-export currency helpers (no React dep) so standalone consumers (studio, vanilla
|
|
177
|
+
// checkouts, …) can do backend-minor → major → wallet-minor conversions without bringing
|
|
178
|
+
// in the React entry-point. NEVER hardcode `* 100` in callers — use these helpers, which
|
|
179
|
+
// read the per-currency ISO decimal count.
|
|
180
|
+
export { formatMoney, getCurrencyInfo, moneyStringOrNumberToMinorUnits, minorUnitsToMajorUnits, } from '../../react/utils/money';
|
|
165
181
|
/**
|
|
166
182
|
* Get BasisTheory public API key based on hostname detection.
|
|
167
183
|
* Delegates to the centralized isProductionBasisTheory() logic.
|
|
@@ -181,3 +197,10 @@ export function getBasisTheoryTenantId() {
|
|
|
181
197
|
// Lightweight tracker for external pages not hosted on Tagadapay
|
|
182
198
|
// NOTE: This is also available as a standalone CDN bundle (external-tracker.min.js)
|
|
183
199
|
export { TagadaTracker, TagadaExternalTracker, } from './external-tracker';
|
|
200
|
+
// ============================================================================
|
|
201
|
+
// AD-TRACKER CLICK-ID RESOLVER
|
|
202
|
+
// ============================================================================
|
|
203
|
+
// Pure utility for resolving ClickFlare / Voluum / Binom / RedTrack / etc.
|
|
204
|
+
// click ids from URL params or cookies. Auto-published to
|
|
205
|
+
// `window.TagadaPay.tracking` on SDK load (see eager block above).
|
|
206
|
+
export { resolveClickId, publishTrackingGlobal, CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES, } from '../core/utils/clickIdResolver';
|
|
@@ -59,6 +59,31 @@ export interface PollingCallbacks {
|
|
|
59
59
|
onFailure: (error: string) => void;
|
|
60
60
|
onRequireAction?: (payment: Payment) => void;
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Outcome of running a requireAction handler. Lets processAndHandle (and
|
|
64
|
+
* polling) decide whether to surface success/redirecting vs failure to the
|
|
65
|
+
* caller, instead of blanket-returning success:true for every action type.
|
|
66
|
+
*/
|
|
67
|
+
type ActionOutcome =
|
|
68
|
+
/** Browser navigated or will navigate (3DS/APM/redirect form). Caller bails. */
|
|
69
|
+
{
|
|
70
|
+
kind: 'redirected';
|
|
71
|
+
}
|
|
72
|
+
/** Action completed in-page with payment in a terminal success state. */
|
|
73
|
+
| {
|
|
74
|
+
kind: 'completed';
|
|
75
|
+
payment: Payment;
|
|
76
|
+
}
|
|
77
|
+
/** Action completed in-page with a definitive failure. */
|
|
78
|
+
| {
|
|
79
|
+
kind: 'failed';
|
|
80
|
+
error: string;
|
|
81
|
+
payment?: Payment;
|
|
82
|
+
}
|
|
83
|
+
/** Action handed off to polling; outcome will arrive via PollingCallbacks. */
|
|
84
|
+
| {
|
|
85
|
+
kind: 'pending';
|
|
86
|
+
};
|
|
62
87
|
export declare class PaymentService {
|
|
63
88
|
private paymentsResource;
|
|
64
89
|
private threedsResource;
|
|
@@ -94,11 +119,18 @@ export declare class PaymentService {
|
|
|
94
119
|
* Shared by processCardPayment, processApplePayPayment, etc.
|
|
95
120
|
*/
|
|
96
121
|
private processAndHandle;
|
|
122
|
+
/**
|
|
123
|
+
* Translate an ActionOutcome into a PaymentResult, or null when the outcome
|
|
124
|
+
* is 'pending' (caller should keep polling instead of resolving).
|
|
125
|
+
*/
|
|
126
|
+
private settleActionOutcome;
|
|
97
127
|
/**
|
|
98
128
|
* After radar / completePaymentAfterAction, handle the resumed payment.
|
|
129
|
+
* Fires callbacks for side effects AND returns an outcome so the caller
|
|
130
|
+
* (handlePaymentAction) can propagate failure into PaymentResult.
|
|
99
131
|
*/
|
|
100
132
|
private handleResumedPayment;
|
|
101
|
-
handlePaymentAction(payment: Payment): Promise<
|
|
133
|
+
handlePaymentAction(payment: Payment): Promise<ActionOutcome>;
|
|
102
134
|
private handleKessPayAuth;
|
|
103
135
|
private handleTrustFlowAuth;
|
|
104
136
|
private handleFinixRadar;
|
|
@@ -144,4 +176,25 @@ export declare class PaymentService {
|
|
|
144
176
|
processApmPayment(checkoutSessionId: string, apmData: ApmData, options?: {
|
|
145
177
|
shippingRateId?: string;
|
|
146
178
|
}): Promise<PaymentResult>;
|
|
179
|
+
/**
|
|
180
|
+
* Stripe Express Checkout Element payment.
|
|
181
|
+
*
|
|
182
|
+
* Mirrors the inline flow from `react/components/StripeExpressButton.onConfirm`:
|
|
183
|
+
* 1. processPaymentDirect with isExpress=true → returns clientSecret
|
|
184
|
+
* 2. stripe.confirmPayment(elements, clientSecret) — must run while wallet sheet is open
|
|
185
|
+
* 3. Poll until webhook marks payment succeeded
|
|
186
|
+
*
|
|
187
|
+
* Used for ECE methods Stripe surfaces in one element: apple_pay, google_pay, link, klarna.
|
|
188
|
+
* The `stripe` and `elements` refs come from Stripe React hooks at the call site.
|
|
189
|
+
*/
|
|
190
|
+
processStripeExpressPayment(checkoutSessionId: string, paymentMethod: string, processorId: string, stripe: {
|
|
191
|
+
confirmPayment: (opts: Record<string, unknown>) => Promise<{
|
|
192
|
+
error?: {
|
|
193
|
+
message?: string;
|
|
194
|
+
};
|
|
195
|
+
}>;
|
|
196
|
+
}, elements: unknown, options?: {
|
|
197
|
+
shippingRateId?: string;
|
|
198
|
+
}): Promise<PaymentResult>;
|
|
147
199
|
}
|
|
200
|
+
export {};
|