2019-10-10 18:12:23 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package payments
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-03-04 13:23:10 +00:00
|
|
|
"time"
|
2020-01-14 16:01:29 +00:00
|
|
|
|
2019-10-17 15:42:18 +01:00
|
|
|
"github.com/zeebo/errs"
|
2020-03-30 10:08:50 +01:00
|
|
|
|
|
|
|
"storj.io/common/uuid"
|
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
|
|
|
|
2020-05-12 18:16:04 +01:00
|
|
|
// Balance returns an object that represents current free credits and coins balance in cents.
|
|
|
|
Balance(ctx context.Context, userID uuid.UUID) (Balance, 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.
|
2020-03-04 13:23:10 +00:00
|
|
|
ProjectCharges(ctx context.Context, userID uuid.UUID, since, before time.Time) ([]ProjectCharge, error)
|
2019-11-15 14:27:44 +00:00
|
|
|
|
2020-10-09 14:40:12 +01:00
|
|
|
// CheckProjectInvoicingStatus returns true if for the given project there are outstanding project records and/or usage
|
|
|
|
// which have not been applied/invoiced yet (meaning sent over to stripe).
|
|
|
|
CheckProjectInvoicingStatus(ctx context.Context, projectID uuid.UUID) (unpaidUsage bool, err 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
|
|
|
}
|