payout

package
v1.801.460 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NewClient(base, token string) *Client

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 (c *Client) Configured() bool

func (*Client) SpendCents

func (c *Client) SpendCents(ctx context.Context, org, user string) (int64, error)

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.

Jump to

Keyboard shortcuts

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