Quickstart

Prerequisites

  • Client credentials for access.
  • A company id.

Step 1

Set up your webhook endpoint.

Create service with a public webhook endpoint.

Show example code (C#)

1. Create a new Web API project

2. Add Azure.Messaging.EventGrid package to project

Copy
Copied
dotnet add package Azure.Messaging.EventGrid

3. Add ZData.Events.Bank package to project

Copy
Copied
dotnet add package ZData.Events.Bank

4. Create Webhook controller

Copy
Copied
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();
        }
    }
}

Step 2

Create a new Event Subscription.

Loading...

Step 3

GET the status of your Event Subscription.

Please complete Step 2 first.