Create a webhook endpoint with the event types your integration needs. Store its signing secret in a secret manager and never expose it to the browser. The signature header name and timestamp format are configured with your endpoint. Use the exact raw bytes received by the HTTP framework:
Apply your endpoint’s timestamp/replay-window rule before accepting the event. Parse JSON only after authenticity checks pass.

Handler checklist

  • Capture the raw body before JSON parsing.
  • Validate the signature, timestamp, and endpoint secret.
  • Reject malformed or unauthorized requests.
  • Insert the event ID into a unique store before applying effects.
  • Queue long-running work and acknowledge quickly.
  • Record processing outcome and last error.
  • Retry transient failures without replaying a financial transition.
  • Alert on repeated failures and stale event backlog.

Reconciliation

If an event is delayed or your handler was unavailable, list or retrieve the event and reconcile the affected resource. Do not create a replacement payment just because delivery was delayed. Keep a unique record for the event ID and a separate processing result. This lets you acknowledge a duplicate safely while still retrying a failed business side effect.