models

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package models holds the persisted Cashier tables (transactions, subscriptions) and their migrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrations

func Migrations() []database.Migration

Migrations creates the Cashier tables. Exposed via the plugin's Migrations() so they run alongside application migrations.

Types

type Subscription

type Subscription struct {
	database.Model
	Gateway    string     `json:"gateway" gorm:"index"`
	GatewayID  string     `json:"gateway_id" gorm:"index"` // subscription id
	Subject    string     `json:"subject" gorm:"index"`    // user id
	Plan       string     `json:"plan"`
	PriceID    string     `json:"price_id"`
	Status     string     `json:"status" gorm:"index"` // active|trialing|canceled|past_due
	EndsAt     *time.Time `json:"ends_at"`
	CanceledAt *time.Time `json:"canceled_at"`
}

Subscription mirrors a gateway subscription locally for access checks.

func (Subscription) Active

func (s Subscription) Active() bool

Active reports whether the subscription currently grants access.

func (Subscription) TableName

func (Subscription) TableName() string

TableName is the DB table for subscriptions.

type Transaction

type Transaction struct {
	database.Model
	Gateway   string `json:"gateway" gorm:"index"`    // stripe|razorpay|payu
	GatewayID string `json:"gateway_id" gorm:"index"` // order/session/payment id
	Reference string `json:"reference" gorm:"index"`  // app order id
	Subject   string `json:"subject" gorm:"index"`    // user id
	Plan      string `json:"plan"`
	Amount    int64  `json:"amount"` // smallest currency unit (paise/cents)
	Currency  string `json:"currency"`
	Status    string `json:"status" gorm:"index"` // created|paid|failed|refunded
	Meta      string `json:"meta"`                // optional JSON blob
}

Transaction records a single charge/payment across any gateway.

func (Transaction) TableName

func (Transaction) TableName() string

TableName is the DB table for transactions.

Jump to

Keyboard shortcuts

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