57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
require_once("./src/config/env.php");
|
|
require_once("./src/config/functions.php");
|
|
|
|
$callbackUrl = $_ENV['IKHOKHA_CALLBACK_URL'] ?? '';
|
|
$secret = $_ENV['IKHOKHA_APP_SECRET'] ?? '';
|
|
$path = '/src/api/ikhokha_webhook.php';
|
|
|
|
// Simulated raw webhook body (EXACT)
|
|
$raw = '{"paylinkID":"ys5225k4z56x0mm","status":"SUCCESS","externalTransactionID":"693efeaca71a9","responseCode":"00","text":null}';
|
|
|
|
// Simulated header signature from iKhokha
|
|
$ikSignFromWebhook = 'bb1702d488a40091ebd5414bc6f524e203e2c5e36b24a1b86e243dad440bb557';
|
|
|
|
// Simulated raw webhook body (EXACT)
|
|
$raw = '{"paylinkID":"ys5225k4z56x0mm","status":"SUCCESS","externalTransactionID":"693efeaca71a9","responseCode":"00","text":null}';
|
|
|
|
// Simulated header signature from iKhokha
|
|
$ikSignFromWebhook = 'bb1702d488a40091ebd5414bc6f524e203e2c5e36b24a1b86e243dad440bb557';
|
|
|
|
// Decode JSON string into array
|
|
$bodyArray = json_decode($raw, true);
|
|
|
|
// Remove `text` key exactly like JS
|
|
unset($bodyArray['text']);
|
|
|
|
// Re-encode JSON (no double-encoding)
|
|
$cleanBody = json_encode($bodyArray, JSON_UNESCAPED_SLASHES);
|
|
|
|
// Now sign the SAME payload JS signs
|
|
$payloadToSign = createPayloadToSign($callbackUrl, $cleanBody);
|
|
|
|
$ikSign = generateSignature($payloadToSign, $secret);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>iKhokha Signature Debug (JS)</title>
|
|
</head>
|
|
<body>
|
|
|
|
<h3>IK-SIGN FROM WEBHOOK:</h3>
|
|
<pre><?= htmlspecialchars($ikSignFromWebhook) ?></pre>
|
|
|
|
<h3>DEBUG INFO</h3>
|
|
<p><strong>Callback URL:</strong> <?= htmlspecialchars($callbackUrl) ?></p>
|
|
|
|
<h3>Payload to Sign (Un-escaped):</h3>
|
|
|
|
<pre><?= $payloadToSign ?></pre>
|
|
|
|
<h3>EXPECTED SIGNATURE (JS):</h3>
|
|
|
|
<pre><?= $ikSign ?></pre>
|
|
|