/** * Checkout Hook using TanStack Query * Replaces the coordinator pattern with automatic cache invalidation */ import { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSessionPreview } from '../../core/resources/checkout'; export interface CheckoutMessages { /** Error shown when CMS session takes too long to initialize. Default: 'Session initialization timeout. Please refresh the page and try again.' */ sessionTimeout?: string; /** Error shown when checkout resource fails to initialize. Default: 'Failed to initialize checkout resource' */ initFailed?: string; /** Error shown when an operation is attempted without an active checkout session. Default: 'No checkout session available' */ noCheckoutSession?: string; } export interface UseCheckoutQueryOptions { checkoutToken?: string; enabled?: boolean; /** Override default error messages (e.g. for i18n). Use with useTranslation's t() to pass translated strings. */ messages?: CheckoutMessages; } export interface UseCheckoutQueryResult { checkout: CheckoutData | undefined; isLoading: boolean; error: Error | null; isSuccess: boolean; init: (params: CheckoutInitParams) => Promise<{ checkoutSession: any; checkoutToken: string; }>; refresh: () => Promise; replaceSessionLineItems: (lineItems: CheckoutLineItem[]) => Promise; updateLineItems: (lineItems: CheckoutLineItem[]) => Promise; updateLineItemsOptimistic: (lineItems: CheckoutLineItem[]) => void; addLineItems: (lineItems: CheckoutLineItem[]) => Promise; removeLineItems: (lineItems: { variantId: string; quantity?: number; }[]) => Promise; setItemQuantity: (variantId: string, quantity: number, priceId?: string) => Promise; updateCustomer: (data: { email: string; acceptsMarketing?: boolean; }) => Promise; updateCustomerAndSessionInfo: (data: { customerData: { email: string; acceptsMarketing?: boolean; }; shippingAddress: any; billingAddress?: any; differentBillingAddress?: boolean; }) => Promise; applyPromotionCode: (code: string) => Promise; removePromotion: (promotionId: string) => Promise; previewCheckoutSession: (lineItems: CheckoutLineItem[], promotionIds?: string[]) => Promise<{ success: boolean; preview: CheckoutSessionPreview; }>; } export declare function useCheckoutQuery(options?: UseCheckoutQueryOptions): UseCheckoutQueryResult;