DevelopersBuild safely
Testing on devnet
Try your whole integration with test USDC on the devnet sandbox, with a test key, the same API and the same checkout page as mainnet.
Devnet is Fianto's sandbox. It runs the same API, the same hosted checkout and the same webhooks as mainnet, but on Solana devnet with test USDC that has no value. Your application keeps its app id, and can have a second secret for devnet, a test key, which you create in the first step.
Devnet is a second network, not a second account
Each application has a live secret (fian_sk_live_…) and a test secret (fian_sk_test_…). The live
secret works only on the mainnet API, https://. The test secret works only on the devnet
API, https://. A valid live secret is refused on devnet and a valid test secret
on mainnet, with 401 api_. There is no grace period: live secrets that worked on devnet before no
longer do. Accounts and applications live on mainnet:
you create, rename and disable an application there, and that applies to both networks.
Before you start
- A merchant account that is approved, or still being set up or reviewed. Approval is decided on mainnet. Before approval a test key works on part of the devnet API: see Before approval. A merchant whose business was not approved (REJECTED) cannot use devnet.
- An application created on mainnet. Its app id goes in
FIANTO_APP_ID; the test secret you create in the first step goes inFIANTO_APP_SECRETfor your devnet deployment. - Node.js 20.3 or later, with a Fianto SDK and CLI release that has the
networkoption. From@fianto/sdkand@fianto/cli0.6.0, a test key selects devnet by itself; older releases neednetwork: 'devnet'. - A Solana wallet to pay with. Test USDC comes from the faucet link on the devnet checkout page.
- A devnet USDC token account on your receiving wallet. Test USDC is its own token, so the account your
wallet has on mainnet does not count: send the wallet any amount of test USDC from
faucet.circle.com once. Until then, creating a devnet checkout fails with
merchant_.token_ account_ missing
Steps
Create a test key
In the dashboard, choose Test mode in the Mode picker in the sidebar, open Developers, then open
your API key. Choose "Create test key". It asks for your password and two-factor code, like rolling
a secret, and shows the test secret (fian_sk_test_…) once: copy it then.
Keep it as FIANTO_APP_SECRET for your devnet deployment, next to the same FIANTO_APP_ID.
FIANTO_APP_ID=fian_app_...
FIANTO_APP_SECRET=fian_sk_test_...In Test mode, "Roll secret" rolls the test secret, with the same grace options as on mainnet. Rolling one network's secret never affects the other's.
Before approval, in Test mode, New API key on Developers creates a key whose first
secret is a test key. It asks for your password, plus your two-factor code only when two-factor
sign-in is on. Every secret you get before approval is a test key: rolling a live secret answers
403 merchant_. Live keys come only after approval, with two-factor sign-in on: then,
in Live mode, the key's page lets you create its live secret, with your password and
two-factor code.
Point the SDK at devnet
With a test key, the SDK selects devnet by itself when neither network nor FIANTO_NETWORK is set.
Any other key stays on mainnet, as before. You can also pass network: 'devnet', or export
FIANTO_; with an older SDK release, you must.
import { Fianto } from '@fianto/sdk';
// Reads FIANTO_APP_ID and FIANTO_APP_SECRET (fian_sk_test_…); calls go to https://devnet-api.fianto.xyz.
const fianto = new Fianto();
console.log(await fianto.application.retrieve());A network that contradicts the key's prefix, from the option or FIANTO_NETWORK, throws a
FiantoError before any request. So does a test key pointed at https://, or a live key
at https://, through baseUrl or FIANTO_BASE_URL. A custom base URL, for a
self-hosted or local backend, is not checked.
The SDK exports the devnet address as DEVNET_BASE_URL, https://. An explicit
baseUrl or FIANTO_BASE_URL wins over network for where requests go, with one more exception: when you
pass network yourself and the URL is the other network's own host (https:// with 'devnet',
https:// with 'mainnet'), the client throws a FiantoError naming both. Any other
network value throws Invalid network: expected "mainnet" or "devnet".
createCheckoutHandler({ network }) and createWebhookHandler({ network }) accept the option too.
The checkout handler uses it for the client it creates, and ignores it when you pass your own
fianto client.
Point the CLI at devnet
Every CLI command that calls the API takes --network mainnet|devnet, or reads FIANTO_NETWORK.
That includes events tail. With neither set, a test key selects devnet. A network that contradicts the
key's prefix exits with code 1 before any request; a value other than mainnet or devnet exits with
code 2.
FIANTO_APP_SECRET=fian_sk_test_... npx @fianto/cli whoamiSet your devnet webhook URL
With Test mode still on in the Mode picker, open Developers and set the webhook URL
there. The devnet endpoint is separate from your mainnet one and
has its own signing secret, so use that secret as FIANTO_ for your devnet
deployment. A mainnet handler rejects a devnet event's signature.
Webhooks open once Fianto approves your business: before approval you cannot set a webhook URL, and no webhooks are sent.
The network picker, labelled Mode in the sidebar, is offered to approved merchants and to merchants still setting up, in review or asked for changes. It reads "Live mode", "Solana Mainnet, real USDC" and "Test mode", "Solana Devnet, test USDC, for trying things out". While Test mode is on, a "Test mode" badge shows on every page.
Create and pay a checkout
Create products, prices and checkout sessions through the API as you do on mainnet. Products and prices are not copied between networks: create them on devnet.
Open the session's url. The checkout page shows a "Test mode" badge and a "Get test USDC" link to
faucet.circle.com. Fund your wallet there, then pay. Explorer links on
the page carry ?cluster=devnet, and links to the payer portal are hidden.
Devnet charges no platform fee and no USDC network fee. Fianto pays the Solana transaction fees and rent, as it does on mainnet.
Card payments on devnet use Stripe test keys: the merchant connects Stripe test keys (pk_test_, rk_test_) on the
devnet dashboard, separately from the live keys on mainnet, and payers use Stripe's test cards. See
Test card payments.
Check the network field in your webhook route
Every webhook event carries network, "mainnet" or "devnet". Pass your network to the verifier
to refuse events from the other one.
import { verifyWebhook } from '@fianto/sdk/webhooks';
export async function POST(request: Request): Promise<Response> {
const rawBody = await request.text();
// Throws WebhookVerificationError with reason `network_mismatch` for another network's event.
const event = await verifyWebhook(rawBody, request.headers, { network: 'devnet' });
console.log(event.type, event.network);
return Response.json({ received: true });
}An event with no network fails the check too. With createWebhookHandler({ network }), the
handler checks after the signature verifies, answers 400 invalid_webhook and calls
onVerificationError with the reason network_mismatch.
What devnet serves
| On devnet | Not on devnet |
|---|---|
| The v1 API | Shops |
| The hosted checkout, for one-time payments and subscriptions | Coupons |
| Payment links and their pages, paid with test USDC | Overview, Needs attention and CSV exports |
| Webhooks, with their own endpoint and signing secret | The payer portal and the admin console |
| Dashboard: Developers (the webhook panel and the test key), Products, Payment links, Checkouts, Payments, Customers and Subscriptions | Creating, renaming or disabling applications: do that in Live mode (before approval, Test mode too; see Before approval) |
Devnet sends no email. Its data is separate from mainnet: what you create on devnet is not in your mainnet lists.
Before approval
While your account is being set up or reviewed, your test key works on the devnet API for these v1 routes, with test data:
| Routes | What you can do |
|---|---|
POST /v1/, GET /v1/, POST /v1/, POST /v1/ | Create, read, cancel and reissue checkout sessions |
GET /v1/products, GET /v1/products/{id}, GET /v1/prices, GET /v1/prices/{id} | Read products and prices |
GET /v1/orders, GET /v1/orders/lookup, GET /v1/orders/{id} | Read orders |
GET /v1/payments, GET /v1/payments/{id} | Read payments |
GET /v1/subscriptions, GET /v1/, POST /v1/ | Read and cancel subscriptions |
The other v1 routes devnet serves, GET /v1/application, GET /v1/events, GET /v1/events/{id}
and POST /v1/, answer 403 merchant_ until Fianto approves your
business. So do fianto. in the SDK and npx @fianto/cli whoami. The
invoice routes are not on devnet at all and answer 404.
On mainnet nothing changes: a merchant that is not approved has no live key, and any key of theirs
answers 401 invalid_ there, a test key included.
In the dashboard, in Test mode, you can also create payment links before approval. The New payment link form, while you have no test wallet yet, also asks under "Test payments" for one ("Where should test payments go?") and for the "Name shown on your test pages". Until Fianto approves your business, a link cannot send payers to your site after payment: see Payment link sales.
Checkout sessions before approval
Checkout sessions work as they do after approval, paid with test USDC into your test wallet, with these differences until Fianto approves your business:
success_urlandcancel_urlare accepted and stored, but not used: the payer stays on Fianto's checkout page. After a payment there is no Continue to button, a cancel does not opencancel_url, and a popup session posts nofianto.checkoutmessage to your page. Once Fianto approves your business, the URLs of your sessions are used as on mainnet.- If you have not set a test wallet yet,
POST /v1/answers 409checkout-sessions checkout_and opens nothing. Add a test wallet in the dashboard in Test mode (the New payment link form on Payment links asks for one), then try again. Like a receiving wallet, it needs a devnet USDC token account.wallet_ required - No webhooks are sent. Read the session (
GET /v1/) or its order (checkout-sessions/{id} GET /v1/orders/{id}) to follow a payment.
The network field
- Every webhook envelope carries
network, in this order:id,type,timestamp,network,data. Theendpoint.request carries it too.verification - Every v1 response object, and each item in a list's
items, carriesnetwork, a response replayed for anIdempotency-Keyincluded. Error bodies do not carry it. - Mainnet responses and events carry
"network": "mainnet".
Check it worked
npx @fianto/cli whoami, with your test key in FIANTO_APP_SECRET, prints your application (before
approval it answers 403 merchant_; create a checkout session instead). A checkout
session created through a client with your test key has "network": "devnet" and opens a page with the "Test mode" badge. After approval,
when you pay it with test USDC, your devnet webhook URL receives order.paid with
"network": "devnet"; before approval no webhooks are sent.
Troubleshooting
| You see | Why | Fix |
|---|---|---|
401 api_ on devnet | You sent the live key (fian_sk_live_…). Live keys work only on mainnet. | Create a test key in Test mode and send it instead. |
401 invalid_ on devnet | The key is unknown, revoked or expired, the application is disabled, or the merchant account is not active or was not approved. | Check the key, or create a test key in Test mode. |
409 checkout_ on devnet | Your account is not approved yet and has no test wallet, so test payments have nowhere to go. | Add a test wallet in the dashboard in Test mode, then create the session again. |
A devnet checkout session you created never opens success_url or cancel_url | Your business is not approved yet, so the page keeps the payer on Fianto's page. See Checkout sessions before approval. | Read the session or its order through the API instead. The URLs are used once Fianto approves your business. |
403 merchant_ on devnet | Your account is not approved yet, and this route waits for approval. See Before approval. | Use the routes listed there until Fianto approves your business. |
422 merchant_ on devnet | Your receiving wallet has no devnet USDC token account yet. Test USDC is its own token, so the account on mainnet does not count. | Send the wallet any amount of test USDC from faucet.circle.com once, then try again. |
503 service_busy with a Retry-After header on devnet | Devnet could not reach mainnet to check your account right now, and refuses rather than guess. | Retry after the delay in Retry-After. |
network_mismatch from verifyWebhook | The event came from the other network, or has no network field. | Check that the route verifies with the secret and the network of the endpoint it serves. |
fianto trigger samples are refused with network_mismatch | The sample carries the CLI's network: --network, else FIANTO_NETWORK, else mainnet. | Run trigger with the same --network as the route's network. |
A FiantoError naming your key and the network or base URL | The key's prefix says one network and network, FIANTO_NETWORK, baseUrl or FIANTO_BASE_URL says the other. | Use the test key with devnet and the live key with mainnet, or remove the setting that contradicts it. |
| Shops, coupons or Overview are missing in Test mode | They are mainnet-only. | Choose Live mode in the Mode picker. |
See also
Was this page helpful? Tell us
fianto.xyz