Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No such plan: monthly; one exists with a name of monthly, but its ID is primary Laravel Cashier

Getting this problem in Stripe test. Everything used to work in test, but when I created a new plan in Stripe, and deleted the original one, I now get the following error:

No such plan: monthly; one exists with a name of monthly, but its ID is primary.

Controller

$user->newSubscription('primary', 'monthly')->create($token, [ ]);

Plan details

ID: primary
Name: monthly
Price: $19.99 USD/month
Trial period: No trial

php artisan config:clear doesn't help. I'm using Laravel 5.2 and Cashier 6.0.

.env file

STRIPE_KEY=pk_test_...
STRIPE_SECRET=sk_test_....

config/services.php

'stripe' => [
    'model'  => App\User::class,
    'key'    => env('STRIPE_KEY'),
    'secret' => env('STRIPE_SECRET'),
],
like image 706
user3489502 Avatar asked Jan 05 '23 04:01

user3489502


1 Answers

It is important to differentiate between a Product identifier and a Plan identifier. Perhaps stripe has changed since many of the tutorials were written. It took me a few hours of searching to recognize this. As I'm new to stripe, it was easy to find the Product and Product Id, but the Plan Id was harder to find. In fact I had to "export plans" to a CSV from the product page to even get the ID for plan Id.

Hopefully this helps someone who was lost like I was

like image 159
Peter Avatar answered Jan 13 '23 08:01

Peter