import { s as PaymentGatewayAdapter } from "../payment.adapter-BOT9T6jQ.js"; //#region src/adapters/paddle.adapter.d.ts interface PaddleConfig { /** Paddle Billing API key (Bearer token, from Paddle dashboard → Developer tools → Authentication) */ apiKey: string; /** Webhook notification secret (pdl_ntfset_xxx) for signature verification */ webhookSecret?: string; /** Paddle environment (defaults to production) */ environment?: "production" | "sandbox"; /** Override the API base URL (defaults to the environment's URL) */ apiUrl?: string; } /** Paddle subscription status */ type PaddleSubscriptionStatus = "active" | "canceled" | "inactive" | "past_due" | "paused" | "trialing"; /** Paddle transaction status */ type PaddleTransactionStatus = "draft" | "ready" | "billed" | "paid" | "completed" | "canceled" | "past_due"; /** Response from Paddle customers API */ interface PaddleCustomer { id: string; email: string; name?: string; status: string; custom_data?: Record | null; created_at: string; updated_at: string; } /** Response from Paddle subscriptions API */ interface PaddleSubscription { id: string; status: PaddleSubscriptionStatus; customer_id: string; currency_code: string; created_at: string; updated_at: string; started_at: string | null; first_billed_at: string | null; next_billed_at: string | null; paused_at: string | null; canceled_at: string | null; current_billing_period: { starts_at: string; ends_at: string; } | null; scheduled_change: { action: "cancel" | "pause" | "resume"; effective_at: string; resume_at: string | null; } | null; items: Array<{ price: { id: string; }; quantity: number; }>; custom_data?: Record | null; } /** Response from Paddle transactions API */ interface PaddleTransaction { id: string; status: PaddleTransactionStatus; customer_id: string | null; currency_code: string; created_at: string; updated_at: string; billed_at: string | null; details?: { totals: { total: string; subtotal: string; tax: string; }; } | null; checkout?: { url: string | null; } | null; custom_data?: Record | null; } /** Response from Paddle customer portal sessions API */ interface PaddlePortalSession { id: string; urls: { general: { overview: string; }; subscriptions: Array<{ id: string; cancel_subscription_url: string; update_subscription_payment_method_url: string; }>; }; } /** Paddle webhook notification payload */ interface PaddleWebhookPayload { event_id: string; event_type: string; occurred_at: string; data: Record; } /** Error response from Paddle API */ interface PaddleErrorResponse { error?: { type?: string; code?: string; detail?: string; documentation_url?: string; errors?: Array<{ field: string; message: string; }>; }; } /** * Paddle adapter error with user-friendly messages */ declare class PaddleAdapterError extends Error { readonly code: string; readonly httpStatus?: number | undefined; readonly userMessage?: string | undefined; readonly isRetryable: boolean; readonly fieldErrors?: Array<{ field: string; message: string; }> | undefined; constructor(message: string, code?: string, httpStatus?: number | undefined, userMessage?: string | undefined, isRetryable?: boolean, fieldErrors?: Array<{ field: string; message: string; }> | undefined); /** Create from HTTP response */ static fromHttpResponse(status: number, errorResponse?: PaddleErrorResponse): PaddleAdapterError; } /** * Create a Paddle Billing payment adapter for subscriptions. * * Uses the Paddle Billing API directly over `fetch` (no npm dependency): * * 1. `createCheckoutSession()` creates a Paddle transaction and returns its * hosted checkout URL — the customer completes payment there * 2. Paddle creates the subscription when checkout completes; subscribe to the * `subscription.created` / `transaction.completed` webhooks to sync state * 3. `createPortalSession()` returns a Paddle customer portal link for * self-service billing management * 4. Webhooks are verified with the Paddle-Signature header (HMAC-SHA256) * * @example * ```typescript * import { paddleAdapter } from '@abshahin/subscriptions/adapters/paddle'; * * const payment = paddleAdapter({ * apiKey: process.env.PADDLE_API_KEY!, * webhookSecret: process.env.PADDLE_WEBHOOK_SECRET!, * environment: 'sandbox', * }); * ``` */ declare function paddleAdapter(config: PaddleConfig): PaymentGatewayAdapter; //#endregion export { PaddleAdapterError, PaddleConfig, PaddleCustomer, PaddleErrorResponse, PaddlePortalSession, PaddleSubscription, PaddleSubscriptionStatus, PaddleTransaction, PaddleTransactionStatus, PaddleWebhookPayload, paddleAdapter }; //# sourceMappingURL=paddle.adapter.d.ts.map