payables

package
v1.49.61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package payables is the manual payables surface: what we owe, and how a human recorded paying it.

Commerce accrues a payable (models/fee.Fee) whenever someone earns — an affiliate commission on an order, a referral revenue share on metered spend, an OSS contributor allocation. One payable shape for all of them: the program is fee.Type, a FIELD, and the payee is fee.PayeeId.

Nothing here executes a payout. The owner pays out-of-band and records the fact; the record is a models/transfer.Transfer naming the payable it settles. A payment is appended, never a mutation of the payable — so what is still owed is a fold over the payments, partial payment needs no special case, and no replay can settle twice.

Mounted under /v1 (api/api.go), platform-admin gated:

GET  /v1/payables                  -> what we owe, per payable and per payee
POST /v1/payables/:feeid/payments  -> record a payment against one payable

The audit trail is the existing transfer REST surface (GET /v1/transfer), where every recorded payment lands.

The sibling of api/costs: costs answers what we owe our VENDORS, this answers what we owe our PAYEES.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(c *zip.Ctx) error

List answers what we owe.

GET /v1/payables?payee=&status=&program=

It matures pending payables past the clawback buffer first (fee.Qualify), then reports. What we owe is a question about NOW, so it is computed when asked rather than by a cron nobody scheduled.

func RecordPayment

func RecordPayment(c *zip.Ctx) error

RecordPayment records that a human paid a payable out-of-band.

POST /v1/payables/:feeid/payments

It moves no money and mutates no payable: it appends the fact. Recording the same (method, reference) twice returns the first record rather than settling twice, because a reference names one real-world payment.

func Route

func Route(r zip.Router, args ...zip.Handler)

Route registers the payables endpoints. What we owe across every payee is a PLATFORM god-view, so on top of the route-level token gate each handler calls middleware.RequirePlatformAdmin — that route gate is a no-op on the IAM path and must never be trusted alone.

Types

type ListResponse

type ListResponse struct {
	Payables []Payable        `json:"payables"`
	ByPayee  []PayeeTotal     `json:"byPayee"`
	Totals   []currency.Money `json:"totals"` // grand total, per asset
	Matured  int              `json:"matured"`
}

ListResponse answers "what do we owe" at a glance.

type Payable

type Payable struct {
	Id          string         `json:"id"`
	Name        string         `json:"name"`
	Program     fee.Type       `json:"program"`
	PayeeId     string         `json:"payeeId"`
	Owed        currency.Money `json:"owed"`
	Paid        currency.Money `json:"paid"`
	Outstanding currency.Money `json:"outstanding"`
	Status      fee.Status     `json:"status"`
	AccruedAt   time.Time      `json:"accruedAt"`
	EarnedBy    string         `json:"earnedBy,omitempty"` // the charge or usage event
}

Payable is one thing we owe.

type PayeeTotal

type PayeeTotal struct {
	PayeeId     string         `json:"payeeId"`
	Program     fee.Type       `json:"program"`
	Outstanding currency.Money `json:"outstanding"`
	Count       int            `json:"count"`
}

PayeeTotal is what one payee is owed in one asset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL