Skip to content

Commit

Permalink
Merge branch 'main' into update-hmacSignature
Browse files Browse the repository at this point in the history
  • Loading branch information
jillingk authored Jul 29, 2024
2 parents 631dbce + 883a33e commit d5b29f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Adyen/Util/HmacSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class HmacSignature
*/
public function validateHMAC(string $hmacKey, string $hmacSign, string $webhook): bool
{
if (!ctype_xdigit($hmacSign)) {
if (!ctype_xdigit($hmacKey)) {
throw new AdyenException("Invalid HMAC key: $hmacKey");
}
$expectedSign = base64_encode(hash_hmac(
'sha256',
$webhook,
pack("H*", $hmacSign),
pack("H*", $hmacKey),
true
));
return hash_equals($expectedSign, $hmacKey);
return hash_equals($expectedSign, $hmacSign);
}

/**
Expand Down

0 comments on commit d5b29f8

Please sign in to comment.