Manage limited inventory with Checkout
For some types of limited-inventory businesses, it’s necessary to limit who can complete a purchase during a specific time window. For example, a ticket seller might want to limit a Checkout Session to be valid for only a few minutes before it expires and disallows purchases. After it expires, the seller could offer the ticket to the next customer without risk of both customers completing a purchase for the same unit of inventory.
Checkout supports two methods of managing limited inventory.
Manual expiration
To control Checkout Session expiration dynamically, use the expire endpoint to immediately disallow purchase completion.
When you expire a checkout session, the status property for that session changes to expired
.
Set an expiration time
When creating the Checkout Session, the expires_at
parameter specifies a specific point in the future at which the link becomes invalid. Session expiration must be set to at least 30 minutes in the future.
Return items to your inventory
When a Checkout Session expires, you can use the checkout.session.expired
event with your webhook handler to return items to your inventory by updating or clearing any state in your application. Your webhook endpoint must listen for the checkout.session.expired
event to receive a notification that it can use to clear a state. For more information, see Expire a Session.