<?php
$root = dirname(__DIR__, 4);
require $root.'/vendor/autoload.php';
$app = require $root.'/bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();

$log = App\Models\WebhookLog::query()->latest('id')->first();
$gateway = App\Models\PaymentGateway::query()->where('code','razorpay')->first();
$secret = data_get($gateway?->config_json ?? [], 'webhook_secret', '');
$expected = hash_hmac('sha256', (string)$log->payload, (string)$secret);
echo json_encode([
  'status' => $log->status,
  'stored_signature' => $log->signature,
  'expected_signature' => $expected,
  'payload' => $log->payload,
  'secret' => $secret,
], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES).PHP_EOL;
