interface DataFastPaymentRequest { transaction_id: string; currency: string; amount: number; timestamp?: string; refunded?: boolean; renewal?: boolean; customer_id?: string; name?: string; email?: string; datafast_visitor_id?: string; datafast_session_id?: string; } interface DataFastPaymentResponse { message: string; transaction_id: string; } interface DataFastConfig { apiKey: string; } /** Nested product object inside a webhook payload. */ interface CreemWebhookProduct { id: string; name: string; description: string; image_url: string | null; price: number; currency: string; billing_type: 'one_time' | 'recurring'; billing_period?: string; status: string; tax_mode: string; tax_category: string; default_success_url: string; created_at: string; updated_at: string; mode: string; } /** Nested customer object inside a webhook payload. */ interface CreemWebhookCustomer { id: string; object: 'customer'; email: string; name: string; country: string; created_at: string; updated_at: string; mode: string; } /** Nested order object inside a checkout.completed webhook. */ interface CreemWebhookOrder { id: string; customer: string; product: string; amount: number; currency: string; status: string; type: string; created_at: string; updated_at: string; mode: string; } /** Nested subscription object inside a checkout.completed webhook. */ interface CreemWebhookSubscription { id: string; object: 'subscription'; product: string | CreemWebhookProduct; customer: string | CreemWebhookCustomer; collection_method: string; status: string; last_transaction_id?: string; last_transaction_date?: string; next_transaction_date?: string; current_period_start_date?: string; current_period_end_date?: string; canceled_at: string | null; created_at: string; updated_at: string; metadata?: Record; mode: string; } interface CreemCheckoutCompletedObject { id: string; object: 'checkout'; request_id?: string; order: CreemWebhookOrder; product: CreemWebhookProduct; customer: CreemWebhookCustomer; subscription?: CreemWebhookSubscription; custom_fields: unknown[]; status: string; metadata?: Record; mode: string; } interface CreemCheckoutCompletedEvent { id: string; eventType: 'checkout.completed'; created_at: number; object: CreemCheckoutCompletedObject; } interface CreemSubscriptionPaidObject { id: string; object: 'subscription'; product: CreemWebhookProduct; customer: CreemWebhookCustomer; collection_method: string; status: string; last_transaction_id?: string; last_transaction_date?: string; next_transaction_date?: string; current_period_start_date?: string; current_period_end_date?: string; canceled_at: string | null; created_at: string; updated_at: string; metadata?: Record; mode: string; } interface CreemSubscriptionPaidEvent { id: string; eventType: 'subscription.paid'; created_at: number; object: CreemSubscriptionPaidObject; } interface CreemRefundCreatedObject { id: string; object: 'refund'; order: CreemWebhookOrder; product: CreemWebhookProduct; customer: CreemWebhookCustomer; amount: number; status: string; reason?: string; created_at: string; updated_at: string; mode: string; metadata?: Record; } interface CreemRefundCreatedEvent { id: string; eventType: 'refund.created'; created_at: number; object: CreemRefundCreatedObject; } type CreemWebhookEvent = CreemCheckoutCompletedEvent | CreemSubscriptionPaidEvent | CreemRefundCreatedEvent; /** Raw webhook envelope before we know the eventType. */ interface CreemWebhookRaw { id: string; eventType: string; created_at: number; object: Record; } interface CreemCheckoutCreateOptions { productId: string; units?: number; discountCode?: string; customer?: { email?: string; name?: string; }; customFields?: Array<{ key: string; label: string; type: string; optional?: boolean; }>; successUrl?: string; cancelUrl?: string; metadata?: Record; } interface CreemConfig { apiKey: string; serverIdx?: 0 | 1; } type WebhookEventType = 'checkout.completed' | 'subscription.paid' | 'refund.created'; interface CreemDataFastConfig { creemApiKey: string; datafastApiKey: string; cookieName?: string; } interface WebhookHandlerOptions { creemApiKey: string; datafastApiKey: string; webhookSecret?: string; cookieName?: string; testMode?: boolean; timeoutMs?: number; retry?: RetryOptions; strictTracking?: boolean; idempotencyStore?: IdempotencyStore; logger?: Logger; onPaymentSuccess?: (data: { creemEvent: CreemWebhookEvent; datafastResponse: DataFastPaymentResponse; }) => Promise | void; onError?: (error: Error) => Promise | void; } interface RetryOptions { retries?: number; baseDelayMs?: number; maxDelayMs?: number; } interface Logger { debug?: (message: string, ...args: unknown[]) => void; info?: (message: string, ...args: unknown[]) => void; warn?: (message: string, ...args: unknown[]) => void; error?: (message: string, ...args: unknown[]) => void; } interface IdempotencyStore { has(id: string): Promise; set(id: string, ttlSeconds?: number): Promise; } export type { CreemConfig as C, DataFastPaymentRequest as D, IdempotencyStore as I, Logger as L, RetryOptions as R, WebhookEventType as W, CreemCheckoutCreateOptions as a, CreemWebhookRaw as b, CreemCheckoutCompletedEvent as c, CreemCheckoutCompletedObject as d, CreemDataFastConfig as e, CreemRefundCreatedEvent as f, CreemRefundCreatedObject as g, CreemSubscriptionPaidEvent as h, CreemSubscriptionPaidObject as i, CreemWebhookCustomer as j, CreemWebhookEvent as k, CreemWebhookOrder as l, CreemWebhookProduct as m, CreemWebhookSubscription as n, DataFastConfig as o, DataFastPaymentResponse as p, WebhookHandlerOptions as q };