πͺ Webhooks
How to set up marketplace webhooks.
Webhooks allow you to subscribe to events from Coinflow about when a seller has registered their account.
Setup
- Navigate to your marketplace dashboard
- Copy your Webhook Validation Key.
Keep this Validation Key secret, but if it gets leaked you can easily regenerate it.
- Select Version 2
- Select the event types to listen to.
-
For seller registration events, select:
Sub-Merchant KYB Created
,Sub-Merchant KYB Success
,Sub-Merchant KYB Failure
- Enter a URL route to your server endpoint
- In your server, create a route that accepts a POST request on that url and route
Ensure that the
Authorization
header in this request matches your Validation Key to verify its origin as Coinflow.
router.post('/submerchant-webhook', async (req, res) => {
try {
const {data} = req.body;
const {merchantId} = data;
console.log(`Merchant KYB: ${merchantId}`);
const authHeader = req.get('Authorization');
// Authorize using your validation key
if (authHeader !== process.env.COINFLOW_VALIDATION_KEY)
throw new ControllerError('User not allowed', 401);
else handleEvent() // react to event
res.sendStatus(200);
} catch (e) {
handleError(res, e);
}
});
Webhooks will retry until your server returns a 200 response code
or until it times out after 36 hours. Webhooks will also time out after 5 seconds without a response and will retry, so make sure your server responds within 5 seconds.
- The webhooks will contain the following data:
{
eventType: string,
category: 'Sub-merchant KYB Created' || 'Sub-merchant KYB Success' || 'Sub-merchant KYB Failure',
data: {
merchantId: string,
email: string,
},
}
- Done! Try listening to different event types by subscribing to the different options below
Event Types
Event Type | Description |
---|---|
Sub-merchant KYB Created | KYB information was submitted for the sub-merchant and is awaiting processing |
Sub-merchant KYB Success | The sub-merchant's KYB application has been approved |
Sub-merchant KYB Failure | The sub-merchant's KYB application did not pass (and probably needs additional information) |
Updated 5 days ago