PHP Code Example to receive payment notification on your webhook page
<?php
header('Content-Type: application/json');
$headers = getallheaders();
$authHeader = $headers['Authorization'] ?? '';
$expectedToken = "jHGSFjgfwugfkweugfwjfwjfgwjegfuwefw";
if (strpos($authHeader, 'Bearer ') === 0) {
$token = substr($authHeader, 7);
if ($token !== $expectedToken) {
echo 'Unauthorized: Invalid token.';
exit;
}
} else {
echo 'Unauthorized: Invalid token.';
exit;
}
$input = file_get_contents("php://input");
if (empty($input)) {
echo 'No input received.';
exit;
}
$data = json_decode($input, true);
if ($data['status'] === 'success' && $data['message'] === 'Data received successfully.') {
$transactionId = $data['transactionId'] ?? null;
$transactionAmount = $data['transactionAmount'] ?? null;
$transactionFee = $data['transactionFee'] ?? null;
$settledAmount = $data['settledamount'] ?? null;
$date = $data['date'] ?? null;
$senderAccountNumber = $data['senderaccountnumber'] ?? null;
$senderAccountName = $data['senderaccountname'] ?? null;
$senderBank = $data['senderbank'] ?? null;
$receiver = $data['receiver'] ?? null;
$receiveraccountnumber = $data['receiveraccountnumber'] ?? null;
}
?>