/** * Core Stripe Webhook Handler * * Provides handleStripeWebhook() — a reusable function that handles the full * Stripe subscription lifecycle. Themes/projects call this from their route file * and can extend it with onOneTimePaymentCompleted for their custom one-time purchases. * * Usage in route.ts: * import { handleStripeWebhook } from '@nextsparkjs/core/lib/billing/stripe-webhook' * export async function POST(request: NextRequest) { * return handleStripeWebhook(request) * } * * With theme extension: * export async function POST(request: NextRequest) { * return handleStripeWebhook(request, { * onOneTimePaymentCompleted: async (session, { teamId, userId }) => { * // theme-specific one-time payment logic * } * }) * } */ import { NextRequest } from 'next/server'; import type { OneTimePaymentContext } from './types'; export type { OneTimePaymentContext }; /** * Provider-agnostic representation of a Stripe checkout session. * Avoids leaking `Stripe.Checkout.Session` SDK type to project code. */ export interface StripeSessionData { id: string; amountTotal: number | null; currency: string | null; customerId: string | null; subscriptionId: string | null; metadata: Record; clientReferenceId: string | null; } export interface StripeWebhookExtensions { /** * Called when a Stripe checkout.session.completed event fires for a session * that is NOT a subscription checkout (no planSlug in metadata). * Use this for credit packs, one-time purchases, etc. */ onOneTimePaymentCompleted?: (session: StripeSessionData, context: OneTimePaymentContext) => Promise; } export declare function handleStripeWebhook(request: NextRequest, extensions?: StripeWebhookExtensions): Promise; //# sourceMappingURL=stripe-webhook.d.ts.map