gnikyt / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
1.24k stars 374 forks source link

app/uninstalled webhook is not dispatched when the app uninstalled #548

Closed hameed-kurla closed 4 years ago

hameed-kurla commented 4 years ago

I have enabled the webhooks in config as below and its not working as expected AppUninstalledJob is not dispatched.

'webhooks' => [ [ 'topic' => env('SHOPIFY_WEBHOOK_1_TOPIC', 'app/uninstalled'), 'address' => env('APP_URL') . '/webhook/app-uninstalled') ], ],

Expected Behavior

When the app is uninstalled expected to dispatch AppUninstalledJob and the should softdelete the shop in the User table

Current Behavior

When the app is installed WebhookInstaller job is dispatched with the payload as below and registered the app/uninstalled webhook successfully, however upon uninstalling the app from the store the AppUninstalledJob is not dispatched.

Payload: {"uuid":"f6142955-a188-4b78-9026-bf8c2c125f84","displayName":"Osiset\ShopifyApp\Messaging\Jobs\WebhookInstaller","job":"Illuminate\Queue\CallQueuedHandler@call","maxTries":null,"maxExceptions":null,"delay":null,"timeout":null,"timeoutAt":null,"data":{"commandName":"Osiset\ShopifyApp\Messaging\Jobs\WebhookInstaller","command":"O:49:\"Osiset\ShopifyApp\Messaging\Jobs\WebhookInstaller\":11:{s:9:\"\u0000\u0000shopId\";O:39:\"Osiset\ShopifyApp\Objects\Values\ShopId\":1:{s:6:\"\u0000\u0000int\";i:1;}s:23:\"\u0000\u0000createWebhooksAction\";O:40:\"Osiset\ShopifyApp\Actions\CreateWebhooks\":1:{s:12:\"\u0000\u0000shopQuery\";O:38:\"Osiset\ShopifyApp\Storage\Queries\Shop\":2:{s:8:\"\u0000*\u0000model\";s:15:\"App\Models\User\";s:6:\"config\";a:27:{s:5:\"debug\";b:0;s:17:\"manual_migrations\";b:0;s:9:\"namespace\";N;s:13:\"job_namespace\";s:10:\"\App\Jobs\\";s:6:\"prefix\";s:0:\"\";s:17:\"appbridge_enabled\";b:1;s:17:\"appbridge_version\";s:1:\"1\";s:8:\"app_name\";s:18:\"Cogent Shopify App\";s:11:\"api_version\";s:7:\"2020-01....................

Failure Information

AppUninstalledJob is not dispatched on uninstalling the app.

Steps to Reproduce

  1. Install app to Shopify store
  2. Uninstall app from Shopify store

User table deleted_at not set

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

Please include any relevant log snippets or files here.

Kyon147 commented 4 years ago

Also, are you testing the webhooks via ngrok or some sort of proxy? They can be very temperamental when trying to use them in this setup.

gnikyt commented 4 years ago

I just created a new app yesterday and tested the uninstall, it worked as intended (using Redis as a backend for Laravel Queue).

Papertrail logged the request about 5 minutes after uninstall.

According to your toolset, you're using Laravel Homestead. So either you're trying to use localhost URIs or passing through a tunnel with something like ngrok as @Kyon147 mentioned. If ngrok, you'll have mixed results.. it seems one of the big issues in my findings is going from https to http, the data gets lost.

gnikyt commented 4 years ago

Closing.