#poneciak_payment-inventory
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1237068654617694228
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
poneciak_payment-inventory
@simple tusk we recommend this flow: https://docs.stripe.com/payments/build-a-two-step-confirmation
This lets you create the PaymentMethod first and then do all your tax/shipping calculations as needed and confirm server-side That lets you "hold" the inventory for the person confirming first
in wich step should i lock the items for the client ?
when you are ready to confirm the PaymentIntent
so:
- Server: creates payment intent sends it to the client
yes
uh i sent to early XD
and then then client accepts that intent and pays
and if intent failed i unlock the inventory
You can also use https://docs.stripe.com/payments/finalize-payments-on-the-server if you prefer. Both flows are conceptually similar
and if intent succeeded i change the order status
but yes I would reserve inventory on PI creation and release it after a few minutes, like what ticket concert selling platforms or airline websites do
ok i see there is an event payment_intent.succeeded but is there any event when payment fails
or do i need to specify the time for items to unlock automatically
there's payment_intent.payment_failed. But really you need to add some specific timer on your end since your customer might leave the page and never confirm
Yeah, I just thought about that a moment ago
ok but what if it just took the customer that long to pay
and my API receives success event
That's really up to you to decide!
You own the whole code here, you can block confirmation of the PaymentIntent after the timer
that's exactly what a those website examples I gave you would do
ok but in this flow
https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web&type=payment#web-fulfillment
I create and submit the payment to stripe and then client handles any next actions and what if those actions take too long
yes but you are the developer here, you handle the confirmation client-side. so you can block the confirmation after 10 minutes.
You can also cancel the PI if it's too late so that they can;'t pay it again
or you can reset the timer if no one else is buying and updated the countdown. Really this is something you need to model based on your own business model.
Sure thing!