radom

package
v0.0.0-...-74d0d06 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 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 Client

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

func New

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

func (*Client) CreateCheckoutSession

func (*Client) GetCheckoutSession

func (c *Client) GetCheckoutSession(ctx context.Context, seshID string) (GetCheckoutSessionResponse, error)

func (*Client) GetSubscription

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

type CreateCheckoutSessionRequest

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

type CreateCheckoutSessionResponse

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

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"`
	PaymentAttemptFailure *SubscriptionPaymentAttemptFailure `json:"subscriptionPaymentAttemptFailure"`
	PaymentOverdue        *SubscriptionPaymentOverdue        `json:"subscriptionPaymentOverdue"`
}

type Gateway

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

type GetCheckoutSessionResponse

type GetCheckoutSessionResponse struct {
	SuccessURL         string                 `json:"successUrl"`
	CancelURL          string                 `json:"cancelUrl"`
	SessionStatus      string                 `json:"sessionStatus"`
	AssocSubscriptions []SubscriptionResponse `json:"associatedSubscriptions"`
}

func (GetCheckoutSessionResponse) IsSessionExpired

func (r GetCheckoutSessionResponse) IsSessionExpired() bool

func (GetCheckoutSessionResponse) IsSessionSuccess

func (r GetCheckoutSessionResponse) IsSessionSuccess() bool

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"`
	DiscountPercentOff float64 `json:"discountPercentOff"`
}

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) ShouldRecordPayFailure

func (n *Notification) ShouldRecordPayFailure() 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 SubscriptionPaymentAttemptFailure

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

type SubscriptionPaymentOverdue

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

type SubscriptionResponse

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

func (*SubscriptionResponse) IsActive

func (s *SubscriptionResponse) IsActive() bool

func (*SubscriptionResponse) LastPaid

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

func (*SubscriptionResponse) NextBillingDate

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

func (*SubscriptionResponse) SubID

func (s *SubscriptionResponse) SubID() (string, bool)

Jump to

Keyboard shortcuts

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