In this episode, we're focusing on making sure that we only create orders after a successful payment has gone through. We walk through how to call the checkout method in our LiveWire component once the payment is complete, and importantly, we double-check the payment status on the server side before proceeding.
You'll see how we verify that the payment intent's status is actually succeeded
—this way, there's no way an order can sneak through without a confirmed payment. If the payment fails for any reason, the order won't be created and we'll notify the user appropriately with a message. This gives us a really robust and safe checkout flow.
We spend some time testing this out, clearing the cart's payment intent, entering new card details, and going through the order process to make sure everything is working as expected. There's also a quick tip about running Mailhog to catch those order confirmation emails while testing.
By the end of the episode, you'll have a solid server-side check in place so that orders are created only when payment is confirmed—no risks of unpaid orders slipping through!