export interface PostPurchaseOfferItem { id: string; productId: string; variantId: string; product: { name: string; description: string; }; variant: { name: string; description: string; imageUrl: string; grams: number | null; }; unitAmount: number; quantity: number; amount: number; adjustedAmount: number; } export interface PostPurchaseOfferSummary { currency: string; totalAmount: number; totalAdjustedAmount: number; items: PostPurchaseOfferItem[]; } export interface PostPurchaseOfferLineItem { id: string; quantity: number; price: { variant: { id: string; name: string; description: string | null; grams: number | null; product: { id: string; name: string; description: string; }; }; }; } export interface PostPurchaseOffer { id: string; titleTrans: Record | null; summaries: PostPurchaseOfferSummary[]; offerLineItems: PostPurchaseOfferLineItem[]; } export interface CurrencyOptions { rate: number; date: string; amount: number; lock: boolean; } export interface VariantOption { id: string; name: string; sku: string | null; default: boolean | null; externalVariantId: string | null; prices: { id: string; currencyOptions: CurrencyOptions; }[]; } export interface OrderSummaryItem { id: string; productId: string; productName: string; productDescription: string | null; variantId: string; variantName: string; variantSku: string | null; variantDefault: boolean | null; variantExternalId: string | null; priceId: string; currencyOptions: CurrencyOptions; quantity: number; unitAmount: number; amount: number; adjustedAmount: number; imageUrl?: string; product: { name: string; description: string; }; variant: { name: string; description: string; imageUrl: string; grams: number | null; }; } export interface OrderSummary { items: OrderSummaryItem[]; totalAmount: number; totalAdjustedAmount: number; totalPromotionAmount: number; currency: string; options: Record; } export interface UsePostPurchasesOptions { /** * OrderID to fetch post-purchase offers for */ orderId: string; /** * Whether to fetch offers automatically on mount * @default true */ enabled?: boolean; /** * Whether to automatically initialize checkout sessions for offers * @default false */ autoInitializeCheckout?: boolean; } export interface CheckoutSessionState { checkoutSessionId: string | null; orderSummary: OrderSummary | null; selectedVariants: Record; loadingVariants: Record; isUpdatingSummary: boolean; } export interface UsePostPurchasesResult { /** * Array of fetched post-purchase offers */ offers: PostPurchaseOffer[]; /** * Loading state */ isLoading: boolean; /** * Error state */ error: Error | null; /** * Refetch post-purchase offers */ refetch: () => Promise; /** * Get offer by ID from the loaded offers */ getOffer: (offerId: string) => PostPurchaseOffer | undefined; /** * Get total value of all post-purchase offers */ getTotalValue: () => number; /** * Get total savings across all post-purchase offers */ getTotalSavings: () => number; /** * Initialize a checkout session for a post-purchase offer */ initCheckoutSession: (offerId: string, orderId: string) => Promise<{ checkoutSessionId: string; }>; /** * Initialize a checkout session for a post-purchase offer with specific variants */ initCheckoutSessionWithVariants: (offerId: string, orderId: string, lineItems: { variantId: string; quantity: number; }[]) => Promise<{ checkoutSessionId: string; }>; /** * Pay with a checkout session for a post-purchase offer */ payWithCheckoutSession: (checkoutSessionId: string, orderId?: string) => Promise; /** * Get checkout session state for an offer */ getCheckoutSessionState: (offerId: string) => CheckoutSessionState | null; /** * Initialize checkout session with variant options for an offer */ initializeOfferCheckout: (offerId: string) => Promise; /** * Get available variants for a product in an offer's checkout session */ getAvailableVariants: (offerId: string, productId: string) => { variantId: string; variantName: string; variantSku: string | null; variantDefault: boolean | null; variantExternalId: string | null; priceId: string; currencyOptions: CurrencyOptions; }[]; /** * Select a variant for a product in an offer's checkout session */ selectVariant: (offerId: string, productId: string, variantId: string) => Promise; /** * Get the order summary for an offer's checkout session */ getOrderSummary: (offerId: string) => OrderSummary | null; /** * Check if variants are being loaded for a specific product in an offer */ isLoadingVariants: (offerId: string, productId: string) => boolean; /** * Check if order summary is being updated for an offer */ isUpdatingOrderSummary: (offerId: string) => boolean; /** * Confirm purchase for an offer with current variant selections */ confirmPurchase: (offerId: string, options?: { draft?: boolean; returnUrl?: string; }) => Promise; } export declare function usePostPurchases(options: UsePostPurchasesOptions): UsePostPurchasesResult;