autorecharge

package
v1.46.39 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Query

Types

type AutoRecharge

type AutoRecharge struct {
	mixin.Model[AutoRecharge]

	UserId         string `json:"userId"` // org slug (billing key)
	Enabled        bool   `json:"enabled"`
	ThresholdCents int64  `json:"thresholdCents"`
	AmountCents    int64  `json:"amountCents"`
	Currency       string `json:"currency"`

	// LastRechargedAt stores the ISO timestamp of the last successful auto
	// top-up — used for observability and as a light guard against a runaway
	// recharge loop within a single cron window.
	LastRechargedAt string `json:"lastRechargedAt,omitempty"`
}

AutoRecharge is a per-org automatic top-up rule. When the org's available balance (balance minus holds) drops below ThresholdCents, the recharge cron charges the org's default payment method AmountCents and credits the balance. Mirrors the Claude/OpenAI "auto-reload" setting. One record per org (keyed by UserId = the org slug, which is the billing key used by topup/balance).

func New

func (*AutoRecharge) Validator

func (a *AutoRecharge) Validator() *val.Validator

Jump to

Keyboard shortcuts

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