Techno
Techno

Reputation: 55

Laravel cashier with stripe : no such plan error?

I have created a Plans table with some data. When I am trying to subscribe the plans, Laravel-Cashier says : No Such Plan.

What I am missing?
I also created a plan through Stripe dashboard, but nothing changed. How can I overcome this issue?

Here is my code :

Plans table have following fields:

protected $fillable = [
    'id',
    'name',
    'stripe_plan',
    'cost',
    'interval',
    'currency',
    'description'
];

And controller code is:

public function create(Request $request)
{
    // Getting choosed plan
    $plan = Plans::findOrFail($request->plan);

    $entity->newSubscription($plan->id,$plan->stripe_plan)->create($request->stripeToken);
    //I tried put hardcoded plans, but still same error
    //    $entity->newSubscription('phone', 'phone')->create($request->stripeToken);
    return redirect()->route('plans')->with('success', 'Your plan subscribed successfully');
}

Upvotes: 2

Views: 1256

Answers (1)

Techno
Techno

Reputation: 55

I passed the plan_id as second param of newSubscription method, which i created in stripe portal and working fine. Also passing plan-name was not working, so i passrd the id of plan like this

$entity->newSubscription('primary', 'plan_EBttg1ziShQ51I')->create($request->stripeToken, [ ]);

but it's strange for me, bcoz if we have multiple plans then how can i pass different plan...

Upvotes: 1

Related Questions