Skip to content
Guides
Webhook notifications

Webhook notifications

UNIPaaS will notify your platform of important events using webhook notifications. There are notification endpoints available for each UNIPaaS products, such as onboarding, accepting payments and paying out.

1. Identify the webhook notifications needed to run your application

Section titled “1. Identify the webhook notifications needed to run your application”

Each UNIPaaS product fires different webhook notifications to your platform. For example, if you are using the UNIPaaS vendor onboarding product, you should listen to onboarding/update webhooks, which will update your application about every vendor’s onboarding status change. Use the UNIPaaS product webhook guide to subscribe to the webhook notifications you need.

Use our webhooks API endpoint to subscribe to the webhook notifications you need.

3. Capture and test webhook notifications on your server

Section titled “3. Capture and test webhook notifications on your server”

Use the UNIPaaS sandbox environment to simulate events that will trigger webhook notifications. For example, take a payment as a vendor, or go through a vendor onboarding flow, while listening to the respective webhook notifications.

UNIPaaS will re-send any webhook notification unless a 200 response status code is received within 10 seconds. There will be 15 webhook notification retries sent until the webhook will be invalidated. UNIPaaS will send an email notification after each 5 failed retries.

To verify that the request came from UNIPaaS, compute the HMAC digest according to the following algorithm and compare it to the value in the X-Hmac-SHA256 header. If they match, then you can be sure that the webhook was sent from UNIPaaS.

Webhooks created through the API are verified by calculating a digital signature. Each webhook request includes a base64-encoded X-Hmac-SHA256 header, which is generated using the <PLATFORM_SECRET_KEY> along with the data sent in the request.

const express = require('express')
const bodyParser = require('body-parser');
const { createHmac } = require('crypto');
const app = express();
const SECRET = '<PLATFORM_SECRET_KEY>';
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.raw());
app.post('/webhook', function (req, res) {
const {headers, body} = req;
const signedHeader = headers["x-hmac-sha256"];
const hash = createHmac('sha256', SECRET)
.update(JSON.stringify(body))
.digest('hex');
const buff = new Buffer(hash);
const calculated = buff.toString('base64');
if (calculated === signedHeader) {
console.log('hook verified successfully')
}
else {
console.log('failed to verify hook!')
}
res.send('Hello World')
})
app.listen(8080)