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_code for logic.

  • Name
    settlement_mode
    Type
    string
    Description

    Funds-flow mode stamped at creation: direct (your own wallet or Stripe account) or custodial (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. 0 until a refund occurs.

  • Name
    settle_on_received
    Type
    boolean
    Description

    true when the charge was created with the settle-on-received opt-in (see settle_on_received under Create a charge below), otherwise false. Immutable.

  • Name
    min_received_amount
    Type
    string
    Description

    The minimum cumulative received amount stamped at creation. Present only when settle_on_received is true. 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. USD or USDT.

  • Name
    status
    Type
    string
    Description

    One of created, pending, paid, expired, canceled, failed, refunded, partially_refunded.

  • Name
    is_test
    Type
    boolean
    Description

    true for 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 to redirect_url), crypto_address (pay to deposit_address), client_secret (confirm client-side), or none.

  • Name
    redirect_url
    Type
    string
    Description

    Hosted-checkout URL, for redirect instructions.

  • Name
    client_secret
    Type
    string
    Description

    Provider client secret, for client_secret instructions: 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_secret instructions: 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_address instructions.

  • 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. With settle_on_received, the order instead settles once at least min_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 as payment.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.


POST/api/v1/charges/fee-quote

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.


POST/api/v1/charges

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 code to charge on. List enabled channels via Channels. When set, network is ignored. If the platform has linked your own Stripe account through Stripe Connect, or you saved your own Stripe key in the portal, pass stripe: 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 returns no_route. Omit this field for local fiat channels such as LianLian; pass channel explicitly.

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, currency and channel: reusing the id with different values returns 409 idempotency_mismatch rather than the earlier order. When omitted, the order's own id is used as its merchant_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 embedded charge expires after 30 minutes. If the order expires (or is canceled) before the payment channel has finished creating its payment, the charge fails with 409 order_closed_during_charge and 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-checkout redirect_url; embedded returns a client_secret instruction for the Stripe Payment Element in your own page (see the note below). Any other value fails with invalid_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_id set 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, with presentation: "embedded" or with method pinned to anything but card, the request fails with 400 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 with 400 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 network route that resolves to a custodial gateway, the request fails with settle_on_received_unsupported. The order settles once the confirmed amount received reaches min_received_amount (or amount less the channel tolerance, whichever is lower) and is credited with exactly what arrived, short, exact or over. The platform fee is the fee on amount, 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 with amount_not_above_fee and a test-mode charge with min_received_amount_not_above_fee. Transfers confirmed after the order is paid are credited too and reported as payment.additional_received (see Webhooks). Omit, or pass false, 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 with 409 idempotency_mismatch.

  • Name
    min_received_amount
    Type
    string
    Description

    Lowest cumulative received amount, as a decimal string, at which a settle_on_received charge settles. Requires settle_on_received: true; must be greater than 0 and not greater than amount, 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 than amount (every receipt is charged the fee rate of amount, so on a channel with a fixed fee component or fee tiers an explicit minimum must fall in the bracket of amount). Otherwise the request fails with invalid_min_received_amount. Defaults to the channel's minimum charge amount (capped at amount), or to amount when the channel has none; on a live charge that default is then raised to the lowest value whose fee rate is not above that of amount, so an omitted minimum is never refused for its rate. On fee tiers that is the lower bound of the tier amount falls in (when higher than the channel minimum); with a pure percentage fee the default is unchanged; with a fixed fee component it is amount itself, 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 as order.min_received_amount.

Request

POST
/api/v1/charges
// 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
}