Sarraf API
    Preparing search index...

    Function webhookRoute

    • Route handler that verifies, normalizes and dispatches provider webhooks. It reads the exact body with req.text(), so signatures are checked over the bytes the provider sent.

      // app/api/webhooks/[provider]/route.ts
      export const POST = webhookRoute(pay, async (event) => {
      await markOrder(event.payment.reference, event.payment.status); // dedupe on event.id
      });

      Answers 404 for an unknown provider, 400 for an invalid signature, 500 when processing fails. Uses only the Fetch API Request / Response, so it also works in any Fetch-based framework.

      Parameters

      Returns RouteHandler