2019-10-15 12:23:54 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package payments
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-10-17 15:42:18 +01:00
|
|
|
|
2020-03-30 10:08:50 +01:00
|
|
|
"storj.io/common/uuid"
|
2019-10-15 12:23:54 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// CreditCards exposes all needed functionality to manage account credit cards.
|
2020-01-29 00:57:15 +00:00
|
|
|
//
|
|
|
|
// architecture: Service
|
2019-10-15 12:23:54 +01:00
|
|
|
type CreditCards interface {
|
2019-10-23 18:33:24 +01:00
|
|
|
// List returns a list of credit cards for a given payment account.
|
2019-10-17 15:42:18 +01:00
|
|
|
List(ctx context.Context, userID uuid.UUID) ([]CreditCard, error)
|
2019-10-15 15:50:28 +01:00
|
|
|
|
|
|
|
// Add is used to save new credit card and attach it to payment account.
|
2019-10-17 15:42:18 +01:00
|
|
|
Add(ctx context.Context, userID uuid.UUID, cardToken string) error
|
2019-10-23 18:33:24 +01:00
|
|
|
|
|
|
|
// Remove is used to detach a credit card from payment account.
|
|
|
|
Remove(ctx context.Context, userID uuid.UUID, cardID string) error
|
|
|
|
|
2020-08-19 13:43:56 +01:00
|
|
|
// RemoveAll is used to detach all credit cards from payment account.
|
|
|
|
// It should only be used in case of a user deletion.
|
|
|
|
RemoveAll(ctx context.Context, userID uuid.UUID) error
|
|
|
|
|
2019-10-23 18:33:24 +01:00
|
|
|
// MakeDefault makes a credit card default payment method.
|
|
|
|
// this credit card should be attached to account before make it default.
|
|
|
|
MakeDefault(ctx context.Context, userID uuid.UUID, cardID string) error
|
2019-10-15 12:23:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreditCard holds all public information about credit card.
|
|
|
|
type CreditCard struct {
|
2019-10-23 18:33:24 +01:00
|
|
|
ID string `json:"id"`
|
|
|
|
ExpMonth int `json:"expMonth"`
|
|
|
|
ExpYear int `json:"expYear"`
|
|
|
|
Brand string `json:"brand"`
|
|
|
|
Last4 string `json:"last4"`
|
|
|
|
IsDefault bool `json:"isDefault"`
|
2019-10-15 12:23:54 +01:00
|
|
|
}
|