How can I set up specific webhook events on the Fynd platform and ensure they are triggered correctly?
The Fynd platform allows you to define specific webhook events that, when triggered, will execute certain desired actions. You set up these events in the webhook_config
section of the setupFdk
function. Here, for different events such as ‘company/location/update’, ‘company/product/create’, or ‘application/coupon/create’, you define a version and a handler. The handler is the function that gets executed when the event is triggered.
To ensure these events are triggered correctly, you need to create an API endpoint that the webhook can listen to. This endpoint should be a POST API path and this API view should call the processWebhook
method of the webhookRegistry
object available under fdkClient
. Here, processWebhook
will validate the payload with the signature and call the individual handlers for the event that gets passed with the webhook configuration.
On a higher level, you can control which events are subscribed to by using the subscribe_on_install
parameter. By default, all webhook events are subscribed to for all companies when they are installed. To disable this behavior, you can set subscribe_on_install
to false, but then you will need to manually enable the webhook event subscription by calling the syncEvents
method of the webhookRegistry
.
Check out the detailed instructions here.