Documentation
Search…
Webhooks
Listen for event notifications whenever certain actions occur on your Paychant merchant account.

What are webhooks?

Webhooks are automated messages sent, whenever something happens on your Paychant merchant account. For example, If you set up a webhook on your merchant account for a payment page, once people are about to use your payment page to pay you, you get event notification for pending, successful, failed or canceled paymentpage.payment.pending paymentpage.payment.successful paymentpage.payment.canceled status.

Setting up webhook

In Paychant merchant dashboard, go to settings > Webhook
Click on the create Webhook, you can create individual webhook for all Paychant payment tools
Secret key are automatically generated for you, please make sure you copy the secret key on this page, you will not be able to copy this later.
Once Webhook as been created, you can monitor all past and present event details in the logs.

Receiving Event

To start receiving event, you need to create unauthenticated POST route on your application.
Node
PHP
Python
const crypto = require('crypto');
const secret = process.env.SECRET_KEY; // Your paychant webhook secret
// Using Express
router.post("/webhook/url", function(req, res) {
res.sendStatus(200); // Return status code 200 quickly
// Validate event
const hmac = crypto.createHmac('sha512', secret);
const hash = hmac.update(JSON.stringify(req.body)).digest('hex');
const headerSig = req.headers['paychant-signature'];
if (hash === headerSig) {
var event = req.body;
// Do someting with the event
}
});
<?php
// Only a post method and headers that contain HTTP_PAYCHANT_SIGNATURE will be allowed
if ((strtoupper($_SERVER['REQUEST_METHOD']) != 'POST' ) || !array_key_exists('HTTP_PAYCHANT_SIGNATURE', $_SERVER) ) {
exit();
}
// Retrieve the request's body
$input = @file_get_contents("php://input");
// Remove escape slashes
$inputClean = stripslashes($input);
// SET the SECRET KEY
define('PAYCHANT_WEBHOOK_SECRET_KEY','SECRET_KEY');
// Validate event
if($_SERVER['HTTP_PAYCHANT_SIGNATURE'] !== hash_hmac('sha512', $inputClean, PAYCHANT_WEBHOOK_SECRET_KEY)){
exit();
}
// Return status code 200 quickly
http_response_code(200);
// Do someting with the event
$event = json_decode($input);
exit();
?>
import os
from flask import Flask, request, Response
import hmac
import hashlib
import urllib.parse
app = Flask(__name__)
secret = os.environ.get('SECRET_KEY') # Your paychant webhook secret
@app.route('/webhook', methods=['POST'])
def respond():
# Validate event
encode = urllib.parse.urlencode(request.json).encode('utf8')
hashMac = hmac.new(secret, encode, hashlib.sha512).hexdigest()
headerSig = request.headers.get('paychant-signature')
if(hashMac === headerSig):
event = request.json; # Do someting with the event
return Response(status=200)

Respond Quickly With Status code 2xx

For webhook notification event delivery to be satisfied, your endpoint must return a HTTP status code of 2xx to Paychant. All response codes outside this range, including 3xx codes, indicate to Paychant that you did not receive the event, and thus continue to the send the notification event every 30 minutes for 24 hours. After 24 hours Paychant marks the event as failed and stops trying to send it to your endpoint.

Events Response

api.payment.new
api.payment.pending
api.payment.paid
api.payment.canceled
api.payment.failed
paymentpage.payment.new
paymentpage.payment.pending
paymentpage.payment.successful
paymentpage.payment.canceled
paymentpage.payment.failed
{
event: 'api.payment.new',
data: {
id: '152',
sandbox: 'false',
title: 'Amino Mart Store',
amount: '2500.56',
currency: 'NGN',
token: 'RnCk5sKjwmWUaYWUYZ3DD1kVGytelv',
order_id: '00BM63MN',
payer_info: null,
description: 'More details about this order. Max 500 characters. It can be cart items, product details or other',
cancel_url: 'http://example.com/payments/cancel?ref=4343h737747',
success_url: 'http://example.com/payments/success?ref=4343h737747',
callback_url: 'http://example.com/payments/callback?ref=4343h737747',
payment_address: null,
payment_currency: null,
plugin: null,
created_at: '2021-04-05 12:03:40 PM',
updated_at: '2021-04-05 12:03:46 PM'
}
} +8s
{
event: 'api.payment.pending',
data: {
id: '152',
sandbox: 'false',
title: 'Amino Mart Store',
amount: '2500.56',
currency: 'NGN',
token: 'RnCk5sKjwmWUaYWUYZ3DD1kVGytelv',
order_id: '00BM63MN',
payer_info: null,
description: 'More details about this order. Max 500 characters. It can be cart items, product details or other',
cancel_url: 'http://example.com/payments/cancel?ref=4343h737747',
success_url: 'http://example.com/payments/success?ref=4343h737747',
callback_url: 'http://example.com/payments/callback?ref=4343h737747',
payment_address: '1BHAxQdnVDFWz4EaXeGCpsiNiNJse5pWGs',
payment_currency: 'BTC',
plugin: null,
created_at: '2021-04-05 12:03:40 PM',
updated_at: '2021-04-05 12:04:38 PM'
}
} +51s
{
event: 'api.payment.paid',
data: {
id: '152',
sandbox: 'false',
title: 'Amino Mart Store',
amount: '2500.56',
currency: 'NGN',
token: 'RnCk5sKjwmWUaYWUYZ3DD1kVGytelv',
order_id: '00BM63MN',
payer_info: null,
description: 'More details about this order. Max 500 characters. It can be cart items, product details or other',
cancel_url: 'http://example.com/payments/cancel?ref=4343h737747',
success_url: 'http://example.com/payments/success?ref=4343h737747',
callback_url: 'http://example.com/payments/callback?ref=4343h737747',
payment_address: '1BHAxQdnVDFWz4EaXeGCpsiNiNJse5pWGs',
payment_currency: 'BTC',
plugin: null,
created_at: '2021-04-05 12:03:40 PM',
updated_at: '2021-04-05 12:04:38 PM'
}
} +51s
{
event: 'api.payment.canceled',
data: {
id: '152',
sandbox: 'false',
title: 'Amino Mart Store',
amount: '2500.56',
currency: 'NGN',
token: 'RnCk5sKjwmWUaYWUYZ3DD1kVGytelv',
order_id: '00BM63MN',
payer_info: null,
description: 'More details about this order. Max 500 characters. It can be cart items, product details or other',
cancel_url: 'http://example.com/payments/cancel?ref=4343h737747',
success_url: 'http://example.com/payments/success?ref=4343h737747',
callback_url: 'http://example.com/payments/callback?ref=4343h737747',
payment_address: null,
payment_currency: null,
plugin: null,
created_at: '2021-04-05 12:03:40 PM',
updated_at: '2021-04-05 12:07:20 PM'
}
} +51s
{
event: 'api.payment.failed',
data: {
id: '152',
sandbox: 'false',
title: 'Amino Mart Store',
amount: '2500.56',
currency: 'NGN',
token: 'RnCk5sKjwmWUaYWUYZ3DD1kVGytelv',
order_id: '00BM63MN',
payer_info: null,
description: 'More details about this order. Max 500 characters. It can be cart items, product details or other',
cancel_url: 'http://example.com/payments/cancel?ref=4343h737747',
success_url: 'http://example.com/payments/success?ref=4343h737747',
callback_url: 'http://example.com/payments/callback?ref=4343h737747',
payment_address: null,
payment_currency: null,
plugin: null,
created_at: '2021-04-05 12:03:40 PM',
updated_at: '2021-04-05 12:07:20 PM'
}
} +51s
{
event: 'paymentpage.payment.new',
data: {
id: '64',
title: 'Book Store',
amount: '122',
currency: 'GBP',
description: 'Payment page (Book Store)',
merchant_url: 'http://pay.paychant.test/pay/book-store',
payment_address: null,
payment_currency: null,
merchant_redirect_url: null,
created_at: '2021-04-05 12:14:34 PM',
updated_at: '2021-04-05 12:14:38 PM'
}
} +60s
{
event: 'paymentpage.payment.pending',
data: {
id: '64',
title: 'Book Store',
amount: '122',
currency: 'GBP',
description: 'Payment page (Book Store)',
merchant_url: 'http://pay.paychant.test/pay/book-store',
payment_address: '0x4482cfa046380e2344d68618e75c8bb6e23bb1f1',
payment_currency: 'CUSD',
merchant_redirect_url: null,
created_at: '2021-04-05 12:14:34 PM',
updated_at: '2021-04-05 12:15:31 PM'
}
} +57s
{
event: 'paymentpage.payment.successful',
data: {
id: '64',
title: 'Book Store',
amount: '122',
currency: 'GBP',
description: 'Payment page (Book Store)',
merchant_url: 'http://pay.paychant.test/pay/book-store',
payment_address: '0x4482cfa046380e2344d68618e75c8bb6e23bb1f1',
payment_currency: 'CUSD',
merchant_redirect_url: null,
created_at: '2021-04-05 12:14:34 PM',
updated_at: '2021-04-05 12:15:31 PM'
}
} +57s
{
event: 'paymentpage.payment.canceled',
data: {
id: '64',
title: 'Book Store',
amount: '122',
currency: 'GBP',
description: 'Payment page (Book Store)',
merchant_url: 'http://pay.paychant.test/pay/book-store',
payment_address: null,
payment_currency: null,
merchant_redirect_url: null,
created_at: '2021-04-05 12:14:34 PM',
updated_at: '2021-04-05 12:19:54 PM'
}
} +4m
{
event: 'paymentpage.payment.failed',
data: {
id: '64',
title: 'Book Store',
amount: '122',
currency: 'GBP',
description: 'Payment page (Book Store)',
merchant_url: 'http://domain/pay/book-store',
payment_address: null,
payment_currency: null,
merchant_redirect_url: null,
created_at: '2021-04-05 12:14:34 PM',
updated_at: '2021-04-05 12:19:54 PM'
}
} +4m
This are some of the webhook events response for Paychant payment tools.
Copy link
On this page
What are webhooks?
Setting up webhook
Receiving Event
Respond Quickly With Status code 2xx
Events Response