Charges
A charge starts the collection of a payment. Creating one persists an order, opens a payment attempt on the chosen channel, and returns a payer instruction telling you how the customer should pay.
The charge result
POST /api/v1/charges returns three objects plus an idempotency flag.
order
- Name
id- Type
- string
- Description
The fluxa order id, prefixed
ord_.
- Name
merchant_order_id- Type
- string
- Description
Your idempotency key for this order.
- Name
channel_code- Type
- string
- Description
The channel the charge was created on.
- Name
channel_name- Type
- string
- Description
Human-readable display name of that channel, resolved by the platform. Render this to people; keep
channel_codefor logic.
- Name
settlement_mode- Type
- string
- Description
Funds-flow mode stamped at creation:
direct(your own wallet or Stripe account) orcustodial(Fluxa balance). Determined by the selected channel and immutable for the order. See Settlement modes.
- Name
amount- Type
- string
- Description
The order amount, as a decimal string.
- Name
refunded_amount- Type
- string
- Description
Cumulative amount refunded so far.
0until a refund occurs.
- Name
settle_on_received- Type
- boolean
- Description
truewhen the charge was created with the settle-on-received opt-in (seesettle_on_receivedunder Create a charge below), otherwisefalse. Immutable.
- Name
min_received_amount- Type
- string
- Description
The minimum cumulative received amount stamped at creation. Present only when
settle_on_receivedistrue. Immutable.
- Name
received_amount- Type
- string
- Description
Cumulative gross amount credited to you for this order under settle-on-received, as a decimal string:
"0"until the order settles, then what actually arrived, growing with every later transfer that is credited. Always"0"for exact-mode orders, where it carries no meaning.
- Name
currency- Type
- string
- Description
ISO currency / asset code, e.g.
USDorUSDT.
- Name
status- Type
- string
- Description
One of
created,pending,paid,expired,canceled,failed,refunded,partially_refunded.
- Name
is_test- Type
- boolean
- Description
truefor orders created with a test-mode key (never settles).
- Name
subject- Type
- string
- Description
Short description shown to the payer.
- Name
description- Type
- string
- Description
Longer free-text description.
- Name
metadata- Type
- object
- Description
The key/value object you attached at creation.
- Name
expires_at- Type
- timestamp
- Description
When an unpaid order expires, or
null.
- Name
paid_at- Type
- timestamp
- Description
When the order was paid, or
null.
- Name
created_at- Type
- timestamp
- Description
When the order was created.
instruction
The instruction tells the payer how to proceed. Its type selects which fields are populated.
- Name
type- Type
- string
- Description
redirect(send the payer toredirect_url),crypto_address(pay todeposit_address),client_secret(confirm client-side), ornone.
- Name
redirect_url- Type
- string
- Description
Hosted-checkout URL, for
redirectinstructions.
- Name
client_secret- Type
- string
- Description
Provider client secret, for
client_secretinstructions: the Stripe PaymentIntent client secret of an embedded charge (presentation: "embedded"). Hand it only to the payer's browser; don't log or store it.
- Name
publishable_key- Type
- string
- Description
For
client_secretinstructions: the Stripe publishable key to initialize Stripe.js with. Take it from each response rather than hard-coding it — test, live and your own Stripe account each have their own.
- Name
deposit_address- Type
- string
- Description
On-chain address to pay, for
crypto_addressinstructions.
- Name
chain- Type
- string
- Description
Chain code of the deposit address (e.g.
usdt_erc20).
- Name
asset- Type
- string
- Description
Asset to pay in (e.g.
USDT).
- Name
amount_due- Type
- string
- Description
Amount that must ARRIVE at
deposit_address. Display it as the required received amount. Wallets and exchanges apply withdrawal fees differently: ask the payer to follow the withdrawal page’s fee rules and verify that the address will receive this amount before confirming. A shortfall parks the order awaiting a top-up; small shortfalls may settle under an operator-configured tolerance, but the API does not promise that. Withsettle_on_received, the order instead settles once at leastmin_received_amount(or the amount less the channel tolerance, whichever is lower) has arrived and credits what actually arrived; later transfers to the same address, while it is still bound to this order, are credited aspayment.additional_received.
- Name
required_confirmations- Type
- integer
- Description
On-chain confirmations required before the order is marked paid.
- Name
expires_at- Type
- timestamp
- Description
When the instruction expires, when applicable.
The result also includes a payment object (the attempt, with id, status, and crypto fields where relevant) and idempotent: true when an existing order was returned for a reused merchant_order_id. If that order has since expired, been canceled or failed, the retry returns it with instruction.type: "none" and nothing payable: no checkout link, client secret or deposit address. Its payment.channel_ref is kept for reconciliation; for an on-chain order that is the deposit address the order was assigned, so never show it to the payer: a deposit to it does not pay the closed order.
Quote payer-paid fees
Request a live fee estimate with the same merchant signing credentials used to create a charge. amount is the discounted subtotal the merchant should receive; precision is required and must match the currency’s payment precision (0–18). Amounts must be positive, at most 1,000,000,000,000, with no more than 18 decimal places.
Every POST signature is single-use. For repeated quotes within the same second, add a unique quote_id query parameter and include the canonical query in the signature; changing only an unsigned header is insufficient.
{"amount":"8.50","currency":"USDT","channel":"usdt_tron","precision":2}
The response contains decimal strings: amount (subtotal), fee (platform surcharge including upward rounding), and total (subtotal plus surcharge), as well as currency and channel. Display all three amounts and pass total as the charge amount. For a merchant rate of 0.3%, a subtotal of 8.50 produces a total of 8.53 and a surcharge of 0.03.
{"amount":"8.5","fee":"0.03","total":"8.53","currency":"USDT","channel":"usdt_tron"}
This read-only quote does not reserve a fee schedule or create an order. Requote before charging and ask the payer to confirm if the total changes. Merchant overrides take precedence over channel fees. Invalid inputs return 400; unavailable fee configuration returns 503. External wallet or exchange withdrawal/network fees are excluded: verify the receiving address will receive the charge instruction’s amount_due, using the withdrawal page’s own fee rules.
Create a charge
Signed locally — your secret stays in this browser and is never sent or stored.
No keys yet? Create an API key pair in the merchant portal — the secret is shown only once. Open the merchant portal →
Create a charge on a channel. Idempotent on merchant_order_id: reusing a value returns the existing order with idempotent: true instead of creating a duplicate.
Required attributes
- Name
amount- Type
- string
- Description
The amount to collect, as a decimal string, e.g.
"49.90".
- Name
currency- Type
- string
- Description
The pricing currency / asset, e.g.
"USD"or"USDT".
Channel selection
Pass one of channel (explicit) or network (routed). With neither, the request fails with channel_or_network_required.
- Name
channel- Type
- string
- Description
The channel
codeto charge on. List enabled channels via Channels. When set,networkis ignored. If the platform has linked your own Stripe account through Stripe Connect, or you saved your own Stripe key in the portal, passstripe: the charge is routed to your Stripe account automatically (see the notes below).
- Name
network- Type
- string
- Description
Lowercase blockchain network label (
"tron","base","bsc","polygon","ethereum","arbitrum", …). Routes the pair (network,currency) to a direct channel or an eligible configured custodial gateway. No eligible route returnsno_route. Omit this field for local fiat channels such as LianLian; passchannelexplicitly.
Optional attributes
- Name
merchant_order_id- Type
- string
- Description
Your idempotency key. Strongly recommended so retries don't double-charge. A retry must repeat the same
amount,currencyandchannel: reusing the id with different values returns409 idempotency_mismatchrather than the earlier order. When omitted, the order's ownidis used as itsmerchant_order_id(it is not treated as an idempotency key).
- Name
subject- Type
- string
- Description
Short description shown to the payer.
- Name
description- Type
- string
- Description
Longer free-text description.
- Name
metadata- Type
- object
- Description
Arbitrary key/value pairs stored with the order and echoed back.
- Name
return_url- Type
- string
- Description
Where to send the payer after a successful hosted checkout.
- Name
cancel_url- Type
- string
- Description
Where to send the payer if they cancel a hosted checkout.
- Name
expires_in_seconds- Type
- integer
- Description
Seconds until an unpaid order expires. When omitted (or not positive), the charge takes the platform default; where there is none, an
embeddedcharge expires after 30 minutes. If the order expires (or is canceled) before the payment channel has finished creating its payment, the charge fails with409 order_closed_during_chargeand the order stays closed (see Errors); keep it comfortably longer than the channel's response time.
- Name
presentation- Type
- string
- Description
How the payer pays:
redirect(default) returns a hosted-checkoutredirect_url;embeddedreturns aclient_secretinstruction for the Stripe Payment Element in your own page (see the note below). Any other value fails withinvalid_presentation. On an idempotent retry it is compared only when present.
- Name
save_payment_method- Type
- boolean
- Description
Save the card the payer pays with on the hosted checkout, so a subscription created afterwards with
payment_method_order_idset to this order charges it off-session. Stripe hosted checkouts only (the platform's Stripe or your own Stripe key, not Stripe Connect); a card is saved only when the payer pays by card. Elsewhere, withpresentation: "embedded"or withmethodpinned to anything butcard, the request fails with400 save_payment_method_unsupported.
- Name
tax_code- Type
- string
- Description
Stripe product tax code ID (
txcd_followed by 8 digits, e.g.txcd_10103000) of what this charge sells, sent as the Checkout line item's product tax code instead of the channel's default. Required when the channel runs on Stripe Managed Payments and has no default tax code (400 tax_code_required); Managed Payments accepts only eligible tax codes. A malformed value fails with400 invalid_tax_code. Channels other than Stripe ignore it.
- Name
settle_on_received- Type
- boolean
- Description
Settle at the amount actually received instead of the exact amount. Direct-settlement (on-chain) channels only: on any other channel, including a
networkroute that resolves to a custodial gateway, the request fails withsettle_on_received_unsupported. The order settles once the confirmed amount received reachesmin_received_amount(oramountless the channel tolerance, whichever is lower) and is credited with exactly what arrived, short, exact or over. The platform fee is the fee onamount, pro-rated on what arrived and never more than the fee on the full amount; if that fee would consume the whole amount, a live charge fails withamount_not_above_feeand a test-mode charge withmin_received_amount_not_above_fee. Transfers confirmed after the order is paid are credited too and reported aspayment.additional_received(see Webhooks). Omit, or passfalse, for exact-amount settlement. On an idempotent retry the two opt-in fields are compared only when present: a retry that omits them returns the existing order with its stamped values; one that states them must match the stamps, or it fails with409 idempotency_mismatch.
- Name
min_received_amount- Type
- string
- Description
Lowest cumulative received amount, as a decimal string, at which a
settle_on_receivedcharge settles. Requiressettle_on_received: true; must be greater than0and not greater thanamount, with at most 18 decimal places, and on a live charge not below the channel's minimum charge amount and not in a higher platform fee rate thanamount(every receipt is charged the fee rate ofamount, so on a channel with a fixed fee component or fee tiers an explicit minimum must fall in the bracket ofamount). Otherwise the request fails withinvalid_min_received_amount. Defaults to the channel's minimum charge amount (capped atamount), or toamountwhen the channel has none; on a live charge that default is then raised to the lowest value whose fee rate is not above that ofamount, so an omitted minimum is never refused for its rate. On fee tiers that is the lower bound of the tieramountfalls in (when higher than the channel minimum); with a pure percentage fee the default is unchanged; with a fixed fee component it isamountitself, so the order settles only once the amount less the channel tolerance has arrived, while still crediting exactly what arrived. The resolved value is echoed asorder.min_received_amount.
Request
// No channel: fluxa routes (network, currency) to an
// on-chain direct-settlement channel — the net settles
// straight to your own wallet.
const res = await pgFetch('POST', '/api/v1/charges', {
merchant_order_id: 'order-1002',
amount: '100',
currency: 'USDT',
network: 'tron',
})
const { order, instruction } = await res.json()
// instruction.type === 'crypto_address'
Response
{
"order": {
"id": "ord_2Zx9Qw8sUaM2",
"merchant_order_id": "order-1001",
"channel_code": "usdc_base",
"settlement_mode": "direct",
"amount": "100",
"refunded_amount": "0",
"settle_on_received": false,
"received_amount": "0",
"currency": "USDC",
"status": "created",
"is_test": false,
"subject": "Pro plan",
"metadata": { "user_id": "u_42" },
"expires_at": null,
"paid_at": null,
"created_at": "2026-06-11T08:25:00Z"
},
"payment": {
"id": "pay_7K2mQ",
"order_id": "ord_2Zx9Qw8sUaM2",
"status": "initiated",
"amount": "100",
"currency": "USDC"
},
"instruction": {
"type": "crypto_address",
"deposit_address": "0x7a3b...c91e",
"amount_due": "100",
"chain": "usdc_base",
"asset": "USDC",
"required_confirmations": 12
},
"idempotent": false
}
For a live on-chain charge you must have a settlement address configured — the net amount settles directly to your own address. Without one, fluxa refuses to create the charge. On-chain orders also cannot be refunded through the platform or paid out (the funds never touch a platform-held balance). See Settlement modes for the full funds-flow model and the routing-specific error codes (no_route, channel_or_network_required, payment_mode_disabled).
Stripe Connect. Once the platform has linked and activated your own Stripe account, a charge with channel: "stripe" is switched transparently onto it: the order's channel_code becomes the platform's Connect channel, settlement_mode is direct, and the instruction is a redirect to a Stripe Checkout page on your account. You never name the Connect channel yourself — passing its code returns 400 channel_not_supported. Connect-specific errors: 409 stripe_account_not_ready (Stripe has not enabled charges on your account yet), 409 stripe_connect_inactive (your link is disabled or disconnected; the charge never falls back to the platform's custodial Stripe), 503 stripe_connect_unavailable (the platform's Connect channel is unavailable right now), and 400 amount_not_above_fee / 400 invalid_amount (the platform fee would not leave a positive amount, or the amount is not a whole number of the currency's smallest unit). See Settlement modes.
Embedded payments (Stripe). With presentation: "embedded" on a Stripe charge, fluxa creates a PaymentIntent instead of a Checkout page and returns instruction.type: "client_secret" with its client_secret and the publishable_key. Load Stripe.js with the key, mount the Payment Element with the client secret and call stripe.confirmPayment; 3DS is handled by Stripe, and Apple Pay / Google Pay appear in the Payment Element where available. The payer never leaves your page, so it works inside an iframe. Treat the result in the browser as a hint only: the order is paid when you receive payment.succeeded. A declined card leaves the order pending (the payer can try another card) and sends no payment.failed. When the order expires or is canceled, fluxa cancels the PaymentIntent in the background, usually within seconds and retrying for up to a few hours if Stripe is unavailable; until then the client secret may still be confirmed, so close the payment page as soon as you receive order.expired or order.canceled. An embedded charge always has a deadline: without expires_in_seconds it takes the platform default, or expires after 30 minutes where there is none, so pass it when you need a specific window. A delayed debit method (such as SEPA Direct Debit or ACH) that is still processing does not extend the deadline, so if your Stripe account offers one, pass an expires_in_seconds long enough for it to settle. Retrying with the same merchant_order_id returns the same client secret while the order is open; once it has expired, been canceled or failed, the retry returns no client secret. Konbini and PayPay work here too on a JPY charge when the channel offers them (pin one with method): a Konbini payer gets the voucher in the Payment Element, and fluxa sends it as payment.pending and keeps the order open until 24 hours after the voucher's deadline. A voucher that lapses unpaid leaves the order pending like a declined card and sends no payment.failed; a new voucher the payer takes in the same Payment Element comes as another payment.pending. Available on the platform's Stripe channels configured with a publishable key and on your own Stripe key when you also saved its publishable key in the portal (your webhook endpoint must then also listen to payment_intent.succeeded, payment_intent.processing, payment_intent.payment_failed, payment_intent.canceled and payment_intent.requires_action, the event that carries a Konbini voucher); otherwise, and for accounts linked through Stripe Connect, the charge fails with 400 presentation_unsupported and nothing is created.
Your own Stripe key. If you saved your own Stripe key for the environment in the portal (and have no Connect link there, which takes precedence), a charge with channel: "stripe" runs on it instead: the order's channel_code becomes your own-key channel (stripe_merchant_<env>_<merchant_id>), settlement_mode is direct, no platform fee is charged, and the instruction is a redirect to a Stripe Checkout page on your account. Passing that code yourself returns 400 channel_not_supported. If the saved key cannot be used right now the charge fails with 503 stripe_account_unavailable rather than falling back to the platform's custodial Stripe. See Settlement modes.