public function handleOrderWebhook(Request $request)
{
// return 404;
// Raw request body
$rawBody = $request->getContent();
// Shopify HMAC header
$hmacHeader = $request->header('X-Shopify-Hmac-Sha256');
// if (empty($hmacHeader)) {
//     Log::warning('Webhook rejected: Missing HMAC header');
//     return response('Missing HMAC header', 401);
// }
// Debugging ke liye logs
Log::info('Shopify Webhook Headers', $request->headers->all());
Log::info('Shopify Raw Body', \[$rawBody\]);
// Secret key from .env (Shopify webhook signing secret)
$secret = '99111bedd1ff7bd43ccd542b0137c512bbf4481f77a88ed0d6444fa29afea17b';
// Calculate HMAC on raw body
$calculatedHmac = base64_encode(
    hash_hmac(
        'sha256',
        $rawBody,
        $secret,
        true
    )
);
// Compare securely
if (!hash_equals($hmacHeader, $calculatedHmac)) {
    Log::warning('Invalid Shopify Webhook Signature', \[
        'received'   => $hmacHeader,
        'calculated' => $calculatedHmac,
    \]);
    return response('Invalid signature', 401);
}
// Signature valid → process webhook
$data = json_decode($rawBody, true);
// Example: save order
$this->storeOrder($data);
return response()->json(\['status' => 'success'\], 200);
}