#asdfgh-p24
1 messages · Page 1 of 1 (latest)
Hi there, if they have already completed authentication, then it shouldn't be possible to cancel the PaymentIntent as it should move to succeeded at that point. You would need to refund the payment in that case and there is no way to return it instantly.
Okay
But maybe is there different way
Maybe I will present my use case
My platform is event app, where customers can buy tickets
Every event has limited amount of tickets
Customer see realtime data with available amount
And if they are already in checkout and number of tickets left is small, they see message which says 'There are only 5 tickets left in the pool'
If someone buys a ticket during this time, the number is automatically reduced
I would not like to make any reservations for tickets
And if a user creates a session and during this time the tickets sell out, I would like to cancel the session
Yeah makes sense. The only two ways really to handle this are to either show a message if they authenticate after there aren't available tickets and then refund that customer (not a great experience for them as it will take several days for the refund to process). Or, to basically not allow other folks to start a payment attempt until the result of each confirmed PaymentIntent is handled.
But there is no way to cancel the authentication here. If you cancel the PaymentIntent while they are authenticating and then they do successfully authenticate, then the payment will fail but the money will still be pulled and later refunded.
Okay, so basically I need to make reservations for them if they already created payment intent, right?
Once they have confirmed the PaymentIntent.
As in... when they hit "Pay"
Assuming that is when you confirm the PaymentIntent
Depends on what Element you are using for when you create the PaymentIntent.... not sure if you are creating that on page-load or upon payment.
I am using Flutter stripe plugin, and I am presenting a payment sheet
Something like that
Gotcha, not super familiar with Flutter, but you likely want to trigger the reservation when they hit Pay to present the Payment Sheet.
Then you check on whether inventory remains or not
If it does not, you show an error message
Then based on the result of Payment Sheet you can either allow future customers to pay or not.
Yess, but this is the solution which I wanted to avoid, because if user will minimize the app and go to sleep or something, he will still have a reserved ticket
And if he already has been redirected to the p24 page, i cannot cancel his payment intent, because, he can come back later and pay
Ah sorry, not when they hit "Pay"
That is after the Payment Sheet was already presented
When you actually present the Payment Sheet
I assume you have some other button to trigger that.
To be clear, you are basically giving the customer a "pending reservation" in this case.
You don't actually provide them the reservation until they complete payment.
But you stop others from going through the payment flow until you know what has happened with the pending reservation.
But in this case, he still can has this pending reservation for long time as I described
The confirmation should time out, I believe?
Hmmm actually you may be right.
It might just sit in requires_action
Since you are offering card as well
If they select p24 and redirect, then it will time out
But.... that isn't true for if they just open the Payment Sheet and then close the App
Hmm let me think for a moment.
The confirmation should time out, I believe? - thats right
If they don't action the PaymentSheet I'm not sure it will though
I'm looking further into this to get specific behavior for Payment Sheet here
Give me a moment
Okay yeah so the best thing to do here is to implement your own timeout if Payment Sheet isn't actioned. This isn't perfect, but basically if that customer comes back to Payment Sheet after say, 10 mins, then you just refund them because no more inventory. That is pretty unlikely to occur.
Actually you can even just dismiss the Payment Sheet yourself if they don't action it.
I understand, but this approach can lead to a lot of negative reviews for the app, because if user session will time out and user will come back and pay on the p24 page, he wont get money back instantly
No that is a different scenario though.
Once they are redirected to p24 they have confirmed the PaymentIntent
Can I detect that in some way?
If the users session times out, you dismiss the Payment Sheet so they can't pay at all.
Then if they come back you check inventory.
You would need to poll your server to retrieve the PaymentIntent and check its status.
So every ~5 seconds you check on whether the PaymentIntent is still in requires_action
Okay, so then i cannot use the flutter stripe library, because it has async method presentPaymentSheet(), which I need to await, and its execution ends only after successful payment or method throws an exception in case of canceling
And still I need to make a reservation on the P24 page on which the user may be for a very long time
But I think it is the final compromise
Yes... I don't remember the timeout length for p24. You likely need to test that out.
But also, the likelihood that the customer sits on the p24 page for a long time is low.
This should really be an edge-case you are solving for.
Which is worth doing imo, but it shouldn't happen often.