Documentation ¶
Index ¶
- Constants
- Variables
- type Accounts
- type Balance
- type CardInfo
- type Charge
- type Coupon
- type CouponDuration
- type CouponOld
- type CouponStatus
- type CouponType
- type Coupons
- type CouponsPage
- type Credit
- type CreditCard
- type CreditCards
- type Credits
- type CreditsPage
- type DepositBonus
- type Invoice
- type Invoices
- type ProjectCharge
- type StorjTokens
- type Transaction
- type TransactionID
- type TransactionInfo
- type TransactionStatus
Constants ¶
const ( // CouponOnce indicates that a coupon can only be applied once. CouponOnce CouponDuration = "once" // CouponRepeating indicates that a coupon is applied every billing period for a definite amount of time. CouponRepeating = "repeating" // CouponForever indicates that a coupon is applied every billing period forever. CouponForever = "forever" )
Variables ¶
var ErrAccountNotSetup = errs.Class("payment account is not set up")
ErrAccountNotSetup is an error type which indicates that payment account is not created.
Functions ¶
This section is empty.
Types ¶
type Accounts ¶ added in v0.24.0
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 }
Accounts exposes all needed functionality to manage payment accounts.
architecture: Service
type Balance ¶ added in v1.5.2
Balance is an entity that holds free credits and coins balance of user. Earned by applying of promotional coupon and coins depositing, respectively.
type CardInfo ¶ added in v0.29.0
type CardInfo struct { ID string `json:"id"` Brand string `json:"brand"` LastFour string `json:"lastFour"` }
CardInfo holds information about credit card used for charge.
type Charge ¶ added in v0.29.0
type Charge struct { ID string `json:"id"` Amount int64 `json:"amount"` CardInfo CardInfo `json:"card"` CreatedAt time.Time `json:"createdAt"` }
Charge contains charge details.
type Coupon ¶ added in v0.27.0
type Coupon struct { ID string `json:"id"` PromoCode string `json:"promoCode"` Name string `json:"name"` AmountOff int64 `json:"amountOff"` PercentOff float64 `json:"percentOff"` AddedAt time.Time `json:"addedAt"` ExpiresAt time.Time `json:"expiresAt"` Duration CouponDuration `json:"duration"` }
Coupon describes a discount to the payment account of a user.
type CouponDuration ¶ added in v1.37.1
type CouponDuration string
CouponDuration represents how many billing periods a coupon is applied.
type CouponOld ¶ added in v1.37.1
type CouponOld struct { ID uuid.UUID `json:"id"` UserID uuid.UUID `json:"userId"` Amount int64 `json:"amount"` // Amount is stored in cents. Duration *int `json:"duration"` // Duration is stored in number of billing periods. Description string `json:"description"` Type CouponType `json:"type"` Status CouponStatus `json:"status"` Created time.Time `json:"created"` }
CouponOld is an entity that adds some funds to Accounts balance for some fixed period. CouponOld is attached to the project. At the end of the period, the entire remaining coupon amount will be returned from the account balance. Deprecated: Use Coupon instead. TODO: This struct should be removed with the rest of the custom coupon implementation code.
func (*CouponOld) ExpirationDate ¶ added in v1.37.1
ExpirationDate returns coupon expiration date.
A coupon is valid for Duration number of full months. The month the user signs up is not counted in the duration. The expirated date is at the last day of the last valid month.
type CouponStatus ¶ added in v0.27.0
type CouponStatus int
CouponStatus indicates the state of the coupon.
const ( // CouponActive is a default coupon state. CouponActive CouponStatus = 0 // CouponUsed status indicates that coupon was used. CouponUsed CouponStatus = 1 // CouponExpired status indicates that coupon is expired and unavailable. CouponExpired CouponStatus = 2 )
type CouponType ¶ added in v0.30.0
type CouponType int
CouponType indicates the type of the coupon.
const ( // CouponTypePromotional defines that this coupon is a promotional coupon. CouponTypePromotional CouponType = 0 )
type Coupons ¶ added in v0.31.4
type Coupons interface { // GetByUserID returns the coupon applied to the specified user. GetByUserID(ctx context.Context, userID uuid.UUID) (*Coupon, error) // ListByUserID return list of all coupons of specified payment account. ListByUserID(ctx context.Context, userID uuid.UUID) ([]CouponOld, error) // TotalUsage returns sum of all usage records for specified coupon. TotalUsage(ctx context.Context, couponID uuid.UUID) (int64, error) // Create attaches a coupon for payment account. Create(ctx context.Context, coupon CouponOld) (coup CouponOld, err error) // AddPromotionalCoupon is used to add a promotional coupon for specified users who already have // a project and do not have a promotional coupon yet. // And updates project limits to selected size. AddPromotionalCoupon(ctx context.Context, userID uuid.UUID) error // PopulatePromotionalCoupons is used to populate promotional coupons through all active users who already have // a project, payment method and do not have a promotional coupon yet. // And updates project limits to selected size. PopulatePromotionalCoupons(ctx context.Context, duration *int, amount int64, projectLimit memory.Size) error // ApplyCouponCode attempts to apply a coupon code to the user. ApplyCouponCode(ctx context.Context, userID uuid.UUID, couponCode string) (*Coupon, error) }
Coupons exposes all needed functionality to manage coupons.
architecture: Service
type CouponsPage ¶ added in v0.27.0
CouponsPage holds set of coupon and indicates if there are more coupons to fetch.
type Credit ¶ added in v0.33.2
type Credit struct { UserID uuid.UUID `json:"userId"` Amount int64 `json:"credit"` TransactionID coinpayments.TransactionID `json:"transactionId"` Created time.Time `json:"created"` }
Credit is an entity that holds bonus balance of user, earned by depositing with storj coins.
type CreditCard ¶ added in v0.24.0
type CreditCard struct { ID string `json:"id"` ExpMonth int `json:"expMonth"` ExpYear int `json:"expYear"` Brand string `json:"brand"` Last4 string `json:"last4"` IsDefault bool `json:"isDefault"` }
CreditCard holds all public information about credit card.
type CreditCards ¶ added in v0.24.0
type CreditCards interface { // List returns a list of credit cards for a given payment account. List(ctx context.Context, userID uuid.UUID) ([]CreditCard, error) // Add is used to save new credit card and attach it to payment account. Add(ctx context.Context, userID uuid.UUID, cardToken string) error // Remove is used to detach a credit card from payment account. Remove(ctx context.Context, userID uuid.UUID, cardID string) error // 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 // 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 }
CreditCards exposes all needed functionality to manage account credit cards.
architecture: Service
type Credits ¶ added in v0.33.2
type Credits interface { // Create attaches a credit for payment account. Create(ctx context.Context, credit Credit) (err error) // ListByUserID return list of all credits of specified payment account. ListByUserID(ctx context.Context, userID uuid.UUID) ([]Credit, error) }
Credits exposes all needed functionality to manage credits.
architecture: Service
type CreditsPage ¶ added in v0.33.2
CreditsPage holds set of credits and indicates if there are more credits to fetch.
type DepositBonus ¶ added in v1.6.1
type DepositBonus struct { TransactionID TransactionID AmountCents int64 Percentage int64 CreatedAt time.Time }
DepositBonus defines a bonus received for depositing tokens.
type Invoice ¶
type Invoice struct { ID string `json:"id"` Description string `json:"description"` Amount int64 `json:"amount"` Status string `json:"status"` Link string `json:"link"` Start time.Time `json:"start"` End time.Time `json:"end"` }
Invoice holds all public information about invoice.
type Invoices ¶ added in v0.25.0
type Invoices interface { // List returns a list of invoices for a given payment account. List(ctx context.Context, userID uuid.UUID) ([]Invoice, error) // CheckPendingItems returns if pending invoice items for a given payment account exist. CheckPendingItems(ctx context.Context, userID uuid.UUID) (existingItems bool, err error) }
Invoices exposes all needed functionality to manage account invoices.
architecture: Service
type ProjectCharge ¶ added in v0.26.0
type ProjectCharge struct { accounting.ProjectUsage ProjectID uuid.UUID `json:"projectId"` // StorageGbHrs shows how much cents we should pay for storing GB*Hrs. StorageGbHrs int64 `json:"storagePrice"` // Egress shows how many cents we should pay for Egress. Egress int64 `json:"egressPrice"` // ObjectCount shows how many cents we should pay for objects count. ObjectCount int64 `json:"objectPrice"` }
ProjectCharge shows project usage and how much money current project will charge in the end of the month.
type StorjTokens ¶ added in v0.24.0
type StorjTokens interface { // Deposit creates deposit transaction for specified amount in cents. Deposit(ctx context.Context, userID uuid.UUID, amount int64) (*Transaction, error) // ListTransactionInfos returns all transactions associated with user. ListTransactionInfos(ctx context.Context, userID uuid.UUID) ([]TransactionInfo, error) // ListDepositBonuses returns all deposit bonuses associated with user. ListDepositBonuses(ctx context.Context, userID uuid.UUID) ([]DepositBonus, error) }
StorjTokens defines all payments STORJ token related functionality.
architecture: Service
type Transaction ¶ added in v0.24.0
type Transaction struct { ID TransactionID Amount monetary.Amount Rate decimal.Decimal Address string Status TransactionStatus Timeout time.Duration Link string CreatedAt time.Time }
Transaction defines deposit transaction which accepts user funds on a specific wallet address.
type TransactionID ¶ added in v0.24.0
type TransactionID []byte
TransactionID is a transaction ID type.
func (TransactionID) String ¶ added in v0.26.0
func (id TransactionID) String() string
String returns string representation of transaction id.
type TransactionInfo ¶ added in v0.26.0
type TransactionInfo struct { ID TransactionID Amount monetary.Amount Received monetary.Amount AmountCents int64 ReceivedCents int64 Address string Status TransactionStatus Link string ExpiresAt time.Time CreatedAt time.Time }
TransactionInfo holds transaction data with additional information such as links and expiration time.
type TransactionStatus ¶ added in v0.24.0
type TransactionStatus string
TransactionStatus defines allowed statuses for deposit transactions.
const ( // TransactionStatusPaid is a transaction which successfully received required funds. TransactionStatusPaid TransactionStatus = "paid" // TransactionStatusPending is a transaction which accepts funds. TransactionStatusPending TransactionStatus = "pending" // TransactionStatusCancelled is a transaction that is cancelled and no longer accepting new funds. TransactionStatusCancelled TransactionStatus = "cancelled" )
func (TransactionStatus) String ¶ added in v0.26.0
func (status TransactionStatus) String() string
String returns string representation of transaction status.