@sumup/sdk
    Preparing search index...

    Class EventsHandler

    Verify incoming events and dispatch them to typed callbacks. Create a handler with client.eventsHandler(secret, fallback), then register callbacks with on(). Known events without a callback and unknown event types reach the fallback. Calls may run concurrently; callbacks must synchronize shared state as needed.

    Index
    • Verify and parse an event, then await its registered callback or the fallback. Callbacks only run after successful verification and parsing. Acknowledge delivery with a 2xx response only after this promise resolves.

      Parameters

      • body: EventBody

        Unchanged request body. The caller owns reading and limiting it.

      • signature: string

        Complete value of the SIGNATURE_HEADER header.

      Returns Promise<void>

      EventSignatureError If verification fails, including the five-minute timestamp check.

      EventPayloadError If the body cannot be decoded as a JSON object.

      EventCallbackError If processing fails; its cause holds the original error.

    • Read a standard Fetch Request and process it with EventsHandler.handle. Consumes the entire body and reads SIGNATURE_HEADER; do not read the body first. Configure body-size limits in your server or hosting platform and send the response yourself. Use handle(body, signature) with Express or other frameworks that provide a different request type.

      Parameters

      • request: Request

      Returns Promise<void>

      Propagates body-read errors and verification, parsing, or callback errors from handle().

    • Register a callback for an event type. Its event and fetched resource types are inferred.

      Type Parameters

      Parameters

      Returns this

      This handler, for chaining registrations.

      EventError If the callback is missing or the type is already registered.