marosmjartan's avatar

Stripe payment integration into Laravel

Hi guys! I'll be honest, I've never integrated a payment gateway before. But finally the "first-time" came, and I'm very confused. In recent days, I have been trying to understand the process of integrating a payment gateway into my laravel project, but without success. Well, after looking at about 50 different tutorials, and reading perhaps all the possible documentation, my despair brought me here. Of course, after all that, I understood something, but I still can't solve my problem.

So what's the problem?

Let's say my app provides digital services. It can also be thought of as an authorization that allows the user to access otherwise locked parts of the site. However, this "authorization" is not free, so the user will have to pay for it. I use Laravel, inertia, and vue stack. So I chose to do all the stripe fun on the front end, using the vuestripe package (https://vuestripe.com/). Nice, this will create a button for the stripe-secure checkout where the whole payment will take place. And here comes the problem. Where, when, and how do I apply my backend logic?

There's something called stripe webhooks. It's the thing that sends a request to my server if, for example, the payment is successfully received. Nice, so now I can trigger my backend logic! or not? There is another problem. There are several such products on my website and each requires a specific backend logic. And you can't (at least as far as I know) set a different webhook for each product in the stripe. And even in the request that sends the stripe, there is nothing like a product_id or something.

Ok, I found another solution. Use something called "stripe elements". Stripe will give me input for entering card details, which will generate some token. I'll send it nicely to my backend. And there I charge the credit card. And then I can do my backend fun there. Sounds like a solved problem, doesn't it? Unfortunately, no. Especially for European cards, there is something like a 3D secure code, in essence, it is 2-factor authentication, managed by a user bank. And I have no idea how to catch this.

I guess, I didn't quite understand something, because, across the first page of Google, I didn't find anyone with similar questions and problems.

I would like one of you to advise me and point me in the right direction, refer me to some documentation or a clear course or something that has also helped you to master this topic.

0 likes
6 replies
jlrdw's avatar

I would also look at some of the videos on payments right here on laracast and look at the documentation as well for cashier which works with stripe.

marosmjartan's avatar

Laravel cashier came to me rather than a subscription handler. I just want a simple one-time payment. And I want to run the backend logic after paying ... nothing more complicating. Is it even possible?

jlrdw's avatar

The back and logic goes hand-in-hand with making the payment through the stripe payment Gateway.

Also, look at laravel spark.

Sabawoon-Yaqubi's avatar

Hello marosmjartan i am fencing some issue like you i want to implement the stripe payment with laravel and vue-stripe but vue-stripe i can pay but i don't know how to store the return response from stripe if you shear youe source code with me i will be so happy Thanks

Please or to participate in this conversation.