import { s as PaymentGatewayAdapter } from "../payment.adapter-BOT9T6jQ.js"; //#region src/adapters/stripe.adapter.d.ts interface StripeConfig { /** Secret API key (sk_live_xxx or sk_test_xxx) */ secretKey: string; /** Webhook signing secret (whsec_xxx) for signature verification */ webhookSecret?: string; /** Stripe API version to pin (sent as Stripe-Version header) */ apiVersion?: string; /** API base URL (defaults to production) */ apiUrl?: string; /** Webhook timestamp tolerance in seconds (defaults to 300 = 5 minutes) */ webhookToleranceSeconds?: number; } /** Stripe subscription status */ type StripeSubscriptionStatus = "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "canceled" | "unpaid" | "paused"; /** Response from the Stripe customers API */ interface StripeCustomer { id: string; email: string | null; name: string | null; metadata?: Record; invoice_settings?: { default_payment_method?: string | null; }; } /** Response from the Stripe subscriptions API */ interface StripeSubscription { id: string; customer: string; status: StripeSubscriptionStatus; metadata?: Record; current_period_start?: number | null; current_period_end?: number | null; cancel_at: number | null; canceled_at: number | null; cancel_at_period_end: boolean; trial_start: number | null; trial_end: number | null; items?: { data: Array<{ id: string; price: { id: string; }; current_period_start?: number; current_period_end?: number; }>; }; } /** Response from the Stripe checkout sessions API */ interface StripeCheckoutSession { id: string; url: string | null; expires_at: number; } /** Response from the Stripe billing portal sessions API */ interface StripePortalSession { id: string; url: string; } /** Response from the Stripe payment intents API */ interface StripePaymentIntent { id: string; status: "requires_payment_method" | "requires_confirmation" | "requires_action" | "processing" | "requires_capture" | "canceled" | "succeeded"; amount: number; currency: string; payment_method: string | null; next_action?: { type: string; redirect_to_url?: { url: string; }; } | null; last_payment_error?: { code?: string; decline_code?: string; message?: string; } | null; } /** Stripe API error payload */ interface StripeErrorResponse { error: { type: string; code?: string; decline_code?: string; message?: string; param?: string; }; } /** Stripe webhook event payload */ interface StripeWebhookPayload { id: string; type: string; data: { object: Record; }; created: number; } /** * Stripe adapter error with structured details from the Stripe API. */ declare class StripeAdapterError extends Error { readonly type: string; readonly code: string; readonly httpStatus?: number | undefined; readonly declineCode?: string | undefined; readonly isRetryable: boolean; constructor(message: string, type?: string, code?: string, httpStatus?: number | undefined, declineCode?: string | undefined, isRetryable?: boolean); /** Create from an HTTP error response */ static fromHttpResponse(status: number, errorResponse?: StripeErrorResponse): StripeAdapterError; } /** * Create a Stripe payment adapter for subscriptions. * * Uses the Stripe REST API directly via `fetch` with form-encoded bodies — * no `stripe` npm dependency — so it works in any runtime with web-standard * APIs (Node 18+, Bun, Deno, Cloudflare Workers). * * @example * ```typescript * import { stripeAdapter } from '@abshahin/subscriptions/adapters/stripe'; * * const payment = stripeAdapter({ * secretKey: process.env.STRIPE_SECRET_KEY!, * webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!, * }); * ``` */ declare function stripeAdapter(config: StripeConfig): PaymentGatewayAdapter; //#endregion export { StripeAdapterError, StripeCheckoutSession, StripeConfig, StripeCustomer, StripeErrorResponse, StripePaymentIntent, StripePortalSession, StripeSubscription, StripeSubscriptionStatus, StripeWebhookPayload, stripeAdapter }; //# sourceMappingURL=stripe.adapter.d.ts.map