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 ¶
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 ¶
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.
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.