> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withflex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Learn how session checkouts work.

When a customer completes a checkout, you can include the `setup_future_use` parameter and Flex will save the customer's payment method for later usage.

Then at any point in the future you may use the Off Session API to charge the customer using that saved payment method, without requiring the customer to be present in the flow or re-enter their payment details.

## Initial (on session) checkout session

This follows the normal checkout flow, with the only difference being that when you create the checkout session your request should include the parameter `setup_future_use` with a value of `off_session`

```bash theme={null}
curl --request \
 POST \
  --url \
 https://api.withflex.com/v1/checkout/sessions \
  --header 'authorization: Bearer fsk_test_YzNiYjdhNWItN2FkOS00ZTMyLWE5MmQtZTdhNzMzYzE2NTIy' \
 \
  --header 'content-type: application/json' \
 \
  --data '{"checkout_session": {"line_items": [{"price": "fprice_01HT5GKN33F6E31WE2RF1GYYKH","quantity": 1}], "setup_future_use": "off_session", success_url": "https://withflex.com","mode": "payment","cancel_url": "https://withflex.com/cancel",}}' \
```

## Verify the customer's payment method

To find your customer's available payment methods, you can use [List Payment Methods API](/api-reference/customers/list-customer-payment-methods). You should see the payment method with a value of `off_session`: `true`. This means that the payment method was successfully saved for future use.

## Off session checkout

Now that the customer has a saved payment method, you can use the off session checkout API to submit charges.

The request payload should look similar to a normal checkout, with a few differences.

* Set the parameter `mode` to `off_session`
* Set the parameter `customer` to the customer\_id
* Set the parameter `payment_method` to be the ID of the saved off session payment method

```bash theme={null}
curl --request \
 POST \
  --url \
 https://api.withflex.com/v1/checkout/sessions \
  --header 'authorization: Bearer fsk_test_YzNiYjdhNWItN2FkOS00ZTMyLWE5MmQtZTdhNzMzYzE2NTIy' \
 \
  --header 'content-type: application/json' \
 \
  --data '{"checkout_session": {"line_items": [{"price": "fprice_01HT5GKN33F6E31WE2RF1GYYKH","quantity": 1}], "mode": "off_session", "customer": "fcus_01JV8Q9SPDQ6PSRSN85FXY924N", "payment_method": "fpm_01JV8Q92PM1QQBP4XHF03CPABZ", success_url": "https://withflex.com","cancel_url": "https://withflex.com/cancel",}}' \
```

## Restrictions

Off session checkouts have some additional restrictions compared to standard checkouts:

* **Letter of Medical Necessity** - If any of the items requires a Letter of Medical Necessity, the customer must already have one on file with Flex
* **No Split Cart** - All the items in the cart must be HSA/FSA eligible in order to pay with an HSA/FSA card
