litepay

package module
v0.0.0-...-93f8aa3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 16 Imported by: 0

README

litepay

💸 Light and fast library for quick payments

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cart

type Cart struct {
	ID       string `json:"id"`
	Currency string `json:"currency"`
	Items    []Item `json:"items"`
}

type Cfg

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

func New

func New(callbackURL, successURL, cancelURL string) Cfg

func (Cfg) Spectrocoin

func (c Cfg) Spectrocoin(merchantID, projectID, privateKey string) LitePay

func (Cfg) Stripe

func (c Cfg) Stripe(apiToken string) LitePay

type Coin

type Coin struct {
	AmountTotal float64 `json:"amount_total"`
	Currency    string  `json:"currency"`
}

type Item

type Item struct {
	PriceData Price `json:"price"`
	Quantity  int   `json:"quantity"`
}

type LitePay

type LitePay interface {
	Pay(cart Cart) (*Payment, error)
	Checkout(payment *Payment, session string) (*Payment, error)
	Response(resp *http.Request) Response
}

type Payment

type Payment struct {
	Provider    Provider `json:"provider"`
	CartID      string   `json:"cart_id"`
	AmountTotal int      `json:"amount_total"`
	Currency    string   `json:"currency"`
	Status      Status   `json:"status"`
	URL         string   `json:"url,omitempty"`
	Coin        *Coin    `json:"coin,omitempty"`
}

type Price

type Price struct {
	UnitAmount int     `json:"init_amount"`
	Product    Product `json:"product"`
}

type Product

type Product struct {
	Name   string   `json:"name"`
	Images []string `json:"images"`
}

type Provider

type Provider string
const (
	STRIPE      Provider = "stripe"
	SPECTROCOIN Provider = "spectrocoin"
)

type Response

type Response interface {
	Callback() (*Payment, error)
	Success() (*Payment, error)
	Cancel() (*Payment, error)
}

type Status

type Status string
const (
	UNPAID    Status = "unpaid"
	PAY       Status = "pay"
	CANCELED  Status = "canceled"
	FAILED    Status = "failed"
	PROCESSED Status = "processed"
	TEST      Status = "test"
)

Jump to

Keyboard shortcuts

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