Skip to content

Integration guide

This guide is for business systems (shops, SaaS billing, membership systems and similar) that accept payments through FlowPayra Lite. It covers every step from the first order to going live. The authoritative definition of fields, status codes and error codes is the OpenAPI specification, which every deployment serves for its own version at GET /v1/openapi.yaml; see the API overview.

The requests and responses below are taken from an actual run of the integration tests (two local development chains). Long responses are shortened with …; IDs and timestamps differ on every run. The test validates every API response and webhook event against the OpenAPI specification.

  • One deployment serves one merchant. FlowPayra Lite is deployed by the merchant (public_url, for example https://pay.example.com). The business API, the checkout, the console and the payer’s “My subscriptions” page all live under that domain. This guide writes $BASE for that address and $KEY for the API key.
  • Non-custodial. The payer’s wallet transfers tokens directly to the payees (the contract splits the payment atomically according to the quote). The system holds no funds; the hot wallet is used only for gas sponsorship and for subscription charge transactions and never handles the payment itself. Refunds are also sent directly from the receiving address to the payer (see Refunds). The structure is described in the security model.
  • Orders and subscriptions. An order (/v1/orders) is a one-time payment: create it, redirect the payer to checkout_url, and the payer chooses a token and network and pays. A subscription (/v1/subscriptions) is based on a plan maintained in the console: the payer signs the terms at the subscription link and authorizes a capped allowance, and the keeper then charges each period automatically.
  • The server state is authoritative. Payment results are pushed as webhooks and can be queried at any time. Return parameters and embed events are for the user interface only. Fulfil orders and activate services based on webhooks or on the status returned by GET /v1/orders/{id} and GET /v1/subscriptions/{id}.
  • Live mode and test mode. Every API key belongs to one mode (fpk_live_… / fpk_test_…) and reads and writes only that mode’s data; objects and events carry a livemode field. Use a test key for integration work; see Test mode.
Method Description
Redirect (default) Create an order (POST /v1/orders) and redirect the payer to checkout_url; after payment the payer returns to return_url
Modal / iframe Load /pay/embed.js in your page; the checkout opens in a modal on desktop and redirects on phones. See Embedding the checkout

Create keys in the console under “Developers → API keys” (admin role, step-up verification required), or on the server:

Terminal window
flowpayra-lite apikey create --name shop # live key, default scopes
flowpayra-lite apikey create --name ci --mode test # test key
flowpayra-lite apikey create --name crm --scope risk:read --scope risk:write

The plaintext key is shown once; only its hash is stored. Send it in the Authorization: Bearer $KEY header. A missing, malformed, unknown or revoked key answers 401 unauthorized.

Each operation names the scope it requires in security in the OpenAPI specification. A key without it answers 403 insufficient_scope.

Scope Endpoints
orders:write POST /v1/orders
orders:read GET /v1/orders, GET /v1/orders/{id}, GET /v1/payees
subscriptions:write POST /v1/subscriptions, …/{id}/cancel, /pause, /resume, /change_plan
subscriptions:read GET /v1/subscriptions/{id}, GET /v1/plans
events:read GET /v1/events
risk:read GET /v1/risk/addresses
risk:write POST /v1/risk/addresses, POST /v1/risk/addresses/import, DELETE /v1/risk/addresses/{address}
  • A key created without naming its scopes gets every scope except risk:read and risk:write. The risk address list is installation-wide screening configuration (risk:write can allow-list an address), so these scopes are granted separately when needed.
  • The orders scope of keys made before scopes existed grants every scope except risk:*.
  • Use separate keys per purpose: for example, default scopes for the shop back end and a dedicated key with only risk:* for a risk synchronization job.
  • GET /v1/openapi.yaml needs no authentication.

A live key sees only live orders, subscriptions and events; a test key sees only test data. Reading another mode’s object answers 404. Plans, payees and split rules are shared by both modes: the same plan_id and payee_ref work in either.

Terminal window
curl -X POST "$BASE/v1/orders" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: ord-SO-10023" \
-H 'Content-Type: application/json' \
-d '{
"merchant_order_no": "SO-10023",
"amount": "100.00",
"currency": "usd",
"tokens": ["USDC"],
"customer_email": "[email protected]",
"return_url": "https://shop.example/orders/SO-10023/done?ref=mail",
"metadata": { "cart": "c_8812", "items": 3 }
}'
HTTP/1.1 201 Created
{
"id": "8a1bb5ea-4a41-4bc1-aff5-7e66f1f812f9",
"livemode": true,
"merchant_order_no": "SO-10023",
"order_hash": "0xbefbeb9a9e16c0184f15e80b00fb0f3b2a80127f372d9826ffced438ef2321eb",
"status": "pending",
"amount": "100",
"currency": "USD",
"prices": null,
"tokens": ["USDC"],
"chains": null,
"split_rule_id": "ed080622-2d55-4224-beba-2b0c0525a400",
"payment": null,
"splits": [
{ "position": 0, "payee_ref": "main", "kind": "ratio", "bps": 8500, "fixed_amount": null, "fixed_currency": null,
"payee_id": "cb365376-3e6f-4ef8-9c78-f9179bd18742", "address": null, "amount": null },
{ "position": 1, "payee_ref": "vendor", "kind": "fixed", "bps": null, "fixed_amount": "2", "fixed_currency": "USD",
"payee_id": "3d420c9d-95b5-4e60-a08a-23ded6d5e3dc", "address": null, "amount": null },
{ "position": 2, "payee_ref": "channel", "kind": "ratio", "bps": 1500, "fixed_amount": null, "fixed_currency": null,
"payee_id": "a499e305-2a44-4d10-950e-d766e2970705", "address": null, "amount": null }
],
"risk_flag": null,
"locale": null,
"return_url": "https://shop.example/orders/SO-10023/done?ref=mail",
"metadata": { "cart": "c_8812", "items": 3 },
"expires_at": "2026-10-22T14:46:07.259144Z",
"created_at": "2026-10-22T14:16:07.260660Z",
"checkout_url": "http://localhost:8080/pay/8a1bb5ea-4a41-4bc1-aff5-7e66f1f812f9"
}
  • merchant_order_no is your own order number (1–128 characters, unique within the mode; a duplicate answers 409 duplicate_order).
  • amount is a decimal string (at most 8 decimals) priced in currency; currency is case-insensitive and stored in upper case.
  • Without splits or split_rule_id the default split rule applies (in the example: main payee 85%, vendor a fixed 2.00 USD, channel 15%).
  • Members of splits reference payees registered in the console by payee_ref or payee_id. Once the merchant turns the split whitelist off in the console, a member may also name a receiving address directly with address (and an optional name), for example [{"payee_ref": "main", "kind": "ratio", "bps": 9000}, {"address": "0x…", "name": "卖家 42", "kind": "ratio", "bps": 1000}]. The first member must be a ratio member that is a registered payee; the address is screened on every chain that could pay, and a hit answers 422 payee_blocked. With the whitelist on, address answers 400 split_address_not_allowed.
  • Orders expire after 30 minutes by default (configuration orders.default_ttl_secs); set expires_in (60–604800 seconds) to choose another lifetime.
  • Every create request needs an Idempotency-Key (see Idempotency and errors). Deriving it from your order number (such as ord-<order number>) is sufficient, and retrying with the same key after a network timeout is safe.

Redirect the payer to checkout_url (or open it in a modal with /pay/embed.js; see Embedding the checkout). The checkout lists the available tokens and networks; the payer connects a wallet, signs and pays. Your system has nothing to do at this step.

Once the order reaches a final state (paid or expired), the checkout result page sends the payer back to return_url with four parameters appended after any existing ones:

https://shop.example/orders/SO-10023/done?ref=mail&order_id=8a1bb5ea-4a41-4bc1-aff5-7e66f1f812f9&status=paid&ts=1792678567&sig=3c6f…a1
  • status is paid (also for a duplicate payment) or expired.
  • sig = hex(HMAC-SHA256(webhook_secret, "<order_id>.<status>.<ts>")), with the same secret as webhooks (test orders use the test webhook secret).
  • Check the age of ts (for example 600 seconds) and take the last occurrence of each parameter (your own return_url may carry parameters with the same names).
  • Verification functions in five languages and test vectors are described under Webhooks: return URL signature.

Enter the endpoint URL in the console under “Developers → Webhooks” and obtain the signing secret whsec_… (one endpoint and secret each for live and test). Once the payment is confirmed, the system sends a POST request:

POST /flowpay/webhook HTTP/1.1
Content-Type: application/json
User-Agent: FlowPayra-Lite/0.1.0
FlowPay-Signature: t=1792678567,v1=5b0c…e9 (signature truncated)
{
"id": "e6744ca8-e69a-479b-bd2c-158757c03bab",
"type": "order.paid",
"created_at": "2026-10-22T14:16:07.746192Z",
"livemode": true,
"data": {
"id": "8a1bb5ea-4a41-4bc1-aff5-7e66f1f812f9",
"merchant_order_no": "SO-10023",
"status": "paid",
"amount": "100",
"currency": "USD",
"payment": { "chain_id": 31337, "token_id": "5ad01eba-75da-4ec2-b7df-23ed1fcd2cf2", "symbol": "USDC", "decimals": 6,
"amount": "100000000",
"payer": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
"tx_hash": "0x2eb3e3a63ad32317eec2955354aa4a089a152a0b0842dab526e4f83fe72cd4a4",
"paid_at": "2026-10-22T14:16:07.653925Z", "confirmed_at": "2026-10-22T14:16:07.740029Z" },
"payments": [{ "chain_id": 31337, "block_number": 19, "status": "confirmed", "amount": "100000000",
"payer": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
"tx_hash": "0x2eb3e3a63ad32317eec2955354aa4a089a152a0b0842dab526e4f83fe72cd4a4" }],
"customer_email": "[email protected]",
"risk_flag": null,
…
}
}

Handling rules:

  1. Verify first, parse second. Compute HMAC-SHA256(secret, "<t>.<body>") over the raw request body bytes and compare it with any v1 in the header; reject requests where |now − t| exceeds 300 seconds. Re-serialized JSON does not verify.
  2. Be idempotent by id. The same event may arrive more than once (a lost acknowledgement, a manual resend from the console). Record the id of handled events and answer 2xx to repeats.
  3. Answer 2xx within 10 seconds. Queue slow work (fulfilment, activation) and process it asynchronously. A non-2xx answer, a timeout or a redirect is retried.
  4. Check livemode. A production endpoint may reject events with livemode: false (test events are sent only to the test endpoint, so this should not occur).
  5. Check risk_flag. review means the paying address matched a review-level list entry or exceeded the payer’s daily limit: hold fulfilment and review it manually (a refund can be issued as described under Refunds). frozen means a payment came from an address that failed risk screening (a block-level entry, or a built-in list such as the FBI’s list of hacker addresses). That payment is frozen and does not count toward the order, and the system sends order.payment_frozen. Do not fulfil the order and do not refund the paying address; the funds are already in the receiving wallets and are to be handled according to your compliance process. Orders from before this behaviour existed may carry hit_after_paid; those orders stay paid.

The data of an order event is the complete order as it stood (the same as GET /v1/orders/{id}, without checkout_url), plus payments (every on-chain payment, the booked one first) and customer_email. The amount in payment is in token base units; symbol and decimals are those the token was listed with, and amount / 10^decimals is the token quantity (for example 100000000 with 6 is 100 USDC).

Delivery rules, the signature algorithm, event types and the retry schedule are documented under Webhooks.

Terminal window
curl "$BASE/v1/orders/8a1bb5ea-4a41-4bc1-aff5-7e66f1f812f9" -H "Authorization: Bearer $KEY"
# or by your own order number:
curl "$BASE/v1/orders?merchant_order_no=SO-10023" -H "Authorization: Bearer $KEY"
{
"id": "8a1bb5ea-4a41-4bc1-aff5-7e66f1f812f9",
"status": "paid",
"payment": { "chain_id": 31337, "chain": { "id": 31337, "caip2": "eip155:31337", "family": "evm" },
"amount": "100000000", "payer": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
"tx_hash": "0x2eb3e3a63ad32317eec2955354aa4a089a152a0b0842dab526e4f83fe72cd4a4",
"token_id": "5ad01eba-75da-4ec2-b7df-23ed1fcd2cf2", "symbol": "USDC", "decimals": 6,
"paid_at": "2026-10-22T14:16:07.653925Z", "confirmed_at": "2026-10-22T14:16:07.740029Z" },
"splits": [
{ "position": 0, "payee_ref": "main", "kind": "ratio", "bps": 8500,
"address": "0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc", "amount": "83300000", … },
{ "position": 1, "payee_ref": "vendor", "kind": "fixed", "fixed_amount": "2", "fixed_currency": "USD",
"address": "0x976ea74026e726554db657fa54763abd0c3a0aa9", "amount": "2000000", … },
{ "position": 2, "payee_ref": "channel", "kind": "ratio", "bps": 1500,
"address": "0x14dc79964da2c08b23698b3d3cc7ca32193d9955", "amount": "14700000", … }
],
…
}

Querying the order after receiving the webhook and before fulfilment rules out both forged requests and out-of-order events. payment.amount and splits[].amount are in token base units (USDC has 6 decimals: 100000000 is 100 USDC).

The payment, payments[] and refund of an order, and the subscription object in subscription, refund and charge events, carry chain: {id, caip2, family} (chain_id is kept as before):

  • id is the chain ID, caip2 the CAIP-2 identifier (eip155:8453, tron:0x2b6653dc, solana:…), and family the chain family: evm | tron | solana.
  • Addresses and transaction identifiers are written in the family’s customary format: lower-case hexadecimal 0x… for EVM (the risk list API returns EIP-55 checksummed addresses), Base58Check (T…) and 64-digit hexadecimal transaction IDs without the 0x prefix for TRON, and Base58 public keys and Base58 transaction signatures for Solana.
  • Addresses and transaction identifiers in requests (account, payer, tx_hash, payee addresses, the risk list) are accepted in all three formats. One that does not match the family of the chain named answers 422 address_family_mismatch; an operation that exists only on EVM chains, used with another family, answers 422 family_unsupported.

When the webhook endpoint is unreachable (downtime, a firewall), events remain stored. Your system can poll GET /v1/events?since=<the last next_since> to obtain every event in commit order (see Webhooks: the event feed), or call GET /v1/orders/{id} for each order that has stayed pending beyond a threshold.

status Meaning Event What to do
pending Awaiting payment — —
paid_unconfirmed A payment was seen on chain but has not reached its confirmations — A “confirming payment” notice may be shown; do not fulfil
paid The first payment reached its confirmations order.paid Fulfil / activate
duplicate_paid A further payment reached its confirmations (for example one on each of two chains) order.duplicate_paid The order still counts as paid; a pending refund is opened automatically and the merchant returns the extra payment from the console
expired Unpaid at expires_at order.expired Close the order; a payment arriving after expiry is still booked (the order becomes paid and order.paid is sent)
reverted A confirmed payment disappeared in a chain reorganization order.payment_reverted Pause or withdraw fulfilment and wait for a new payment or manual handling
partially_refunded The booked payment was refunded in part (or in full while a duplicate payment remains) order.refunded Act on the refunded amount
refunded Every payment has been refunded in full order.refunded Cancel the order
  • An order is booked against the first confirmed payment only (payment); later duplicate payments do not replace it.
  • A payment from an address that fails risk screening is frozen and does not count toward the order: the order stays unpaid, risk_flag is frozen, and the system sends order.payment_frozen (data.frozen_payment gives the frozen payment).
  • Expiry is evaluated about 2 minutes after expires_at (orders.expiry_grace_secs) and waits for transactions that were submitted and are still within their quote’s validity.
  • After a duplicate payment is refunded, the order returns from duplicate_paid to paid (order.refunded is sent as well).
  • A checkout quote is valid for 10 minutes; the payer receives a new quote when changing token or network. These details are transparent to your system.

Amounts, currencies, per-token pricing and splits

Section titled “Amounts, currencies, per-token pricing and splits”
  • An order is priced by amount and currency. Stablecoins pegged to that currency pay 1:1 (a USD order can be paid in USDC, USDT, DAI and so on).
  • tokens restricts the accepted token symbols (case-insensitive, stored in upper case). The default is every listed stablecoin, plus the token whose symbol equals currency (for example ETH when the order is priced in ETH).
  • chains further restricts the networks (chain IDs). The default is every enabled network that serves the key’s mode (live: mainnets; test: testnets; local development chains serve both).
  • prices sets a price per token: the key is the token symbol (case-insensitive, stored with the listed spelling) and the value is the quantity of that token due. Tokens not listed are still converted from amount, which works for pegged tokens only.
{ "merchant_order_no": "SO-10024", "amount": "100", "currency": "USD", "prices": { "usdc": "99.50" },
"tokens": ["usdc"], "chains": [31337], "expires_in": 3600, "locale": "EN",
"splits": [{ "payee_ref": "main", "kind": "ratio", "bps": 7000 }, { "payee_ref": "channel", "kind": "ratio", "bps": 3000 }] }

The response carries "prices": {"USDC": "99.5"}, "tokens": ["USDC"], "locale": "en" and "split_rule_id": null.

  • Payees are registered in the console (GET /v1/payees lists id, ref, name, is_primary, active). Orders reference them by payee_ref or payee_id, and only active payees can be referenced.
  • Choose exactly one of three ways: splits (splits for this order), split_rule_id (a split rule maintained in the console), or neither (the default rule). Sending both splits and split_rule_id answers 400.
  • 1–10 members. A ratio member gives bps (basis points; the ratio members sum to 10000); a fixed member gives fixed_amount. At least one ratio member is required, no payee may appear twice, and a member receiving zero is refused (400 invalid_splits).
  • Calculation: fixed amounts are paid first and the remainder is divided by ratio. The first ratio member is the main payee and absorbs the rounding remainder. Under the default rule above, 100 USDC is divided as: vendor 2, main payee (100 − 2) × 85% = 83.3, channel (100 − 2) × 15% = 14.7.
  • Currency of fixed amounts: a fixed_amount sent with the order is in the order’s currency; a fixed amount in a split rule is in the rule member’s own currency (fixed_currency in the response). Fixed amounts can only be paid in tokens pegged to that currency; other tokens are not offered at the checkout.
  • When an order is created the system checks that a payable route exists (network × token × screened payee addresses) and answers 422 when none does:
    • split_total_too_small: the amount does not cover the fixed splits (params.amount, currency, fixed[]);
    • split_currency_mismatch: no accepted token is pegged to a fixed split’s currency;
    • no_payable_route: any other cause (token filter, prices, a payee address that failed screening on the chain, and so on). When the payees’ addresses are the reason, params.reason is payee_address and params.payees[] lists them (payee_id, name, problem: missing no address for the network’s family, unscreened not screened yet, blocked refused by screening), with the candidate networks in params.chains[]. The same applies to subscriptions.
  • Live orders are also subject to the order amount limits configured in the console: an order priced in the limits’ currency outside the per-order minimum or maximum answers 422 amount_out_of_range (params.limit, bound, currency, amount). Test orders are not subject to the limits.

Payee and split rule configuration is described under Payees and splits.

Writes that create (POST /v1/orders, /v1/subscriptions, /v1/subscriptions/{id}/change_plan, /v1/risk/addresses, /v1/risk/addresses/import) require an Idempotency-Key header (1–255 characters); without it they answer 400 invalid_request.

  • Keys are scoped to the API key. The system stores a hash of the raw body of the first request together with its answer (2xx and 4xx alike): a replay with the same key and the same body returns the first status code and body unchanged.
  • The same key with another body: 422 idempotency_key_reused. A retry while the first request is still running: 409 request_in_progress (retry later).
  • 5xx answers are not stored, so the request can be retried with the same key. Stored keys do not expire; do not reuse a key for a different business request.
  • The hash is computed over the raw bytes: send exactly the same bytes when retrying (for example by caching the body as first serialized).
  • cancel, pause, resume and DELETE take no key: the outcome of a repeated call is predictable (canceling a subscription that has ended returns it unchanged; pausing twice answers 409 not_pausable).
{ "error": { "code": "invalid_request", "message": "expires_in must be between 60 and 604800 seconds",
"params": { "field": "expires_in", "min": 60, "max": 604800 } } }

code is stable and suitable for program logic. params carries the field at fault and the limits, so that your system can word the message in its own language. message is English, intended for logs, and may change. The status codes and code values each operation may return are defined in the OpenAPI specification (every response lists its code values). The common ones are:

Status code When params
400 invalid_request The body is not JSON, has an unknown field or a wrong type; a field is invalid; Idempotency-Key is missing; a path or query parameter is malformed field, and min, max, max_decimals, allowed, token and others
400 invalid_splits The split members do not form a valid rule —
400 split_address_not_allowed / main_payee_first / main_payee_not_registered Split members named by address: the split whitelist is on; the first member is not a ratio member; the first member is not a registered payee —
400 invalid_entries A bulk risk list import contains invalid entries invalid, errors[{index, message}]
401 unauthorized Missing or invalid API key —
403 insufficient_scope The key lacks the operation’s scope —
403 testnet_only A test key writing an entry not scoped to a testnet chain_id, testnets
404 not_found The object does not exist or belongs to the other mode what: order, subscription, entry
409 duplicate_order The order number already exists in this mode —
409 request_in_progress A request with the same Idempotency-Key is still running —
409 not_pausable / not_paused / risk_paused The subscription’s status does not allow pausing or resuming, or it was paused by risk screening —
409 same_plan / not_changeable / switch_in_flight / plan_change_in_flight The plan change cannot be carried out not_changeable: status
409 list_is_feed / entry_not_removable Risk list: a URL feed is not writable; the entry comes only from imported sources list / sources
413 payload_too_large The body exceeds 64 KiB (4 MiB for the bulk import) —
422 idempotency_key_reused The same key with another body —
422 split_total_too_small / split_currency_mismatch / no_payable_route / amount_out_of_range The order (for subscriptions only no_payable_route) cannot be paid or is outside the limits See Splits
422 payee_blocked A split member named by address failed screening on a chain that could pay field, address, chain_id, hits
422 address_family_mismatch / family_unsupported An address or transaction identifier does not match the family of the chain named; the operation exists only on EVM chains —
500 internal Server error Retry later (with the same key for idempotent requests)
503 chain_unavailable None of the networks that could pay a split member named by address could be reached to screen it; nothing is recorded, retry later —

Actual responses:

POST /v1/orders 400 {"error":{"code":"invalid_request","message":"locale must be one of zh-CN, en","params":{"allowed":["zh-CN","en"],"field":"locale"}}}
POST /v1/orders 400 {"error":{"code":"invalid_request","message":"XYZ is not a listed token","params":{"field":"prices.XYZ","token":"XYZ"}}}
POST /v1/orders 422 {"error":{"code":"split_total_too_small","message":"the amount does not cover the fixed split amounts","params":{"amount":"1","currency":"USD","fixed":[{"amount":"2","currency":"USD","payee_id":"3d420c9d-95b5-4e60-a08a-23ded6d5e3dc"}]}}}
POST /v1/orders 422 {"error":{"code":"amount_out_of_range","message":"the amount is above the maximum order amount of 50 USD","params":{"amount":"60","bound":"50","currency":"USD","limit":"max"}}}
GET /v1/orders/not-a-uuid 400 {"error":{"code":"invalid_request","message":"Invalid URL: Cannot parse `id` with value `not-a-uuid`: …","params":{"field":"id"}}}
POST /v1/subscriptions/f99a…3eb6c3/change_plan 409 {"error":{"code":"not_changeable","message":"the subscription is canceled","params":{"status":"canceled"}}}

In addition, a request that takes longer than 30 seconds answers 408 (empty body), and a path or method that does not exist answers 404 / 405 (empty body).

Plans are maintained in the console under “Plans” (a single price or per-token prices, period, number of periods, immediate start or trial, grace period, retry interval, unpaid or canceled once the grace period runs out, default split rule, accepted tokens, whether the payer may pause) and are shared by both modes. GET /v1/plans lists the active plans; pass a plan’s id as plan_id. A subscription snapshots its plan when created, so later plan edits affect only new subscriptions. The console workflow is described under Subscriptions.

Terminal window
curl -X POST "$BASE/v1/subscriptions" -H "Authorization: Bearer $KEY" -H "Idempotency-Key: sub-cus_1001" \
-H 'Content-Type: application/json' \
-d '{"plan_id":"2ff2d006-6bcb-4935-b2a9-d57346819a05","customer_ref":"cus_1001","customer_email":"[email protected]",
"locale":"ZH-cn","return_url":"https://shop.example/account/billing","metadata":{"account":"acct_77"}}'
HTTP/1.1 201 Created
{
"id": "f99a7f93-65b3-482d-821c-77de043eb6c3",
"livemode": true,
"plan_id": "2ff2d006-6bcb-4935-b2a9-d57346819a05",
"plan_name": "Pro",
"customer_ref": "cus_1001",
"status": "incomplete",
"checkout_url": "http://localhost:8080/pay/sub/f99a7f93-65b3-482d-821c-77de043eb6c3",
"chain_id": null, "token": null, "payer": null, "sub_id": null, "amount_per_period": null,
"period_seconds": 86400, "max_periods": 4, "trial_seconds": 0,
"start_at": null, "trial_end_at": null, "next_charge_at": null,
"charges_made": 0, "last_charged_index": null, "past_due_since": null, "last_error": null,
"cancel_source": null, "splits": [],
"locale": "zh-CN",
"return_url": "https://shop.example/account/billing",
"metadata": { "account": "acct_77" },
"created_at": "2026-10-22T14:16:11.212803Z", "canceled_at": null,
"replaces": null, "replaced_by": null, "pending_plan_change": null
}
  • Send the payer to checkout_url (/pay/sub/{id}, valid for 7 days by default; expires_in accepts 60 seconds to 30 days). The payer chooses a token and network, confirms the terms and authorizes an allowance capped at the plan’s periods. On some networks the system sponsors the gas and the payer only signs.
  • customer_ref (at most 128 characters) is your customer number. customer_email is used for subscription receipts (activation, charge, failed charge, trial ending, end) and for email sign-in to “My subscriptions”.
  • trial_seconds can shorten the trial (trial plans only, and not beyond the plan’s trial length). tokens and chains default to the plan’s settings. Splits default to the plan’s default rule, and after that to the system default rule.
  • locale is the same as for orders: only zh-CN and en are accepted (case-insensitive).
  • After subscribing, the payer returns to return_url with subscription_id and status (trialing or active) appended. These two parameters are not signed; rely on subscription.activated or GET /v1/subscriptions/{id} for activation.
status Meaning
incomplete The link was issued; no on-chain subscription yet
trialing In trial (the on-chain subscription is confirmed)
active Charging normally
past_due The latest charge failed; retried at the plan’s retry interval
unpaid The grace period ran out without a successful charge (for plans set to “unpaid”); no more charges
paused Paused: periods while paused are not charged, then or later
canceled Canceled (cancel_source says by whom)
completed Every period has passed
Event When Additional data fields
subscription.activated The on-chain subscription reached its confirmations (for an immediate start, subscription.charged for the first period follows) —
subscription.trial_will_end N days before the trial ends (receipt setting, 3 days by default) —
subscription.charged A period’s charge reached its confirmations charge: {id, period_index, amount, tx_hash}
subscription.charge_failed A charge failed; the subscription becomes past_due charge: {id, period_index, error}, retry_at
subscription.unpaid The grace period ran out; the subscription becomes unpaid As above
subscription.paused / subscription.resumed Paused / resumed paused: previous_status
subscription.risk_paused Screening before a charge matched a block-level entry; the subscription was paused by risk control —
subscription.canceled Canceled (with charge and retry_at when the grace period ran out on a plan set to “cancel”; with canceled_by after an on-chain cancel) Depends
subscription.charged_after_cancel A period was charged after the subscription was canceled in the system and before the on-chain cancel: a refund is due; no receipt is sent charge
subscription.completed Every period has passed —
subscription.allowance_low The remaining allowance no longer covers the remaining periods (sent once) allowance, needed
subscription.payment_method_changed The payer moved to another wallet, token or network in “My subscriptions” previous: {chain_id, token, payer}, switch: {chain_id, payer}
subscription.migration_requested After the merchant replaced the quote signer key, the payer is asked to migrate to the new payment contracts migration: {reason, action}
subscription.plan_change_pending / _expired / _canceled A plan change was requested, expired or withdrawn (sent on the old subscription) plan_change
subscription.plan_changed The plan change took effect (sent on the new subscription, instead of activated) previous: {id, plan_id, plan_name}, effective_at
subscription.replaced The old subscription of a plan change ended (sent on the old subscription, now canceled with cancel_source: plan_changed, usually together with plan_changed). Not a cancellation: the service goes on with the new subscription replaced_by, effective_at

The data of a subscription event is the complete subscription as it stood (the same as GET /v1/subscriptions/{id}, without checkout_url), plus the fields in the table. A failed charge, for example:

{ "type": "subscription.charge_failed", "data": { "status": "past_due", "last_error": "balance",
"charge": { "id": "675c384f-ccba-4032-adb3-9d7f4d1d9389", "period_index": 0, "error": "balance" },
"retry_at": "2026-10-22T15:16:11.750158Z", … } }

Recommended handling: activate the service on activated and plan_changed; extend it on charged; on charge_failed ask the customer to top up or check the allowance; stop the service on unpaid, canceled and completed; keep it on replaced (the old subscription of a plan change was replaced, and the new one in replaced_by carries the service on); on allowance_low remind the customer to renew the allowance; on migration_requested ask the customer to open “My subscriptions” and complete the migration.

Terminal window
curl -X POST "$BASE/v1/subscriptions/$SUB/pause" -H "Authorization: Bearer $KEY" # → 200, status: paused
curl -X POST "$BASE/v1/subscriptions/$SUB/resume" -H "Authorization: Bearer $KEY" # → 200, status: active
curl -X POST "$BASE/v1/subscriptions/$SUB/cancel" -H "Authorization: Bearer $KEY" # → 200, status: canceled
  • Pause: a trialing, active, past_due or unpaid subscription can be paused; other statuses answer 409 not_pausable. While paused the keeper does not charge; a third party can still charge on chain (such charges are booked as usual).
  • Resume: charging resumes from the next period. Periods while paused are not charged later, and the failure count and the past-due start are reset. A subscription that is not paused answers 409 not_paused. A subscription paused by risk screening (subscription.risk_paused) can be resumed only from the console after the payer is screened again; the API answers 409 risk_paused.
  • Cancel: charging stops at once (cancel_source: merchant); the system then cancels on chain with cancelByMerchant, after which nobody can charge. Canceling an incomplete subscription sends no event; canceling a subscription that has ended returns it unchanged with 200. The payer can also cancel in “My subscriptions” or on chain, or revoke the allowance (cancel_source: payer); a cancel by the main payee on chain is reported as chain.

On-chain terms cannot be modified, so a plan change works as “the old subscription runs out and a new one starts from the next period”:

Terminal window
curl -X POST "$BASE/v1/subscriptions/f99a7f93-65b3-482d-821c-77de043eb6c3/change_plan" \
-H "Authorization: Bearer $KEY" -H "Idempotency-Key: chg-1" -H 'Content-Type: application/json' \
-d '{"plan_id":"f8bc8289-c389-483f-90ad-794691e4c334"}'
HTTP/1.1 201 Created
{
"id": "43557641-89f1-4a38-b142-c0335cac03ac",
"status": "incomplete",
"plan_name": "Team",
"replaces": "f99a7f93-65b3-482d-821c-77de043eb6c3",
"checkout_url": "http://localhost:8080/pay/sub/43557641-89f1-4a38-b142-c0335cac03ac",
"customer_ref": "cus_1001", "locale": "zh-CN", "return_url": "https://shop.example/account/billing",
"plan_change": {
"id": "7b5adb4a-7db3-4458-8f39-6c769c5dc4aa",
"subscription_id": "f99a7f93-65b3-482d-821c-77de043eb6c3",
"new_subscription_id": "43557641-89f1-4a38-b142-c0335cac03ac",
"plan_id": "f8bc8289-c389-483f-90ad-794691e4c334", "plan_name": "Team",
"status": "pending", "source": "api", "reason": null,
"effective_at": "2026-10-23T14:15:11.275580Z",
"expires_at": "2026-10-23T14:00:11.275580Z",
"created_at": "2026-10-22T14:16:11.459767Z", "ended_at": null
},
…
}
  1. The request returns a new incomplete subscription (replaces points to the old one). The old subscription receives subscription.plan_change_pending, and GET on the old subscription shows the payer’s confirmation link in pending_plan_change.checkout_url. Send the payer to the new subscription’s checkout_url; the new terms are confirmed with the wallet paying the old subscription.
  2. The first period of the new terms starts at the old subscription’s next period boundary that is at least 30 minutes ahead (effective_at) and is not charged in the subscribe transaction. The old subscription keeps its current period and nothing is prorated (bill a difference as a separate one-time order). From the request on, the old subscription charges no period from the boundary onwards.
  3. Once the new subscription reaches its confirmations, it receives subscription.plan_changed (not activated). The old subscription becomes canceled (cancel_source: plan_changed) as soon as its current period is charged (or over) and receives subscription.replaced with replaced_by and effective_at (not subscription.canceled: the customer did not cancel); it is then canceled on chain. Both events usually arrive when the payer confirms, before the new plan’s first period (effective_at): switch the customer to the new plan then, or keep the old plan until effective_at (it is paid until then) and switch at that time. Reading the old subscription back shows canceled: when you act on states, go by the new subscription in replaced_by and keep the service on.
  4. The link expires at the latest 15 minutes before the boundary (plan_change.expires_at). If the change is not on chain 10 minutes after the link expires, it expires (subscription.plan_change_expired; the new subscription is canceled with cancel_source: expired) and the old subscription continues to be charged as before.
  5. A new request before the payer confirms supersedes the earlier change (subscription.plan_change_canceled with reason: superseded for the earlier one). Canceling either subscription also withdraws the change (reason: subscription_ended or canceled).

Additional rules:

  • Only trialing / active subscriptions confirmed on chain can change plan; otherwise 409 not_changeable (params.status). The same plan answers 409 same_plan; a payment method switch in flight 409 switch_in_flight; the subscribe transaction of an earlier change in flight 409 plan_change_in_flight.
  • A change during a trial does not grant a second trial: the new plan starts charging where the trial ends.
  • The new subscription carries over the customer number, receipt email, locale, metadata and return URL of the old one (return_url, locale and metadata in the request override them). Its splits are taken from the request, else the new plan’s default rule, else the old subscription’s splits.

“My subscriptions”, payment method changes and migration

Section titled ““My subscriptions”, payment method changes and migration”

Payers sign in at $BASE/my/subscriptions with a wallet signature or a one-time link from a receipt email. There they can view the charge history, pause or resume (when the plan allows), cancel, change the payment method, change the receipt email, revoke the allowance, and confirm plan changes and contract migrations requested by the merchant. Your account page can link to that address.

  • Changing the payment method: the payer moves to another wallet, token or network. The subscription ID, charge dates and number of charged periods stay the same, and subscription.payment_method_changed is sent once it takes effect. Your system usually only needs to record the new payer / token / chain_id.
  • Migration: after replacing the quote signer key, the merchant asks payers to migrate their subscriptions from the console, and each subscription receives subscription.migration_requested. The payer completes the migration in “My subscriptions” by changing the payment method; the system cannot migrate on the payer’s behalf. Until then, charges on the old contracts continue as usual, so notify your customers accordingly.

Refunds are started from the order detail page in the console; the business API has no refund endpoint:

  1. An admin or operator starts a full or partial refund for a confirmed payment (not exceeding the amount still refundable) and gives a reason. A duplicate payment opens a pending refund automatically.
  2. The transfer is sent from the receiving wallet connected in the console, or made outside it and then recorded by transaction hash.
  3. The system verifies that the transaction transfers at least the refund amount of the same token from that payment’s receiving address to the paying address. The refund completes once it reaches its confirmations.

On completion your system receives order.refunded; data is the order’s new state plus refund:

{ "type": "order.refunded", "data": { "status": "partially_refunded", "customer_email": "[email protected]",
"refund": { "id": "f2deaf41-1e50-409e-9f4e-e84b1b86d6c2", "payment_id": "611af994-39c7-448e-b57c-245f99c0178a",
"chain_id": 31337, "token": "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0", "amount": "30000000",
"to": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", "from": "0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"tx_hash": "0xeaccf16ee6a04f03310c258595ca77e788d7bb1266dca7d8548190222156a46d",
"reason": "partial return", "method": "offline", "verification": "transfer" }, … } }
  • token is the token contract address (the zero address for the native coin) and amount is in base units. from is the receiving address the refund was sent from. method is wallet (the wallet connected in the console) or offline (a recorded transaction hash). verification is transfer, trace (found in the call trace, for example a transfer out of a Safe) or manual (confirmed by an operator).
  • Charges that landed after a subscription was canceled (subscription.charged_after_cancel) and duplicate charges are returned by the merchant in a separate transfer; the system only raises the notice.

Your system can read and maintain the risk address list, for example to synchronize a deny list from your own risk system. The list takes effect once payer screening is turned on: paying addresses are screened before a quote, before a sponsored submission, at booking and before each subscription charge. The console configuration is described under Risk.

Endpoint Scope Description
GET /v1/risk/addresses risk:read Entries of every source, filtered by source, address, level and chain_id; paged with limit (1–500, default 100) and after (the previous page’s next_after)
POST /v1/risk/addresses risk:write Adds one entry (an entry for the same address and chain scope in the same list is replaced) and answers 201; requires Idempotency-Key
DELETE /v1/risk/addresses/{address} risk:write Removes the address’s entries from the merchant’s list (or the named list given by ?list=); ?chain_id= removes only one chain’s entry (all for the entry that applies to all chains)
POST /v1/risk/addresses/import risk:write Bulk write of up to 10,000 entries, written only if all are valid (otherwise 400 invalid_entries, with params.errors listing them by index); mode: replace makes the list hold exactly these entries; requires Idempotency-Key
  • Scopes: risk:read and risk:write are not among the default scopes and are selected separately when the key is created; on the command line, flowpayra-lite apikey create --name crm --scope risk:read --scope risk:write. The orders scope of early keys does not include them.
  • Sources: an entry’s source is manual (the merchant’s list), ofac (the OFAC SDN list), feed:<name> (a URL feed) or list:<name> (a named list). Write endpoints write to the merchant’s list by default; pass list to write to a named list (created on first use; it cannot be a URL feed, which answers 409 list_is_feed). OFAC and URL feed entries are maintained by their own imports and cannot be removed through the API (409 entry_not_removable).
  • Levels: block (quotes are refused), review (payment is allowed and the order is flagged for review once booked), allow (allowed, taking precedence over every other source). In screening, an allow from any source wins, then block, then review.
  • Fields: address (EVM addresses in any case), level (default block), category (sanctions, scam, hack, mixer, false_positive, other; other names are mapped by meaning), chain_id (a chain configured in this deployment; omitted for all chains; an array in bulk imports, one entry per chain), reason (at most 200 characters, visible in the console only), expires_at (RFC 3339 or YYYY-MM-DD).
  • Test mode: a test key (fpk_test_…) reads every entry but writes only entries whose chain_id is a testnet (otherwise 403 testnet_only). Its replace imports and removals also touch only testnet entries and do not affect the screening of live payments.
  • Writes are recorded in the audit log (actor api:<key name>), and the console shows which key wrote an entry.
Terminal window
# Add to the block list
curl -X POST "$BASE/v1/risk/addresses" -H "Authorization: Bearer $KEY" -H "Idempotency-Key: $(uuidgen)" \
-H 'content-type: application/json' \
-d '{"address":"0x098B716B8Aaf21512996dC57EB0615e2383E2f96","level":"block","category":"hack","reason":"fraud team"}'
# Replace the named list crm with the risk system's complete list
curl -X POST "$BASE/v1/risk/addresses/import" -H "Authorization: Bearer $KEY" -H "Idempotency-Key: $(uuidgen)" \
-H 'content-type: application/json' \
-d '{"list":"crm","mode":"replace","entries":["0x098B716B8Aaf21512996dC57EB0615e2383E2f96",{"address":"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC","level":"review","chain_id":[1,8453]}]}'
# → {"list":"crm","source":"list:crm","mode":"replace","total":3,"added":3,"removed":0,"duplicates":0}
# List an address's entries; remove its entry from the merchant's list
curl "$BASE/v1/risk/addresses?address=0x098B716B8Aaf21512996dC57EB0615e2383E2f96" -H "Authorization: Bearer $KEY"
curl -X DELETE "$BASE/v1/risk/addresses/0x098B716B8Aaf21512996dC57EB0615e2383E2f96" -H "Authorization: Bearer $KEY"

An actual response:

POST /v1/risk/addresses → 201
{ "id": "51be397f-2b18-48cc-9219-37fee947b95a", "address": "0x098B716B8Aaf21512996dC57EB0615e2383E2f96",
"chain_id": null, "source": "manual", "category": "scam", "level": "block", "reason": "Reported by the fraud team",
"expires_at": null, "created_at": "2026-10-22T14:16:11.818131Z", "updated_at": "2026-10-22T14:16:11.818131Z" }

In the request behind this response, "category": "fraud" was mapped to scam, and the address is returned in EIP-55 checksum format.

  • Modal / iframe embedding: load /pay/embed.js in the merchant page; the checkout opens in a modal on desktop and redirects on phones. The embedding site must be allowed in the console. See Embedding the checkout.
  • Test mode (Sandbox): test keys, testnets and faucets, the test webhook and deleting test data are described under Test mode. Going live only requires replacing the API key and the webhook secret with the live ones.
Item Limit
Request rate The business API has no rate limit; call it as needed and within reason (leave several seconds between polls of the event feed)
Request body 64 KiB (4 MiB for POST /v1/risk/addresses/import); larger bodies answer 413 payload_too_large
Request duration 30 seconds; a timeout answers 408
Pagination GET /v1/events and GET /v1/risk/addresses return at most 500 items per page
Orders Lifetime 60 seconds to 7 days; amounts with at most 8 decimals and not above 10^12; at most 10 split members
Subscription links 60 seconds to 30 days, 7 days by default; a plan change link expires at the latest 15 minutes before the effective boundary
Risk list import At most 10,000 entries per request
Webhooks Acknowledge within 10 seconds; 12 attempts over about 24 hours
  • Complete the full flow on a testnet with a test key: create an order → pay at the checkout → verify the return signature → verify the webhook signature and handle it idempotently → check with GET /v1/orders/{id} → fulfil. Do the same for subscriptions: activation, charge, cancellation (and a plan change if you use them).
  • Set the live webhook endpoint to an HTTPS URL in the console and store the live signing secret. The receiver verifies the signature and timestamp, deduplicates by event id and answers 2xx within 10 seconds.
  • The return page verifies sig and ts; fulfilment depends only on webhooks or the query API.
  • Switch to a live key (fpk_live_…) with the least scopes needed for its purpose. Keep the key and the webhook secret in a secrets manager, out of the code repository and logs.
  • Every create request carries a stable Idempotency-Key; network errors and 5xx answers are retried with the same key.
  • Handle every order status: duplicate_paid (return the extra payment from the console), reverted (pause fulfilment), expired, refunded / partially_refunded; review manually when risk_flag is set.
  • Subscriptions: handle charge_failed, unpaid, canceled, completed, allowance_low, plan_change_* and migration_requested; the account page links to “My subscriptions” ($BASE/my/subscriptions).
  • Deploy an event feed fallback job (or query orders that stay pending for long) and persist next_since.
  • Monitor system.* events or configure an alert center channel, in particular for the kinds marked as requiring a refund.
  • Confirm in the console the live networks and tokens, the payee addresses (screened), the default split rule, the amount limits and the receipt email settings.
  • Confirm that the version of GET /v1/openapi.yaml matches your locally generated client (the Postman collection in the repository, docs/developers/postman/flowpay.postman_collection.json, can also be used to spot-check the endpoints).