2019-10-10 18:12:23 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package payments
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-01-14 16:01:29 +00:00
|
|
|
|
2019-10-17 15:42:18 +01:00
|
|
|
"github.com/skyrings/skyring-common/tools/uuid"
|
|
|
|
"github.com/zeebo/errs"
|
2019-10-10 18:12:23 +01:00
|
|
|
)
|
|
|
|
|
2019-10-17 15:42:18 +01:00
|
|
|
// ErrAccountNotSetup is an error type which indicates that payment account is not created.
|
|
|
|
var ErrAccountNotSetup = errs.Class("payment account is not set up")
|
|
|
|
|
2019-10-10 18:12:23 +01:00
|
|
|
// Accounts exposes all needed functionality to manage payment accounts.
|
2020-01-29 00:57:15 +00:00
|
|
|
//
|
|
|
|
// architecture: Service
|
2019-10-10 18:12:23 +01:00
|
|
|
type Accounts interface {
|
|
|
|
// Setup creates a payment account for the user.
|
2019-10-17 15:42:18 +01:00
|
|
|
// If account is already set up it will return nil.
|
|
|
|
Setup(ctx context.Context, userID uuid.UUID, email string) error
|
2019-10-11 16:00:35 +01:00
|
|
|
|
|
|
|
// Balance returns an integer amount in cents that represents the current balance of payment account.
|
2019-10-17 15:42:18 +01:00
|
|
|
Balance(ctx context.Context, userID uuid.UUID) (int64, error)
|
2019-10-15 12:23:54 +01:00
|
|
|
|
2019-11-15 14:27:44 +00:00
|
|
|
// ProjectCharges returns how much money current user will be charged for each project.
|
|
|
|
ProjectCharges(ctx context.Context, userID uuid.UUID) ([]ProjectCharge, error)
|
|
|
|
|
2020-01-03 14:21:05 +00:00
|
|
|
// Charges returns list of all credit card charges related to account.
|
|
|
|
Charges(ctx context.Context, userID uuid.UUID) ([]Charge, error)
|
|
|
|
|
2019-10-15 12:23:54 +01:00
|
|
|
// CreditCards exposes all needed functionality to manage account credit cards.
|
|
|
|
CreditCards() CreditCards
|
2019-10-31 16:56:54 +00:00
|
|
|
|
2019-10-17 15:04:50 +01:00
|
|
|
// StorjTokens exposes all storj token related functionality.
|
|
|
|
StorjTokens() StorjTokens
|
2019-10-31 16:56:54 +00:00
|
|
|
|
|
|
|
// Invoices exposes all needed functionality to manage account invoices.
|
|
|
|
Invoices() Invoices
|
2020-01-29 00:57:15 +00:00
|
|
|
|
|
|
|
// Coupons exposes all needed functionality to manage coupons.
|
|
|
|
Coupons() Coupons
|
2019-10-10 18:12:23 +01:00
|
|
|
}
|