Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Seller Ledger UI — payment splits, transfers and payouts in both panels
Status: Implemented (2026-09-09) — backend, both SDKs, both panels, specs and E2E all in
Target: Spree 6.0
Depends on: 6.0-multi-vendor-marketplace.md (Decision 5 — PaymentSplit; Decision 9 — the two-level ledger; Decision 10 — the seller branch; Phases 3, 3a, 3b — all shipped), 6.0-seller-order-management.md (the seller order page this extends, and its money constraints), 6.0-admin-spa.md (panel composition)
Author: Damian Legawiec
Last updated: 2026-09-09
Summary
The marketplace's money model is complete on the backend — one customer payment recorded per child order as a PaymentSplit, a SellerTransfer credited to the seller when their order ships, a SellerPayout sweeping those transfers to the seller's bank, and Stripe Connect executing both — but nobody can see any of it. A seller's order page shows what the sale came to and what the marketplace charged them, and nothing about what was paid or what they earned; the seller panel has no earnings or payouts screens at all. The operator dashboard has the ledger endpoints in the SDK and consumes none of them: no transfers list, no payouts queue, no balance on a seller's page, and on an order that came out of a split checkout the payments card is empty, because the payment hangs off the group. This plan closes the marketplace plan's Phase 4 ledger items: the read-only balance, transfer and payout ledger in the seller panel, the payment share on a seller's order, and the operator's transfers list, payouts review queue with mark-paid, balance card and grouped-order payments.
Key Decisions (do not deviate without discussion)
1. The seller sees their own share of the payment, never the payment (RESOLVED 2026-09-09)
Reaffirms the marketplace plan (Decision 10: "the seller sees its payment_split, never the group's Payment") and the seller order plan (Seller::OrderSerializer "does not gain payments"). The seller order serializer gains payment_splits, serialized by a Seller::PaymentSplitSerializer that carries the split's amounts and nothing about the payment behind it — no method, no gateway status, no source. A seller reconciling their statement needs "how much of my order was captured, refunded and is still refundable"; how the buyer paid the marketplace stays the marketplace's.
An order placed with a single seller does not split and has no PaymentSplit rows: the panel's payment card then shows only what the order already serializes — payment_status, payment_total, amount_due — and no per-payment rows. This is deliberate. Exposing the order's own Payment on that path would mean two shapes for one card, and would reopen the payments question the seller order plan closed. If a seller-facing payment row is ever wanted for ungrouped orders, it is a Seller::PaymentSerializer with the split's field list, never a subclass of the store or admin one.
2. The seller ledger gets its own read-only key, seller_earnings (RESOLVED 2026-09-09)
Spree::SellerTransfer and Spree::SellerPayout are subjects of the operator's payouts resource, which is closed to the seller audience by design (the catalog comment: a seller reads their own earnings through their own branch, scope-fetched, never through a key that could reach the whole ledger). The seller branch therefore gates its balance, transfer and payout endpoints on a new catalog resource:
register_scope(:seller_earnings, group: :seller, resources: -> { [:seller_earnings] },
write: false, audiences: %i[seller])
A symbol resource, exactly like seller_profile and for the same reason: the model classes belong to payouts, and claiming them twice would make scope_for_resource answer by registration order. Controllers declare scoped_resource :seller_earnings and override authorize_resource! to authorize the symbol (the PoliciesController pattern); which rows a seller may read is current_seller scope-fetching, never an ability rule.
Chosen over reusing seller_profile because a seller's owner must be able to give a packing teammate orders and fulfilments without showing them the money — settlement configuration is profile, but the ledger is the seller's books. A seller admin role is born with grantable_keys(:seller) at creation, so every seller created from here on holds the key; sellers are new in 6.0 and nothing older needs catching up, so there is no backfill (2026-09-09). A development database seeded before this key needs its seller role re-created or the key added by hand.
3. Operator ledger screens live under Sellers; the seller panel gets Earnings and Payouts (RESOLVED 2026-09-09)
Operator: /sellers/transfers and /sellers/payouts (+ /sellers/payouts/:id) as children of the existing Sellers nav entry, gated on Subject.SellerTransfer / Subject.SellerPayout. They are about sellers, the way returns and exchanges sit under Orders; a store selling only its own goods never sees the entry. The existing settings/payouts page (store defaults and provider choice) is untouched.
Seller panel: two top-level entries between Orders and Profile — Earnings (/earnings: the balance per currency, then the transfer list) and Payouts (/payouts, /payouts/:id: settlements, each itemizing the transfers it covers). Two entries rather than one because they answer different questions on different days: "what did I earn on that order" and "did last week's payout go out". Both gated on the seller_earnings subject.
4. Balance is a value object computed from the ledger, per currency, on both branches
Spree::SellerBalance (ActiveModel::Model + ActiveModel::Attributes, per the project's no-Struct rule) is one seller's position in one currency: earned (Σ completed transfers, reversals included), paid (Σ completed payouts), balance (earned − paid — what the marketplace still owes, the same figure Seller#balance(currency) already answers), and pending (Σ transfers still pending/processing/unresolved — money in flight with the provider, shown so a seller does not read a shipped order as unpaid). Seller#balances answers one per currency the seller has ever earned or been paid in, so a multi-currency marketplace never collapses two ledgers into one number.
Served by GET /api/v3/seller/balances and GET /api/v3/admin/sellers/:id/balances. Deliberately not a marketplace-wide "owed by seller" endpoint: the payouts list filtered to owed is the operator's queue, and the sweep is what turns a balance into something to act on.
5. A grouped order's payments card shows the group's payments, read-only, with this order's share (RESOLVED 2026-09-09)
On an order that came out of a split checkout, order.payments is empty and the operator's payments card renders "no payments" — which is wrong, not merely incomplete. The card fetches the order group (GET /admin/order_groups/:id, which already serializes payments) and the order's payment_splits (a new expand), and renders each payment with an extra column: this order's authorized / captured / refunded share. Capture and void are not offered on a grouped child: those act on the group's payment, i.e. on every sibling's money, and belong on a surface that says so. Admin::OrderSerializer#payments keeps its meaning (the order's own rows), so the nested orders/:id/payments controller and everything reading order.payments are unchanged.
6. Read and write stay where they are
Nothing here creates, edits or moves money. Transfers and payouts are written by fulfilment and the sweep; the one write in scope is the existing PATCH /admin/seller_payouts/:id/complete (the built-in provider's "the bank transfer went out"), which the operator's payouts pages now expose with a reference field. The seller branch is read-only end to end — a seller sees unresolved and failed rows with their status and the marketplace's contact is how they follow up.
Design Details
Backend
Core
seller_earningscatalog resource.Spree::SellerBalance—spree/core/app/models/spree/seller_balance.rb. Attributesseller,currency,earned,paid,balance,pending(decimals),display_*viaSpree::Money.SellerBalance.for(seller, currency)computes fromseller.seller_transfers/seller.seller_payoutsin four grouped sums;Seller#balancesmaps it overcurrencies = transfers.distinct.pluck(:currency) | payouts.distinct.pluck(:currency).Seller#balance(currency)stays as the canonical single figure (the payout sweep reads it).Spree::SellerTransfer.whitelisted_ransackable_attributes+=seller_id order_id payout_id;Spree::SellerPayout.whitelisted_ransackable_attributes+=seller_id. Without these aq[order_id_eq]filter silently matches nothing (the lesson recorded in the marketplace plan's Phase 4 note). The base controller already decodes prefixed ids in*_id_eqpredicates.Spree::PaymentSplit:claimed_amountjoinsmoney_methodsso every amount has adisplay_twin;net_captured_amountandrefundable_amountget display twins the same way.
Seller API (/api/v3/seller, all read-only, all scoped_resource :seller_earnings with the PoliciesController-style authorization override, all rooted in current_seller):
GET /balances—Seller::BalancesController < Seller::BaseController(a computed collection, no model; renderscurrent_seller.balances).GET /transfers,GET /transfers/:id—Seller::TransfersController < Seller::ResourceController,seller_association :seller_transfers,collection_includes [:order, :payout].GET /payouts,GET /payouts/:id—Seller::PayoutsController,seller_association :seller_payouts, with the same page-widetransfer_countsthe admin controller builds.- Serializers, all from
V3::BaseSerializer(never a subclass of the admin ones — the seller order plan's constraint):Seller::TransferSerializer:id kind status currency amount display_amount provider reference order_id order_number payout_id reversed_from_id created_at updated_at. Nometadata(provider internals), norefund_id(refunds are not a seller resource), noseller_id/seller_name(there is one seller in play).Seller::PayoutSerializer:id status currency amount display_amount provider reference period_start period_end transfers_count created_at updated_at.Seller::BalanceSerializer:currency earned paid balance pending+display_twins.idisnil— the base serializer rendersidonly for objects answeringprefixed_id; the SDK type marks it absent.Seller::PaymentSplitSerializer:id currency authorized_amount captured_amount refunded_amount claimed_amount net_captured_amount refundable_amount+display_twins,created_at.Seller::OrderSerializergainsmany :payment_splits, always rendered (an order page fetches one order; a list never embeds them because the seller orders index uses the same serializer — so the relation is gatedif: proc { expand?('payment_splits') }, and the panel's order query asks for it).
- Routes:
resources :balances, only: [:index],resources :transfers, only: [:index, :show],resources :payouts, only: [:index, :show]in the seller block, next toorders.
Admin API:
Admin::PaymentSplitSerializer: the seller field list pluspayment_id,payment_number,order_id,order_number,updated_at. Registered asadmin_payment_split_serializer.Admin::OrderSerializergainsmany :payment_splits, if: expand?('payment_splits');Admin::PaymentSerializergains the same, so a group's payment can itemize its shares.GET /admin/sellers/:id/balances—Admin::Sellers::BalancesController,scoped_resource :payouts, seller fetched throughcurrent_store.sellers.Admin::SellerBalanceSerializeraddsseller_idto the seller shape.Admin::OrdersController#showexpandallowlist admitspayment_splits;Admin::OrderGroupsController#showkeeps serializingpayments(already does).
Permissions: the seller_earnings resource (Decision 2). Seller endpoints authorize :seller_earnings; admin balances sit under payouts; payment splits ride on orders (the order expand) and payments (PaymentSplit is already a payments subject). The seller panel gates the Earnings and Payouts entries and the order page's earnings card on the seller_earnings subject; the payment card rides on the order itself.
OpenAPI: integration specs under spree/api/spec/integration/spree/api/v3/seller/{balances,transfers,payouts}_spec.rb and admin/sellers/balances_spec.rb; swaggerize regenerates seller.yaml and admin.yaml. Typelizer emits Balance, Transfer, Payout, PaymentSplit into @spree/seller-sdk and PaymentSplit, SellerBalance into @spree/admin-sdk.
SDKs
@spree/seller-sdk:balances.list(),transfers.list(params)/get(id),payouts.list(params)/get(id);orders.getacceptsexpand.@spree/admin-sdk:sellers.balances(id),orderGroups.get(id)(the endpoint exists, the client never wrapped it),orders.getalready takesexpand.
Seller panel (@spree/seller-dashboard)
nav/default.ts → earnings (130), payouts (140), subject 'seller_earnings'
routes/_authenticated/$sellerId/earnings/index.tsx
routes/_authenticated/$sellerId/payouts/index.tsx
routes/_authenticated/$sellerId/payouts/$payoutId.tsx
pages/earnings.tsx → BalanceSummary + ResourceTable<Transfer> ('seller-transfers')
pages/payouts.tsx → ResourceTable<Payout> ('seller-payouts')
pages/payout.tsx → header (status, amount, reference, period) + the transfers it settled
components/finance/balance-summary.tsx → one card per currency: balance owed, pending; empty state before the first sale
components/orders/order-payment-card.tsx → payment status, paid, due; split rows when the order is grouped
components/orders/order-earnings-card.tsx → this order's transfers: kind, status, amount, payout link; nothing until fulfilled
tables/seller-transfers.tsx, tables/seller-payouts.tsx
hooks/use-balances.ts, use-transfers.ts, use-payouts.ts
The order page mounts the payment card after the summary card and the earnings card after it, both in the main column. The transfers table filters by status, kind and created_at; the payouts table by status and created_at. Rows open the payout page; a transfer row links to its order. unresolved joins statusToneMap (warning) in @spree/dashboard-ui, since both panels render it.
Operator dashboard (@spree/dashboard)
nav/default.ts → sellers gains children: sellers.transfers, sellers.payouts
routes/_authenticated/$storeId/sellers/transfers.tsx → ResourceTable<SellerTransfer>
routes/_authenticated/$storeId/sellers/payouts/index.tsx → ResourceTable<SellerPayout>, row action "Mark as paid"
routes/_authenticated/$storeId/sellers/payouts/$payoutId.tsx → header + complete + its transfers
tables/seller-transfers.tsx → filters: seller (resource), status, kind, provider, created_at; links to order/seller/payout
tables/seller-payouts.tsx → filters: seller (resource), status, provider, created_at; default quick filter "owed"
components/spree/sellers/seller-balance-card.tsx → sidebar of the seller page, per currency, links to both lists filtered by seller
components/spree/sellers/payout-complete-dialog.tsx → reference input; shown only for owed payouts
components/spree/orders/order-payments-card.tsx → grouped branch: group payments + this order's share, no actions
components/spree/orders/order-seller-transfers-card.tsx → the earning and its reversals for a seller's order
hooks/use-seller-ledger.ts → useSellerBalances, usePayout, useCompletePayout, useOrderGroup
"Mark as paid" confirms through the dialog (the reference is the confirmation — no second confirm on top). It is offered for pending, processing and unresolved payouts, matching SellerPayouts::Complete's compare-and-swap. Every new key lands in all six dashboard locales; the seller panel ships en.json only, as today.
E2E
packages/dashboard/e2e/seller-ledger.spec.ts: seed a seller with a completed transfer and an owed payout through the API fixtures, open the payouts queue, mark it paid with a reference, assert the status badge and the reference on the detail page. Seller-panel coverage stays at controller + integration specs until that package has an e2e stack.
Migration Path
No schema change; everything was additive. Shipped in this order:
- Core + Admin API.
Spree::SellerBalance,Seller#balances, theseller_earningscatalog resource, Ransack allowlist additions (seller_idon both ledger models, plusorder_id/payout_idon transfers),PaymentSplitdisplay methods forclaimed_amount,net_captured_amountandrefundable_amount, the admin payment-split and seller-balance serializers,payment_splitsexpands on the admin order and payment serializers, andGET /admin/sellers/:id/balances. - Seller API.
BalancesController,TransfersController,PayoutsController, four serializers, routes, andpayment_splitson the seller order serializer behind an expand. - SDKs. Typelizer regeneration,
balances/transfers/payoutson the seller client withorders.gettaking an expand,sellers.balancesand a neworderGroupsresource on the admin client. - Seller panel. The payment and earnings cards on the order page, then Earnings, then Payouts and the payout detail page.
- Operator dashboard. The grouped-payments branch on the payments card, the seller-transfers card on the order page, the balance card on the seller page, the two ledger lists, the payout page, the mark-as-paid dialog, nav children, and locale keys in all six languages.
ReadRow was extracted out of the seller panel's profile page into components/read-row.tsx rather than copied a third time.
Sample data. spree:sellers:sample_data gained a fund ledger, so the new screens have something to render in a fresh development environment: five sales, a completed payout carrying its bank reference, one still owed for the mark-as-paid flow, an earning not yet swept into either, and a refund reversal. The reversal is deliberately left unsettled — a refund after its sale was already paid out belongs to the next period rather than to a closed settlement, which is the behaviour the ledger models. Written directly rather than through fulfilment and the sweep: reaching those would mean placing and shipping real orders, and the screens read the rows either way. Idempotent, and development/test only like the rest of that task.
Constraints on Current Work
- A seller serializer for money carries amounts, never provenance.
Seller::PaymentSplitSerializermust not growpayment_id, a method name, a gateway status or a source;Seller::TransferSerializermust not growmetadataorrefund_id. Anything that identifies the marketplace's payment or the buyer's instrument is the admin serializer's. - Seller ledger endpoints authorize
:seller_earningsand root incurrent_seller. Do not addpayoutsorpaymentsto the seller audience to makeauthorize!on the model class pass — that is the leak the catalog comment warns about. - A seller role holds the keys it was created with. Adding a seller-audience key to the catalog reaches new roles only; that is acceptable while sellers are new in 6.0, and a key added after 6.0 ships is a different conversation.
- Nothing on either panel offers capture, void or refund on a grouped child's payment until a surface exists that names every sibling the action touches.
- Filters go through the allowlist. A new
q[<column>_eq]on the ledger needs the column inwhitelisted_ransackable_attributes; an association name alone does not make its foreign key filterable. Seller#balance(currency)stays the single figure the sweep reads.SellerBalancepresents it; it must not compute a different number.
Open Questions
None. The four questions the draft raised (the seller permission key, ungrouped-order payments, operator navigation, and the grouped child's payments card) were settled on 2026-09-09 and are recorded in Key Decisions 2, 1, 3 and 5.
Deferred, not open: a seller-facing payment row on ungrouped orders (Decision 1 names the shape if wanted), and capture/void on a grouped child's payment (Decision 5 — needs a surface that names every sibling).
References
docs/plans/6.0-multi-vendor-marketplace.md— Decisions 5, 9, 10; Phases 3, 3a, 3b, 4.docs/plans/6.0-seller-order-management.md— the seller order page and its money constraints.docs/plans/6.0-admin-api.md— Marketplace endpoint group.spree/api/app/controllers/spree/api/v3/seller/policies_controller.rb— theseller_profileauthorization pattern.spree/api/app/controllers/spree/api/v3/admin/seller_payouts_controller.rb—completeand the page-wide transfer count.