payments

package
v1.107.0-rc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2024 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	// NoCoupon represents an invalid coupon registration attempt.
	NoCoupon CouponType = "noCoupon"
	// FreeTierCoupon represents the default free tier coupon.
	FreeTierCoupon = "freeTierCoupon"
	// SignupCoupon represents a valid promo code coupon.
	SignupCoupon = "signupCoupon"
)
View Source
const (
	// InvoiceStatusDraft indicates the invoice is a draft.
	InvoiceStatusDraft = "draft"
	// InvoiceStatusOpen indicates the invoice is open.
	InvoiceStatusOpen = "open"
	// InvoiceStatusPaid indicates the invoice is paid.
	InvoiceStatusPaid = "paid"
	// InvoiceStatusUncollectible indicates the invoice is uncollectible.
	InvoiceStatusUncollectible = "uncollectible"
	// InvoiceStatusVoid indicates the invoice is void.
	InvoiceStatusVoid = "void"
)
View Source
const (
	// PaymentStatusConfirmed indicates that payment has required number of confirmations.
	PaymentStatusConfirmed = "confirmed"
	// PaymentStatusPending indicates that payment has not meet confirmation requirements.
	PaymentStatusPending = "pending"
)

Variables

View Source
var (
	// ErrInvalidCoupon defines invalid coupon code error.
	ErrInvalidCoupon = errs.Class("invalid coupon code")
	// ErrCouponConflict occurs when attempting to replace a protected coupon.
	ErrCouponConflict = errs.Class("coupon conflict")
)
View Source
var ErrAccountNotSetup = errs.Class("payment account is not set up")

ErrAccountNotSetup is an error type which indicates that payment account is not created.

View Source
var TaxCountries = []TaxCountry{
	{"Andorra", ad},
	{"Argentina", ar},
	{"Australia", au},
	{"Austria", at},
	{"Belgium", be},
	{"Bolivia", bo},
	{"Brazil", br},
	{"Bulgaria", bg},
	{"Canada", ca},
	{"Chile", cl},
	{"China", cn},
	{"Colombia", co},
	{"Costa Rica", cr},
	{"Croatia", hr},
	{"Cyprus", cy},
	{"Czech Republic", cz},
	{"Denmark", dk},
	{"Dominican Republic", do},
	{"Ecuador", ec},
	{"Egypt", eg},
	{"El Salvador", sv},
	{"Estonia", ee},
	{"Finland", fi},
	{"France", fr},
	{"Georgia", ge},
	{"Germany", de},
	{"Greece", gr},
	{"Hong Kong", hk},
	{"Hungary", hu},
	{"Iceland", is},
	{"India", in},
	{"Indonesia", id},
	{"Ireland", ie},
	{"Israel", il},
	{"Italy", it},
	{"Japan", jp},
	{"Kenya", ke},
	{"Latvia", lv},
	{"Liechtenstein", li},
	{"Lithuania", lt},
	{"Luxembourg", lu},
	{"Malaysia", my},
	{"Malta", mt},
	{"Mexico", mx},
	{"Netherlands", nl},
	{"New Zealand", nz},
	{"Norway", no},
	{"Oman", om},
	{"Peru", pe},
	{"Philippines", ph},
	{"Poland", pl},
	{"Portugal", pt},
	{"Romania", ro},
	{"Russia", ru},
	{"Saudi Arabia", sa},
	{"Serbia", rs},
	{"Singapore", sg},
	{"Slovakia", sk},
	{"Slovenia", si},
	{"South Africa", za},
	{"South Korea", kr},
	{"Spain", es},
	{"Sweden", se},
	{"Switzerland", ch},
	{"Taiwan", tw},
	{"Thailand", th},
	{"Turkey", tr},
	{"Ukraine", ua},
	{"United Arab Emirates", ae},
	{"United Kingdom", gb},
	{"United States", us},
	{"Uruguay", uy},
	{"Venezuela", ve},
	{"Vietnam", vn},
}

TaxCountries is a list of all countries whose taxes Stripe supports.

View Source
var Taxes = []Tax{
	{stripe.TaxIDTypeADNRT, "Andorran NRT number", "A-123456-Z", ad},
	{stripe.TaxIDTypeARCUIT, "Argentinian tax ID number", "12-3456789-01", ar},
	{stripe.TaxIDTypeAUABN, "Australian Business Number (AU ABN)", "12345678912", au},
	{stripe.TaxIDTypeAUARN, "Australian Taxation Office Reference Number", "123456789123", au},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "ATU12345678", at},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "BE0123456789", be},
	{stripe.TaxIDTypeBOTIN, "Bolivian tax ID", "123456789", bo},
	{stripe.TaxIDTypeBRCNPJ, "Brazilian CNPJ number", "01.234.456/5432-10", br},
	{stripe.TaxIDTypeBRCPF, "Brazilian CPF number", "123.456.789-87", br},
	{stripe.TaxIDTypeBGUIC, "Bulgaria Unified Identification Code", "123456789", bg},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "BG0123456789", bg},
	{stripe.TaxIDTypeCABN, "Canadian BN", "123456789", ca},
	{stripe.TaxIDTypeCAGSTHST, "Canadian GST/HST number", "123456789RT0002", ca},
	{stripe.TaxIDTypeCAPSTBC, "Canadian PST number (British Columbia)", "PST-1234-5678", ca},
	{stripe.TaxIDTypeCAPSTMB, "Canadian PST number (Manitoba)", "123456-7", ca},
	{stripe.TaxIDTypeCAPSTSK, "Canadian PST number (Saskatchewan)", "1234567", ca},
	{stripe.TaxIDTypeCAQST, "Canadian QST number (Québec)", "1234567890TQ1234", ca},
	{stripe.TaxIDTypeCLTIN, "Chilean TIN", "12.345.678-K", cl},
	{stripe.TaxIDTypeCNTIN, "Chinese tax ID", "123456789012345000", cn},
	{stripe.TaxIDTypeCONIT, "Colombian NIT number", "123.456.789-0", co},
	{stripe.TaxIDTypeCRTIN, "Costa Rican tax ID", "1-234-567890", cr},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "HR12345678912", hr},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "CY12345678Z", cy},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "CZ1234567890", cz},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "DK12345678", dk},
	{stripe.TaxIDTypeDORCN, "Dominican RCN number", "123-4567890-1", do},
	{stripe.TaxIDTypeECRUC, "Ecuadorian RUC number", "1234567890001", ec},
	{stripe.TaxIDTypeEGTIN, "Egyptian Tax Identification Number", "123456789", eg},
	{stripe.TaxIDTypeSVNIT, "El Salvadorian NIT number", "1234-567890-123-4", sv},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "EE123456789", ee},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "FI12345678", fi},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "FRAB123456789", fr},
	{stripe.TaxIDTypeGEVAT, "Georgian VAT", "123456789", ge},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "DE123456789", de},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "EL123456789", gr},
	{stripe.TaxIDTypeHKBR, "Hong Kong BR number", "12345678", hk},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "HU12345678", hu},
	{stripe.TaxIDTypeHUTIN, "Hungary tax number (adószám)", "12345678-1-23", hu},
	{stripe.TaxIDTypeISVAT, "Icelandic VAT", "123456", is},
	{stripe.TaxIDTypeINGST, "Indian GST number", "12ABCDE3456FGZH", in},
	{stripe.TaxIDTypeIDNPWP, "Indonesian NPWP number", "12.345.678.9-012.345", id},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "IE1234567AB", ie},
	{stripe.TaxIDTypeILVAT, "Israel VAT", "12345", il},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "IT12345678912", it},
	{stripe.TaxIDTypeJPCN, "Japanese Corporate Number (*Hōjin Bangō*)", "1234567891234", jp},
	{stripe.TaxIDTypeJPRN, "Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)", "12345", jp},
	{stripe.TaxIDTypeJPTRN, "Japanese Tax Registration Number (*Tōroku Bangō*)", "T1234567891234", jp},
	{stripe.TaxIDTypeKEPIN, "Kenya Revenue Authority Personal Identification Number", "P000111111A", ke},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "LV12345678912", lv},
	{stripe.TaxIDTypeLIUID, "Liechtensteinian UID number", "CHE123456789", li},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "LT123456789123", lt},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "LU12345678", lu},
	{stripe.TaxIDTypeMYFRP, "Malaysian FRP number", "12345678", my},
	{stripe.TaxIDTypeMYITN, "Malaysian ITN", "C 1234567890", my},
	{stripe.TaxIDTypeMYSST, "Malaysian SST number", "A12-3456-78912345", my},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "MT12345678", mt},
	{stripe.TaxIDTypeMXRFC, "Mexican RFC number", "ABC010203AB9", mx},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "NL123456789B12", nl},
	{stripe.TaxIDTypeNZGST, "New Zealand GST number", "123456789", nz},
	{stripe.TaxIDTypeNOVAT, "Norwegian VAT number", "123456789MVA", no},
	{stripe.TaxIDTypePERUC, "Peruvian RUC number", "12345678901", pe},
	{stripe.TaxIDTypePHTIN, "Philippines Tax Identification Number", "123456789012", ph},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "PL1234567890", pl},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "PT123456789", pt},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "RO1234567891", ro},
	{stripe.TaxIDTypeROTIN, "Romanian tax ID number", "1234567890123", ro},
	{stripe.TaxIDTypeRUINN, "Russian INN", "1234567891", ru},
	{stripe.TaxIDTypeRUKPP, "Russian KPP", "123456789", ru},
	{stripe.TaxIDTypeSAVAT, "Saudi Arabia VAT", "123456789012345", sa},
	{stripe.TaxIDTypeRSPIB, "Serbian PIB number", "123456789", rs},
	{stripe.TaxIDTypeSGGST, "Singaporean GST", "M12345678X", sg},
	{stripe.TaxIDTypeSGUEN, "Singaporean UEN", "123456789F", sg},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "SK1234567891", sk},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "SI12345678", si},
	{stripe.TaxIDTypeSITIN, "Slovenia tax number (davčna številka)", "12345678", si},
	{stripe.TaxIDTypeZAVAT, "South African VAT number", "4123456789", za},
	{stripe.TaxIDTypeKRBRN, "Korean BRN", "123-45-67890", kr},
	{stripe.TaxIDTypeESCIF, "Spanish NIF number (previously Spanish CIF number)", "A12345678", es},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "ESA1234567Z", es},
	{stripe.TaxIDTypeEUVAT, "European VAT number", "SE123456789123", se},
	{stripe.TaxIDTypeCHVAT, "Switzerland VAT number", "CHE-123.456.789 MWST", ch},
	{stripe.TaxIDTypeTWVAT, "Taiwanese VAT", "12345678", tw},
	{stripe.TaxIDTypeTHVAT, "Thai VAT", "1234567891234", th},
	{stripe.TaxIDTypeTRTIN, "Turkish Tax Identification Number", "123456789", tr},
	{stripe.TaxIDTypeUAVAT, "Ukrainian VAT", "123456789", ua},
	{stripe.TaxIDTypeAETRN, "United Arab Emirates TRN", "123456789012345", ae},
	{stripe.TaxIDTypeEUVAT, "Northern Ireland VAT number", "XI123456789", gb},
	{stripe.TaxIDTypeGBVAT, "United Kingdom VAT number", "GB123456789", gb},
	{stripe.TaxIDTypeUSEIN, "United States EIN", "12-3456789", us},
	{stripe.TaxIDTypeUYRUC, "Uruguayan RUC number", "123456789012", uy},
	{stripe.TaxIDTypeVERIF, "Venezuelan RIF number", "A-12345678-9", ve},
	{stripe.TaxIDTypeVNTIN, "Vietnamese tax ID number", "1234567890", vn},
}

Taxes is a list of all taxes that Stripe supports.

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, signupPromoCode string) (CouponType, error)

	// SaveBillingAddress saves billing address for a user and returns the updated billing information.
	SaveBillingAddress(ctx context.Context, userID uuid.UUID, address BillingAddress) (*BillingInformation, error)

	// AddTaxID adds a new tax ID for a user and returns the updated billing information.
	AddTaxID(ctx context.Context, userID uuid.UUID, taxID TaxID) (*BillingInformation, error)

	// RemoveTaxID removes a tax ID from a user and returns the updated billing information.
	RemoveTaxID(ctx context.Context, userID uuid.UUID, id string) (*BillingInformation, error)

	// GetBillingInformation gets the billing information for a user.
	GetBillingInformation(ctx context.Context, userID uuid.UUID) (*BillingInformation, error)

	// UpdatePackage updates a customer's package plan information.
	UpdatePackage(ctx context.Context, userID uuid.UUID, packagePlan *string, timestamp *time.Time) error

	// ChangeEmail changes a customer's email address.
	ChangeEmail(ctx context.Context, userID uuid.UUID, email string) 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)

	// Balances exposes functionality to manage account balances.
	Balances() Balances

	// ProjectCharges returns how much money current user will be charged for each project.
	ProjectCharges(ctx context.Context, userID uuid.UUID, since, before time.Time) (ProjectChargesResponse, error)

	// GetProjectUsagePriceModel returns the project usage price model for a partner name.
	GetProjectUsagePriceModel(partner string) ProjectUsagePriceModel

	// CheckProjectInvoicingStatus returns error 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) 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

	// 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

type Balance struct {
	FreeCredits int64           `json:"freeCredits"`
	Coins       decimal.Decimal `json:"coins"` // STORJ token balance from storjscan.
	Credits     decimal.Decimal `json:"credits"`
}

Balance is an entity that holds free credits and coins balance of user. Earned by applying of promotional coupon and coins depositing, respectively.

type BalanceTransaction added in v1.76.2

type BalanceTransaction struct {
	ID          string
	Amount      int64
	Description string
}

BalanceTransaction represents a single transaction affecting a customer balance.

type Balances added in v1.76.2

type Balances interface {
	// ApplyCredit applies a credit of `amount` to the user's stripe balance with a description of `desc`.
	ApplyCredit(ctx context.Context, userID uuid.UUID, amount int64, desc string) (*Balance, error)
	// Get returns the customer balance.
	Get(ctx context.Context, userID uuid.UUID) (Balance, error)
	// ListTransactions returns a list of transactions on the customer's balance.
	ListTransactions(ctx context.Context, userID uuid.UUID) ([]BalanceTransaction, error)
}

Balances exposes needed functionality for managing customer balances.

type BillingAddress added in v1.104.1

type BillingAddress struct {
	Name       string     `json:"name"`
	Line1      string     `json:"line1"`
	Line2      string     `json:"line2"`
	City       string     `json:"city"`
	PostalCode string     `json:"postalCode"`
	State      string     `json:"state"`
	Country    TaxCountry `json:"country"`
}

BillingAddress contains a user's custom billing address.

type BillingInformation added in v1.104.1

type BillingInformation struct {
	Address *BillingAddress `json:"address"`
	TaxIDs  []TaxID         `json:"taxIDs"`
}

BillingInformation contains a user's billing information.

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 CountryCode added in v1.104.1

type CountryCode string

CountryCode is the ISO 3166-1 alpha-2 country codes that Stripe supports for tax reporting.

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 CouponType added in v0.30.0

type CouponType string

CouponType is an enum representing the outcome a coupon validation check.

type CouponUsage added in v1.41.1

type CouponUsage struct {
	Coupon      Coupon
	Amount      int64
	PeriodStart time.Time
	PeriodEnd   time.Time
}

CouponUsage describes the usage of a coupon on an invoice.

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)
	// ApplyFreeTierCoupon applies the free tier coupon to the specified user.
	ApplyFreeTierCoupon(ctx context.Context, userID uuid.UUID) (*Coupon, error)
	// ApplyCoupon applies coupon to user based on coupon ID.
	ApplyCoupon(ctx context.Context, userID uuid.UUID, couponID string) (*Coupon, 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 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) (CreditCard, error)

	// AddByPaymentMethodID is used to save new credit card, attach it to payment account and make it default
	// using the payment method id instead of the token. In this case, the payment method should already be
	// created by the frontend using stripe elements for example.
	AddByPaymentMethodID(ctx context.Context, userID uuid.UUID, pmID string) (CreditCard, 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

type CreditsPage struct {
	Credits    []Credit
	Next       bool
	NextOffset int64
}

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 DepositWallets added in v1.57.1

type DepositWallets interface {
	// Claim gets a new crypto wallet and associates it with a user.
	Claim(ctx context.Context, userID uuid.UUID) (blockchain.Address, error)
	// Get returns the crypto wallet address associated with the given user.
	Get(ctx context.Context, userID uuid.UUID) (blockchain.Address, error)
	// Payments returns payments for a particular wallet.
	Payments(ctx context.Context, wallet blockchain.Address, limit int, offset int64) ([]WalletPayment, error)
	// PaymentsWithConfirmations returns payments with confirmations count for a particular wallet.
	PaymentsWithConfirmations(ctx context.Context, wallet blockchain.Address) ([]WalletPaymentWithConfirmations, error)
}

DepositWallets exposes all needed functionality to manage token deposit wallets.

architecture: Service

type Invoice

type Invoice struct {
	ID          string    `json:"id"`
	CustomerID  string    `json:"-"`
	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 InvoiceCursor added in v1.87.1

type InvoiceCursor struct {
	Limit int

	// StartingAfter is the last invoice ID of the previous page.
	// The next page will start after this ID.
	StartingAfter string
	// EndingBefore is the id before which a page should end.
	EndingBefore string
}

InvoiceCursor holds info for invoices cursor pagination.

type InvoicePage added in v1.87.1

type InvoicePage struct {
	Invoices []Invoice
	// Next indicates whether there are more events to retrieve.
	Next bool
	// Previous indicates whether there are previous items.
	Previous bool
}

InvoicePage returns paginated invoices.

type Invoices added in v0.25.0

type Invoices interface {
	// Create creates an invoice with price and description.
	Create(ctx context.Context, userID uuid.UUID, price int64, desc string) (*Invoice, error)
	// Get returns an invoice by invoiceID.
	Get(ctx context.Context, invoiceID string) (*Invoice, error)
	// Pay pays an invoice.
	Pay(ctx context.Context, invoiceID, paymentMethodID string) (*Invoice, error)
	// List returns a list of invoices for a given payment account.
	List(ctx context.Context, userID uuid.UUID) ([]Invoice, error)
	// ListPaged returns a paged list of invoices.
	ListPaged(ctx context.Context, userID uuid.UUID, cursor InvoiceCursor) (*InvoicePage, error)
	// ListFailed returns a list of failed invoices.
	ListFailed(ctx context.Context, userID *uuid.UUID) ([]Invoice, error)
	// ListWithDiscounts returns a list of invoices and coupon usages for a given payment account.
	ListWithDiscounts(ctx context.Context, userID uuid.UUID) ([]Invoice, []CouponUsage, error)
	// CheckPendingItems returns if pending invoice items for a given payment account exist.
	CheckPendingItems(ctx context.Context, userID uuid.UUID) (existingItems bool, err error)
	// AttemptPayOverdueInvoices attempts to pay a user's open, overdue invoices.
	AttemptPayOverdueInvoices(ctx context.Context, userID uuid.UUID) (err error)
	// AttemptPayOverdueInvoicesWithTokens attempts to pay a user's open, overdue invoices with token only.
	AttemptPayOverdueInvoicesWithTokens(ctx context.Context, userID uuid.UUID) (err error)
	// Delete a draft invoice.
	Delete(ctx context.Context, id string) (inv *Invoice, err error)
}

Invoices exposes all needed functionality to manage account invoices.

architecture: Service

type PackagePlan added in v1.73.4

type PackagePlan struct {
	Price  int64
	Credit int64
}

PackagePlan is an amount to charge a user one time in exchange for credit of greater value. Price and Credit are in cents USD.

type PaymentStatus added in v1.60.1

type PaymentStatus string

PaymentStatus indicates payment status.

type ProjectCharge added in v0.26.0

type ProjectCharge struct {
	accounting.ProjectUsage

	// StorageMBMonthCents is how many cents we should pay for storing MB*months.
	StorageMBMonthCents int64 `json:"storagePrice"`
	// EgressMBCents is how many cents we should pay for megabytes of egress.
	EgressMBCents int64 `json:"egressPrice"`
	// SegmentMonthCents is how many cents we should pay for objects count.
	SegmentMonthCents int64 `json:"segmentPrice"`
}

ProjectCharge contains project usage and how much it will cost at the end of the month.

type ProjectChargesResponse added in v1.77.2

type ProjectChargesResponse map[uuid.UUID]map[string]ProjectCharge

ProjectChargesResponse represents a collection of project usage charges grouped by project ID and partner name. It is implemented as a map of project public IDs to a nested map of partner names to ProjectCharge structs.

The values of the inner map are ProjectCharge structs which contain information about the charges associated with a particular project-partner combination.

type ProjectUsagePriceModel added in v1.71.1

type ProjectUsagePriceModel struct {
	StorageMBMonthCents decimal.Decimal `json:"storageMBMonthCents"`
	EgressMBCents       decimal.Decimal `json:"egressMBCents"`
	SegmentMonthCents   decimal.Decimal `json:"segmentMonthCents"`
	EgressDiscountRatio float64         `json:"egressDiscountRatio"`
}

ProjectUsagePriceModel represents price model for project usage.

type StorjTokens added in v0.24.0

type StorjTokens interface {
	// 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 Tax added in v1.104.1

type Tax struct {
	Code        stripe.TaxIDType `json:"code"`
	Name        string           `json:"name"`
	Example     string           `json:"example"`
	CountryCode CountryCode      `json:"countryCode"`
}

Tax is a tax that Stripe supports for tax reporting.

type TaxCode added in v1.104.1

type TaxCode string

TaxCode the tax codes that Stripe supports for tax reporting.

type TaxCountry added in v1.104.1

type TaxCountry struct {
	Name string      `json:"name"`
	Code CountryCode `json:"code"`
}

TaxCountry is a country that Stripe supports for tax reporting.

type TaxID added in v1.104.1

type TaxID struct {
	ID    string `json:"id"`
	Tax   Tax    `json:"tax"`
	Value string `json:"value"`
}

TaxID contains a user's tax information.

type Transaction added in v0.24.0

type Transaction struct {
	ID        TransactionID
	Amount    currency.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        currency.Amount
	Received      currency.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.

type WalletPayment added in v1.60.1

type WalletPayment struct {
	ChainID     int64              `json:"chainID"`
	From        blockchain.Address `json:"from"`
	To          blockchain.Address `json:"to"`
	TokenValue  currency.Amount    `json:"tokenValue"`
	USDValue    currency.Amount    `json:"usdValue"`
	Status      PaymentStatus      `json:"status"`
	BlockHash   blockchain.Hash    `json:"blockHash"`
	BlockNumber int64              `json:"blockNumber"`
	Transaction blockchain.Hash    `json:"transaction"`
	LogIndex    int                `json:"logIndex"`
	Timestamp   time.Time          `json:"timestamp"`
}

WalletPayment holds storj token payment data.

type WalletPaymentWithConfirmations added in v1.84.1

type WalletPaymentWithConfirmations struct {
	ChainID       int64           `json:"chainID"`
	From          string          `json:"from"`
	To            string          `json:"to"`
	TokenValue    decimal.Decimal `json:"tokenValue"`
	USDValue      decimal.Decimal `json:"usdValue"`
	Status        PaymentStatus   `json:"status"`
	BlockHash     string          `json:"blockHash"`
	BlockNumber   int64           `json:"blockNumber"`
	Transaction   string          `json:"transaction"`
	LogIndex      int             `json:"logIndex"`
	Timestamp     time.Time       `json:"timestamp"`
	Confirmations int64           `json:"confirmations"`
	BonusTokens   decimal.Decimal `json:"bonusTokens"`
}

WalletPaymentWithConfirmations holds storj token payment data with confirmations count.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL