Oct 20, 2019
0
Level 8
How to check if user is subscribed to some stripe's plan
Hello, In my Laravel 5.8 I search how to check if used is subscribed to some stripe's plan. I make subscription with stripe and I have installed
"stripe/stripe-php": "^7.2",
"laravel/cashier": "^10.3",
In app/User.php :
use Laravel\Cashier\Billable;
...
class User extends Authenticatable implements MustVerifyEmail
{
use Billable;
use Notifiable;
When I ned to subscribe to stripe's plan I make :
$ret= $user->newSubscription('main', 'plan_ID')->create($requestData['purchaseDetails']['payment_token']);
where plan_ID is id of plan registered at stripe dashboard
Searching for checking subscribed method I found and tried:
if( Auth::user()->subscribed( 'main', $item['stripe_plan_id'] ) ) {
die("-1 XXZ === subscribed");
}
I tried stripe_plan_id or stripe_plan_name - but failed in both cases
Also I tried :
$user->subscriptions
but it returned empty array. In Stripe dashboard I see that logged user is subscribed to stripe_plan_id... Which way is correct ?
Thanks!
Please or to participate in this conversation.