autorecharge

package
v1.48.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 4 Imported by: 1 module, 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

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