20. Webhook Api - Viincenttt/MollieApi GitHub Wiki

This API is used to retrieve events that are published by the next-gen webhooks system.

The WebhookEventClient provides methods to retrieve webhook events from the Mollie API. It supports both generic and non-generic retrieval, allowing you to fetch events with or without strongly-typed embedded entities.

Use the first method if you know the type of the entity before calling the API. Use the second one if the type is not known beforehand.

Method 1: Retrieve a webhook event and specify the type using generics

const string webhookEventId = "event_GvJ8WHrp5isUdRub9CJyH";
using IWebhookEventClient client = new WebhookEventClient("{yourKey}");
FullWebhookEventResponse<PaymentLinkResponse> response = await client.GetWebhookEventAsync<PaymentLinkResponse>(webhookEventId);
PaymentLinkResponse paymentLink = response.Entity; // Strongly typed

Method 2: Retrieve a webhook event without specifying the type

const string webhookEventId = "event_GvJ8WHrp5isUdRub9CJyH";
using IWebhookEventClient client = new WebhookEventClient("{yourKey}");
FullWebhookEventResponse response = await client.GetWebhookEventAsync(webhookEventId);
IEntity entity = response.Entity;
PaymentLinkResponse paymentLink = (PaymentLinkResponse)response.Entity; // Or other type