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

# How the Shopify Flex Payments App Works

> How the Shopify Flex Payments app processes HSA/FSA payments and handles different cart eligibility scenarios.

## Checking out with Flex

Once the app is installed "Flex | pay with HSA/FSA" will show up as one of the payment options during checkout.
When selected Shopify will send a request to Flex to generate a checkout session to redirect the customer to. As part of
generating the checkout session, Flex will check all the items in the customer's cart and determine its eligibility.

The items in the cart can fall under one of the following:

### All items are HSA/FSA eligible

All items in their cart are HSA/FSA eligible either through Auto Substantiation or a Letter of Medical Necessity. The customer will be presented
with a banner informing them that all items are eligible and to proceed with the HSA/FSA card.

### Some items are HSA/FSA eligible

Some of the items in their cart are HSA/FSA eligible and the remaining items are not. We refer to this scenario as a split cart. In a split cart
the customer is presented with a banner letting them know that some items are eligible while the remaining are not. They're prompted for their HSA/FSA card to pay for the eligible products, and their credit card for the items that aren't eligible.

The steps for a split cart are:

1. Place a temporary hold on the HSA/FSA payment for the HSA/FSA eligible amount.
2. Process the credit/debit card for the non eligible amount.
3. Capture the HSA/FSA funds that were placed on hold.
4. Redirect to the shopify order completion page.

On the shopify side, this appears as a single order.

### Not eligible

None of the customer's items in the cart have been deemed as HSA/FSA eligible. A banner informs the customer that none of the items in their cart are HSA/FSA eligible. They're then prompted to proceed with their credit card to complete the purchase.

Flex optimizes for conversion which is why we prompt the customer to proceed with their credit card. Our research shows that restarting the checkout session process converts worse than prompting the customer for a credit card.

## Fulfillment

When a customer checks out with Flex you'll see the order processed as it would be for any other payment method. The only difference is in the order details page,
the payment gateway specified will be "Flex".

> [card] [Install the Flex Extensions app](https://docs.withflex.com/merchant-success/website/flex-extensions.md)
>
> The Flex Extensions app (formerly Flex Marketing) is required for HSA/FSA checkout. It syncs your catalog to Flex, keeps HSA/FSA eligibility up to date on your products, and adds eligibility badges and blocks to your storefront.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.