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

jjmu15's avatar

Laravel Cashier with React Stripe Library

Has anyone managed to hook Laravel Cashier up with the Stripe React frontent library for subscription payments?

I'm really struggling despite reading both sets of documents multiple times how to hook them up.

I've also tried googling extensively but there seem to be next to no results about using Laravel Cashier with React.

Thank you in advance for any help you can give. I'm tearing my hear out a little here.

0 likes
8 replies
martinbean's avatar

@jjmu15 We’d probably be able to help more if you told us exactly what issues you were facing?

The Stripe React library will just be a set of a pre-built components that let you create payment methods using Elements, that you then submit to your server to work with subscriptions.

jjmu15's avatar

Apologies.

Specifically i'm looking for the flow to enter card details and use those right away to sign up to a recurring subscription.

As far as I can tell Laravel Cashier only supports the setupIntent method which gets applied to the react elements library in stripe for the card field to store it as a payment method to be used at a later date but instead of that I want to have one single entry of card details during signup which are then used to create a recurring subscription.

What would be the flow for that?

jjmu15's avatar

Just bumping this to see if anyone has any suggestions or advice.

Thanks in advance.

jjmu15's avatar
jjmu15
OP
Best Answer
Level 6

OK so I finally figured it out.

The problem was that the React Stripe library documentation is incomplete as far as I can tell. They only provide an example for setting up a single payment intent with React rather than a subscription. The page in question can be found here (https://stripe.com/docs/stripe-js/react).

Behind the scenes of this is the standard Stripe elements library so what you need to do is set it up using the structure of the React Stripe documentation but then instead of using the stripe.createPaymentMethod() method they suggest, use the stripe.confirmCardSetup() method instead.

The documentation for stripe.confirmCardSetup() can be found here: https://stripe.com/docs/js/setup_intents/confirm_card_setup

The object structure at this point is the same so just hook that method into your react setup from the previous steps and it should work.

1 like
laugre's avatar

Hi, Good to know that you figured it out.

I want to use Stripe to manage my customer subscriptions and I need to integrate it with a Laravel backend API working with a React frontend.

I'm a bit confused with the workflow too.

Could you tell me if I'm on the wrong way plz ?

I think I have to use Laravel Cashier to deal with stripe and manage customer subscriptions, backend side. I need to create backend API routes for front deal with back subscription controller. What is React Stripe library for ? Is it just a set of UI components as form inputs to enter subscriptions infos or does it directly deal with stripe account and what for ?

Thx for your answer.

1 like
jjmu15's avatar

Yes, your logic is correct with using the API endpoints to use Laravel Cashier methods.

The React Stripe library is some of the fancy javascript they use to allow you to take payments on page without needing to leave the site. Sometimes you need levels of PCI compliance that are quite hard to obtain to take payments on-site without a lot of extra work but by using some additional security in the frontend they can secure the requests.

Anyway, you need to register the request with the frontend component and then send that data to Stripe via the Laravel Cashier methods.

I hope this clears things up a little better.

1 like
zenmiami's avatar

@laugre I am having the same conceptual issue. How to use cashier. From what I see the developer has a choice. We can use the react library and handle it all in the front end - or - hard code the UI and capture the CC information and pass it to the controller to allow the cashier code to handle the rest. For me, I am leaning to use the react library and skip the cashier code because I'm uncertain and haven't found any reliable example that wasn't in the weeds.

Racc00n's avatar

Hello, I am also trying to make an application that uses subscriptions. I am trying to make it with Laravel Cashier (Stripe), Laravel Passport API (for the api part) and ReactJS (as frontend).

As @laugre also said, I'm confused too about the whole setup I need to do. So I have a question for you or anyone that has over done this.

I know it may be a lot that I am asking but I would appreciate if someone could help me.

Does anyone already have a setup with the things I wrote above or maybe an example I can look at. Personally seeing an example makes me understand it better and quicker than using the documentation.

I know it is a lot and it is really big. I am just curious.

Thank you for your answer

Please or to participate in this conversation.