checkout

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides high-level operations for managing checkout sessions

func NewService

func NewService(reg registry.Provider) *Service

NewService creates a new checkout service with the given registry

func (*Service) CreateSession

func (s *Service) CreateSession(
	ctx context.Context,
	sessionID string,
	id string,
	txID uuid.UUID,
	userID uuid.UUID,
	accountID uuid.UUID,
	amount int64,
	currencyCode string,
	checkoutURL string,
	expiresIn time.Duration,
) (*Session, error)

CreateSession creates a new checkout session

func (*Service) GetSession

func (s *Service) GetSession(
	ctx context.Context,
	id string,
) (*Session, error)

GetSession retrieves a checkout session by ID

func (*Service) GetSessionByTransactionID

func (s *Service) GetSessionByTransactionID(
	ctx context.Context,
	txID uuid.UUID,
) (*Session, error)

GetSessionByTransactionID retrieves a checkout session by transaction ID

func (*Service) UpdateStatus

func (s *Service) UpdateStatus(
	ctx context.Context,
	id, status string,
) error

UpdateStatus updates the status of a checkout session

type Session

type Session struct {
	ID            string    `json:"id"`
	TransactionID uuid.UUID `json:"transaction_id"`
	UserID        uuid.UUID `json:"user_id"`
	AccountID     uuid.UUID `json:"account_id"`
	Amount        int64     `json:"amount"`
	Currency      string    `json:"currency"`
	Status        string    `json:"status"`
	CheckoutURL   string    `json:"checkout_url"`
	CreatedAt     time.Time `json:"created_at"`
	ExpiresAt     time.Time `json:"expires_at"`
	// contains filtered or unexported fields
}

Session represents a checkout session with its metadata

func FromJSON

func FromJSON(data []byte) (*Session, error)

FromJSON creates a Session from its JSON representation

func (*Session) FormatAmount

func (s *Session) FormatAmount() (string, error)

FormatAmount formats the amount according to the currency's decimal places

func (*Session) GetCurrencySymbol

func (s *Session) GetCurrencySymbol() (string, error)

GetCurrencySymbol returns the currency symbol

func (*Session) ToJSON

func (s *Session) ToJSON() ([]byte, error)

ToJSON converts a Session to its JSON representation

func (*Session) Validate

func (s *Session) Validate() error

Validate checks if the session is valid

Jump to

Keyboard shortcuts

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