radom

package
v0.0.0-...-f003305 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMetadataKey = errors.New("invalid metadata key")
)

Functions

This section is empty.

Types

type AutomatedEVMSubscription

type AutomatedEVMSubscription struct {
	BuyerAddress                string `json:"buyerAddress"`
	SubscriptionContractAddress string `json:"subscriptionContractAddress"`
}

AutomatedEVMSubscripton defines an automated subscription

type CheckoutSession

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

CheckoutSession describes a radom checkout session

type CheckoutSessionRequest

type CheckoutSessionRequest struct {
	SuccessURL     string                 `json:"successUrl"`
	CancelURL      string                 `json:"cancelUrl"`
	Currency       string                 `json:"currency"`
	ExpiresAt      int64                  `json:"expiresAt"` // in unix seconds
	LineItems      []LineItem             `json:"lineItems"`
	Metadata       Metadata               `json:"metadata"`
	Customizations map[string]interface{} `json:"customizations"`
	Total          decimal.Decimal        `json:"total"`
	Gateway        Gateway                `json:"gateway"`
}

CheckoutSessionRequest represents a request to create a checkout session.

type CheckoutSessionResponse

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

CheckoutSessionResponse represents the result of submission of a checkout session.

type Client

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

Client communicates with Radom.

func New

func New(srvURL, secret, proxyAddr string) (*Client, error)

New returns a ready to use Client.

func (*Client) CreateCheckoutSession

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

CreateCheckoutSession creates a Radom checkout session.

type Data

type Data struct {
	CheckoutSession CheckoutSession `json:"checkoutSession"`
}

Data is radom specific data attached to webhook calls

type EventData

type EventData struct {
	ManagedRecurringPayment *ManagedRecurringPayment `json:"managedRecurringPayment"`
	NewSubscription         *NewSubscriptionData     `json:"newSubscription"`
}

EventData encapsulates the webhook event

type Gateway

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

Gateway provides access to managed services configurations

type InstrumentedClient

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

func NewInstrumented

func NewInstrumented(srvURL, secret, proxyAddr string) (*InstrumentedClient, error)

func (*InstrumentedClient) CreateCheckoutSession

func (_d *InstrumentedClient) CreateCheckoutSession(ctx context.Context, cp1 *CheckoutSessionRequest) (cp2 *CheckoutSessionResponse, err error)

type KeyValue

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

KeyValue represents a key-value metadata pair.

type LineItem

type LineItem struct {
	ProductID string                 `json:"productId"`
	ItemData  map[string]interface{} `json:"itemData"`
}

LineItem is a line item for a checkout session request.

type Managed

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

Managed is the Radom managed services configuration

type ManagedRecurringPayment

type ManagedRecurringPayment struct {
	PaymentMethod Method          `json:"paymentMethod"`
	Amount        decimal.Decimal `json:"amount"`
}

ManagedRecurringPayment provides details about the recurring payment from webhook

type Metadata

type Metadata []KeyValue

Metadata represents metaadata in a checkout session request.

func (Metadata) Get

func (m Metadata) Get(key string) (string, error)

Get allows returns a value based on the key from the Radom metadata.

type Method

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

Method is a Radom payment method type

type MockClient

type MockClient struct {
	FnCreateCheckoutSession func(ctx context.Context, req *CheckoutSessionRequest) (*CheckoutSessionResponse, error)
}

func (*MockClient) CreateCheckoutSession

func (c *MockClient) CreateCheckoutSession(
	ctx context.Context,
	req *CheckoutSessionRequest,
) (*CheckoutSessionResponse, error)

type NewSubscriptionData

type NewSubscriptionData struct {
	SubscriptionID       string            `json:"subscriptionId"`
	Subscription         Subscription      `json:"subscriptionType"`
	Network              string            `json:"network"`
	Token                string            `json:"token"`
	Amount               decimal.Decimal   `json:"amount"`
	Currency             string            `json:"currency"`
	Period               string            `json:"period"`
	PeriodCustomDuration string            `json:"periodCustomDuration"`
	CreatedAt            *time.Time        `json:"createdAt"`
	Tags                 map[string]string `json:"tags"`
}

NewSubscriptionData provides details about the new subscription

type Subscription

type Subscription struct {
	AutomatedEVMSubscription AutomatedEVMSubscription `json:"automatedEVMSubscription"`
}

Subscription is a radom subscription

type WebhookRequest

type WebhookRequest struct {
	EventType string    `json:"eventType"`
	EventData EventData `json:"eventData"`
	Data      Data      `json:"radomData"`
}

WebhookRequest represents a radom webhook submission

Jump to

Keyboard shortcuts

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