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

# HSA/FSA payment links

> Create a link a shopper pays with an HSA/FSA card, share it, and read its payments

A payment link is a page a shopper opens to pay for set items with an HSA/FSA
card. These are the links the merchant app shows under Payments. The roots are
**experimental**: add `@experimental` to each one.

Reads need the `payments_read` scope and writes need `payments_write`. HSA/FSA
payments must be on for the store, which fails with `PAYMENTS_NOT_ENABLED`
otherwise, and links need a Shopify store: a store without one has no links,
and a write fails with `HSA_PAYMENT_LINKS_REQUIRE_SHOPIFY`.

## 1. Find the products to sell

A line takes a `Product` id. Read them with `products` (`products_read`): a line
needs a live Shopify variant priced in USD whose HSA/FSA eligibility Redo knows.

## 2. Create a link

Amounts are `MoneyInput` values in USD. Fields you leave out take the merchant
app's defaults: a single-use link expires 15 days after it is created, and a
reusable one never expires and lets the shopper change quantities.

```graphql theme={null}
mutation CreateLink($input: HsaPaymentLinkCreateInput!) {
  hsaPaymentLinkCreate(input: $input) @experimental {
    id
    url
    state
  }
}
```

```json theme={null}
{
  "input": {
    "usage": "SINGLE_USE",
    "lines": [
      {
        "productId": "prd_…",
        "unitPrice": { "amount": "49.99", "currency": "USD" },
        "quantity": 1
      }
    ],
    "customerName": "Dana Ortiz",
    "customerEmail": "dana@example.com"
  }
}
```

A link the rules refuse fails with `INVALID_HSA_PAYMENT_LINK`, its message
naming the field: for example a discount larger than the items, or a total
below \$2.00.

## 3. Share its url

Send the shopper the link's `url` as given. While its `state` is `ACTIVE`,
shoppers can pay it.

## 4. Read its payments

```graphql theme={null}
query Payments($linkId: ID!, $after: String) {
  hsaPaymentLinkPayments(linkId: $linkId, first: 25, after: $after)
    @experimental {
    nodes {
      paidAt
      amount { amount currency }
      payerName
      payerEmail
      order { name adminUrl }
    }
    pageInfo { hasNextPage endCursor }
  }
}
```

`hsaPaymentLink` returns `paidCount` and `paidAmount` for the whole link.

## 5. Turn it off

```graphql theme={null}
mutation TurnOff($id: ID!) {
  hsaPaymentLinkActiveSet(id: $id, active: false) @experimental {
    state
  }
}
```

New shoppers can't pay a link that is off. A checkout a shopper already started
can still be paid.

## 6. Delete it

Only a link that is off or expired, took no payment, and has no checkout a
shopper may still pay can be deleted. Read `deleteBlockedReason` first: it is
null when the link can be deleted. `hsaPaymentLinkDelete` returns `true` once
the link is gone, and fails with `HSA_PAYMENT_LINK_DELETE_BLOCKED` when it
can't be deleted. A link that took a payment keeps the record of it, so turn it
off instead.


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