jeudi 17 octobre 2019

How to check if used is subscribed to some stripe's plan

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 ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OUD5r5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire