Search…
πŸͺ
Webhooks
Listen to webhook events whenever certain actions occurs

What are webhooks?

Webhooks are a way for you to subscribe to events that occur when an event involving your business occurs. This guide will walk through what webhooks are and how you can use them in order to get started with integrating them into your application.
A webhook URL is an endpoint on your server where you can receive notifications about such events. When an event occurs, we'll make a POST request to that endpoint, with a JSON body containing the details about the event, including the type of event and the data associated with it.
Rather than continuously polling the server to check if the state has changed, webhooks provide information to you as it becomes available, which is a lot more efficient and beneficial for developers.
Here are some sample webhook payloads for deposit transactions:
{
"id": "183f0a97-9de8-4cdc-b130-e8dd5f06caf4",
"reference": "3H1WTK8k8PC78p6TWEbKptT",
"senderAddress": "0x8aFDD7Ee323E98adcB59445AE49118673950Ff19",
"recipientAddress": "0x0B4d358D349809037003F96A3593ff9015E89efA",
"actualAmount": 100,
"amountPaid": 100,
"amountReceived": 100,
"coin": "USDT",
"hash": "0xa3ef6266d29c096eb824112fcb32a90d42276bb1c94f88790f3d47a80992a9d8",
"blockNumber": 19767423,
"type": "withdrawal",
"status": "confirmed",
"network": "mainnet",
"blockchain": "Binance Smart Chain",
"metadata": {},
"createdAt": "2022-05-30T20:22:54.674Z",
"updatedAt": "2022-05-30T20:22:54.674Z",
"feeInCrypto": 0,
"webhookType": "CRYPTO_TRANSFER"
}
and here's example webhook for bank payout
{
"id": "cbc49dc9-ca73-4458-8f1d-9bd33e7b33dc",
"reference": "XXXX",
"senderAddress": "0x89Af0fFA21d7XXXXX812D8d06F41D5001",
"recipientAddress": "0x18689E41XXXXXXX9B2d59874",
"amountPaid": 5,
"amountPaidFiat": 4.9,
"amountReceived": 5,
"amountReceivedFiat": 4.9,
"coin": "USDT",
"currency": "USD",
"hash": "0x8b7c07XXXXXXX1929537f41053d68f263f9f5",
"blockNumber": 22XXX044,
"type": "bank_withdrawal",
"status": "pending",
"network": "testnet",
"blockchain": "Binance Smart Chain",
"fiatRate": 0.98,
"metadata": {},
"createdAt": "2022-09-05T16:35:22.986Z",
"updatedAt": "2022-09-05T16:35:22.986Z",
"bankPayout": {
"id": "3605e847-ffa7-49ea-aea0-80236daaeb02",
"bankName": "blue ridge bank national association",
"bankCode": null,
"accountName": "XXX inc",
"accountNumber": "69XX4265",
"accountType": "personal",
"routingNumber": "0XXX29",
"currency": "USD",
"country": "united states",
"state": "california",
"city": "san francisco, ca",
"address": "XXX spear street",
"street": null,
"postalCode": "94XX05",
"network": "testnet",
"status": "approved",
"default": false,
"deleted": false,
"createdAt": "2022-09-04T20:48:05.416Z",
"updatedAt": "2022-09-04T20:48:05.416Z",
"deletedAt": null
},
"feeInCrypto": 2.05,
"webhookType": "BANK_TRANSFER"
}

Enabling webhooks

You can specify your webhook URL on your dashboard where we would send POST requests to whenever an event occurs.
Here's how to set up a webhook on your Lazerpay account:
  • Login to your dashboard and click on the Settings
  • Navigate to the API Keys and Webhooks tab
  • specify your webhook url and click on Update
When testing, you can get an instant webhook URL by visiting webhook.site. This will allow you to inspect the received payload without having to write any code or set up a server.

Validating webhooks signature

Every webhook event payload will contain a hashed authentication signature in the header which is computed by generating a hash from concatenating your API key and request body, using the HMAC SHA256 hash algorithm.
In order to verify this signature came from Lazerpay, you simply have to generate the HMAC SHA256 hash and compare it with the signature received.
var crypto = require('crypto');
var secret = process.env.SECRET_KEY;
// Using Express
app.post("/my/webhook/url", function(req, res) {
//validate event
var hash = crypto.createHmac('sha256', secret).update(JSON.stringify(req.body), 'utf8').digest('hex');
if (hash == req.headers['x-lazerpay-signature']) {
// Retrieve the request's body
var event = req.body;
// Do something with event
}
res.send(200);
});

Responding to webhooks request

You must respond with a 200 OK status code. Any other response codes outside of the 2xx range, we will consider it will be considered as a failure, including 3xx codes. We don't care about the response body or headers.
If we don't get a 200 OK status code, we'll retry the webhook every one minute for the next 24 hours.
​

Supported Webhooks types.

Here are the webhooks request types we support. We'll add more to this list as we keep adding webhook supports for different API operations in the future.
Webhook Type
Description
CRYPTO_TRANSFER
A crypto transfer has occurred. It could have a status of confirmed or failed
BANK_TRANSFER
A bank transfer has occurred. It could have a status of confirmed or failed
Copy link
Edit on GitHub
Outline
What are webhooks?
Enabling webhooks
Validating webhooks signature
Responding to webhooks request
Supported Webhooks types.