Where if there is no error I will call a livewire event to create an order/user through PHP right then and there. My only issue is what happens if after Stripe processes the payment for some reason (internet or just something) we never hit the stripe.confirmCardPayment function. Does this happen? I honestly trust webhooks a little more but also hate using them since they seem harder to test and are less versatile on what I can pass Stripe through meta data.
@packyconfirmCardPayment is what will make the actual charge. You should then be only creating an order and fulfilling any items after the PaymentIntent is completed. Stripe’s documentation does go over this:
Stripe sends a payment_intent.succeeded event when the payment completes. Use the Dashboard, a custom webhook, or a partner solution to receive these events and run actions, like sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.
Thanks for the info, I have used that webhook before. I guess my question is why cant I use the JS to just fulfill the order? In their docs it makes it seem that this a valid way to do it, and which I have done it this way, I am just curious if there is more odds something can break in the flow by not using a webhook
from Stripe on using custom payment flow
stripe
.confirmCardPayment(clientSecret, {
payment_method: {
card: card
}
})
.then(function(result) {
if (result.error) {
// Show error to your customer
showError(result.error.message);
} else {
// The payment succeeded!
orderComplete(result.paymentIntent.id);
}
});
@packy Because of the reasons Stripe will list in the documentation.
Whilst on your page, a user could potentially close the browser in between the payment being completed and your orderComplete function firing and completing. In which case you will have charged someone’s card but not created the corresponding order.