🕸️ Webhook

This webhook documentation outlines how to integrate and handle payment notifications from HeedPay. When a payment is successfully processed, a webhook notification will be sent to your provided URL. This webhook contains information regarding the transaction, including the status, amount, sender, receiver, and other relevant details.

Virtual-Account-Payment Webhook sample

You are advice to verify real authentication of the transaction by

Always Verify HeedPAy webhooks:

Webhook security is critical. Your HeedPay webhook URL is publicly accessible, which means anyone can send a fake request pretending to be HeedPay. To prevent your system from processing fraudulent transactions, always verify every incoming webhook before acting on it. Follow these steps every time a webhook arrives.

Compare Sign Key:

Before proceeding to honor the received webhook, it is crucial to compare your sign Key with the hashed "api_key" present in the header section and your business id. This verification step ensures that the request is legitimate and enhances the security of your integration with HeedPay.

Prevent Duplicate Transactions:

Always verify transactions by querying the transaction reference before proceeding to honor the received webhook. This additional step ensures that you confirm the transaction details and enhances the reliability of your transaction processing workflow.

Requery Transaction:

Alway requery transaction with our fetch transaction details endpoint to reconfirm the transaction before you honor it the received webhook.

By incorporating the following security measures, you can fortify your webhook endpoint against data tampering, validate the authenticity of requests from trusted origins, and mitigate the risk of duplicate transaction processing. These steps will bolster the overall security and dependability of your webhook integration with HeedPay.

The Notification sample here

The webhook will send a JSON payload to your endpoint, with the following structure below:

{
"eventType": "VIRTUAL_DEPOSIT",
"status": "succcess",
"sign": "fgggertg5teerttergertt4r2335413423r4t523414235343r334r3434235rwefr34",
"message": "Your payment has been successfully processed.",
"timestamp": "2024-11-22T13:00:04.256092Z",
"bussinessId":"GR45G7HU89K",
"data": {
"amount_received": "100.00",
"fee_deducted": "0.5",
"amount_credited": "99.5",
"session_id": "988625325234443568021345231247",
"reference": "2034943894287423RESERVED"
},
"sender": {
"senderName": "Heedtech Universal,
"senderAccountNumber": "6679854996",
"senderBankName": "HeedPay Bank",
"senderBankCode": "103212"
},
"customer": {
"name": "Heedtech Sahee(Heedpay)" ,
"email": "john@gmail.com",
"account": "5357321222",
"customer_id": "23456788445678RESERVED"
},
}

To verify the sign key on the webhook is below:


// 1. Get the raw input data sent from HeedPay
$payload = file_get_contents('php://input');

// 2. Retrieve the signature sent from the HTTP Request Headers
$headers = getallheaders();
$heedpay_signature = isset($headers['X-HeedPay-Signature']) ? $headers['X-HeedPay-Signature'] : '';

// 3. Your secret API key stored securely on your server
$secret_key = "YOUR_HEEDPAY_API_KEY";

// 4. Calculate your local signature check
$expected_signature = hash_hmac('sha256', $payload, $secret_key);

// 5. Match verification status cleanly
if (hash_equals($expected_signature, $heedpay_signature)) {
// Webhook is authentic! Process credit safely.
http_response_code(200);
echo "success";
} else {
// Fraud alert! Reject connection immediately
http_response_code(401);
echo "Unauthorized Signature Mismatch";
}