cryptonator

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// US dollar (USD) - "usd"
	InvoiceCurrencyUSDollar = InvoiceCurrency(CurrencyUSDollar)
	// Euro (EUR) - "eur"
	InvoiceCurrencyEuro = InvoiceCurrency(CurrencyEuro)
	// Russian ruble (RUB) - "rur"
	InvoiceCurrencyRURuble = InvoiceCurrency(CurrencyRURuble)

	// Bitcoin (BTC) - "bitcoin"
	InvoiceCurrencyBitcoin = InvoiceCurrency(CurrencyBitcoin)
	// Bitcoin Cash (BCH) - "bitcoincash"
	InvoiceCurrencyBitcoinCash = InvoiceCurrency(CurrencyBitcoinCash)
	// Dash (DASH) - "dash"
	InvoiceCurrencyDash = InvoiceCurrency(CurrencyDash)
	// Dogecoin (DOGE) - "dogecoin"
	InvoiceCurrencyDogecoin = InvoiceCurrency(CurrencyDogecoin)
	// Ethereum (ETH) - "ethereum"
	InvoiceCurrencyEthereum = InvoiceCurrency(CurrencyEthereum)
	// Litecoin (LTC) - "litecoin"
	InvoiceCurrencyLitecoin = InvoiceCurrency(CurrencyLitecoin)
	// Monero (XMR) - "monero"
	InvoiceCurrencyMonero = InvoiceCurrency(CurrencyMonero)
	// Ripple (XRP) - "ripple"
	InvoiceCurrencyRipple = InvoiceCurrency(CurrencyRipple)
	// TetherUS (USDT) - "usdt"
	InvoiceCurrencyTetherUS = InvoiceCurrency(CurrencyTetherUS)
	// Zcash (ZEC) - "zcash"
	InvoiceCurrencyZcash = InvoiceCurrency(CurrencyZcash)
)
View Source
const (
	// Bitcoin (BTC) - "bitcoin"
	CheckoutCurrencyBitcoin = CheckoutCurrency(CurrencyBitcoin)
	// Bitcoin Cash (BCH) - "bitcoincash"
	CheckoutCurrencyBitcoinCash = CheckoutCurrency(CurrencyBitcoinCash)
	// Dash (DASH) - "dash"
	CheckoutCurrencyDash = CheckoutCurrency(CurrencyDash)
	// Dogecoin (DOGE) - "dogecoin"
	CheckoutCurrencyDogecoin = CheckoutCurrency(CurrencyDogecoin)
	// Ethereum (ETH) - "ethereum"
	CheckoutCurrencyEthereum = CheckoutCurrency(CurrencyEthereum)
	// Litecoin (LTC) - "litecoin"
	CheckoutCurrencyLitecoin = CheckoutCurrency(CurrencyLitecoin)
	// Monero (XMR) - "monero"
	CheckoutCurrencyMonero = CheckoutCurrency(CurrencyMonero)
	// Ripple (XRP) - "ripple"
	CheckoutCurrencyRipple = CheckoutCurrency(CurrencyRipple)
	// TetherUS (USDT) - "usdt"
	CheckoutCurrencyTetherUS = CheckoutCurrency(CurrencyTetherUS)
	// Zcash (ZEC) - "zcash"
	CheckoutCurrencyZcash = CheckoutCurrency(CurrencyZcash)
)
View Source
const (
	// Minimum acceptable amount by Cryptonator in Bitcoin (BTC)
	MinimumPaymentAmountBitcoin float64 = 0.0001
	// Minimum acceptable amount by Cryptonator in Bitcoin Cash (BCH)
	MinimumPaymentAmountBitcoinCash float64 = 0.0001
	// Minimum acceptable amount by Cryptonator in Dash (DASH)
	MinimumPaymentAmountDash float64 = 0.001
	// Minimum acceptable amount by Cryptonator in Dogecoin (DOGE)
	MinimumPaymentAmountDogecoin float64 = 10
	// Minimum acceptable amount by Cryptonator in Ethereum (ETH)
	MinimumPaymentAmountEthereum float64 = 0.001
	// Minimum acceptable amount by Cryptonator in Litecoin (LTC)
	MinimumPaymentAmountLitecoin float64 = 0.001
	// Minimum acceptable amount by Cryptonator in Monero (XMR)
	MinimumPaymentAmountMonero float64 = 0.001
	// Minimum acceptable amount by Cryptonator in Ripple (XRP)
	MinimumPaymentAmountRipple float64 = 1
	// Minimum acceptable amount by Cryptonator in TetherUS (USDT)
	MinimumPaymentAmountTetherUS float64 = 10
	// Minimum acceptable amount by Cryptonator in Zcash (ZEC)
	MinimumPaymentAmountZcash float64 = 0.0001

	// Minimum acceptable amount by Cryptonator in US Dollar (equivalent)
	MinimumPaymentAmountUSDollar float64 = 1.0
	// Minimum acceptable amount by Cryptonator in Euro (equivalent)
	MinimumPaymentAmountEuro float64 = 1.0
	// Minimum acceptable amount by Cryptonator in Russian Ruble (equivalent)
	MinimumPaymentAmountRURuble float64 = 10.0
)

Minimum acceptable amounts of cryptocurrencies by Cryptonator. Minimum invoce amounts of EUR, USD, and RUR can be calculated by multiplying price of single unit of checkout cryptocurrency in needed fiat on minum payement amount of checkout cryptocurrency (below).

https://rf.cryptonator.com/fees https://cryptonator.zendesk.com/hc/en-us/articles/203324122-Is-there-an-incoming-transaction-minimum-

Variables

View Source
var ErrCryptonatorAPIErr = errors.New("cryptonator api error")

Functions

func GetMinimumInvoiceAmountsInFiat

func GetMinimumInvoiceAmountsInFiat() (map[CheckoutCurrency]map[InvoiceCurrency]float64, error)

Returns minimum fiat (usd, eur, rub) invoice amounts for each supported cryptocurrency

Types

type CheckoutCurrency

type CheckoutCurrency Currency

Cryptonator checkout currency

type CreateInvoiceOptions

type CreateInvoiceOptions struct {
	// orderID - order ID for your accounting purposes.
	OrderID string `url:"order_id,omitempty"`
	// Name of an item or service. (REQUIRED)
	ItemName string `url:"item_name"`
	// Description of an item or service.
	ItemDescription string `url:"item_name,omitempty"`
	// Invoice currency. (REQUIRED)
	InvoiceCurrency InvoiceCurrency `url:"invoice_currency"`
	// InvoiceAmount - invoice amount. (REQUIRED)
	InvoiceAmount float64 `url:"invoice_amount"`
	// CheckoutCurrency - checkout currency. (REQUIRED)
	CheckoutCurrency CheckoutCurrency `url:"checkout_currency"`
	// An URL to which users will be redirected after a successful payment. If undefined, default setting is used.
	SuccessURL string `url:"success_url,omitempty"`
	// An URL to which users will be redirected after a cancelled or failed payment. If undefined, default setting is used.
	FailedURL string `url:"failed_url,omitempty"`
	// Language of the checkout page. If empty, English is used by default.
	Language Language `url:"language,omitempty"`
}

type CreateInvoiceReponseData

type CreateInvoiceReponseData struct {
	// Invoice ID
	InvoiceID string `json:"invoice_id"`
	// URL of the hosted payment page
	InvoiceURL string `json:"invoice_url"`
	// Creation timestamp UTC
	InvoiceCreated int64 `json:"invoice_created"`
	// Expiration timestamp UTC
	InvoiceExpires int64 `json:"invoice_expires"`
	// Checkout cryptocurrency
	CheckoutCurrency CheckoutCurrency `json:"checkout_currency"`
	// Amount due in cryptocurrency
	CheckoutAmount float64 `json:"checkout_amount"`
	// Cryptocurrency payment address
	CheckoutAddress string `json:"checkout_address"`

	// Internal field for api errors checking (DON NOT CHECK, IT IS CHECKED BY THE LIBRARY)
	Error string `json:"error"`
}

type Currency

type Currency string
const (
	// US dollar (USD) - "usd"
	CurrencyUSDollar Currency = "usd"
	// Euro (EUR) - "eur"
	CurrencyEuro Currency = "eur"
	// Russian ruble (RUB) - "rur"
	CurrencyRURuble Currency = "rur"

	// Bitcoin (BTC) - "bitcoin"
	CurrencyBitcoin Currency = "bitcoin"
	// Bitcoin Cash (BCH) - "bitcoincash"
	CurrencyBitcoinCash Currency = "bitcoincash"
	// Dash (DASH) - "dash"
	CurrencyDash Currency = "dash"
	// Dogecoin (DOGE) - "dogecoin"
	CurrencyDogecoin Currency = "dogecoin"
	// Ethereum (ETH) - "ethereum"
	CurrencyEthereum Currency = "ethereum"
	// Litecoin (LTC) - "litecoin"
	CurrencyLitecoin Currency = "litecoin"
	// Monero (XMR) - "monero"
	CurrencyMonero Currency = "monero"
	// Ripple (XRP) - "ripple"
	CurrencyRipple Currency = "ripple"
	// TetherUS (USDT) - "usdt"
	CurrencyTetherUS Currency = "usdt"
	// Zcash (ZEC) - "zcash"
	CurrencyZcash Currency = "zcash"
)

type GetInvoiceResponseData

type GetInvoiceResponseData struct {
	// Your ID for this order
	OrderID string `json:"order_id"`
	// Invoice status
	InvoiceStatus InvoiceStatus `json:"status"`
	// Invoice currency
	InvoiceCurrency InvoiceCurrency `json:"currency"`
	// Invoice amount. API returns string, but it can always be parsed as float64 without errors.
	InvoiceAmount string `json:"amount"`

	// Internal field for api errors checking (DON NOT CHECK, IT IS CHECKED BY THE LIBRARY)
	Error string `json:"error"`
}

type InvoiceCurrency

type InvoiceCurrency Currency

Cryptonator invoice currency

type InvoiceStatus

type InvoiceStatus string

Cryptonator invoice status

const (
	// Unpaid - "unpaid"
	InvoiceStatusUnpaid InvoiceStatus = "unpaid"
	// Confirming - "confirming"
	InvoiceStatusConfirming InvoiceStatus = "confirming"
	// Paid - "paid". Final.
	InvoiceStatusPaid InvoiceStatus = "paid"
	// Cancelled - "cancelled". Final.
	InvoiceStatusCancelled InvoiceStatus = "cancelled"
	// Mispaid - "mispaid". Final.
	InvoiceStatusMispaid InvoiceStatus = "mispaid"
)

type Language

type Language string

Cryptonator display language

const (
	// English - "en"
	LanguageEnglish Language = "en"
	// German - "de"
	LanguageGerman Language = "de"
	// Spanish - "es"
	LanguageSpanish Language = "es"
	// French - "fr"
	LanguageFrench Language = "fr"
	// Russian - "ru"
	LanguageRussian Language = "ru"
	// Chinese - "cn"
	LanguageChinese Language = "cn"
)

type ListInvoicesResponseData

type ListInvoicesResponseData struct {
	// Count of invoices in InvoiceList
	InvoiceCount int `json:"invoice_count"`
	// Invoice ID list
	InvoiceList []string `json:"invoice_list"`

	// Internal field for api errors checking (DON NOT CHECK, IT IS CHECKED BY LIBRARY)
	Error string `json:"error"`
}

type MerchantAPI

type MerchantAPI struct {
	// Your merchant ID.
	ID string
	// Your merchant secret.
	Secret string
	// net/http client to be used to perform api requests.
	HttpClient *http.Client
}

Cryptonator API instance

func NewMerchantAPI

func NewMerchantAPI(merchantID string, merchantSecret string) *MerchantAPI

A wrapper for API instancing

merchantID - your merchant ID. (REQUIRED) secret - your merchant secret. (REQUIRED)

func (*MerchantAPI) CreateInvoice

func (mapi *MerchantAPI) CreateInvoice(options *CreateInvoiceOptions) (*CreateInvoiceReponseData, error)

Create new invoice with a predefined checkout currency.

Users cannot choose different payment method from checkoutCurrency argument.

A successful request will create a hosted checkout page https://www.cryptonator.com/merchant/invoice/<invoice_id> and an HTTP-notification with all the invoice parameters will be sent to the provided callback URL.

See required values for CreateInvoiceOptions in it's commentaries.

func (*MerchantAPI) GetInvoice

func (mapi *MerchantAPI) GetInvoice(invoiceID string) (*GetInvoiceResponseData, error)

Get information and status of an invoice.

invoiceID - Invoice ID. Can't be empty.

func (*MerchantAPI) ListInvoices

func (mapi *MerchantAPI) ListInvoices(invoiceStatus InvoiceStatus, invoiceCurrency InvoiceCurrency, checkoutCurrency CheckoutCurrency) (*ListInvoicesResponseData, error)

Get a list of all your invoices filtered by given parameters.

invoiceStatus - invoice status filter. Use empty string to not use the filter. invoiceCurrency - invoice currency filter. Use empty string to not use the filter. checkoutCurrency - checkout currency filter. Use empty string to not use the filter.

Jump to

Keyboard shortcuts

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