Quantcast
Channel: Opinion: Shopify Community - Shopify APIs & SDKs
Viewing all articles
Browse latest Browse all 25503

Product Update Webhook repeat excessively till getting deleted. by Jason T

$
0
0

Hi, 

I have created a product update webhook that simply just insert the productId that was modified into a database queue.

However Shopify Webhook seems to repeatedly send back the same webhook.

My code is just as simple as this:

<?php
header("HTTP/1.1 200 OK");
include_once('shopify_credentials.php');

function verify_webhook($data, $hmac_header)
{
  $calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_SECRET, true));
  return ($hmac_header == $calculated_hmac);
}

$hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
$data        = file_get_contents('php://input');
$verified    = verify_webhook($data, $hmac_header);

if ($verified) {
	
	$domain           = $_SERVER['HTTP_X_SHOPIFY_SHOP_DOMAIN'];
	$shopifyProductId = $_SERVER['HTTP_X_SHOPIFY_PRODUCT_ID'];
       // Insert this data into queue.

} 
?>

When I profiled this script, the time it takes for this file to run is 0.001s

So there should be no reason for Shopify Webhook to resend the same webhook. 

May I know have I done something wrong here?


Viewing all articles
Browse latest Browse all 25503

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>