payment.success
or ticket.request_refund
and handle them in your application.
In this guide, weβll show you how to listen to webhooks and handle the events.
Creating a webhook endpoint in your app
To create a webhook endpoint, you need to create a new endpoint in your application that will listen to the events. You can use any programming language or framework to create this endpoint. You will need to expose this endpoint to the internet, so the Fourvenues API can send the events to it. Letβs see an example of how to create a webhook endpoint in Node.js using Express:Register your webhook endpoint
To register your webhook endpoint, you need to send a request to the [webhook endpoints]channel-manager//api-reference/webhooks/create-a-new-webhook-endpoint) with the URL of your endpoint and the events you want to listen to. If you are in a local environment, you can use a tool like ngrok to expose your local server to the internet.sign_secret
value, you will need it to verify the events.
Listening to the events
Now that you have your webhook endpoint registered, you can start listening to the events. When an event happens, the Fourvenues API will send a POST request to your endpoint with the event data. Letβs see the example ofpayment.success
event:
id
: The unique identifier of the webhook event.event
: The name of the event.payload
: The data of the event.
Verifying the events
To verify the events, you need to use thesign_secret
value that you received when you registered the webhook endpoint. You can use this value to verify the signature of the event.
Here is an example of how to verify the event in Node.js: