3
votes

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'),
],
4
Please don't add your answer to your question. Please add it an answer.Bhargav Rao♦

4 Answers

6
votes

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

1
votes

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.

1
votes

the main issue is that your are passing plan name instead of plan id in second parameter of newSubscription(). it should be like this

$user->newSubscription('main' , 'plan_GNxxxxxxx')->create($request->stripeToken,[ ]);

0
votes

$user->newSubscription('XXXX', 'price_XXXXXXX')->create($request->stripeToken);

Steps:

  1. Create a Subscription for the stripe account (Test Mode).
  2. Under subscription need to create a product with quantity and price and recurring option.
  3. Once product is created you can see a product inside Product menu, click on it and find API ID.
  4. SO finally inside function newSubscription(), first parameter would be the subscription name that you written while creating it and second parameter would be the APP ID under product.