How Checkout Works

How Checkout Works

Learn how to use checkout to collect HSA/FSA payments on your website.

Flex provides a hosted checkout page that allows businesses to accept HSA/FSA as a payment method. Flex takes care of ensuring your customer's remain compliant with the IRS.

Flex Checkout supports payments for both one-time purchases and subscriptions.

Checkout lifecycle

  1. When customers are ready to complete their purchase, your application creates a new Checkout Session.
  2. The Checkout Session provides a URL that redirects customers to a Flex-hosted payment page.
  3. Customers enter their payment details and intake form if applicaple on the payment page and complete the transaction.
  4. After the transaction, a webhook fulfills the order using the checkout.session.completed event.

Checkout Session

The Checkout Session is a programmatic representation of what your customers see on the payment form. After creating a Checkout Session, redirect your customers to the Session’s URL to complete the purchase. When customers complete their purchase, you can fulfill their orders by configuring webhooks on Checkout Session events. T his code snippet from the quickstart guide is an example of how to create a Checkout Session in your application.

curl --request \
  --url \ \
  --header 'authorization: Bearer fsk_MzkxYzU2MTAtZGYxOC00OWUyLThlODQtYTA0ODMwNjhiYmVm' \
  --header 'content-type: application/json' \
  --data '{"checkout_session": {"line_items": [{"price": "fprice_01HT5GKN33F6E31WE2RF1GYYKH","quantity": 1}],"success_url": "","mode": "payment","cancel_url": "",}}' \

Checkout Session HSA FSA Eligibility Types

Depending on the products or services being purchased a checkout session could fall under one of the following:

  • Not Eligible - None of the items being purchased are HSA/FSA eligible.
  • Auto Substantiation - The items being purchased are on the Eligible Product List or Private Label List.
  • Letter of Medical Necessity - The item being purchased may become eligible via a letter of medical necessity.
  • Split Cart - Some of the items are HSA/FSA eligible and the remaining items are not. A customer will be prompted for both their HSA/FSA card and a credit card.

Flex will determine the type of cheeckout for you based off of the price id's that are passed into the payload when creating a checkout session.

One-time and recurring payments

Allow customers to make one-time payments or subscribe to a product or service by setting the mode parameter in a Checkout Session.

ModePurchase Type
PaymentOne-time purchases
SubscriptionRecurring purchases and recurring purchases with one-time purchases

Complete a transaction

Fulfill orders when a customer completes their purchase by running webhooks after the checkout.session.completed event sends a notification. Webhooks are HTTP calls that run when an event occurs. For example, if a customer doesn’t make a purchase and their cart expires, you can set a webhook on the checkout.session.expired event and return items to your inventory or you can send them a cart abandonment email.