ARTICLE AD BOX
After payment is successful, the paystack payload doesn't reach my server. These are the things I have done so far to narrow down the issue.
I pointed the webhook url to webhook.site and I received the json payload.
The webhook file was run directly on browser and it logged the neccessary message.
All paystack ip address was whitelisted and ModSecurity disabled but the webhook did not respond.
Tried to run it on a different domain (to no avail)
I contacted my hosting platform and per their investigations, there was no firewall blocking the request but yet, it fails to respond.
This is a snippet of the debugging code used
<?php function log_webhook($message) { $logFile = DIR . '/paystack_webhook.log'; $time = date('Y-m-d H:i:s'); file_put_contents( $logFile, "[$time] $message" . PHP_EOL, FILE_APPEND ); } log_webhook('Before Webhook hit'); log_webhook('Webhook processed successfully'); http_response_code(200); require_once 'config.php'; log_webhook('Webhook hit'); $input = file_get_contents("php://input"); if (!$input) { log_webhook('Empty payload received'); } $signature = $_SERVER['HTTP_X_PAYSTACK_SIGNATURE'] ?? ''; if (!$signature) { log_webhook('Missing Paystack signature header'); } log_webhook('Payload: ' . $input); log_webhook('Signature header: ' . $signature); $expected = hash_hmac( 'sha512', $input, $paystack_topup_secret_key ); log_webhook('Computed signature: ' . $expected); if (!hash_equals($expected, $signature)) { log_webhook('Signature verification FAILED'); http_response_code(400); exit; } log_webhook('Signature verification PASSED'); $data = json_decode($input, true); if (json_last_error() !== JSON_ERROR_NONE) { log_webhook('JSON decode error: ' . json_last_error_msg()); http_response_code(400); exit; } log_webhook('Event received: ' . ($data['event'] ?? 'none')); if (($data['event'] ?? '') === 'charge.success') { $reference = $data['data']['reference'] ?? ''; $amount = ($data['data']['amount'] ?? 0) / 100; log_webhook("Processing charge.success | Ref: $reference | Amount: $amount"); } exit(); ?>