stripecoinpayments

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClearing = errs.Class("stripecoinpayments clearing error")

ErrClearing is stripecoinpayments clearing loop error class.

View Source
var Error = errs.Class("stripecoinpayments service error")

Error defines stripecoinpayments service error.

Functions

This section is empty.

Types

type Clearing

type Clearing struct {
	TransactionCycle sync2.Cycle
	// contains filtered or unexported fields
}

Clearing runs process of reconciling transactions deposits, customer balance, invoices and usages.

func NewClearing

func NewClearing(log *zap.Logger, service *Service, txInterval time.Duration) *Clearing

NewClearing creates new clearing loop.

func (*Clearing) Close

func (clearing *Clearing) Close() (err error)

Close closes all underlying resources.

func (*Clearing) Run

func (clearing *Clearing) Run(ctx context.Context) (err error)

Run runs all clearing related cycles.

type Config

type Config struct {
	StripeSecretKey           string        `help:"stripe API secret key" default:""`
	CoinpaymentsPublicKey     string        `help:"coinpayments API public key" default:""`
	CoinpaymentsPrivateKey    string        `help:"coinpayments API preivate key key" default:""`
	TransactionUpdateInterval time.Duration `help:"amount of time we wait before running next transaction update loop" devDefault:"1m" releaseDefault:"30m"`
}

Config stores needed information for payment service initialization.

type CustomersDB

type CustomersDB interface {
	// Insert inserts a stripe customer into the database.
	Insert(ctx context.Context, userID uuid.UUID, customerID string) error

	// GetCustomerID return stripe customers id.
	GetCustomerID(ctx context.Context, userID uuid.UUID) (string, error)
}

CustomersDB is interface for working with stripe customers table.

type Service

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

Service is an implementation for payment service via Stripe and Coinpayments.

func NewService

func NewService(log *zap.Logger, config Config, customers CustomersDB, transactionsDB TransactionsDB) *Service

NewService creates a Service instance.

func (*Service) Accounts

func (service *Service) Accounts() payments.Accounts

Accounts exposes all needed functionality to manage payment accounts.

type Transaction

type Transaction struct {
	ID        coinpayments.TransactionID
	AccountID uuid.UUID
	Address   string
	Amount    big.Float
	Received  big.Float
	Status    coinpayments.Status
	Key       string
	CreatedAt time.Time
}

Transaction defines coinpayments transaction info that is stored in the DB.

type TransactionUpdate

type TransactionUpdate struct {
	TransactionID coinpayments.TransactionID
	Status        coinpayments.Status
	Received      big.Float
}

TransactionUpdate holds transaction update info.

type TransactionsDB

type TransactionsDB interface {
	// Insert inserts new coinpayments transaction into DB.
	Insert(ctx context.Context, tx Transaction) (*Transaction, error)
	// Update updates status and received for set of transactions.
	Update(ctx context.Context, updates []TransactionUpdate) error
	// ListPending returns TransactionsPage with pending transactions.
	ListPending(ctx context.Context, offset int64, limit int, before time.Time) (TransactionsPage, error)
}

TransactionsDB is an interface which defines functionality of DB which stores coinpayments transactions.

architecture: Database

type TransactionsPage

type TransactionsPage struct {
	Transactions []Transaction
	Next         bool
	NextOffset   int64
}

TransactionsPage holds set of transaction and indicates if there are more transactions to fetch.

func (*TransactionsPage) IDList

IDList returns transaction id list of page's transactions.

Jump to

Keyboard shortcuts

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