UNPKG

cosmic-payments

Version:

A payments library for cosmic.new. Designed to be used and deployed on cosmic.new

39 lines (38 loc) 1.04 kB
import { NextRequest, NextResponse } from 'next/server'; export interface AuthSession { uid: string; } export interface CosmicPaymentsHandlerOptions { /** * Function to get the current server session * Should return null if user is not authenticated */ getServerSession: () => Promise<AuthSession | null>; } /** * Creates a Next.js API route handler for Cosmic Payments * * @example * ```ts * // app/api/cosmic-payments/route.ts * import { createCosmicPaymentsHandler } from 'cosmic-payments/server'; * import { getServerSession } from '@/lib/auth'; * * const handler = createCosmicPaymentsHandler({ * getServerSession * }); * * export const POST = handler; * ``` */ export declare function createCosmicPaymentsHandler(options: CosmicPaymentsHandlerOptions): (request: NextRequest) => Promise<NextResponse<{ error: string; }> | NextResponse<{ url: any; }> | NextResponse<{ products: any; }> | NextResponse<{ purchaseHistory: any; }> | NextResponse<{ activeSubscriptions: any; }>>;