android

package
v0.159.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigEnvPrefix is the prefix applied to environment variables for configuring Android Billing.
	ConfigEnvPrefix = "ANDROID_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// PackageName is what the app package is named in the Google Play Store.
	PackageName string `koanf:"package_name" validate:"required"`
}

Config is the configuration for Android Billing.

type Entitlement

type Entitlement struct {
	UserID        string
	SKU           string
	PurchaseToken string
	ExpiresAt     *time.Time // nil for lifetime/one-time purchases
	GrantedAt     time.Time
}

Entitlement represents a verified, active entitlement for a user.

func VerifyAndAcknowledgeProduct

func VerifyAndAcknowledgeProduct(
	ctx context.Context,
	user *models.User, sku, token string,
) (*Entitlement, error)

VerifyAndAcknowledgeProduct verifies a one-time product purchase and acknowledges it. Must be called within 3 days of purchase or Google will refund automatically.

func VerifyAndAcknowledgeSubscription

func VerifyAndAcknowledgeSubscription(
	ctx context.Context,
	user *models.User, sku, token string,
) (*Entitlement, error)

VerifyAndAcknowledgeSubscription verifies a subscription purchase.

type PurchaseState

type PurchaseState int

PurchaseState mirrors the Play API integer values.

const (
	PurchaseStatePurchased PurchaseState = 0
	PurchaseStateCancelled PurchaseState = 1
	PurchaseStatePending   PurchaseState = 2
)

type SKUDetails

type SKUDetails struct {
	ID          string
	Title       string
	Description string
	Price       string
	Currency    string
	Type        string // "subs" or "inapp"
}

SKUDetails holds Play Store product metadata.

Jump to

Keyboard shortcuts

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