Laravel with Stripe returns "No such plan: 1 error"

Viewed 2103

I am using Laravel for payment gateway. For payment gateway I use Stripe. When I run this code it will show me:

No such plan: 1 error

Controller:

public function create(Request $request, Plan $plan)
    {
        if($request->user()->subscribedToPlan($plan->stripe_plan, 'main')) {
            return redirect()->route('home')->with('success', 'You have already subscribed the plan');
        }
        $plan = Plan::findOrFail($request->get('plan'));
        $stripeToken = $request->stripeToken;
        $user = $request->user();
        $stripeplan = $request->stripe_plan;
        $planid = $request->plan;

        $user->newSubscription($stripeplan, $planid)->create($stripeToken, [ ]);

        return redirect()->route('home')->with('success', 'Your plan subscribed successfully');
    }
1 Answers

Go to stripe account, create 2 payment monthly & yearly on products. Remember while creating product you should give it id. Ex. 1 for monthly & 2 for yearly. Then run it again.

Related