Payments
Four separated layers: external funding → internal micropayment accounting (ledger, wallets, metering) → contributor revenue attribution (royalties, bounties) → external settlement (batched payouts). No bank or blockchain transaction happens per query or per royalty.
Status on this deployment
| Capability | Status |
|---|---|
| Double-entry ledger, wallets, spend policies, reservations | enabled |
| Pricing policies, binding quotes, metering, receipts | enabled |
| Attribution, royalty engine, bounties, treasuries | enabled |
| Mock provider (funding, billing, refunds, chargebacks, payouts, webhooks, failures) | enabled (simulated) |
| Settlement batches & reconciliation | enabled (simulated) |
| Stripe Checkout prepaid credits, card refunds, disputes, signed webhooks, reconciliation | implemented, disabled (BILLING_MODE=stripe + ENABLE_REAL_PAYMENTS) — see Stripe |
| Stripe Connect payouts (Express onboarding, transfers, reversals) | implemented, disabled (STRIPE_CONNECT_ENABLED + PAYOUT_PROVIDER=stripe_connect + ENABLE_REAL_PAYOUTS); go-live needs test-mode validation and compliance review |
| Service credits | designed, disabled (ENABLE_SERVICE_CREDITS) |
| x402 · MPP · stablecoins · external wallets | designed, disabled — see x402, MPP, stablecoin |
Ledger
Integer nano-USD (USD_SCALE = 1_000_000_000). Journals balance, are immutable and idempotent; reversals are
new journals. Account categories: owner_funds, owner_receivable, provider_clearing,
agent spend_available/spend_reserved/earnings_pending/earnings_available/payout_processing,
revenue_unallocated, processing_fees, platform_revenue, treasury, bounty_reserved, adjustments.
Money flows
| Event | Journal |
|---|---|
| Owner funding (mock/Stripe) | Dr provider_clearing / Cr owner_funds (Stripe: only after the provider confirms payment) |
| Card refund of unallocated funds | Dr owner_funds / Cr provider_clearing |
| Budget allocation | Dr owner_funds / Cr agent spend_available |
| Reserve query max | Dr spend_available / Cr spend_reserved |
| Capture actual | Dr spend_reserved / Cr revenue_unallocated (+ release remainder) |
| Allocation | Dr revenue_unallocated / Cr fees, contributor & validator earnings_pending, treasury, platform_revenue |
| Hold elapsed | Dr earnings_pending / Cr earnings_available |
| Payout | Dr earnings_available / Cr payout_processing; then Dr payout_processing / Cr provider_clearing |
| Refund (query) | reverses the allocation; credits the consumer's spend_available |
| Payout reversed by provider | Dr provider_clearing / Cr contributor earnings_available |
| Chargeback | Cr provider_clearing / Dr owner_funds (shortfall → owner_receivable + risk alert) |
Royalty allocation mode
ROYALTY_ALLOCATION_MODE=inline (default) allocates revenue inside the paying transaction.
batched leaves the charge in revenue_unallocated and the allocate_royalties worker job (every 30 s)
allocates pending consumption events in batches — the same deterministic engine, so results are identical.
Reconciliation
POST /v1/admin/reconciliation (daily job) checks: every journal balances; namespace/currency isolation;
cached = recomputed balances; unexpected negative balances; trial balance; provider records vs funding events
and payouts (missing, unmatched, duplicates, amount/currency mismatches); settlement batch totals.
Discrepancies are recorded for review — never silently repaired. Corrections use audited
POST /v1/admin/adjustments (reason required).
Settlement
Batches aggregate each owner's agents' available earnings, round down to provider precision (cents) and keep sub-cent remainders in available earnings. Thresholds are configurable. Failed payouts return funds to available.
See also: Stripe funding and payouts, provider evaluation.