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.
B2B Payment Terms, Deposits Schedule & Bank Transfer References
Status: Draft — nothing built. Re-scoped 2026-09-07: this plan is the single home for the whole subject — deposits, net terms and credit — after deposits were ruled out of scope for wholesale shipping (decisions.md 2026-09-07). It needs rewriting to cover both halves together, since they are two parts of one arrangement, before anything is built.
Target: Not scheduled. The 6.0 slot this plan assumed (riding the wholesale deposit work) no longer exists.
Depends on: B2B Companies (6.0-b2b-companies-and-catalogs.md), Customer PO Numbers (6.0-b2b-customer-po-numbers.md), Document Numbers (6.0-document-numbers.md)
Author: Damian + Claude
Last updated: 2026-09-07 (deposits removed from the wholesale-shipping plan; this plan owns the subject end to end and is unscheduled pending a rewrite that covers net terms too)
Summary
Spree already understands order total, payment total and outstanding balance —
and multiple partial payments against one order work today (each capped at the
outstanding balance, partially_paid derived automatically, the dashboard
add-payment dialog is the "record the wire" UI). What's missing is the
commercial layer: how much is due now, what the agreed terms are, and a
reconciliation-grade payment reference for bank transfers. This plan adds
deposit-style payment terms (collect-first: 100% prepayment, N% deposit +
balance-before-X) as a frozen order snapshot resolved from layered sources, a
derived payment schedule ("Deposit due $8,000 → Deposit paid ✓ → Balance
$12,000 — due before shipping"), a real PaymentMethod::BankTransfer with
structured, stored, searchable payment references (no commerce platform
generates these natively — only one PSP does), and the storefront
pay-the-balance route. Ship-first terms (Net 7/30/60, credit accounts,
invoicing, due dates, dunning) remain Enterprise roadmap item #1 — the
tier line is risk: collecting before shipping is OSS mechanics, extending
credit is the commercial instrument (decided 2026-08-30).
Key Decisions (do not deviate without discussion)
- One
payment_termssnapshot on the order (2026-08-30, interactive review — amends the wholesale plan; resolution narrowed 2026-09-07): the cart resolves{kind, deposit_percentage, balance_due_label, source}and the order freezes the copy at placement — agreed terms survive later changes to the company's arrangement, exactly like negotiated prices.Cart#amount_due_at_checkoutreads the snapshot. - Terms resolve from the buying company, and open source resolves
nothing (2026-09-07, interactive review — supersedes the layered chain
above and the wholesale plan's method-level fields; see
decisions.md2026-09-07).Spree::PaymentTerms.from_companyis the single point terms enter the system and answers nil in open source, so every purchase there owes its full total. A deposit is negotiated with a buyer, so the arrangement belongs to the company — not to the shipping method, which no comparable platform uses for this and which cannot express "this buyer, these terms" at all. The 6.0 preset model andspree_companies.payment_term_idare removed: an unreachable table configuring a feature open source does not expose earns no place in it. The quote/order override stays 6.1. - The balance-due moment is a label, not automation (the merchant's own
framing):
balance_due_label("Before shipping", "Before dispatch") is recorded and displayed; real due dates arrive with Enterprise net terms. OSS derives the payment schedule on read — due-now amount, deposit state (due / paid), outstanding balance, the label — exposed on store + admin serializers; nothing persisted,Orders::UpdateStatusesstays untouched (itspartially_paidalready tells the ledger truth; the schedule tells the commercial truth). PaymentMethod::BankTransferjoins core (6.1) besidePaymentMethod::Check: an offline method whose account details and instruction lines are public preferences (thepublic_preference_keysmechanism — labels configurable because banking fields differ by country), shown at checkout, in order mails and on the payment-instructions print.- Every payment gets a stored, generated
reference(6.1): unique, ransackable, created with the payment (structured creditor-reference style — RF/ISO 11649 check-digits over the payment's prefixed id — so a bank statement line matches exactly one payment). This is deliberately a stored column, never the derivedR1001-P1number: derived numbers shift when a sibling is destroyed (the code's own idempotency warning) and their column is NULL on 6.0 rows — which is also why the derived number quietly broke search and the Stripe gateway'sfind_by(number:)lookup. 6.0 fixes (implemented 2026-08-30, riding the draft-order negotiation mechanics per the Wave 1 bundling): the misleadingnumberransack whitelist entry is removed, and the gateway lookup keys on a newpayment_prefixed_identry inSpree::Payment::GatewayOptions#to_hash(payments.find_by_prefix_id, stored-number lookup kept as the legacy fallback) — the prefixed id is the stable handle the idempotency key was already built on; 6.1'sreferencebecomes the reconciliation identifier the dashboard searches alongside order and PO numbers. - Storefront pay-balance (6.1):
POST /store/orders/:id/payments/ payment sessions on a placed order, owner-authorized, amount capped by the existingmax_amountvalidation — resolves the wholesale plan's open question 1. The deprecatedPayments::Createservice is not touched (nothing calls it; removed in 7.0). - PO and terms stay separate (merchant point 10, already our stance): a PO authorizes the purchase buyer-side; terms say when the merchant requires payment. No coupling anywhere.
Design Details
- Snapshot storage:
payment_termsjsonb onspree_carts+spree_orders(nil = pay in full — today's behavior); resolved by the cart, copied at completion with the purchase fields. Serializers expose the snapshot and the derived schedule ({amount_due_now, deposit_amount, deposit_paid, outstanding_balance, balance_due_label}). Carts::Completevalidates payments againstamount_due_at_checkout(already the wholesale design — unchanged, just re-sourced); the invoice-laterpayment_pending:path composes as before.- Company: where the arrangement is read from — nothing in open source, which
advertises the feature on the company profile instead;
Enterprise's quote flow writes the order-level override
(
b2b-quotes.mdshows terms on the quotation and acceptance freezes them via placement — no quote-side fields). - Bank reference surfaces: checkout confirmation + order mails ("Amount to
pay now: $8,000 · Reference: RF71-…"), the payment-instructions print
(
6.1-b2b-order-documents.md), dashboard payment rows + the combined reference search (order number / PO number / payment reference).
Migration Path
Unscheduled — the deposit engine (
payment_termssnapshot, schedule value object + serializers,partially_paid) lands with the rest of this plan, not before. Shipping it alone gives a vocabulary with no way to set it, and leaves net terms — the other half of the same arrangement — without a home.The attachment point is already in core, so this plan starts from a hook rather than from patching:
Purchase#amount_due_at_checkoutanswers the full total viaSpree::Purchases::AmountDueAtCheckout, registered throughSpree::Dependencies, and the four decisions that gate on money arriving (checkout requirements, both completion guards, dispatch) already read it. Terms resolution replaces that service; it does not rewrite the call sites.The
numberransack/Stripe lookup fixes did ship early (2026-08-30, with the negotiation mechanics) and are unaffected.6.1: the remaining snapshot source layer (quote/order override);
PaymentMethod::BankTransfer; paymentreferencecolumn + generation + search; store pay-balance route + storefront balance UI.
Constraints on Current Work
- Terms are read from the order snapshot, never re-resolved from company/method after placement.
- Nothing durable keys on the derived payment number (
R1001-P1is display + gatewayorder_idonly); reconciliation identifiers are the storedreference. - No net-terms/credit/due-date machinery in OSS —
kindvalues beyondprepaid | depositand anything invoice-shaped belong to the Enterprise terms plan. - New payment-collecting surfaces must respect
amount_due_at_checkoutvs. full total per the snapshot, and the existingmax_amountcap.
Open Questions
- Progress payments (30/30/40 three-stage schedules) — the payment model supports arbitrary partials already; whether the terms vocabulary grows multi-stage schedules is deferred until real demand (Enterprise terms likely owns it).
References
- Merchant feedback, 2026-08 (terms by company; deposit calculation; balance-due label; terms frozen on order; bank/TT references; multiple payments; payment due status; net terms; PO separation).
docs/plans/6.0-b2b-wholesale-shipping.md— deposit collection (amended: method deposit is now a source).ee/docs/plans/b2b-companies.md— terms/invoicing roadmap (thenetkind's home);b2b-quotes.md— terms on quotations.- Payments machinery:
spree/core/app/models/spree/payment.rb(max_amount),app/services/spree/orders/update_statuses.rb(partially_paid),payment/gateway_options.rb(derived-number warning),payment_method/check.rb(offline method precedent).