Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClearing = errs.Class("stripecoinpayments clearing error")
ErrClearing is stripecoinpayments clearing loop error class.
var Error = errs.Class("stripecoinpayments service error")
Error defines stripecoinpayments service error.
Functions ¶
This section is empty.
Types ¶
type Clearing ¶
Clearing runs process of reconciling transactions deposits, customer balance, invoices and usages.
func NewClearing ¶
NewClearing creates new clearing loop.
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.
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 ¶
func (page *TransactionsPage) IDList() coinpayments.TransactionIDList
IDList returns transaction id list of page's transactions.