/** * useStepConfig Hook - Access runtime step configuration from HTML injection * * This hook provides access to step-specific configuration that is injected * into the HTML by the CRM when the page is served. This includes: * - Payment flow overrides * - Static resources (offer, product IDs for A/B variants) * - Custom scripts * - Pixel tracking configuration * * Usage: * ```tsx * const { stepConfig, paymentFlowId, resources } = useStepConfig(); * * // Access payment flow override * if (paymentFlowId) { * console.log('Using custom payment flow:', paymentFlowId); * } * * // Access resource bindings (e.g., offer ID for current A/B variant) * const offerId = resources?.offer; * ``` */ import { type PaymentSetupConfig, type PixelsConfig, type RuntimeStepConfig } from '../../core/funnelClient'; export interface UseStepConfigResult { /** * Full step configuration object * Contains payment, staticResources, scripts, and pixels */ stepConfig: RuntimeStepConfig | undefined; /** * Payment flow ID override for this step * If set, this payment flow should be used instead of the store default */ paymentFlowId: string | undefined; /** * Resource bindings for this step/variant. * e.g., { offer: 'offer_xxx', product: 'product_xxx' } */ resources: Record | undefined; /** @deprecated Use `resources` instead */ staticResources: Record | undefined; /** * Get scripts for a specific injection position * Only returns enabled scripts * @param position - Where the scripts should be injected */ getScripts: (position?: 'head-start' | 'head-end' | 'body-start' | 'body-end') => RuntimeStepConfig['scripts']; pixels: PixelsConfig | undefined; /** * Payment setup configuration for this step. * Keys: "{method}" or "{method}:{provider}" (e.g. "card", "apple_pay:stripe") * Use helpers: getEnabledMethods(), getExpressMethods(), findMethod() */ paymentSetupConfig: PaymentSetupConfig | undefined; /** * Enabled order bump offer IDs for this step. * undefined = inherit all store bumps, string[] = only these IDs. */ orderBumpOfferIds: string[] | undefined; /** * Enabled upsell offer IDs for this step. * undefined = inherit all store upsells, string[] = only these IDs. */ upsellOfferIds: string[] | undefined; } /** * Hook to access runtime step configuration injected via HTML * * The step config is read from window.__TGD_STEP_CONFIG__ or the x-step-config meta tag. * Values are memoized and only re-computed on mount. * * @returns Step configuration values and helpers */ export declare function useStepConfig(): UseStepConfigResult;