Before you begin, make sure you have completed the Getting Started guide - you'll need your CLIENT_ID and CLIENT_SECRET, and a valid access token.
You will also need:
- A company id.
Create service with a public webhook endpoint.
Show example code (C#)
dotnet add package Azure.Messaging.EventGriddotnet add package ZData.Events.BankC#
using Azure.Messaging.EventGrid;
using Azure.Messaging.EventGrid.SystemEvents;
using Microsoft.AspNetCore.Mvc;
using ZData.Events.Bank;
namespace WebhookTest.Controllers
{
[ApiController]
[Route("webhooks")]
public class WebhookController : ControllerBase
{
private readonly ILogger\<WebhookController> logger;
public WebhookController(ILogger\<WebhookController> logger)
{
this.logger = logger;
}
[HttpPost("events")]
public IActionResult HandleEvents(EventGridEvent[] events)
{
foreach (EventGridEvent eventGridEvent in events)
{
// Handle system events
if (eventGridEvent.TryGetSystemEventData(out object eventData))
{
// Handle the subscription validation event
if (eventData is SubscriptionValidationEventData subscriptionValidationEventData)
{
var responseData = new SubscriptionValidationResponse()
{
ValidationResponse = subscriptionValidationEventData.ValidationCode
};
return Ok(responseData);
}
}
// 2. Check if event is an Aritma (ZData) event.
if (eventGridEvent.EventType == typeof(SettlementReceived).FullName)
{
var settlementReceivedEvent = eventGridEvent.Data.ToObjectFromJson\<SettlementReceived>();
// TODO: handle the event:
logger.LogInformation(settlementReceivedEvent.BatchId.ToString());
}
}
return BadRequest();
}
}
}
Loading...
Before you continue
Use the same company ID and subscription name you entered in Step 2.
Loading...