@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.
Files changed (63) hide show
  1. package/README.md +1129 -1129
  2. package/build-cdn.js +499 -499
  3. package/dist/external-tracker.js +156 -2
  4. package/dist/external-tracker.min.js +2 -2
  5. package/dist/external-tracker.min.js.map +4 -4
  6. package/dist/react/providers/TagadaProvider.js +5 -5
  7. package/dist/tagada-react-sdk-minimal.min.js +2 -2
  8. package/dist/tagada-react-sdk-minimal.min.js.map +4 -4
  9. package/dist/tagada-react-sdk.js +696 -245
  10. package/dist/tagada-react-sdk.min.js +2 -2
  11. package/dist/tagada-react-sdk.min.js.map +4 -4
  12. package/dist/tagada-sdk.js +2908 -94
  13. package/dist/tagada-sdk.min.js +2 -2
  14. package/dist/tagada-sdk.min.js.map +4 -4
  15. package/dist/v2/core/funnelClient.d.ts +40 -0
  16. package/dist/v2/core/funnelClient.js +30 -0
  17. package/dist/v2/core/pixelTracker.d.ts +51 -0
  18. package/dist/v2/core/pixelTracker.js +425 -0
  19. package/dist/v2/core/resources/checkout.d.ts +45 -1
  20. package/dist/v2/core/resources/checkout.js +13 -3
  21. package/dist/v2/core/resources/offers.d.ts +1 -1
  22. package/dist/v2/core/resources/offers.js +3 -1
  23. package/dist/v2/core/resources/promotionEvents.d.ts +5 -0
  24. package/dist/v2/core/resources/promotionEvents.js +2 -0
  25. package/dist/v2/core/resources/promotions.d.ts +6 -1
  26. package/dist/v2/core/resources/promotions.js +6 -1
  27. package/dist/v2/core/resources/shippingRates.d.ts +18 -0
  28. package/dist/v2/core/resources/shippingRates.js +18 -0
  29. package/dist/v2/core/utils/clickIdResolver.d.ts +79 -0
  30. package/dist/v2/core/utils/clickIdResolver.js +169 -0
  31. package/dist/v2/core/utils/index.d.ts +2 -0
  32. package/dist/v2/core/utils/index.js +4 -0
  33. package/dist/v2/core/utils/metaEventId.d.ts +14 -0
  34. package/dist/v2/core/utils/metaEventId.js +16 -0
  35. package/dist/v2/core/utils/previewModeIndicator.js +101 -101
  36. package/dist/v2/index.d.ts +7 -0
  37. package/dist/v2/index.js +10 -0
  38. package/dist/v2/react/components/ApplePayButton.js +50 -0
  39. package/dist/v2/react/components/FunnelScriptInjector.js +9 -9
  40. package/dist/v2/react/components/GooglePayButton.js +39 -1
  41. package/dist/v2/react/components/StripeExpressButton.js +54 -2
  42. package/dist/v2/react/hooks/payment-actions/useNgeniusThreedsAction.js +11 -11
  43. package/dist/v2/react/hooks/useCheckoutQuery.js +41 -29
  44. package/dist/v2/react/hooks/useDiscountsQuery.js +4 -0
  45. package/dist/v2/react/hooks/useFunnel.d.ts +7 -0
  46. package/dist/v2/react/hooks/useFunnel.js +2 -1
  47. package/dist/v2/react/hooks/usePixelTracking.d.ts +10 -5
  48. package/dist/v2/react/hooks/usePixelTracking.js +32 -374
  49. package/dist/v2/react/hooks/usePreviewOffer.d.ts +3 -1
  50. package/dist/v2/react/hooks/usePreviewOffer.js +8 -2
  51. package/dist/v2/react/hooks/usePromotionsQuery.js +9 -3
  52. package/dist/v2/react/hooks/useShippingRatesQuery.js +36 -21
  53. package/dist/v2/react/hooks/useStepConfig.d.ts +9 -0
  54. package/dist/v2/react/hooks/useStepConfig.js +5 -1
  55. package/dist/v2/react/index.d.ts +4 -0
  56. package/dist/v2/react/index.js +8 -0
  57. package/dist/v2/react/providers/TagadaProvider.js +18 -5
  58. package/dist/v2/standalone/apple-pay-service.d.ts +1 -1
  59. package/dist/v2/standalone/index.d.ts +3 -0
  60. package/dist/v2/standalone/index.js +23 -0
  61. package/dist/v2/standalone/payment-service.d.ts +54 -1
  62. package/dist/v2/standalone/payment-service.js +228 -61
  63. package/package.json +115 -115
@@ -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 client = getGlobalApiClient();
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 state
27
- const [previewedRates, setPreviewedRates] = useState();
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
- setIsPreviewLoading(true);
142
- const response = await shippingRatesResource.previewShippingRates(effectiveSessionId, {
143
- countryCode,
144
- stateCode,
145
- });
146
- // Sort rates: free first, then by ascending amount
147
- const sortedRates = [...response.rates].sort((a, b) => {
148
- if (a.isFree && !b.isFree)
149
- return -1;
150
- if (!a.isFree && b.isFree)
151
- return 1;
152
- return (a.amount ?? 0) - (b.amount ?? 0);
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
- finally {
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
  }
@@ -99,6 +99,10 @@ export type { UseStoreConfigQueryOptions as UseStoreConfigOptions, UseStoreConfi
99
99
  export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession } from './hooks/useThreeds';
100
100
  export type { UseVipOffersQueryOptions as UseVipOffersOptions, UseVipOffersQueryResult as UseVipOffersResult } from './hooks/useVipOffersQuery';
101
101
  export { formatMoney } from '../../react/utils/money';
102
+ export { makeMetaEventId } from '../core/utils/metaEventId';
103
+ export type { TrackOptions } from './hooks/usePixelTracking';
104
+ export { resolveClickId, publishTrackingGlobal, CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES, } from '../core/utils/clickIdResolver';
105
+ export type { ResolvedClickId, TagadaTrackingGlobal, ClickIdSource, } from '../core/utils/clickIdResolver';
102
106
  export { TagadaError, TagadaApiError, TagadaNetworkError, TagadaAuthError, TagadaValidationError, TagadaCircuitBreakerError, TagadaErrorCode, } from '../core/errors';
103
107
  export type { TagadaErrorOptions, TagadaErrorCodeValue } from '../core/errors';
104
108
  export type { PaymentMethodName } from '../core/resources/checkout';
@@ -63,5 +63,13 @@ export { FunnelActionType } from '../core/resources/funnel';
63
63
  export { getEnabledMethods, getExpressMethods, getExpressMethodsByProcessor, findMethod, isMethodEnabled } from '../core/funnelClient';
64
64
  // Re-export utilities from main react
65
65
  export { formatMoney } from '../../react/utils/money';
66
+ // Meta CAPI / browser pixel deduplication helper.
67
+ // Use this to build a stable `eventId` shared between the browser pixel
68
+ // (`track('Purchase', params, { eventId })`) and the server-side Meta CAPI
69
+ // `ServerEvent.setEventId(...)`. Both sides must agree on the formula.
70
+ export { makeMetaEventId } from '../core/utils/metaEventId';
71
+ // Click-id resolver (ad-tracker integrations: ClickFlare, Voluum, Binom, RedTrack, ClickMagick, …)
72
+ // Lives in core (runtime-agnostic) so the standalone SDK / studio builder can use it too.
73
+ export { resolveClickId, publishTrackingGlobal, CLICK_ID_URL_PARAMS, CLICK_ID_COOKIES, } from '../core/utils/clickIdResolver';
66
74
  // Error types
67
75
  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, &hellip;) 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<void>;
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 {};