Reputation: 3727
I'm developing a Shopify app that sets up a "product/create" Webhook through the Shopify API.
While the Webhook is sending a POST to the correct address with no problem, it seems that it is not supplying the ID of the shop that the product has been created for. This is a problem because I need to store metadata for the shop and its products. I need to ensure that the link exists in my database between the shop and its products.
Is there a way to either:
Find the shop ID for the product which is being given to me through the Webhook
Configure the Webhook with custom data that is handed back when the webhook sends its request, so that I can force it to hand back the shop ID when I create it
Thanks in advance!
Upvotes: 4
Views: 4621
Reputation: 1958
When Shopify sends request to your webhook url. it will also send some extra details in HTTP header.
You can find X-Shopify-Shop-Domain
header which will contain domain name of
store. From domain name you can extract name of store.
it also contains X-Shopify-Hmac-SHA256 to verify aunthenticity of request.
Upvotes: 9
Reputation: 11427
If you are handed a product in the products/create webhook, you are handed the domain of the incoming call. Once you authenticate the incoming domain, you can clearly query your persistance layer for the shop's token to match the domain. With that, establish the API connection you need, and voila... you can get the Shop and all it's details.
Typically you do NOT need the shop ID for anything, since the myshopify_domain is your key in almost all cases of any work done between Shopify and your App.
Upvotes: 3