-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can we use products webhook ? #25
Comments
First of all when testing on local, shopify won't allow you to send webhooks through their cloudflare tunnels so remember we installed ngrok if you havent refer to download ngrok after you have ngrok setup do the following Step 1in your terminal run Step 2Modify the dev command in your root
Step 3run Step 4
import webhookHooks from "./webhooks/webhook-handlers.js";
// Set up Shopify authentication and webhook handling
app.post(
shopify.config.webhooks.path,
// change from `GDPRWebhookHandlers` to `webhookHooks`
shopify.processWebhooks({
webhookHandlers: webhookHooks,
})
); Step 5in ORDERS_CREATE: {
deliveryMethod: DeliveryMethod.Http,
callbackUrl: "/api/webhooks",
callback: async (topic, shop, body, webhookId) => {
do something with that data like console.log(topic, shop, body)
},
}, VERY IMPORTANTAccording to shopify webhook data can be duplicated, so one way to handle that will be store the Also to get your app approved you need to verify your webhooks, use it as a middleware in import { validateWebhookRequest } from "somewhere";
app.post(
shopify.config.webhooks.path,
validateWebhookRequest,
shopify.processWebhooks({
webhookHandlers: webhookHooks,
})
); |
Thanks for the quick reply |
Please provide the code for validateWebhookRequest, |
Since I don't know exactly how your app works, I can't provide a "validateWebhookRequest" implementation However you can take a look at this github issue to get started Validating Webhooks |
Marking this as closed |
|
OK,I have implemented the above steps in my code for webhook.If I am trying to uninstall the app getting the error. |
the webhooks take a string as the body and parse them, make sure any middleware that parses the data to JSON comes AFTER const app = express();
app.get(shopify.config.auth.path, shopify.auth.begin());
app.get(
shopify.config.auth.callbackPath,
shopify.auth.callback(),
shopify.redirectToShopifyOrAppRoot()
);
app.post(
shopify.config.webhooks.path,
shopify.processWebhooks({ webhookHandlers: YOUR_WEBHOOK_HANDLERS})
);
// middlewares should come after this |
Thanks for response |
Hello @Mini-Sylar ,
How can we use products and order_create webhooks like 'topic' => 'products/update','topic' => 'orders/create' in this template code ?
The text was updated successfully, but these errors were encountered: