Search code examples
laravellaravel-5laravel-cashier

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'),
],

Solution

  • Use this instead :

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

    From documentation :

    The first argument passed to the newSubscription method should be the name of the subscription. The second argument is the specific Stripe plan the user is subscribing to. This value should correspond to the plan's identifier in Stripe.

    So the second argument must be equal to the ID value from my Stripe plan! In this case, that value is primary, not monthly.