DevelopersAccept payments
Checkout sessions
Create a one-time USDC checkout session from your server, send the payer to it, and reissue or cancel it.
A checkout session is one checkout link for one of your orders. Your server creates it with
POST /v1/, the payer pays on Fianto's hosted checkout page, and Fianto tells your
server when the payment is final. This guide covers one-time payments (mode: payment); for
recurring prices see Subscriptions.
Scroll sideways to see the whole diagram →
Show as text
- From your server, create a session with `POST /v1/checkout-sessions`. The first create returns its `url`; creating again for the same open order returns `url: null`, so reissue the link instead.
- Send the payer to that `url`: Fianto's hosted checkout page.
- The payer's wallet signs the transaction. The wallet only signs; it does not send.
- The checkout page hands the signed transaction to Fianto.
- Fianto broadcasts it to Solana, and rebroadcasts it when needed.
- When the transaction is confirmed, Fianto tells the checkout page, which shows the payer success. The order is not `PAID` yet.
- When it is finalized, the order becomes `PAID`, the payment `SUCCEEDED`, and Fianto sends `order.paid` and `checkout.session.completed` to your webhook endpoint — only at finalized.
Before you start
- Your merchant account is approved. On devnet you can try checkout sessions before approval with a test key: see Checkout sessions before approval.
- You have an application's app id and secret. See Authentication.
- Your receiving wallet has a USDC token account. If it has none, send it any amount of USDC once,
or creating a session fails with
merchant_.token_ account_ missing - You have a webhook route for
order.paid. See Webhooks.
Steps
Decide what the payer pays
Send exactly one of these:
price_id: an active one-time price on an active product, created in the dashboard. The price sets the amount.amountwithdescription: a decimal USDC string from0.01to1000000, with at most 6 decimals, such as"12.50".descriptionis required withamount(up to 1,000 characters). A card can be offered only for an amount in whole cents, from 1.00 to 999,999.99: see Card payments.
line_items (up to 50, each with a name, a quantity and an amount) are shown to the payer only.
Fianto never adds them up or checks them against the amount, so they do not set what the payer pays.
The fees are added on top
On a crypto payment, when the platform's service fee is above zero, it is added on top of your amount and paid by the
payer, in the same transaction, to Fianto's treasury. The fee is rounded down in the payer's favour
and fixed on the session when you create it. The payer also pays the network fee in USDC, with the
service fee. The session's total_amount is amount + fee_amount + network_fee_amount. In
payment mode network_fee_amount is the network fee fixed on the order when its session is
created ("0" on a session from before one-time payments carried it); in subscription mode it is the
plan's network fee (see Subscriptions). A session that is card-only, or that a card
paid, reads currency: "USD", with fee_amount and network_fee_amount "0" and total_amount equal to amount.
Create the session
mode, order_id (your own id, up to 128 characters), success_url and cancel_url are
required. The URLs must be https, up to 2,048 characters. Unknown fields are refused with 400
validation_failed.
curl https://api.fianto.xyz/v1/checkout-sessions \
--user "$FIANTO_APP_ID:$FIANTO_APP_SECRET" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: checkout-order_1001-1" \
-d '{
"mode": "payment",
"order_id": "order_1001",
"amount": "12.50",
"description": "Coffee beans, 1 kg",
"success_url": "https://shop.example/thank-you",
"cancel_url": "https://shop.example/cart"
}'Optional fields:
| Field | Rules |
|---|---|
customer_email, customer_reference | Your own details about the payer |
ui_mode | redirect (the default) or popup |
expires_at | From 5 minutes to 24 hours from now. Default: 30 minutes |
metadata | Up to 20 keys; key up to 40 characters, value up to 500 |
line_items | Display only, see the previous step |
payment_methods | One or two unique values of crypto and card. Leave it out to offer every method the merchant has enabled. ["card"] that no card can serve answers 422 payment_: see Card payments. On a one-time session, crypto covers both a wallet payment and Pay by transfer |
The url comes back only once
The response carries url only when you create a session or reissue its link. Every other read
returns url: null. Creating again with the same order_id while its session is still open
returns that same session with url: null. To get a working link for it, reissue the link (step 5).
Send the payer to checkout
- Redirect (
ui_mode: redirect): send the browser tourl. After a payment succeeds, the page stays on its receipt ("Payment received"), and the payer leaves with Continue to your shop's name, which openssuccess_url; Fianto never sends the payer there on its own. After a subscription starts, the page ("You are subscribed") offers links to the payer portal instead and never openssuccess_url. A cancel goes tocancel_urlat once. An expired session stays on the checkout page. Fianto adds no query parameters to either URL. On devnet, until Fianto approves your business, the page uses neither URL and the payer stays on it. - Popup (
ui_mode: popup): openurlin a popup with@fianto/jsor@fianto/react. When the payer succeeds, cancels or the session expires, the popup posts{ type: 'fianto.checkout', session_id, status }to the origin of yoursuccess_url, then closes. Serve the page that opens checkout from that origin.
The SDK's checkout route helpers always create popup sessions. See the quickstart.
Fulfil the order from Fianto, not from the browser
The checkout page shows the payer a success message once the payment is confirmed. Fianto marks
the order PAID and the payment SUCCEEDED, and sends order.paid and
checkout., only once it is finalized.
success_url is not proof of payment
Reaching success_url, or a popup reporting succeeded, only means the payer's browser believes
checkout finished. Fulfil the order from the order.paid webhook, or from a server-side read that
shows the order PAID.
Reissue or cancel the session when you need to
Reissue the link with POST /v1/ (reissueLink in the SDK). It
returns a new url and the old link stops working. Fianto refuses when the session is not open or
has less than 120 seconds left (session_), when a payment is in progress or the
last transaction prepared for the payer could still land (payment_in_progress), or when Fianto
could not check Solana in time (checkout_, with Retry-After).
Cancel with POST /v1/. Only an open session with no payment in
progress can be cancelled. Fianto sends checkout.; there is no order event, and the
order stays PENDING. The payer can also cancel on the checkout page, with the same result.
import { Fianto } from '@fianto/sdk';
const fianto = new Fianto();
export async function newLink(sessionId: string) {
const session = await fianto.checkoutSessions.reissueLink(sessionId);
return session.url; // the old link no longer works
}
export async function cancelCheckout(sessionId: string) {
await fianto.checkoutSessions.cancel(sessionId);
}Both are POSTs, so the curl form needs an Idempotency-Key too.
Discount codes
Merchants create discount codes (coupons) in the dashboard, and the payer types one on the checkout page. There is no v1 endpoint or SDK method that creates a coupon or applies a code: your server only reads the result. A checkout session and an order carry three fields for it:
list_amount: the price before any discount.discount_amount: what the code took off, in base units;"0"when none.discount:null, or{ "code": "SPRING-25", "duration": null, "periods": null }with the code the payer applied.durationandperiodsare only set on subscriptions.
amount is what is charged, after the discount, so list_amount = amount + discount_amount.
fee_amount is worked out on the discounted amount; network_fee_amount does not change with a
code. A payer can apply or remove a code until they press Pay, so read the amounts from the
checkout. and order.paid events, not from the session you created. On webhook
payloads the three fields are missing on events created before discount codes (October 2026). For
subscriptions, see Subscriptions.
On a session that would offer a card at the discounted price, the discounted amount is rounded down to whole cents
and discount_amount grows to match, so a card and a wallet pay the same. Without a card offer the exact 6-decimal
amount stays.
Session statuses
| Status | Meaning | What you can do |
|---|---|---|
OPEN | Waiting for the payer. The link works until expires_at. | Reissue the link, or cancel. |
COMPLETED | The payment succeeded: a crypto payment once finalized, a card payment once Stripe reports it paid. The order is PAID. | Fulfil the order (from order.paid). |
EXPIRED | No payment was accepted: expires_at passed, or a payment failed after its USDC reached your wallet. | Check the dashboard's Payments chip "Money moved", then create a new session with the same order_id to try again. |
CANCELED | You or the payer cancelled it. The order stays PENDING. | Create a new session with the same order_id to try again. |
Fianto checks for expired sessions every 30 seconds, and a payment in flight keeps a session from
expiring. When that check expires a session, Fianto sends checkout. and
order.expired. A session also expires at once, before expires_at, when its payment fails after
the payer's USDC reached your wallet (for example the wrong amount) and no other payment for it is
under way: Fianto sends checkout. and, for a payment session, order.expired.
Before you ask the payer to pay again, check the dashboard's Payments chip "Money moved" (the
API's payments do not show what arrived): only you can refund that USDC. When a new create for the same order_id replaces a lapsed session, that session
still sends checkout., but there is no order.expired: the order is reopened for the
new session.
EXPIRED and CANCELED are not final for the order. If a payment for that session still
finalizes, and you have not opened a newer session for the order, the order becomes PAID and
Fianto sends order.paid (without checkout.). Keep your webhook route listening.
Check it worked
Read the session back from your server:
curl https://api.fianto.xyz/v1/checkout-sessions/SESSION_ID \
--user "$FIANTO_APP_ID:$FIANTO_APP_SECRET"Right after creating it, status is OPEN and url is null. After a payer pays and the payment
finalizes, status is COMPLETED, order.status is PAID, and your webhook route received
order.paid.
Troubleshooting
| You see | Why | Fix |
|---|---|---|
400 amount_ | You sent neither price_id nor amount, both, or amount without description. | Send price_id alone, or amount with description. |
400 amount_out_of_range | The amount is below 0.01 or above 1,000,000 USDC. | Send an amount in range, as a decimal string. |
400 validation_failed with field: "amount" | amount is not a decimal string with at most 6 decimal places (for example a JSON number, or "10.1234567"). | Send the amount as a string such as "10.5". |
400 url_insecure | success_url or cancel_url is http. | Use https URLs. |
400 expires_ | expires_at is less than 5 minutes or more than 24 hours away. | Pick a time in that window, or leave it out for 30 minutes. |
price_not_found, price_ended, product_ended or price_type_mismatch | The price_id does not name an active one-time price on an active product of yours. | Copy the price id from the dashboard, and check it is one-time and not ended. |
409 order_already_paid | This order_id is already paid. | Use a new order_id to charge again. |
409 order_id_in_use | This order_id already belongs to a completed checkout session that has no order to call paid, such as a completed subscription session. | Use a new order_id. |
422 merchant_ | Your receiving wallet has no USDC token account. | Send the wallet any amount of USDC once. |
409 checkout_ on devnet | Your account is not approved yet and has no test wallet. | Add a test wallet in the dashboard in Test mode. See Checkout sessions before approval. |
url is null | The order already has an open session, or you read the session instead of creating it. | Reissue the link with POST /v1/. |
409 session_ | The session is not open, or has less than 120 seconds left. | If it is still open, cancel it first. Then create a new session with the same order_id. |
409 payment_in_progress | A payment for this session is being processed, or (on a reissue) the last transaction prepared for the payer could still land. | Wait for it to finish; do not create a second payment for the order. |
409 session_ | The session is no longer open. | Read the session to see its status. |
The checkout page refuses with build_limit_reached or too_close_to_expiry | A session allows 10 successful builds and 30 build attempts, and no build in its last 120 seconds. | Cancel the session, then create a new one with the same order_id. |
409 checkout_ | Fianto could not reach or check Solana in time (for example while checking your receiving wallet, or before a reissue). | Retry after Retry-After (5 seconds). The SDK retries it for you. |
See also
Was this page helpful? Tell us
fianto.xyz