import { q as WebhookHandlerOptions } from '../index-2mzMgi45.mjs'; import { Request, Response, NextFunction } from 'express'; import { NextRequest, NextResponse } from 'next/server'; declare class WebhookHandler { private webhookSecret?; private datafastApiKey; private testMode; private timeoutMs; private retryRetries; private retryBaseDelayMs; private retryMaxDelayMs; private strictTracking; private idempotencyStore; private logger; private onPaymentSuccess?; private onError?; constructor(options: WebhookHandlerOptions); handleWebhook(rawBody: string, signature?: string): Promise<{ success: boolean; message: string; ignored?: boolean; }>; verifySignature(payload: string, signature: string): boolean; private isSupportedEvent; private sendToDataFastWithRetry; private isRetryableError; private sendToDataFast; private sleep; } declare function createWebhookHandler(options: WebhookHandlerOptions): WebhookHandler; interface ExpressWebhookMiddlewareOptions extends WebhookHandlerOptions { } /** * Express middleware that handles incoming CREEM webhooks and forwards * payment events to DataFast. * * **Important:** The request body must be available as a raw string for * signature verification. If you use `express.json()` globally, this * middleware will fall back to `JSON.stringify(req.body)`. For proper * signature verification, register a raw body parser on this route: * * ```ts * app.post('/webhooks/creem', * express.raw({ type: 'application/json' }), * creemDataFastWebhook({ ... }) * ); * ``` */ declare function creemDataFastWebhook(options: ExpressWebhookMiddlewareOptions): (req: Request, res: Response, next: NextFunction) => Promise; interface NextJsWebhookOptions extends WebhookHandlerOptions { } /** * Handle a CREEM webhook inside a Next.js App Router `POST` handler. * * ```ts * // app/api/webhooks/creem/route.ts * import { creemDataFastWebhookHandler } from 'creem-datafast-integration'; * * export async function POST(request: NextRequest) { * return creemDataFastWebhookHandler(request, { ... }); * } * ``` */ declare function creemDataFastWebhookHandler(req: NextRequest, options: NextJsWebhookOptions): Promise; /** * Create a reusable Next.js POST handler with baked-in options. */ declare function createNextJsWebhookHandler(options: NextJsWebhookOptions): (req: NextRequest) => Promise; interface GenericWebhookHandlerOptions extends WebhookHandlerOptions { /** Return the raw request body as a string. */ getRawBody: () => Promise | string; /** Return the request headers. */ getHeaders: () => Record; } /** * Framework-agnostic webhook handler. Works with Hono, Fastify, Koa, * Cloudflare Workers, or anything else. * * ```ts * const result = await handleGenericWebhook({ * creemApiKey: '...', * datafastApiKey: '...', * webhookSecret: '...', * getRawBody: () => rawBodyString, * getHeaders: () => requestHeaders, * }); * ``` */ declare function handleGenericWebhook(options: GenericWebhookHandlerOptions): Promise<{ success: boolean; message: string; }>; export { type ExpressWebhookMiddlewareOptions, type GenericWebhookHandlerOptions, type NextJsWebhookOptions, WebhookHandler, WebhookHandlerOptions, createNextJsWebhookHandler, createWebhookHandler, creemDataFastWebhook, creemDataFastWebhookHandler, handleGenericWebhook };