Integration
Checkout
Off Session Checkouts

How Off 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

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. 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
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