Skip to content

Commit

Permalink
Fix check for billing was missing after shop auth
Browse files Browse the repository at this point in the history
  • Loading branch information
a47ae committed Apr 29, 2024
1 parent 79ba8f4 commit 8a3929b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Http/Middleware/EnsureShopifyInstalled.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Codelayer\LaravelShopifyIntegration\Events\ShopifyAppInstalled;
use Codelayer\LaravelShopifyIntegration\Lib\EnsureBilling;
use Codelayer\LaravelShopifyIntegration\Lib\ShopifyOAuth;
use Codelayer\LaravelShopifyIntegration\Models\ShopifySession;
use Illuminate\Http\Request;
Expand All @@ -28,10 +29,21 @@ public function handle(Request $request, Closure $next)
return $next($request);
}

ShopifyOAuth::authorizeFromRequest($request);
$session = ShopifyOAuth::authorizeFromRequest($request);

event(new ShopifyAppInstalled($shop));

if (config('shopify-integration.billing.required')) {
[$hasPayment, $confirmationUrl] = EnsureBilling::check(
$session,
config('shopify-integration.billing')
);

if (! $hasPayment) {
return redirect($confirmationUrl);
}
}

return $next($request);
}
}

0 comments on commit 8a3929b

Please sign in to comment.