App reviews, troubleshooting, and recommendations
There are three components that allows webhooks to work in Shopify Apps.
A: Loading the handlers
Shopify.Webhooks.Registry.addHandler("APP_UNINSTALLED", {
path: "/webhook/uninstall",
webhookHandler: async (topic, shop, body) => {
// I don't want to process it here. Instead, I want to do it in C directly.
console.log(topic, shop, body);
},
});
B: Register the webhook
const response = await Shopify.Webhooks.Registry.register({
shop: shopSession.shop,
accessToken: String(shopSession.accessToken),
topic: "APP_UNINSTALLED",
path: "/webhook/uninstall",
});
if (!response.APP_UNINSTALLED.success) {
console.log(
`Failed to register APP_UNINSTALLED webhook: ${response.result}`
);
} else {
console.log("webhook registered");
}
C: Process webhook
app.post("/webhook/uninstall", async (req, res) => {
try {
// I want to process the webhook here instead of doing it in A because I need to fetch some user information in the req object.
await Shopify.Webhooks.Registry.process(req, res);
console.log("Webhook processed, returned status code 200");
} catch (error) {
console.log(`Failed to process webhook: ${error}`);
if (!res.headersSent) {
res.status(500).send(error.message);
}
}
});
Is it possible to process the webhook in C instead of doing it in the callback function in A ? If the answer is no. How can I do it so that I can access the req or res object when a webhook is called.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025