Shopify Webhook not working for app/uninstalled

Dev_Shopify_1_A
Shopify Partner
23 0 5

I've created a shopify app with PHP. and registered a webhook for 'app/uninstalled'. Which will remove data from my database.

But when I delete this app the webhook isn't triggering. Because the store isn't removing from my database.

Here is my code:

`POST /admin/webhooks.json
'webhook'  => array(
    "topic" => "app/uninstalled",
    "address" => "https://my-domain/apps/app-name/uninstall.php",
    "format" => 'json',
 ),`

Can anyone tell me what is the problem and what things should I need to edit?

I've tried for a long time but now I'm stuck with this....

Felix2
Shopify Partner
98 0 16

Can you see a request from the webhook in your webserver log?

How do you parse the shop name from the request?

Looga.io
0 Likes
Dev_Shopify_1_A
Shopify Partner
23 0 5

I've parsed the shop name by $_POST['X-Shopify-Shop-Domain']. Here is my code:

$shop_domain = $_POST['X-Shopify-Shop-Domain'];
$sql = "DELETE FROM install WHERE SHOP_DOMAIN=$shop_domain";

 

0 Likes
Felix2
Shopify Partner
98 0 16

Do you see requests coming to your webserver in the logs?

I'm not sure whether $_POST returns headers, too.

Looga.io
0 Likes
Josh
Shopify Staff
Shopify Staff
1131 82 191

While I won't be as much help with the PHP coding itself in all honesty - if you could provide the shop you've uninstalled the app from and the timeframe in which it happened, I'd gladly check our logs here for you to ensure the webhook is firing as expected.

From my interpretation of $_POST (which I found here) this will also only work properly when application/x-www-form-urlencoded or multipart/form-data are used as the Content-Type in the request, and webhooks from us should be sending application/json as the Content-Type instead. I could be misinterpreting this though given that I'm not a PHP developer.

Perhaps that would explain the issue here? As Felix mentioned though I'd definitely recommend checking out your own server logs as well, I think the answer to this will probably be found there.

0 Likes
Jay_El-Kaake
Tourist
12 0 2

I'm not sure if this is related but today we noticed that we stopped getting uninstallation webhooks. We're 100% certain the webhook is installed and it was working perfectly before yesterday and we didn't change anything.

Other webhooks are working fine, it's just the uninstall one. We're not even seeing a request come from Shopify at all.

Shameless plug: Banana Stand is a social proof and urgency platform that helps increase conversions. Check it out!
0 Likes
Jay_El-Kaake
Tourist
12 0 2

I checked the webhook logs this morning and it looks like SOME stores are dispatching webhook requests for uninstallations but many are not still.

There are still stores that certainly uninstalled yesterday that still have not received uninstall webhooks.

This would be a minor issue however it is actaully a BIG issue for us because many merchants install then re-install apps in an attempt to test things out, but unless we know that they uninstalled the app we don't know to refresh API details the second time they access the app.

I'm going to escalate this to Shopify further since it's clearly an issue on their end.

Shameless plug: Banana Stand is a social proof and urgency platform that helps increase conversions. Check it out!
0 Likes
Jay_El-Kaake
Tourist
12 0 2

OK another update: it looks like they're working now for all new uninstalls, but old stores that were uninstalled for a short period didn't get webhooks called on them.

We'll have to go clean them up manually.

I'll post back if I see the issue come up again for future uninstalls.

Shameless plug: Banana Stand is a social proof and urgency platform that helps increase conversions. Check it out!
0 Likes
Dev_Shopify_1_A
Shopify Partner
23 0 5

I've also tried with HTTP $_GET. But it is also not working....

@ Felix

0 Likes