Documentation
¶
Overview ¶
Package payout is what the referral, affiliate and author programs ask of the money plane, and it is a QUESTION: what has this org spent? That read is the qualify signal / accrual base. It was three byte-identical commerce.go copies; extracted here so the S2S commerce binding lives exactly ONCE.
IT NO LONGER DEPOSITS. It carried a Deposit — the ONE money-in primitive all three programs shared — which is how a GET on three surfaces came to mint platform credit. Earnings are PAYABLES now: each program ACCRUES and RECORDS what is owed, and a human settles it out of band. Platform credit is issued only by an admin grant (apps/admin/core.ApplyGrant). TestSeamIsReadOnly fails if a write returns.
Commerce is an INTERFACE so each program's store/handler logic stays testable with a fake ledger; Client is the ONE production binding. A program keeps its own narrow (unexported-method) seam and a thin adapter delegating to Client — Go package-scoped interface methods can't cross packages, and the adapter is where a program still names its own grant tag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnconfigured = errors.New("payout: commerce endpoint not configured")
ErrUnconfigured is returned by a read against an unwired commerce so the caller records an honest failure rather than inventing a number.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the production commerce binding (COMMERCE_SERVICE_TOKEN S2S).
func NewClient ¶
NewClient builds the production binding. base is the commerce HTTP URL (via transport.BaseURL at the call site); token is COMMERCE_SERVICE_TOKEN.
func (*Client) Configured ¶
func (*Client) SpendCents ¶
SpendCents reads GET /v1/billing/usage/rollup and returns consumedCents. Zero (not an error) when commerce is unconfigured so a partial deploy degrades to "no spend to accrue yet" rather than a 5xx.
type Commerce ¶
type Commerce interface {
Configured() bool
// SpendCents is the org's month-to-date metered consumption — the qualify
// signal / commission accrual base (spend × the program's rate).
SpendCents(ctx context.Context, org, user string) (int64, error)
}
Commerce is the ONE thing an attributed-credit program asks of the money plane, and it is a QUESTION: what has this org spent? The HTTP impl (Client) below is the ONE production binding. There is no write method, by design.