Cannot pass hmac verification . Install your App for php

Highlighted
Shopify Partner
1 0 0

Hi. 

        I was testing the application by installing it in my development store.Cannot pass hmac verification. Here is my code.

// Helper method to determine if a request is valid
function validateHmac($params, $secret) {
  $hmac = $params['hmac'];
  unset($params['hmac']);
  //$params = array_diff_key($params, array('hmac' => '')); // Remove hmac from params
  ksort($params);

  $computedHmac = hash_hmac('sha256', http_build_query($params), $secret);
  echo "$computedHmac";
  return hash_equals($hmac, $computedHmac);
}

 

I am a beginner. Do you have any good Suggestions for me?Thank you for your attention

 

 

0 Likes
Highlighted
Shopify Partner
7 0 0

Hi lanmao, 

try to remove   http_build_query function from the below line and compute the hash, hopefully it should work,.

$computedHmac = hash_hmac('sha256', http_build_query($params), $secret);

 


Try OxeBox Marketing Automation for free ( https://goo.gl/3zSJrm

Thanks,
OxeBox Technologies  

0 Likes