storj/satellite/payments/stripecoinpayments/customers.go
JT Olio a89a2b4b43 satellite/billing: make stripe invoice generation work with multiregion satellites
multiregion satellites have complex database connection strings
largely due to using a different backend for the repair queue than
cockroach.

billing stuff didn't work right with this.

Change-Id: Ie8759a8c47e71347c3a190abfc9d53945d7b8855
2021-05-06 11:51:03 -06:00

46 lines
1.2 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package stripecoinpayments
import (
"context"
"time"
"storj.io/common/uuid"
"storj.io/storj/satellite/satellitedb/dbx"
)
// ErrNoCustomer is error class defining that there is no customer for user.
var ErrNoCustomer = Error.New("customer doesn't exist")
// CustomersDB is interface for working with stripe customers table.
//
// architecture: Database
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)
// List returns page with customers ids created before specified date.
List(ctx context.Context, offset int64, limit int, before time.Time) (CustomersPage, error)
// TODO: get rid of this.
Raw() *dbx.DB
}
// Customer holds customer id and user id.
type Customer struct {
ID string
UserID uuid.UUID
}
// CustomersPage holds customers and
// indicates if there is more data available
// and provides next offset.
type CustomersPage struct {
Customers []Customer
Next bool
NextOffset int64
}