Skip to content

Instantly share code, notes, and snippets.

@tiagomatos
Created March 28, 2018 20:13
Show Gist options
  • Save tiagomatos/d7f09e2ab52ff6ca916335b3d0679515 to your computer and use it in GitHub Desktop.
Save tiagomatos/d7f09e2ab52ff6ca916335b3d0679515 to your computer and use it in GitHub Desktop.
Verify Webhooks Secret
<?php
define('HOOKS_TOKEN', 'XXXXX'); // get your token at Admin Panel > Config > Notifications / Webhooks.
function verify_webhook($data, $hmac_header)
{
$calculated_hmac = base64_encode(hash_hmac('sha256', $data, HOOKS_TOKEN, true));
return ($hmac_header == $calculated_hmac);
}
$hmac_header = $_SERVER['HTTP_JUMPSELLER_HMAC_SHA256'];
$data = file_get_contents('php://input');
$verified = verify_webhook($data, $hmac_header);
print_r(var_export($verified, true));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment