Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

paduraruionutandrei's avatar

Stripe payment with Laravel

Hello everyone, I have a little problem.I am trying to implement Stripe payment gateway using Laravel Cashier.I setup all the things, but something went wrong.

public function store(Request $request)
{
        $stripeToken = $request->get('stripe_token');

        $user = User::findOrFail(auth()->user()->id);

        $plan = 'enterprise';

        $user->newSubscription('main', $plan)->trialDays(5)->create($stripeToken);
 }

I try to make a simple payment, but the payment is successful and still get this error.

https://imgur.com/a/gbol7kL

The payment is canceled

Thanks in advice!

0 likes
3 replies
fylzero's avatar

Your subscription is already set up in Stripe?

1 like
Cronix's avatar
Cronix
Best Answer
Level 67

Not to do with your problem, but...

$user = User::findOrFail(auth()->user()->id);

Why do you requery the database to get what you already have, which is the current user? Just use auth()->user(), which is the current logged in user instance.

$stripeToken = $request->get('stripe_token');

$plan = 'enterprise';

auth()->user()->newSubscription('main', $plan)->trialDays(5)->create($stripeToken);

That will eliminate 1 query on that page which wasn't necessary.

1 like

Please or to participate in this conversation.