whitepay

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

README

Go-WhitePay

Go Reference Go Report Card Go GitHub license

logo

Introduction

SDK for Whitepay written in Go

Dependency free

Installation

go get github.com/fairytale5571/go-whitepay

Docs

Examples:

Donations

If you want to support me, you can do it here:

  • Monobank
  • USDT (TRC20): TVpRMLNMwFoM5L2R1YN4DpeNJPkrrVeJzY
  • USDT (ERC20): 0x4c197743E4340C5695a687882663816F4F3948Bf
  • BTC: bc1qjnvkr3asrwvh55eycucnrchftwdl82w3vsk3tt
  • ETH: 0x4c197743E4340C5695a687882663816F4F3948Bf

Special thanks to:

  • WhitePay aka WhiteBit - For API

Documentation

Index

Constants

View Source
const (
	BaseURL = "https://api.whitepay.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalancesResponse

type AccountBalancesResponse struct {
	Balances []*Balance `json:"balances"`
}

type Balance

type Balance struct {
	ID       string   `json:"id"`
	Value    string   `json:"value"`
	Currency Currency `json:"currency"`
}

Balance represents a WhitePay balance.

type CoinLimit added in v0.0.5

type CoinLimit struct {
	Min string `json:"min"`
	Max string `json:"max"`
}

type CompleteCryptoOrderResponse

type CompleteCryptoOrderResponse struct {
	Order `json:"order"`
}

CompleteCryptoOrderResponse body for CompleteCryptoOrder

type CreateCryptoTopUpRequest

type CreateCryptoTopUpRequest struct {
	CreateNewOrderRequest
}

CreateCryptoTopUpRequest body for CreateCryptoTopUp

type CreateCryptoTopUpResponse

type CreateCryptoTopUpResponse struct {
	Order `json:"order"`
}

CreateCryptoTopUpResponse response for CreateCryptoTopUp

type CreateNewFiatOrder

type CreateNewFiatOrder struct {
	Amount          string `json:"amount"`
	Currency        string `json:"currency"`
	ExternalOrderID string `json:"external_order_id"`
}

type CreateNewFiatOrderResponse

type CreateNewFiatOrderResponse struct {
	Order `json:"order"`
}

type CreateNewOrderRequest

type CreateNewOrderRequest struct {
	// Amount Min value depends on currency. Becomes required in case if “currency“ was specified.
	Amount string `json:"amount"`

	// Currency Becomes required in case if “amount“ was specified.
	Currency string `json:"currency"`

	// ExternalOrderId Unique order identifier in client Database (usually Internal Payment or Order ID used). Number of characters: min 1, max 255. Allowed symbols: aA-zZ, 0-9. Special characters: “-“, “_“.
	ExternalOrderID string `json:"external_order_id"`

	// SuccessfulLink Link used to redirect user from payment form after order completion. Has to be URL
	SuccessfulLink string `json:"successful_link"`

	// FailureLink Link used to redirect user from payment form after order failure. Has to be URL
	FailureLink string `json:"failure_link"`
}

CreateNewOrderRequest body for CreateNewOrder

type CreateNewOrderResponse

type CreateNewOrderResponse struct {
	Order `json:"order"`
}

CreateNewOrderResponse body for CreateNewOrder

type CreatePaymentRequest added in v0.0.5

type CreatePaymentRequest struct {
	Amount     int    `json:"amount"`
	CurrencyID string `json:"currency_id"`
	Method     string `json:"method"`
	Network    string `json:"network"`
}

CreatePaymentRequest represents a request to create a payment. Deprecated: DO NOT USE THIS METHODS RIGHT NOW

type CreatePaymentResponse added in v0.0.5

type CreatePaymentResponse struct {
	Order struct {
		ID string `json:"id"`
	} `json:"order"`
}

CreatePaymentResponse represents a response to create a payment. Deprecated: DO NOT USE THIS METHODS RIGHT NOW

type CryptoCurrency added in v0.0.5

type CryptoCurrency struct {
	ID                   string               `json:"id"`
	Precision            int                  `json:"precision"`
	Icon                 string               `json:"icon"`
	Ticker               string               `json:"ticker"`
	IsFiat               bool                 `json:"is_fiat"`
	Limits               map[string]CoinLimit `json:"limits"`
	Min                  string               `json:"min"`
	Max                  string               `json:"max"`
	IsStable             bool                 `json:"is_stable"`
	Name                 string               `json:"name"`
	Networks             map[string]Network   `json:"networks"`
	ExchangeRate         string               `json:"exchange_rate"`
	PresetDonationValues []interface{}        `json:"preset_donation_values"`
}

type Currency

type Currency struct {
	// ID 	currency identifier
	ID string `json:"id"`

	// Ticker 	currency ticker
	Ticker string `json:"ticker"`

	// Title 	currency title
	Title string `json:"title"`

	// Value 	currency value
	Value string `json:"value"`
}

Currency represents a WhitePay currency.

type ErrorBody

type ErrorBody struct {
	Message string              `json:"message"`
	Errors  map[string][]string `json:"errors,omitempty"`
}

ErrorBody represents an error response body.

func (ErrorBody) Error

func (e ErrorBody) Error() string

type EventType

type EventType string

EventType https://docs.whitepay.com/docs/webhooks/events#webhooks-settings

const (
	EventWithdrawalCompleted EventType = "withdrawal::completed"
	EventWithdrawalDeclined  EventType = "withdrawal::declined"
	EventRollbackToMerchant  EventType = "rollback::to_merchant"
	EventRollbackToClient    EventType = "rollback::to_client"

	EventOrderCompleted              EventType = "order::completed"
	EventOrderDeclined               EventType = "order::declined"
	EventOrderPartiallyFulfilled     EventType = "order::partially_fulfilled"
	EventOrderFinalAmountWasReceived EventType = "order::final_amount_was_received"

	EventTransactionCompleted        EventType = "transaction::complete"
	EventTransactionDeclined         EventType = "transaction::decline"
	EventTransactionWasFinalExchange EventType = "transaction::was_final_exchange"
)

type Events added in v0.0.6

type Events struct {
	Transaction *Transaction `json:"transaction,omitempty"`
	Order       *Order       `json:"order,omitempty"`
	EventType   EventType    `json:"event_type"`
}

type Filters

type Filters func() url.Values

func CompletedAtFrom

func CompletedAtFrom(completedAtFrom time.Time) Filters

func CompletedAtTo

func CompletedAtTo(completedAtTo time.Time) Filters

func DateFrom

func DateFrom(dateFrom time.Time) Filters

func DateTo

func DateTo(dateTo time.Time) Filters

func ExternalOrderID

func ExternalOrderID(externalOrderID string) Filters

func OrderStatusID

func OrderStatusID(orderStatusID string) Filters

func Page

func Page(page int) Filters

func PerPage

func PerPage(perPage int) Filters

type GetCryptoOrderDetailsResponse

type GetCryptoOrderDetailsResponse struct {
	Order `json:"order"`
}

GetCryptoOrderDetailsResponse body for GetCryptoOrderDetails

type InvoiceCurrencies

type InvoiceCurrencies struct {
	// ID 	currency identifier
	ID string `json:"id"`
	// Ticker 	currency ticker
	Ticker string `json:"ticker"`
	// IsFiat a parameter that determines whether the currency is fiat
	IsFiat bool `json:"is_fiat"`
	// Title 	currency title
	Title string `json:"title"`
	// MinAmount 	minimum amount for the currency (numeric)
	MinAmount string `json:"min_amount"`
	// MaxAmount 	maximum amount for the currency (numeric)
	MaxAmount string `json:"max_amount"`
	// Precision (numeric) currency precision - number of characters after the decimal point
	Precision string `json:"precision"`
	// Icon 	currency icon for acquiring form
	Icon string `json:"icon"`
}

InvoiceCurrencies represents a WhitePay invoice currency.

type ListCurrencies added in v0.0.5

type ListCurrencies struct {
	CryptoCurrency []CryptoCurrency `json:"crypto_currency"`
}

ListCurrencies represents a list of cryptocurrencies. Deprecated: DO NOT USE THIS METHODS RIGHT NOW

type Network added in v0.0.5

type Network struct {
	MinAmount string      `json:"min_amount"`
	MaxAmount string      `json:"max_amount"`
	Fixed     string      `json:"fixed"`
	Flex      interface{} `json:"flex"`
}

type Option

type Option func(*WhitePay)

func WithChannelSize added in v0.0.6

func WithChannelSize(size int) Option

WithChannelSize sets the size of the updates channel.

func WithClient

func WithClient(client *http.Client) Option

WithClient sets the HTTP client for the WhitePay client.

func WithMerchantSignatureToken added in v0.0.6

func WithMerchantSignatureToken(token string) Option

WithMerchantSignatureToken sets the merchant signature token for the WhitePay client.

func WithSlugSignatureToken added in v0.0.6

func WithSlugSignatureToken(token string) Option

WithSlugSignatureToken sets the slug signature token for the WhitePay client.

type Order

type Order struct {
	// ID 	internal order identifier
	ID string `json:"id"`

	// Currency invoice currency (ticker)
	Currency string `json:"currency"`

	// OrderNumber 	unique 9-digit numeric order identifier in WhitePay CRM system.
	OrderNumber string `json:"order_number"`

	// Value (numeric)	invoice currency amount
	Value string `json:"value"`

	// ExpectedAmount (numeric)	expected amount to be deposited
	ExpectedAmount string `json:"expected_amount"`

	// ReceivedTotal (numeric)	received amount in balance currency
	ReceivedTotal string `json:"received_total"`

	// ExchangeRate (numeric)	fixated exchange rate of invoice
	ExchangeRate string `json:"exchange_rate"`

	// CleanExchangeRate -
	CleanExchangeRate interface{} `json:"clean_exchange_rate"`

	// IsInternal 	identifies whether payment was made via WhiteBIT platform or not where true = WhiteBIT platform payment and false = any other platform.
	IsInternal        bool        `json:"is_internal"`
	DepositedCurrency interface{} `json:"deposited_currency"`

	// ReceivedCurrency balance currency (ticker)
	ReceivedCurrency string `json:"received_currency"`

	// Status 	order status label
	Status Status `json:"status"`

	// ExternalOrderID external order identifier
	ExternalOrderID string `json:"external_order_id"`

	// CreatedAt 	order creation date
	CreatedAt string `json:"created_at"`

	// CompletedAt 	order completion date
	CompletedAt string `json:"completed_at"`

	// AcquiringURL	unique payment form url. Should be used to redirect website customer to the payment form.
	AcquiringURL string `json:"acquiring_url"`

	// SuccessfulLink Link used to redirect user from payment form after order completion. Has to be URL
	SuccessfulLink string `json:"successful_link"`

	// FailureLink Link used to redirect user from payment form after order failure. Has to be URL
	FailureLink string `json:"failure_link"`

	Transactions []*Transaction `json:"transactions"`
}

Order represents a WhitePay order.

type OrderStatusesListResponse

type OrderStatusesListResponse struct {
	OrderStatuses []*StatusObject `json:"order_statuses"`
}

type Pagination

type Pagination struct {
	PerPage  int `json:"per_page"`
	LastPage int `json:"last_page"`
	Total    int `json:"total"`
}

func (*Pagination) Next

func (p *Pagination) Next() bool

type ShowCryptoOrdersListResponse

type ShowCryptoOrdersListResponse struct {
	Orders []*Order   `json:"orders"`
	Meta   Pagination `json:"meta"`
}

ShowCryptoOrdersListResponse body for ShowCryptoOrdersList

func (*ShowCryptoOrdersListResponse) Next

type ShowInvoiceCurrenciesForCryptoOrderCreationResponse

type ShowInvoiceCurrenciesForCryptoOrderCreationResponse struct {
	Currencies []*Currency `json:"currencies"`
}

type ShowInvoiceCurrenciesForFiatOrderCreationResponse

type ShowInvoiceCurrenciesForFiatOrderCreationResponse struct {
	Currencies []*Currency `json:"currencies"`
}

type ShowOrderDetailsResponse added in v0.0.7

type ShowOrderDetailsResponse struct {
	Order `json:"order"`
}

type ShowOrdersListResponse

type ShowOrdersListResponse struct {
	Orders []*Order   `json:"orders"`
	Meta   Pagination `json:"meta"`
}

func (*ShowOrdersListResponse) Next

func (s *ShowOrdersListResponse) Next() bool

type Status

type Status string
const (
	StatusComplete           Status = "COMPLETE"
	StatusOpen               Status = "OPEN"
	StatusDeclined           Status = "DECLINED"
	StatusInit               Status = "INIT"
	StatusPartiallyFulfilled Status = "PARTIALLY_FULFILLED"
)

type StatusObject added in v0.0.7

type StatusObject struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

StatusObject represents a WhitePay status.

type StockOrder

type StockOrder struct {
	Amount       string `json:"amount"`
	Status       Status `json:"status"`
	Pair         string `json:"pair"`
	Date         string `json:"date"`
	Time         string `json:"time"`
	ExchangeRate string `json:"exchange_rate"`
	CreatedAt    string `json:"created_at"`
}

StockOrder represents a WhitePay stock order.

type Transaction

type Transaction struct {
	// ID 	transaction identifier
	ID string `json:"id"`
	// Currency 	transaction currency (ticker)
	Currency string `json:"currency"`
	// Value 	transaction amount
	Value string `json:"value"`
	// Status 	transaction status label
	Status Status `json:"status"`
	// Hash transaction hash
	Hash string `json:"hash"`
	// IsInternal 	identifies whether payment was made via WhiteBIT platform or not where true = WhiteBIT platform payment and false = any other platform.
	IsInternal bool `json:"is_internal"`
	// CreatedAt 	transaction creation date
	CreatedAt string `json:"created_at"`
	// CompletedAt 	transaction completion date
	CompletedAt string `json:"completed_at"`
	// StockOrders 	stock orders
	StockOrders []*StockOrder `json:"stock_orders,omitempty"`
}

Transaction represents a WhitePay transaction.

type WalletOrderDetailResponse added in v0.0.5

type WalletOrderDetailResponse struct {
	Address string `json:"address"`
	Network string `json:"network"`
	Memo    string `json:"memo,omitempty"`
}

WalletOrderDetailResponse represents a response to get wallet order details. Deprecated: DO NOT USE THIS METHODS RIGHT NOW

type WhitePay

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

WhitePay represents a WhitePay client.

func New

func New(token, slug string, opts ...Option) *WhitePay

New creates a new WhitePay client with the given token.

func (*WhitePay) CompleteCryptoOrder

func (wp *WhitePay) CompleteCryptoOrder(ctx context.Context, orderID string) (*CompleteCryptoOrderResponse, error)

CompleteCryptoOrder Complete Crypto Order

func (*WhitePay) CreateCryptoTopUp

func (wp *WhitePay) CreateCryptoTopUp(ctx context.Context, req *CreateCryptoTopUpRequest) (*CreateCryptoTopUpResponse, error)

CreateCryptoTopUp Create Crypto Top Up

func (*WhitePay) CreateNewFiatOrder

func (wp *WhitePay) CreateNewFiatOrder(ctx context.Context, req *CreateNewFiatOrder) (*CreateNewFiatOrderResponse, error)

CreateNewFiatOrder Create New Fiat Order

func (*WhitePay) CreateNewOrder

func (wp *WhitePay) CreateNewOrder(ctx context.Context, req *CreateNewOrderRequest) (*CreateNewOrderResponse, error)

CreateNewOrder Create New Crypto Order

func (*WhitePay) CreatePayment added in v0.0.5

func (wp *WhitePay) CreatePayment(ctx context.Context, req *CreatePaymentRequest) (*CreatePaymentResponse, error)

CreatePayment creates a payment. Deprecated: DO NOT USE THIS METHODS RIGHT NOW

func (*WhitePay) GetListCurrencies added in v0.0.5

func (wp *WhitePay) GetListCurrencies(ctx context.Context) (*ListCurrencies, error)

GetListCurrencies gets a list of currencies. Deprecated: DO NOT USE THIS METHODS RIGHT NOW

func (*WhitePay) GetWalletOrderDetail added in v0.0.5

func (wp *WhitePay) GetWalletOrderDetail(ctx context.Context, orderID string) (*WalletOrderDetailResponse, error)

GetWalletOrderDetail gets wallet order details. Deprecated: DO NOT USE THIS METHODS RIGHT NOW

func (*WhitePay) SetSlug

func (wp *WhitePay) SetSlug(slug string)

SetSlug sets the slug for the WhitePay client.

func (*WhitePay) ShowAccountBalances

func (wp *WhitePay) ShowAccountBalances(ctx context.Context) (*AccountBalancesResponse, error)

ShowAccountBalances Get Show Account Balances

func (*WhitePay) ShowCryptoOrderDetails

func (wp *WhitePay) ShowCryptoOrderDetails(ctx context.Context, orderID string) (*GetCryptoOrderDetailsResponse, error)

ShowCryptoOrderDetails Get Show Crypto Order Details

func (*WhitePay) ShowCryptoOrdersList

func (wp *WhitePay) ShowCryptoOrdersList(ctx context.Context, filters ...Filters) (*ShowCryptoOrdersListResponse, error)

ShowCryptoOrdersList Get Show Crypto Orders List

func (*WhitePay) ShowInvoiceCurrenciesForCryptoOrderCreation

func (wp *WhitePay) ShowInvoiceCurrenciesForCryptoOrderCreation(ctx context.Context) (*ShowInvoiceCurrenciesForCryptoOrderCreationResponse, error)

ShowInvoiceCurrenciesForCryptoOrderCreation Get Show Invoice Currencies For Crypto Order Creation

func (*WhitePay) ShowInvoiceCurrenciesForCryptoTopUpOrderCreation

func (wp *WhitePay) ShowInvoiceCurrenciesForCryptoTopUpOrderCreation(ctx context.Context) *ShowInvoiceCurrenciesForCryptoOrderCreationResponse

ShowInvoiceCurrenciesForCryptoTopUpOrderCreation Get Show Crypto Top Up Details

func (*WhitePay) ShowInvoiceCurrenciesForFiatOrderCreation

func (wp *WhitePay) ShowInvoiceCurrenciesForFiatOrderCreation(ctx context.Context) (*ShowInvoiceCurrenciesForFiatOrderCreationResponse, error)

ShowInvoiceCurrenciesForFiatOrderCreation Get Show Invoice Currencies For Fiat Order Creation

func (*WhitePay) ShowOrderDetails

func (wp *WhitePay) ShowOrderDetails(ctx context.Context, orderID string) (*ShowOrderDetailsResponse, error)

ShowOrderDetails Show Order Details

func (*WhitePay) ShowOrderStatusesList

func (wp *WhitePay) ShowOrderStatusesList(ctx context.Context) (*OrderStatusesListResponse, error)

ShowOrderStatusesList Get Show Statuses List

func (*WhitePay) ShowOrdersList

func (wp *WhitePay) ShowOrdersList(ctx context.Context, filters ...Filters) (*ShowOrdersListResponse, error)

ShowOrdersList Get Show Orders List

func (*WhitePay) SignOrder added in v0.0.8

func (wp *WhitePay) SignOrder(payload []byte) string

func (*WhitePay) SignTransaction added in v0.0.8

func (wp *WhitePay) SignTransaction(payload []byte) string

func (*WhitePay) Updates added in v0.0.6

func (wp *WhitePay) Updates() <-chan *Events

Updates returns a channel that can be used to receive WhitePay events.

func (*WhitePay) WebhookHandler added in v0.0.6

func (wp *WhitePay) WebhookHandler() http.HandlerFunc

WebhookHandler returns a http.HandlerFunc that can be used to handle WhitePay webhooks.

Directories

Path Synopsis
internal
api

Jump to

Keyboard shortcuts

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