In this episode, we walk through setting up the Stripe card form for our payments page. By the end, you'll have a proper card input field where users can enter their card details—though we won't submit payments just yet (that's coming in the next video).
We kick things off by talking a bit about payment intents and why you shouldn't keep creating a new intent every time someone reloads the payment page. For now, we leave it as is just to get things working, but we'll loop back and tidy up that logic later.
The main focus here is creating the view for the payment form. We set up a new Blade template in Laravel and use Alpine.js to make our form interactive. We also pull in the Stripe.js library—adding it to our main layout so Stripe can do its thing on every page (this helps with things like fraud detection).
After that, we set up the basic structure of the card form, initialize Alpine.js components, and connect everything with the Stripe API using our public key straight from config. You'll see how easy it is to mount the Stripe Card Element onto the page and visually confirm it's working by typing in card information.
Finally, we add a payment button (using Laravel Breeze's Blade components for quick styling) and wire up a submit handler with Alpine. For now, it just logs to the console, but everything's in place to start processing payments in the next episode. If you're curious where that button styling comes from, we also show you how to check the Blade components directory so you can customize as needed.
So, by the end of this episode, you'll have Stripe's secure card input form rendering on your Laravel site and ready for the final payment step next time!