In this episode, we're kicking off the process of handling payments with Stripe by creating a Payment Intent. We take a moment to chat about the two main ways you can process payments with Stripe: the old-school Charges API (easy but pretty basic) and the more modern Payments Intents API. While the latter is a bit trickier to set up, it comes packed with benefits like strong customer authentication (3D secure), less risk of double charges, and just generally more robust handling.
The focus here is on making a new controller in our Laravel app that starts a Payment Intent for our logged-in user. We set up a route, make sure only authenticated users can hit it, and start with a basic placeholder. From there, we interact with the Stripe SDK, define the amount for our transaction (e.g. $100), pick a currency, and add any other key details—especially user ID as metadata. This is important for later, because when Stripe calls back to us after payment (via webhooks), we’ll want to know whose payment it was so we can update records accordingly.
We take a look at this initial intent on the Stripe dashboard, check that our metadata and payment details went through, and discuss the next step: passing the client secret from our new Payment Intent to our (soon to be created) card form. That client secret is the key piece we need on the front end to actually complete the payment.
Stay tuned for the next episode, where we'll wire up the card form and see how it all comes together!