/** * Centralized redirect URL builders for the Express Checkout payment handler. * * Before redirecting, the origin article URL is persisted to localStorage under * the `checkout-redirect` key so that sma-checkout / the onboarding app can * return the user to the article after checkout and onboarding complete. * * Matches sma-checkout: src/lib/navigate-to-checkout/index.tsx */ /** * What the post-checkout "return to" target (`checkout-redirect`, read by the onboarding app once the user has * finished onboarding) should be. Chosen per entry point in `ENTRY_POINT_CONFIG` (apple-pay-button.ts). */ export declare enum ReturnUrlPolicy { /** Return the user to the page the button is on, e.g. the article behind a paywall. */ CURRENT_PAGE = "current_page", /** * Leave `checkout-redirect` untouched: the host owns it. sma-checkout's /subscribe pages store the article the * user arrived from (and never themselves), so overwriting it would send the user back to the offers page. * With nothing stored, onboarding returns the user to the home page. */ HOST_MANAGED = "host_managed" } export declare const resolveCheckoutRedirectUrl: (policy: ReturnUrlPolicy, currentPageUrl: string) => string | null; /** Persists the return target. `null` (see `ReturnUrlPolicy.HOST_MANAGED`) leaves the stored value as it is. */ export declare const writeCheckoutRedirect: (originUrl: string | null) => void; /** * Captures the current page URL (the article the user is reading). * Must be called before any redirect occurs. */ export declare const captureOriginUrl: () => string; /** * Extracts only the `country` query param from the current page URL for * forwarding to /checkout/complete. All other params are intentionally excluded. * * Matches sma-checkout: src/hooks/use-query-string/useCountryCodeQueryString * Only `country` is forwarded — feature flags, UTM tags, and all other host-page * params must NOT be propagated to /checkout/complete. */ export declare const buildQueryString: () => string; /** * Decodes a Commerce Services encoded SKU to the raw offer path. * e.g. LO-L29mZmVyczIvTkEt... → /offers2/NA-US.DIGITAL.MAAR... * * Matches sma-checkout: src/lib/commerce-services/decode-sku.ts */ export declare const decodeSku: (sku: string) => string; /** * Builds the success redirect URL. * /checkout/complete?basketId={id}&lmo_offer={sku}&status={userStatus}&redirectToCheckout=true * &email={email}&country={country} * * `email` — the user's email address (from session for lex users, from Apple Pay * shipping contact for nex users). Always appended when non-empty so checkout * can pre-fill the account field. * * `country` — the offer country code forwarded from the payment handler config. * Always appended when non-empty to preserve geo-context across the redirect. * * The origin article URL is written to localStorage by the caller via * writeCheckoutRedirect() so sma-checkout can return the reader after * passwordless confirmation (`nspc`) or after onboarding. */ export declare const redirectToCheckoutComplete: (params: { basketId: string; status: "nex" | "lex" | "nspc"; skuId: string; email?: string; country?: string; }) => string; /** * Builds the fallback redirect URL for error scenarios. * /checkout?lmo_offer={offerPath}&inlineError=...&email={email}&country={country} * * The skuId is decoded via decodeSku() before being set as lmo_offer, producing * a Limio offer path (e.g. /offers2/UK-UK.DIGITAL.1YAR.X.DISC.30.NYT) as * checkout expects. If decoding fails (malformed SKU), the raw skuId is used. * * `email` — always appended when non-empty so checkout can pre-fill the email * field on the fallback page (e.g. for EMAIL_COLLISION flows). * * `country` — the offer country code, always appended when non-empty to preserve * geo-context across the redirect. * * Builds on top of the current page URL (window.location.href) so that any * existing query params (UTM tags, campaign flags) are preserved — matching * sma-checkout: src/lib/navigate-to-checkout/index.tsx * * The origin article URL is written to localStorage by the caller via * writeCheckoutRedirect() before this redirect fires. */ export declare const redirectToCheckoutFallback: (params: { skuId: string; inlineError?: string; emailError?: string; email?: string; country?: string; }) => string;