storj/satellite/payments/account.go
Stefan Benten 1d3b728766 satellite/{console/payments/satellitedb}: add validation for deletion of account and project
The same was that our Admin API handles project and account deletions currently, we would like
to have the same checks on the user-facing API. This PR adds the same checks to the console service.
General more applicable checks have been moved directly into the payments service.

In addition it adds the BucketsDB to the console DB, to have easier access and avoiding import cycles with
the metainfo package.

A small cleanup around our unnecessary monkit imports made it in as well.

Change-Id: I8769b01c2271c1687fbd2269a738a41764216e51
2020-10-13 07:55:26 +00:00

55 lines
1.9 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package payments
import (
"context"
"time"
"github.com/zeebo/errs"
"storj.io/common/uuid"
)
// ErrAccountNotSetup is an error type which indicates that payment account is not created.
var ErrAccountNotSetup = errs.Class("payment account is not set up")
// Accounts exposes all needed functionality to manage payment accounts.
//
// architecture: Service
type Accounts interface {
// Setup creates a payment account for the user.
// If account is already set up it will return nil.
Setup(ctx context.Context, userID uuid.UUID, email string) error
// Balance returns an object that represents current free credits and coins balance in cents.
Balance(ctx context.Context, userID uuid.UUID) (Balance, error)
// ProjectCharges returns how much money current user will be charged for each project.
ProjectCharges(ctx context.Context, userID uuid.UUID, since, before time.Time) ([]ProjectCharge, error)
// 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)
// Charges returns list of all credit card charges related to account.
Charges(ctx context.Context, userID uuid.UUID) ([]Charge, error)
// CreditCards exposes all needed functionality to manage account credit cards.
CreditCards() CreditCards
// StorjTokens exposes all storj token related functionality.
StorjTokens() StorjTokens
// Invoices exposes all needed functionality to manage account invoices.
Invoices() Invoices
// Coupons exposes all needed functionality to manage coupons.
Coupons() Coupons
// PaywallEnabled returns a true if a credit card or account
// balance is required to create projects
PaywallEnabled(uuid.UUID) bool
}