@extends('layouts.app') @section('title', 'Webhook secret') @section('content')
$secret = 'YOUR_SECRET';
$header = $_SERVER['HTTP_X_TREVO_SIGNATURE'] ?? '';
parse_str(str_replace(',', '&', $header), $parts); // gives t and v1
$body = file_get_contents('php://input'); // the raw body, unmodified
if (abs(time() - (int) ($parts['t'] ?? 0)) > 300) { http_response_code(400); exit; }
$expected = hash_hmac('sha256', $parts['t'] . '.' . $body, $secret);
if (! hash_equals($expected, $parts['v1'] ?? '')) { http_response_code(401); exit; }
// Process the event once: skip it if X-Trevo-Delivery was already handled.