Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
I registered a webhook. But I don't know how to use it in Java code or JSP code.
I want to access product information and fetch the variants from it. Also I want to update inventory of that product.
I searched from forums. There are a lot of Ruby code. I can't find any Java/JSP code example.
Please give me any hints. Thank you very much!
There isn't anything really to it. You'll have a publicly accessible endpoint that will accept POSTs.
When a message comes in you will have some information in the headers, specifically: the shop for which the webhook is related to, the content in the body, and a signature for that content in the header.
If you read up on validating webhooks we tell you how to verify the signature. Even though it's in ruby, it's pretty straight-forward. You put some things in the right places, use HMACSHA256 to generate the message signature and compare the resulting hex digest with the one provided by Shopify.
If they match you know it's a legitimate request from Shopify.
Chris | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Thank you. I will try.
According to what you said, it seems like I can only receive information from Shopify. Is that right?
Yes, webhooks are sent from Shopify to inform you about events that have happened. It's to save you the time of having your server actively fetch data from shopify, especially since you could be wasting API calls to find out nothing has changed.
Chris | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog