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.
|
2021-10-26 14:30:19 +01:00
|
|
|
Setup(ctx context.Context, userID uuid.UUID, email string, signupPromoCode string) (CouponType, error)
|
2019-10-11 16:00:35 +01:00
|
|
|
|
2023-03-22 20:23:44 +00:00
|
|
|
// UpdatePackage updates a customer's package plan information.
|
|
|
|
UpdatePackage(ctx context.Context, userID uuid.UUID, packagePlan *string, timestamp *time.Time) error
|
|
|
|
|
|
|
|
// GetPackageInfo returns the package plan and time of purchase for a user.
|
|
|
|
GetPackageInfo(ctx context.Context, userID uuid.UUID) (packagePlan *string, purchaseTime *time.Time, err error)
|
|
|
|
|
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
|
|
|
|
2023-02-23 16:27:37 +00:00
|
|
|
// GetProjectUsagePriceModel returns the project usage price model for a partner name.
|
|
|
|
GetProjectUsagePriceModel(partner string) ProjectUsagePriceModel
|
2023-01-12 03:41:14 +00:00
|
|
|
|
2022-04-28 16:59:55 +01:00
|
|
|
// CheckProjectInvoicingStatus returns error if for the given project there are outstanding project records and/or usage
|
2020-10-09 14:40:12 +01:00
|
|
|
// which have not been applied/invoiced yet (meaning sent over to stripe).
|
2022-04-28 16:59:55 +01:00
|
|
|
CheckProjectInvoicingStatus(ctx context.Context, projectID uuid.UUID) error
|
|
|
|
|
|
|
|
// CheckProjectUsageStatus returns error if for the given project there is some usage for current or previous month.
|
|
|
|
CheckProjectUsageStatus(ctx context.Context, projectID uuid.UUID) error
|
2020-10-09 14:40:12 +01:00
|
|
|
|
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
|
|
|
}
|