Stuck on the same issue @greevesh did you figure this out?
Stripe\Exception\InvalidRequestException: No such plan:
I'm trying to create a subscription with Laravel Cashier and Stripe. My post request that subscribes a user is successfully being passed onto the Stripe back-end. I know this because I've checked the Stripe logs and the requests have statuses 200.
Wonderful.
Despite Stripes approval, Laravel is actually throwing an exception whenever I submit the subscribe form: Stripe\Exception\InvalidRequestException: No such plan: yearly_plan.
yearly_plan is the ID I've given one of my subscription plans that the user gives and the Stripe API retrieves.
The ID's I've given for each of the two plans are correct. I've checked multiple times.
// subscribe.blade.php
<select class="form-control" name="plan" id="plans">
<option selected value="">Choose a plan</option>
@foreach($plans as $planId => $planName)
<option value="{{ $planId }}">{{ $planName }}</option>
@endforeach
</select>
// SubscribeController.php
public function storePaymentMethod()
{
$user = Auth::user();
// if user is logged in
if (!$user)
{
return redirect('login');
}
$plans = [
'plan_H1SbSi9r1YhXNG' => 'Monthly',
'yearly_plan' => 'Yearly'
];
return view('subscribe', [
'intent' => $user->createSetupIntent(),
'plans' => $plans
]);
}
public function subscribe(Request $request)
{
$user = Auth::user();
$paymentMethod = $request->paymentMethod;
$plan = $request->planId;
if (!$user->subscribed())
{
// 'create' method will automatically store customers payment method
$user->newSubscription('subscription', $request->plan)->create($paymentMethod);
}
redirect()
->route('confirmation')
->with('subscriptionSuccessMessage', 'You have successfully subscribed. See you around!');
}
Please or to participate in this conversation.