App reviews, troubleshooting, and recommendations
Hello, I need help with the hmac validation, I am creating a Shopify App but to confirm installation I need to add the security checks, the problem is to validate the hmac because the documentation has a Ruby example but I need to do it with PHP, I have been doing many test and always I am getting FALSE after compare the hmacs.
Here my code:
$hmac = $params['hmac'];
$secret = 'hush';
$uri = $request->getUri();
//get the queries from the URI
$queryString = $uri->getQuery();
//remove the hmac from the query string
$queryString = str_replace('&hmac='.$hmac, '', $queryString);
//create the hmac
$crypted = hash_hmac('sha256', $queryString, $secret);
//verify if the hmacs match
$validation = hash_equals($crypted, $hmac);
error_log('VALIDATION '.var_export($validation, true));
Please help me!
Thanks in advance
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025