Processing a Webhook Payload
How to parse the CloudEvent envelope, base64-decode the `data_base64` field, and deserialize the RTGS.global message payload into your domain model. Run this after both signatures have been verified.
// dotnet add package Azure.Messaging.CloudEvents
using Azure.Messaging;
// CloudEvent.Parse decodes data_base64 automatically.
var cloudEvent = CloudEvent.Parse(BinaryData.FromString(rawBody))
?? throw new InvalidOperationException("Invalid CloudEvent");
// Data.ToString() gives the decoded UTF-8 string.
var rtgsPayload = cloudEvent.Data!.ToString()!;
var eventType = cloudEvent.Type!;