Notification When Settlement Completes
The acknowledgement of settlements have been completed are provided in real-time using webhooks, then to get further information of the settlement data, we can use the API endpoints in the following sections.
Webhooks are automated messages sent from DMG systems when an event happens. They are a way for an app to provide other applications with real-time information. A webhook delivers data to other applications as it happens, meaning you get data immediately. Webhooks are commonly used to automate workflows and integrate different services.
In the context of this system, webhooks notify merchants about specific settlement events, such as after the processing of settlements has occurred. When such an event occurs, the webhook sends an HTTP POST request to a specified URL with a payload containing the event data.
How to Implement Webhooks in Your Code
Implementing webhooks involves two main steps: setting up a server to receive the webhook data and handling the incoming data. For simplicity sake, we will just focus on the code to show the event details in the console log, we’ll leave you to discuss with your system integrator on the exact logic required for your business.
You need to set up a server that can receive HTTP POST requests. Here’s an example using Node.js and Express.
// Import required modules
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 3000;
// Middleware to parse JSON bodies
app.use(bodyParser.json());
// Define a route to receive webhooks
app.post('/webhook', (req, res) => {
const event = req.body;
// Log the received event data
console.log('Received webhook event:', event);
// Handle the event (e.g., store it in a database, trigger other actions)
// ...
// Respond to acknowledge receipt of the webhook
res.status(200).send('Webhook received');
});
// Start the server
app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
});
Setting up Settlement Webhooks
To set up Settlement Webhooks:
-
Log into the Merchant Dashboard.
-
Click on Webhooks.
-
Add a new webhook by clicking on Add Webhook (Note: You can also edit an existing webhook to include Settlement Webhooks. For simplicity, we will refer to creating a new webhook.)
-
In the Webhook Name field, give the webhook a name. We recommend using the name of the system and general webhooks for ease of reference.
-
Add the intended URL location in the Webhook Endpoint field to let DMG know where to send the POST request. In our case, we will use https://acme.com/webhook/
-
Click on Webhook Events. This will display a list of events that can be selected. For our purposes, select "Settled," "Settled Out Of Balance," and "Pending Settlement."
-
Enter a description of the webhook in the Webhook Description field. This can be left blank.
-
Enter the authentication details under the Authentication section. This is for HTTP AUTH (authentication prompt) set onto the destination URL in the Webhook Endpoint. Note that anything conforming to validation can be entered, and the endpoint doesn’t require this.
-
Click Save, which should direct you back to the webhook listing.
-
Ensure the webhook Status is set to “On”.
Now, wait for the next settlement to arrive, which normally happens every bank workday, depending on the bank and location.