radom

package
v0.0.0-...-bfe46a2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrUnsupportedEvent      = Error("radom: unsupported event")
	ErrNoCheckoutSessionData = Error("radom: no checkout session data")
	ErrBraveOrderIDNotFound  = Error("radom: brave order id not found")
	ErrNoRadomPaymentData    = Error("radom: no radom payment data")

	ErrDisabled               = Error("radom: disabled")
	ErrVerificationKeyEmpty   = Error("radom: verification key is empty")
	ErrVerificationKeyInvalid = Error("radom: verification key is invalid")
)
View Source
const ErrSubPaymentsEmpty = Error("radom: subscription payments empty")

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckoutSession

type CheckoutSession struct {
	CheckoutSessionID string     `json:"checkoutSessionId"`
	Metadata          []Metadata `json:"metadata"`
}

type CheckoutSessionRequest

type CheckoutSessionRequest struct {
	LineItems  []LineItem `json:"lineItems"`
	Gateway    *Gateway   `json:"gateway"`
	SuccessURL string     `json:"successUrl"`
	CancelURL  string     `json:"cancelUrl"`
	Metadata   []Metadata `json:"metadata"`
	ExpiresAt  int64      `json:"expiresAt"` // in unix seconds
}

type CheckoutSessionResponse

type CheckoutSessionResponse struct {
	SessionID  string `json:"checkoutSessionId"`
	SessionURL string `json:"checkoutSessionUrl"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(srvURL, authToken string) (*Client, error)

func (*Client) CreateCheckoutSession

func (c *Client) CreateCheckoutSession(ctx context.Context, creq *CheckoutSessionRequest) (CheckoutSessionResponse, error)

func (*Client) GetSubscription

func (c *Client) GetSubscription(ctx context.Context, subID string) (*SubscriptionResponse, error)

type Data

type Data struct {
	CheckoutSession *CheckoutSession `json:"checkoutSession"`
	Subscription    *Subscription    `json:"subscription"`
}

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type EventData

type EventData struct {
	New       *NewSubscription       `json:"newSubscription"`
	Payment   *SubscriptionPayment   `json:"subscriptionPayment"`
	Cancelled *SubscriptionCancelled `json:"subscriptionCancelled"`
	Expired   *SubscriptionExpired   `json:"subscriptionExpired"`
}

type Gateway

type Gateway struct {
	Managed Managed `json:"managed"`
}

type LineItem

type LineItem struct {
	ProductID string `json:"productId"`
}

type Managed

type Managed struct {
	Methods []Method `json:"methods"`
}

type MessageAuthConfig

type MessageAuthConfig struct {
	Enabled bool
	Token   []byte
}

type MessageAuthenticator

type MessageAuthenticator struct {
	// contains filtered or unexported fields
}

func NewMessageAuthenticator

func NewMessageAuthenticator(cfg MessageAuthConfig) *MessageAuthenticator

func (*MessageAuthenticator) Authenticate

func (r *MessageAuthenticator) Authenticate(_ context.Context, token string) error

type Metadata

type Metadata struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Method

type Method struct {
	Network string `json:"network"`
	Token   string `json:"token"`
}

type NewSubscription

type NewSubscription struct {
	SubscriptionID uuid.UUID `json:"subscriptionId"`
}

type Notification

type Notification struct {
	EventType string     `json:"eventType"`
	EventData *EventData `json:"eventData"`
	RadomData *Data      `json:"radomData"`
}

func ParseNotification

func ParseNotification(b []byte) (*Notification, error)

func (*Notification) Effect

func (n *Notification) Effect() string

func (*Notification) IsNewSub

func (n *Notification) IsNewSub() bool

func (*Notification) NtfType

func (n *Notification) NtfType() string

func (*Notification) OrderID

func (n *Notification) OrderID() (uuid.UUID, error)

func (*Notification) ShouldCancel

func (n *Notification) ShouldCancel() bool

func (*Notification) ShouldProcess

func (n *Notification) ShouldProcess() bool

func (*Notification) ShouldRenew

func (n *Notification) ShouldRenew() bool

func (*Notification) SubID

func (n *Notification) SubID() (uuid.UUID, error)

type Payment

type Payment struct {
	Date string `json:"date"`
}

type Subscription

type Subscription struct {
	SubscriptionID uuid.UUID `json:"subscriptionId"`
}

type SubscriptionCancelled

type SubscriptionCancelled struct {
	SubscriptionID uuid.UUID `json:"subscriptionId"`
}

type SubscriptionExpired

type SubscriptionExpired struct {
	SubscriptionID uuid.UUID `json:"subscriptionId"`
}

type SubscriptionPayment

type SubscriptionPayment struct {
	RadomData *Data `json:"radomData"`
}

type SubscriptionResponse

type SubscriptionResponse struct {
	ID                string    `json:"id"`
	NextBillingDateAt string    `json:"nextBillingDateAt"`
	Payments          []Payment `json:"payments"`
}

func (*SubscriptionResponse) LastPaid

func (s *SubscriptionResponse) LastPaid() (time.Time, error)

func (*SubscriptionResponse) NextBillingDate

func (s *SubscriptionResponse) NextBillingDate() (time.Time, error)

Jump to

Keyboard shortcuts

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