darkdiamond
darkdiamond

Reputation: 353

How to set a timeout for a stripe session checkout?

Is there a timeout for a customer to make their payment and can it be changed ?

Let me explain my situation :

I have to add the payment on a PHP booking platform.

To ensure that a time slot is not reserved several times, the platform blocks the reservation for 20 minutes when the user clicks on the reserve button. If he has not completed filling in his information after this time, he must start again or if he does not finish, the reservation is released.

I should be able to make sure that the payment is a maximum of 5 minutes long. In this way, I initiate the payment after maximum 15 minutes after the start of the reservation.

It’s the easiest way I’ve found to not touch up the whole code. Unfortunately, I can't find this option in the API.

Otherwise, if I block the reservation permanently before the payment process, I have no method to unblock it if the user does not complete the transaction by closing their browser.

Upvotes: 22

Views: 20947

Answers (2)

Simon Ness
Simon Ness

Reputation: 2540

There's a Manage limited inventory with Checkout documentation page that explains that Stripe Checkout supports both manual and timed session expiration.

Timed session expiration must be between 30 minutes and 24 hours at the time of writing, so for your use case you'll need to manually expire the checkout session.

Upvotes: 3

Justin Michael
Justin Michael

Reputation: 6475

When a Checkout Session is created it has a Payment Intent associated with it (no longer true in more recent API versions, see Update 2 below for details). You can cancel that Payment Intent when you release the reservation, which will prevent the customer from paying.

Update: You can now set expires_at when creating the Checkout Session:

The Epoch time in seconds at which the Checkout Session will expire. It can be anywhere from 30 minutes to 24 hours after Checkout Session creation. By default, this value is 24 hours from creation.

You can also now explicitly and immediately expire a Checkout Session using the dedicated "Expire a Session" API endpoint.

Update 2: As of API version 2022-08-01 Checkout Sessions in payment mode no longer create a Payment Intent immediately:

  • A PaymentIntent is no longer created during Checkout Session creation in payment mode. Instead, a PaymentIntent will be created when the Session is confirmed.

Upvotes: 39

Related Questions