ptcpayclient

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 15 Imported by: 2

README

Build Status Quality Gate Status Go Report Card

BTCPay Server Client

A Golang client for BTCPay Server that is mockable

BTCPay Server is a self-hosted, open-source cryptocurrency payment processor. It's secure, private, censorship-resistant and free.

This client will be used to add cryptocurrency payments to Six910 E-Commerce System.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BTCPayClient

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

BTCPayClient BTCPayClient

func (*BTCPayClient) CreateInvoice

func (a *BTCPayClient) CreateInvoice(inv *InvoiceReq) *InvoiceResponse

CreateInvoice CreateInvoice

func (*BTCPayClient) GetClientID

func (a *BTCPayClient) GetClientID() string

GetClientID GetClientID

func (*BTCPayClient) GetInvoice

func (a *BTCPayClient) GetInvoice(invoiceID string) *InvoiceResponse

GetInvoice GetInvoice

func (*BTCPayClient) GetInvoices

func (a *BTCPayClient) GetInvoices(args *InvoiceArgs) *InvoiceListResponse

GetInvoices GetInvoices

func (*BTCPayClient) GetPairingCodeRequest

func (a *BTCPayClient) GetPairingCodeRequest(code string) string

GetPairingCodeRequest GetPairingCodeRequest

func (*BTCPayClient) GetRates

func (a *BTCPayClient) GetRates(currencyPairs []string, storeID string) *RateResponse

GetRates GetRates

func (*BTCPayClient) New

func (a *BTCPayClient) New(host string, kp *ecdsa.PrivateKey, token string) Client

New New

func (*BTCPayClient) OverrideProxy

func (a *BTCPayClient) OverrideProxy(proxy px.Proxy)

OverrideProxy OverrideProxy

func (*BTCPayClient) PairClient

func (a *BTCPayClient) PairClient(code string) *TokenResponse

PairClient PairClient

func (*BTCPayClient) SetHeader

func (a *BTCPayClient) SetHeader(head Headers)

SetHeader SetHeader

func (*BTCPayClient) SetLogLevel

func (a *BTCPayClient) SetLogLevel(level int)

SetLogLevel SetLogLevel

func (*BTCPayClient) Token

func (a *BTCPayClient) Token(req *TokenRequest) *TokenResponse

Token Token

type Buyer

type Buyer struct {
	Name       string `json:"name"`
	Address1   string `json:"address1"`
	Address2   string `json:"address2"`
	City       string `json:"city"`
	Locality   string `json:"locality"`
	Region     string `json:"region"`
	PostalCode string `json:"postalCode"`
	State      string `json:"state"`
	Zip        string `json:"zip"`
	Country    string `json:"country"`
	Phone      string `json:"phone"`
	Notify     bool   `json:"notify"`
	Email      string `json:"email"`
}

Buyer Buyer

type BuyerFields

type BuyerFields struct {
	BuyerName     string `json:"buyerName"`
	BuyerAddress1 string `json:"buyerAddress1"`
	BuyerAddress2 string `json:"buyerAddress2"`
	BuyerCity     string `json:"buyerCity"`
	BuyerState    string `json:"buyerState"`
	BuyerZip      string `json:"buyerZip"`
	BuyerCountry  string `json:"buyerCountry"`
	BuyerPhone    string `json:"buyerPhone"`
	BuyerNotify   bool   `json:"buyerNotify"`
	BuyerEmail    string `json:"buyerEmail"`
}

BuyerFields BuyerFields

type Client

type Client interface {
	GetClientID() string
	Token(req *TokenRequest) *TokenResponse
	PairClient(code string) *TokenResponse
	GetPairingCodeRequest(code string) string
	GetRates(currencyPairs []string, storeID string) *RateResponse
	CreateInvoice(inv *InvoiceReq) *InvoiceResponse
	GetInvoice(invoiceID string) *InvoiceResponse
	GetInvoices(args *InvoiceArgs) *InvoiceListResponse
	SetLogLevel(level int)
}

Client Client

type Crypto

type Crypto interface {
	GenerateKeyPair(ec elliptic.Curve) *ecdsa.PrivateKey
	LoadKeyPair(privateKey string, ec elliptic.Curve) *ecdsa.PrivateKey
	GetSinFromKey(kp *ecdsa.PrivateKey) string
	Sign(hash []byte, kp *ecdsa.PrivateKey) ([]byte, error)
	GetPublicKey(kp *ecdsa.PrivateKey) string
}

Crypto Crypto

type CryptoCode

type CryptoCode struct {
	CryptoCode  string             `json:"cryptoCode"`
	PaymentType string             `json:"paymentType"`
	Rate        float64            `json:"rate"`
	ExRates     map[string]float64 `json:"exRates"`
	Paid        string             `json:"paid"`
	Price       string             `json:"price"`
	Due         string             `json:"due"`
	PaymentUrls map[string]string  `json:"paymentUrls"`
	Address     string             `json:"address"`
	URL         string             `json:"url"`
	TotalDue    string             `json:"totalDue"`
	NetworkFee  string             `json:"networkFee"`
	TxCount     int64              `json:"txCount"`
	CryptoPaid  string             `json:"cryptoPaid"`
	Payments    []Payment          `json:"payments"`
}

CryptoCode CryptoCode

type Cryptography

type Cryptography struct {
}

Cryptography Cryptography

func (*Cryptography) GenerateKeyPair

func (c *Cryptography) GenerateKeyPair(ec elliptic.Curve) *ecdsa.PrivateKey

GenerateKeyPair GenerateKeyPair

func (*Cryptography) GetPublicKey

func (c *Cryptography) GetPublicKey(kp *ecdsa.PrivateKey) string

GetPublicKey GetPublicKey

func (*Cryptography) GetSinFromKey

func (c *Cryptography) GetSinFromKey(kp *ecdsa.PrivateKey) string

GetSinFromKey GetSinFromKey

func (*Cryptography) LoadKeyPair

func (c *Cryptography) LoadKeyPair(privateKey string, ec elliptic.Curve) *ecdsa.PrivateKey

LoadKeyPair LoadKeyPair

func (*Cryptography) New

func (c *Cryptography) New() Crypto

New New

func (*Cryptography) Sign

func (c *Cryptography) Sign(hash []byte, kp *ecdsa.PrivateKey) ([]byte, error)

Sign Sign

type Erate

type Erate struct {
}

Erate Erate

type Headers

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

Headers Headers

func (*Headers) Set

func (h *Headers) Set(key string, value string)

Set Set

type InvFlags

type InvFlags struct {
	Refundable bool `json:"refundable"`
}

InvFlags InvFlags

type Invoice

type Invoice struct {
	GUID                        string                        `json:"guid"`
	ID                          string                        `json:"id"`
	URL                         string                        `json:"url"`
	BtcPrice                    string                        `json:"btcPrice"`
	BtcDue                      string                        `json:"btcDue"`
	CryptoInfo                  []CryptoCode                  `json:"cryptoInfo"`
	ExRates                     map[string]float64            `json:"exRates"`
	BuyerTotalBtcAmount         string                        `json:"buyerTotalBtcAmount"`
	InvoiceTime                 int64                         `json:"invoiceTime"`
	CurrentTime                 int64                         `json:"currentTime"`
	LowFeeDetected              bool                          `json:"lowFeeDetected"`
	BtcPaid                     string                        `json:"btcPaid"`
	Rate                        float64                       `json:"rate"`
	ExceptionStatus             interface{}                   `json:"exceptionStatus"`
	PaymentUrls                 PayURLs                       `json:"paymentUrls"`
	RefundAddressRequestPending bool                          `json:"refundAddressRequestPending"`
	BuyerPaidBtcMinerFee        string                        `json:"buyerPaidBtcMinerFee"`
	BitcoinAddress              string                        `json:"bitcoinAddress"`
	Flags                       InvFlags                      `json:"flags"`
	PaymentSubtotals            map[string]float64            `json:"paymentSubtotals"`
	PaymentTotals               map[string]float64            `json:"paymentTotals"`
	AmountPaid                  float64                       `json:"amountPaid"`
	MinerFees                   map[string]MinerFee           `json:"minerFees"`
	ExchangeRates               map[string]map[string]float64 `json:"exchangeRates"`
	Addresses                   map[string]string             `json:"addresses"`
	PaymentCodes                map[string]map[string]string  `json:"paymentCodes"`
	Currency                    string                        `json:"currency"`
	Price                       float64                       `json:"price"`
	OrderID                     string                        `json:"orderId"`
	ExpirationTime              int64                         `json:"expirationTime"`
	ItemDesc                    string                        `json:"itemDesc"`
	ItemCode                    string                        `json:"itemCode"`
	PosData                     string                        `json:"posData"`
	Status                      string                        `json:"status"`
	//RedirectURL                    string                   `json:"redirectURL"`
	//TransactionSpeed               string                   `json:"transactionSpeed"`
	//Physical                       bool                     `json:"physical"`
	SupportedTransactionCurrencies map[string]TranCurStatus `json:"supportedTransactionCurrencies"`
	//Refundable                     bool                     `json:"refundable"`
	TaxIncluded           float64 `json:"taxIncluded"`
	Token                 string  `json:"token"`
	RedirectAutomatically bool    `json:"redirectAutomatically"`
	NotificationEmail     string  `json:"notificationEmail"`
	NotificationURL       string  `json:"notificationURL"`
	ExtendedNotifications bool    `json:"extendedNotifications"`
	FullNotifications     bool    `json:"fullNotifications"`
	//BuyerFields                    BuyerFields              `json:"buyerFields"`
	Buyer Buyer `json:"buyer"`
}

Invoice Invoice

type InvoiceArgs

type InvoiceArgs struct {
	Status    string `json:"status"`
	OrderID   string `json:"orderId"`
	ItemCode  string `json:"itemCode"`
	DateStart string `json:"dateStart"`
	DateEnd   string `json:"dateEnd"`
	Limit     string `json:"limit"`
	Offset    string `json:"offset"`
}

InvoiceArgs InvoiceArgs

type InvoiceListResponse

type InvoiceListResponse struct {
	Data []Invoice `json:"data"`
}

InvoiceListResponse InvoiceListResponse

type InvoiceReq

type InvoiceReq struct {
	Currency string  `json:"currency"`
	Price    float64 `json:"price"`
	OrderID  string  `json:"orderId"`
	//ExpirationTime                 int64                    `json:"expirationTime"`
	ItemDesc                       string                   `json:"itemDesc"`
	ItemCode                       string                   `json:"itemCode"`
	PosData                        string                   `json:"posData"`
	Status                         string                   `json:"status"`
	RedirectURL                    string                   `json:"redirectURL"`
	TransactionSpeed               string                   `json:"transactionSpeed"`
	Physical                       bool                     `json:"physical"`
	SupportedTransactionCurrencies map[string]TranCurStatus `json:"supportedTransactionCurrencies"`
	Refundable                     bool                     `json:"refundable"`
	TaxIncluded                    float64                  `json:"taxIncluded"`
	Token                          string                   `json:"token"`
	RedirectAutomatically          bool                     `json:"redirectAutomatically"`
	NotificationEmail              string                   `json:"notificationEmail"`
	NotificationURL                string                   `json:"notificationURL"`
	ExtendedNotifications          bool                     `json:"extendedNotifications"`
	FullNotifications              bool                     `json:"fullNotifications"`
	Buyer                          Buyer                    `json:"buyer"`
}

InvoiceReq InvoiceReq

type InvoiceResponse

type InvoiceResponse struct {
	Data Invoice `json:"data"`
}

InvoiceResponse InvoiceResponse

type MinerFee

type MinerFee struct {
	SatoshisPerByte float64 `json:"satoshisPerByte"`
	TotalFee        float64 `json:"totalFee"`
}

MinerFee MinerFee

type PairClientResponse

type PairClientResponse struct {
	Merchant string `json:"merchant"`
}

PairClientResponse PairClientResponse

type PayURLs

type PayURLs struct {
	BIP21  string `json:"BIP21"`
	BIP72  string `json:"BIP72"`
	BIP72b string `json:"BIP72b"`
	BIP73  string `json:"BIP73"`
	BOLT11 string `json:"BOLT11"`
}

PayURLs PayURLs

type Payload

type Payload struct {
	ClientID    string `json:"id"`
	PairingCode string `json:"pairingCode"`
}

Payload Payload

type Payment

type Payment struct {
	ID           string  `json:"id"`
	ReceivedDate string  `json:"receivedDate"`
	Value        float64 `json:"value"`
	Fee          float64 `json:"fee"`
	PaymentType  string  `json:"paymentType"`
	Confirmed    bool    `json:"confirmed"`
	Completed    bool    `json:"completed"`
	Destination  string  `json:"destination"`
}

Payment Payment

type Policy

type Policy struct {
	Policy string   `json:"policy"`
	Method string   `json:"method"`
	Params []string `json:"params"`
}

Policy Policy

type Rate

type Rate struct {
	Name         string  `json:"name"`
	CryptoCode   string  `json:"cryptoCode"`
	CurrencyPair string  `json:"currencyPair"`
	Code         string  `json:"code"`
	Rate         float64 `json:"rate"`
}

Rate Rate

type RateResponse

type RateResponse struct {
	Data []Rate `json:"data"`
}

RateResponse RateResponse

type TokenData

type TokenData struct {
	Policies          []Policy `json:"policies"`
	Token             string   `json:"token"`
	Facade            string   `json:"facade"`
	CreateDate        int64    `json:"dateCreated"`
	PairingExpiration int64    `json:"pairingExpiration"`
	ParingCode        string   `json:"pairingCode"`
}

TokenData TokenData

type TokenRequest

type TokenRequest struct {
	ID          string `json:"id"`
	Facade      string `json:"facade"`
	Label       string `json:"label"`
	PairingCode string `json:"pairingCode"`
}

TokenRequest TokenRequest

type TokenResponse

type TokenResponse struct {
	Data []TokenData `json:"data"`
	Code int64       `json:"code"`
}

TokenResponse TokenResponse

type TranCurStatus

type TranCurStatus struct {
	Enabled bool   `json:"enabled"`
	Reason  string `json:"reason"`
}

TranCurStatus TranCurStatus

Jump to

Keyboard shortcuts

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