Created
March 28, 2018 20:13
-
-
Save tiagomatos/d7f09e2ab52ff6ca916335b3d0679515 to your computer and use it in GitHub Desktop.
Verify Webhooks Secret
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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