storj/satellite/payments/coupons.go
Jeremy Wharton 3b751a35c5 satellite/{payments,satellitedb}: Remove custom coupon implementation
Removes database tables and functionality related to our custom
coupon implementation because it has been superseded by the Stripe
coupon and promo code system. Requires implementations of the
payments Invoices interface to return coupon usages along with
invoices.

Change-Id: Iac52d2ff64afca8cc4dbb2d1f20e6ad4b39ddfde
2021-10-11 19:47:00 +00:00

47 lines
1.4 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package payments
import (
"context"
"time"
"storj.io/common/uuid"
)
// Coupons exposes all needed functionality to manage coupons.
//
// architecture: Service
type Coupons interface {
// GetByUserID returns the coupon applied to the specified user.
GetByUserID(ctx context.Context, userID uuid.UUID) (*Coupon, error)
// ApplyCouponCode attempts to apply a coupon code to the user.
ApplyCouponCode(ctx context.Context, userID uuid.UUID, couponCode string) (*Coupon, error)
}
// Coupon describes a discount to the payment account of a user.
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"`
}
// CouponDuration represents how many billing periods a coupon is applied.
type CouponDuration string
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"
)