Documentation
¶
Index ¶
- Constants
- func New() app.Component
- type AnyppDB
- func (anyppdb *AnyppDB) Close(ctx context.Context) (err error)
- func (anyppdb *AnyppDB) CreateOrUpdateSubscription(ctx context.Context, sub *Subscription, userAnyID string) (err error)
- func (anyppdb *AnyppDB) GetAllSubscriptionsInStatus(ctx context.Context, status proto.SubscriptionStatus) (subsIds []string, err error)
- func (anyppdb *AnyppDB) GetPaymentRequest(ctx context.Context, billingID string) (pr *PaymentRequest, err error)
- func (anyppdb *AnyppDB) GetPaymentRequest_TestData() (*PaymentRequest, error)
- func (anyppdb *AnyppDB) GetSubscription(ctx context.Context, subID string) (sub *Subscription, err error)
- func (anyppdb *AnyppDB) GetSubscriptionForUser(ctx context.Context, userAnyID string) (sub *Subscription, err error)
- func (anyppdb *AnyppDB) Init(a *app.App) (err error)
- func (anyppdb *AnyppDB) Name() (name string)
- func (anyppdb *AnyppDB) SaveNewPaymentRequest(ctx context.Context, bsr *proto.BuySubscriptionRequest, billingID string) (err error)
- func (anyppdb *AnyppDB) UpdatePaymentRequest(ctx context.Context, pr *PaymentRequest, billingID string) (err error)
- type DBService
- type NSOperation
- type NSOperationType
- type Payment
- type PaymentProvider
- type PaymentRequest
- type ReqState
- type Subscription
Constants ¶
View Source
const CName = "any-pp.db"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnyppDB ¶
type AnyppDB struct {
// contains filtered or unexported fields
}
func (*AnyppDB) Close ¶
TODO: check if it is even called, this is not a app.ComponentRunnable instance so maybe it won't be called
func (*AnyppDB) CreateOrUpdateSubscription ¶
func (*AnyppDB) GetAllSubscriptionsInStatus ¶
func (*AnyppDB) GetPaymentRequest ¶
func (*AnyppDB) GetPaymentRequest_TestData ¶
func (anyppdb *AnyppDB) GetPaymentRequest_TestData() (*PaymentRequest, error)
func (*AnyppDB) GetSubscription ¶
func (*AnyppDB) GetSubscriptionForUser ¶
func (*AnyppDB) SaveNewPaymentRequest ¶
func (*AnyppDB) UpdatePaymentRequest ¶
type DBService ¶
type DBService interface {
// A PaymentRequest is created first by the user
SaveNewPaymentRequest(ctx context.Context, bsr *proto.BuySubscriptionRequest, billingID string) (err error)
GetPaymentRequest(ctx context.Context, billingID string) (pr *PaymentRequest, err error)
UpdatePaymentRequest(ctx context.Context, pr *PaymentRequest, billingID string) (err error)
// When payment is completed, we create a new subscription
// with []payments array (do not confuse with PaymentRequest)
GetSubscriptionForUser(ctx context.Context, userAnyID string) (sub *Subscription, err error)
GetSubscription(ctx context.Context, subID string) (sub *Subscription, err error)
// max output - 100 items
GetAllSubscriptionsInStatus(ctx context.Context, status proto.SubscriptionStatus) (subsIds []string, err error)
CreateOrUpdateSubscription(ctx context.Context, sub *Subscription, userAnyID string) (err error)
app.Component
}
type NSOperation ¶
type NSOperation struct {
OperationType NSOperationType `bson:"OperationType"`
OperationId string `bson:"OperationId"`
OperationState anyns_api.OperationState `bson:"OperationState"`
}
type NSOperationType ¶
type NSOperationType uint8
const ( NSOperationTypeUnknown NSOperationType = 0 NSOperationTypeFundUserAccount NSOperationType = 1 )
type Payment ¶
type Payment struct {
Id primitive.ObjectID `bson:"_id"`
PaymentState ReqState `bson:"PaymentState"`
PaymentProvider PaymentProvider `bson:"PaymentProvider"`
// If through Stripe
StripePaymentMethod uint8 `bson:"StripePaymentMethod"`
}
type PaymentProvider ¶
type PaymentProvider uint8
const ( PaymentProviderUnknown PaymentProvider = 0 PaymentProviderStripe PaymentProvider = 1 )
type PaymentRequest ¶
type PaymentRequest struct {
Id primitive.ObjectID `bson:"_id"`
// random generated string
BillingID string `bson:"BillingID"`
RequestedTier proto.SubscriptionTier `bson:"RequestedTier"`
OwnerAnyID string `bson:"OwnerAnyID"`
OwnerEthAddress string `bson:"OwnerEthAddress"`
PaymentMethod proto.PaymentMethod `bson:"PaymentMethod"`
PaymentRequestState ReqState `bson:"PaymentRequestState"`
}
type Subscription ¶
type Subscription struct {
Id primitive.ObjectID `bson:"_id"`
OwnerAnyID string `bson:"OwnerAnyID"`
OwnerEthAddress string `bson:"OwnerEthAddress"`
CurrentTier proto.SubscriptionTier `bson:"CurrentTier"`
Started uint64 `bson:"Started"`
Ends uint64 `bson:"Ends"`
SubscriptionStatus proto.SubscriptionStatus `bson:"SubscriptionStatus"`
IsAutoRenew bool `bson:"IsAutoRenew"`
// if through Stripe
StripeSessionId string `bson:"StripeSessionId"`
StripeSubscriptionID string `bson:"StripeSubscriptionID"`
Payments []Payment `bson:"Payments"`
NameServiceOperations []NSOperation `bson:"NameServiceOperations"`
}
Click to show internal directories.
Click to hide internal directories.