/** * Polar.sh Payment Gateway Implementation * * Implements BillingGateway interface for Polar.sh. * Wraps Polar SDK types into provider-agnostic result types. * * Key differences from Stripe: * - Checkout uses `products: [productId]` (Polar product IDs, not Stripe price IDs) * - Cancel = "revoke" in Polar terminology (immediate) * - Customer portal via "customer sessions" (not a hosted portal page) * - Webhook verification requires ALL headers, not just a signature string * - Uses `validateEvent` from @polar-sh/sdk/webhooks * * NOTE: In billing.config.ts, Polar's `providerPriceIds` should contain Polar **product IDs** * (not price IDs). Polar associates prices with products, so the product ID is used for checkout * and subscription plan changes. * * NOTE: Polar also offers @polar-sh/better-auth for direct Better Auth integration. * That is an ALTERNATIVE approach to this gateway. If you want the simpler plugin-based * approach (auto-create customer on signup, client-side checkout helpers), use the * Better Auth plugin instead of this gateway. The two approaches are mutually exclusive * for the same project - pick one. */ import { Polar } from '@polar-sh/sdk'; import type { BillingGateway } from './interface'; import type { CheckoutSessionResult, PortalSessionResult, SubscriptionResult, CustomerResult, WebhookEventResult, CreateCheckoutParams, CreatePortalParams, CreateCustomerParams, UpdateSubscriptionParams, CreateOneTimeCheckoutParams } from './types'; /** * Polar.sh implementation of the BillingGateway interface. * Maps Polar SDK types to provider-agnostic result types. */ export declare class PolarGateway implements BillingGateway { createCheckoutSession(params: CreateCheckoutParams): Promise; createOneTimeCheckout(params: CreateOneTimeCheckoutParams): Promise; createPortalSession(params: CreatePortalParams): Promise; verifyWebhookSignature(payload: string | Buffer, signatureOrHeaders: string | Record): WebhookEventResult; getCustomer(customerId: string): Promise; createCustomer(params: CreateCustomerParams): Promise; updateSubscriptionPlan(params: UpdateSubscriptionParams): Promise; cancelSubscriptionAtPeriodEnd(subscriptionId: string): Promise; cancelSubscriptionImmediately(subscriptionId: string): Promise; getProviderName(): string; getResourceHintDomains(): { preconnect: string[]; dnsPrefetch: string[]; }; getSubscriptionDashboardUrl(externalSubscriptionId: string | null | undefined): string | null; reactivateSubscription(subscriptionId: string): Promise; } /** * Get raw Polar instance for advanced usage (e.g., webhook handlers that need full types). * Prefer using getBillingGateway() for all other operations. */ export declare function getPolarInstance(): Polar; //# sourceMappingURL=polar.d.ts.map