Webhook from shopify admin page verify problem

New Member
1 0 0

Hi i have some problem when test verify webhook it alway return the wrong hash and it never match what did i do wrong?



public function shopify()
        // Check signature
        $header = $this->request->getHeader('x-shopify-hmac-sha256');   
        $body = file_get_contents('php://input');

        $result = ShopifyController::verify_webhook($body, $header);
        if ($result) {
          $response = new Response();
          return $response;
        // Error
        $response = new Response();
        return $response;






static function verify_webhook($data, $hmac_header)

      $secret = file_get_contents($_ENV['SHOPIFY_WEBHOOK_PATH']) ?? null;
      $calculated_hmac = base64_encode(hash_hmac('sha256', $data, $secret, true));      
      return hash_equals($hmac_header, $calculated_hmac);



The result alway not match i use secret in the buttom of notification admin page
hmc_header "+RpGt0vu...."
calculate_hash: "BIYF+9...."

Any though? Thank you.

Replies 0 (0)