Webhooks
Webhooks

A Webhook resource primarily refers to a certain URL where we send events that are happening from your account. You can check the webhook section of our integration guide to find out some good use cases for webhooks.
​More Details​

/**
* These are the required properties
* @param {Object} data Data payload
* @param {Object} data.attributes Payload attributes
* @param {string} data.attributes.url The destination URL of the events that happened from your account. Please make sure that the URL is publicly accessible in order for you to receive the event.
* @param {string[]} data.attributes.events The list of events to be sent to this webhook. Possible value in the meantime is source.chargeable.
*/
const result = await paymongo.webhooks.create(data);
​

{
data: {
attributes: {
url: 'https://yourwebsite.com/webook-listener', // Developer's note: this is unique in paymongo. You can't create multiple webhooks with same url.
events: ['source.chargeable'] // The only event supported for now is 'source.chargeable'.
}
}
}
​

const result = await paymongo.webhooks.list();

{
data: [] // Array of webhooks
}

​
/**
* @param {string} id Webhook id
*/
const result = await paymongo.webhooks.retrieve(id);
​

Enable or disable a webhook.
/**
* @param {string} id Webhook id
* @param {string} action Toggle options 'enable' or 'disable'
*/
const result = await paymongo.webhooks.toggle(id, action);
​
Last modified 7mo ago
Copy link
On this page
The Webhook Resource
Creating a Webhook
Listing Webhooks
Retrieving a Webhook
Toggling a Webhook