Webhooks

Overview

Paychant webhooks allow you to get automatic updates anytime the status on your widget instance changes.

The webhook will be called when the transaction reaches the processing status and also when it is complete. Once configured, your URL will receive notifications for the PROCESSING, COMPLETE, and FAILED statuses.

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.

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
   }
    
});

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 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

{
     event: 'WIDGET.CREATED',
     data: {
       env: 'sandbox',
       pid: '8847431020',
       date: '30/03/2023 - 01:46:02',
       fiat: 'NGN',
       asset: 'CUSD',
       chain: 'CELO',
       action: 'BUY',
       fiatAmount: 149241,
       assetAmount: 300,
       userAddress: '0xCd96602dBbeE307a1d50cb074C294847aB4702FB',
       exchangeRate: 497.47,
       paymentMethod: 'Bank Transfer',
       cryptoAddress: '---',
       transactionRef: '7CMJS1Q90GS79AA'
    }
 }

Below is the list of the events when we send the webhook:

Buy (OnRamp)

Sell (OffRamp)

Last updated