Home > Blockchain >  Are Stripe's Checkout Sessions stored "forever"?
Are Stripe's Checkout Sessions stored "forever"?

Time:10-17

Using stripe's API and the Integration Builder, before you go to the checkout page, you can get the id of the Ceckout Sessions in the create-checkout-session.php file. (enter image description here

  • Get the customer (customerId) and subscriptionId from the session retrieve api response and store both into database for later use.
  • Further to get the customer information, you can use the customer api and pass the customerId to get the detailed information about that customer.
  • enter image description here
  • Similarly, you can use the subscription api to retrieve the particular subscription.
  • enter image description here
  • CodePudding user response:

    To be clear,

    • You can retrieve the full details of a Checkout Session any time using the API : https://stripe.com/docs/api/checkout/sessions/retrieve. There is no "expiry" for this.
    • You can only access the full data of an Event e.g. checkout.session.completed if it was created within the last 13 months from the Dashboard. Events older than 30 days will only provide a summary view. Events within the last 30 days will be fully visible via the API and Dashboard. (source)
    • A Checkout Session expires 24 hours after they’re created (i.e. the customer cannot access/pay via the Checkout url), but you can shorten the expiration time by setting expires_at (source). Note that you can still access the details of the Checkout Session as mentioned in the first point.

    Ideally, you should rely on webhooks :

    The checkout.session.completed event will contain the customer and subscription.

    • Related