function parseWebhookPayload
parseWebhookPayload(
payload: string,
errorCode: ErrorCodeType,
toEvent: (body: unknown) => WebhookEvent | null,
): WebhookVerifyResult

The one door every webhook body comes through. A body that is not JSON is refused the same way for every provider. What the body then means differs — a signed provider posts the event itself, SumUp posts two fields we build one from — so each provider passes its own reading, run outside the catch so a bug in it never reads as bad JSON. A reading that answers nothing means the body is JSON this provider cannot read, which earns the same refusal.

Parameters

payload: string
errorCode: ErrorCodeType
toEvent: (body: unknown) => WebhookEvent | null

Return Type

Usage

import { parseWebhookPayload } from "docs/payments.ts";