Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dipesh-rajak's avatar

Create and Verify webhook shopify using laravel

ErrorException Undefined index: HTTP_X_SHOPIFY_HMAC_SHA256

Illuminate\Foundation\Bootstrap\HandleExceptions::handleError C:\xampp\htdocs\handwritten\app\Http\Controllers\WebHookController.php:24 /**

 * Create a new controller instance.

 *

 * @return void

 */

public function __construct()

{

    define('SHOPIFY_APP_SECRET', '**********my_shopify_secret***********');



    function verify_webhook($data, $hmac_header)

    {

        $calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_APP_SECRET, true));

        return hash_equals($hmac_header, $calculated_hmac);

    }



    $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];

    $data = file_get_contents('php://input');

    $verified = verify_webhook($data, $hmac_header);

    error_log('Webhook verified: ' . var_export($verified, true));

}



/**

 * Show the application dashboard.

 *

 * @return \Illuminate\Contracts\Support\Renderable

 */

public function index()

{

}

}

Controller

0 likes
0 replies

Please or to participate in this conversation.