API Reference
Payout Webhook

Payout Webhooks

The Payout webhook allows you to receive real-time notifications about the status of your payout transactions. You can configure your webhook URL in the dashboard under Dev Settings.

Webhook Configuration

  1. Go to your dashboard
  2. Click on "Dev Settings" tab
  3. Find the "Webhook Configuration" section
  4. Enter your webhook URL
  5. Save the configuration

Webhook Payload

When a payout transaction status changes, you'll receive a POST request to your configured webhook URL with the following payload:

{
  "type": "payout",
  "timestamp": "2024-03-20T10:30:00Z",
  "data": {
    "order_id": "987654321098765",
    "status": "SUCCESS",
    "beneficiary_name": "Jason Stathom",
    "account_number": "390000000003",
    "amount": "99",
    "utr": "UTR24031545789",
    "timestamp": "2024-03-20T10:29:45Z",
    "wallet_balance": {
      "available": 5000.00,
      "on_hold": 100.00
    }
  }
}

Payload Fields

FieldTypeDescription
typestringAlways "payout" for payout webhooks
timestampstringISO 8601 timestamp of when the webhook was sent
data.order_idstringYour merchant order ID for the payout
data.statusstringTransaction status (SUCCESS, FAILED, PENDING)
data.beneficiary_namestringName of the beneficiary
data.account_numberstringBeneficiary's account number
data.amountstringAmount of the payout
data.utrstringUTR number for successful transactions
data.timestampstringISO 8601 timestamp of the transaction
data.wallet_balance.availablenumberAvailable balance in wallet
data.wallet_balance.on_holdnumberAmount on hold in wallet

Headers

Each webhook request includes the following headers:

HeaderValue
Content-Typeapplication/json
X-Webhook-SourcePayVanta

Response

Your webhook endpoint should return a 2xx status code to acknowledge receipt of the webhook. Any other status code will be considered a failure, and we may retry the webhook delivery.

Retry Policy

If your webhook endpoint fails to respond with a 2xx status code, we will retry the webhook delivery with the following schedule:

  1. First retry: 1 minute after initial failure
  2. Second retry: 5 minutes after first retry
  3. Third retry: 15 minutes after second retry
  4. Fourth retry: 30 minutes after third retry

Security

To ensure the webhook is coming from PayVanta:

  1. Verify the X-Webhook-Source header is set to "PayVanta"
  2. Implement IP whitelisting for PayVanta's webhook servers
  3. Use HTTPS for your webhook endpoint

Example Implementation

const express = require('express');
const app = express();
 
app.post('/webhook', (req, res) => {
  // Verify webhook source
  if (req.headers['x-webhook-source'] !== 'PayVanta') {
    return res.status(401).json({ error: 'Invalid webhook source' });
  }
 
  const { type, timestamp, data } = req.body;
 
  // Handle payout webhook
  if (type === 'payout') {
    console.log('Received payout webhook:', {
      orderId: data.order_id,
      status: data.status,
      amount: data.amount,
      utr: data.utr,
      walletBalance: data.wallet_balance
    });
 
    // Process the webhook data
    // Update your database, notify users, etc.
  }
 
  // Always return 200 to acknowledge receipt
  res.status(200).send('Webhook received');
});
 
app.listen(3000, () => {
  console.log('Webhook server listening on port 3000');
});

Testing Webhooks

You can test your webhook configuration using the "Test Webhook" button in the Dev Settings tab. This will send a test payload to your configured webhook URL.

Best Practices

  1. Always respond quickly to webhook requests (within 5 seconds)
  2. Implement idempotency to handle duplicate webhooks
  3. Log all webhook requests for debugging
  4. Use HTTPS for your webhook endpoint
  5. Implement proper error handling
  6. Store webhook data in your database for record-keeping
  7. Update your system's transaction status based on webhook notifications
  8. Monitor wallet balance changes through webhook notifications