laravel-shopify: App Uninstall webhook is not working

I have created app uninstalled webhook. But it did not work after uninstall the app it did not add deleted _at value in users table. Kindly check source code in Job.
`public function app_uninstalled_job($shop) {

    try {

        $shop = User::where('name',$shop)->first();
        info($shop);
        
        PixelDetail::where('shop_id',$shop->id)->delete();
        PixelEvent::where('shop_id',$shop->id)->delete();
        PixelProduct::where('shop_id',$shop->id)->delete();
        
        $shop->delete();
        
        
        $dir = base_path().'/pull/'.$shop->name;
        
        $this->rrmdir($dir);
          
    }
    
    catch(\Exception $e) {
        
        Log::error($e->getMessage());
        
    }

}

public function rrmdir($dir)
{
    if (is_dir($dir))
    {
         $objects = scandir($dir);
        
         foreach ($objects as $object)
         {
               if ($object != '.' && $object != '..')
               {
                    if (filetype($dir.'/'.$object) == 'dir') {rrmdir($dir.'/'.$object);}
                    else {unlink($dir.'/'.$object);}
               }
         }
        
         reset($objects);
         
         rmdir($dir);
     }
}`

Please check output Screenshot.

Screenshot_17

Kindly resolve the issue. Thanks

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Did you use this to generate your app Uninstall job class?

php artisan vendor:publish --tag=shopify-jobs

And then inside shopify-app.php you need to add this too:

 'webhooks' => [
        [
            'topic' => 'APP_UNINSTALLED',
            'address' => 'https://(your-domain).com/webhook/app-uninstalled'
        ],
    ],

Your address has to end in /webhook/app-uninstalled

And then once you have done those steps then you have to uninstall and reinstall your app for the webhooks to take effect.