enotio

package module
v0.0.0-...-01a88fc Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 11 Imported by: 0

README

Go Client для API Enot.io

Go Reference License

Go-клиент для взаимодействия с API платежной системы Enot.io. Клиент поддерживает все методы API, включая создание платежей, вывод средств, проверку баланса и другие.

Установка

Для установки пакета выполните:

go get github.com/BlaisePopov/enotio

Примеры использования

Инициализация клиента
package main

import (
    "fmt"
    "github.com/BlaisePopov/enotio"
)

func main() {
    client := enotio.NewClient(Config{
      APIKey: "test",
    })
}
Создание платежа
invoice, err := client.CreateInvoice(enot.CreateInvoiceRequest{
    Amount:   100.0,
    OrderID:  "order_123",
    Currency: enot.CurrencyRUB,
    ShopID:   "your_shop_id",
    Expire:   360, // 6 часов
})
if err != nil {
    panic(err)
}
fmt.Printf("Ссылка для оплаты: %s\n", invoice.URL)
Получение баланса
balance, err := client.GetBalance("your_user_id")
if err != nil {
    panic(err)
}
fmt.Printf("Баланс: %.2f RUB\n", balance.Balance)
Создание выплаты
payoff, err := client.CreatePayoff(enot.CreatePayoffRequest{
    UserID:   "your_user_id",
    Service:  enotio.PaymentMethodCard,
    WalletTo: "4000000000000000",
    Amount:   500.0,
})
if err != nil {
    panic(err)
}
fmt.Printf("ID выплаты: %s\n", payoff.PayoffID)

Документация API

Официальная документация Enot.io:
https://docs.enot.io

Лицензия

Этот проект распространяется под лицензией MIT. Подробности см. в файле LICENSE.

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL        = "https://api.enot.io"
	DefaultRequestTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func VerifyWebhookSignature

func VerifyWebhookSignature(body []byte, signature, secretKey string) bool

VerifyWebhookSignature проверяет сигнатуру Webhook'а.

Входные параметры:

  • body: тело Webhook'а в формате JSON.
  • signature: сигнатура из заголовка x-api-sha256-signature.
  • secretKey: секретный ключ для проверки подписи.

Возвращаемое значение: true, если сигнатура верна, иначе false.

Types

type BalanceResponse

type BalanceResponse struct {
	Balance       float64 `json:"balance"`
	ActiveBalance float64 `json:"active_balance"`
	FreezeBalance float64 `json:"freeze_balance"`
}

type Bank

type Bank struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type BaseResponse

type BaseResponse struct {
	Data        interface{} `json:"data"`
	Status      int         `json:"status"`
	StatusCheck bool        `json:"status_check"`
	Error       string      `json:"error,omitempty"`
}

type Client

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

func NewClient

func NewClient(cfg Config) *Client

func (*Client) CreateH2H

func (c *Client) CreateH2H(request CreateH2HRequest) (*H2HResponse, error)

CreateH2H создает платеж h2h. [https://docs.enot.io/e/new/create-invoice-h2h#info]

Входные параметры:

  • request: структура CreateH2HRequest.

Возвращаемое значение: структура H2HResponse и ошибка, если она возникла.

func (*Client) CreateInvoice

func (c *Client) CreateInvoice(request CreateInvoiceRequest) (*InvoiceResponse, error)

CreateInvoice создает новый инвойс. [https://docs.enot.io/e/new/create-invoice#request]

Входные параметры:

  • request: структура CreateInvoiceRequest.

Возвращаемое значение: структура InvoiceResponse и ошибка, если она возникла.

func (*Client) CreatePayoff

func (c *Client) CreatePayoff(request CreatePayoffRequest) (*PayoffResponse, error)

CreatePayoff создает заявку на вывод средств. [https://docs.enot.io/e/new/new-create-withdraw#payoff-request]

Входные параметры:

  • request: структура CreatePayoffRequest.

Возвращаемое значение: структура PayoffResponse и ошибка, если она возникла.

func (*Client) GetBalance

func (c *Client) GetBalance(userID string) (*BalanceResponse, error)

GetBalance получает баланс пользователя. [https://docs.enot.io/e/new/new-get-balance#request]

Входные параметры:

  • userID: идентификатор пользователя.

Возвращаемое значение: структура BalanceResponse и ошибка, если она возникла.

func (*Client) GetInvoiceInfo

func (c *Client) GetInvoiceInfo(request GetInvoiceInfoRequest) (*InvoiceInfoResponse, error)

GetInvoiceInfo получает информацию о платеже. [https://docs.enot.io/e/new/invoice-info-new#request]

Входные параметры:

  • request: структура GetInvoiceInfoRequest.

Возвращаемое значение: структура InvoiceInfoResponse и ошибка, если она возникла.

func (*Client) GetPaymentTariffs

func (c *Client) GetPaymentTariffs(request GetPaymentTariffsRequest) (*PaymentTariffsResponse, error)

GetPaymentTariffs получает список доступных методов оплаты. [https://docs.enot.io/e/new/payments-methods-new#request]

Входные параметры:

  • request: структура GetPaymentTariffsRequest.

Возвращаемое значение: структура PaymentTariffsResponse и ошибка, если она возникла.

func (*Client) GetPayoffInfo

func (c *Client) GetPayoffInfo(request GetPayoffInfoRequest) (*PayoffInfoResponse, error)

GetPayoffInfo получает информацию о выводе. [https://docs.enot.io/e/new/new-payment-info#get-payoff-info]

Входные параметры:

  • request: структура GetPayoffInfoRequest.

Возвращаемое значение: структура PayoffInfoResponse и ошибка, если она возникла.

func (*Client) GetSbpBankList

func (c *Client) GetSbpBankList(request GetSbpBankListRequest) (*SbpBankListResponse, error)

GetSbpBankList получает список банков для СБП. [https://docs.enot.io/e/new/get-sbp-bank-list#get-list-bank]

Входные параметры:

  • request: структура GetSbpBankListRequest.

Возвращаемое значение: структура SbpBankListResponse и ошибка, если она возникла.

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

type CreateH2HRequest

type CreateH2HRequest struct {
	InvoiceID   string      `json:"invoice_id"`
	ShopID      string      `json:"shop_id"`
	IP          string      `json:"ip"`
	UserAgent   string      `json:"user_agent"`
	PaymentData PaymentData `json:"payment_data"`
}

type CreateInvoiceRequest

type CreateInvoiceRequest struct {
	Amount         float64         `json:"amount"`
	OrderID        string          `json:"order_id"`
	Currency       Currency        `json:"currency"`
	ShopID         string          `json:"shop_id"`
	HookURL        string          `json:"hook_url,omitempty"`
	CustomFields   string          `json:"custom_fields,omitempty"`
	Comment        string          `json:"comment,omitempty"`
	FailURL        string          `json:"fail_url,omitempty"`
	SuccessURL     string          `json:"success_url,omitempty"`
	Expire         int             `json:"expire,omitempty"`
	IncludeService []PaymentMethod `json:"include_service,omitempty"`
	ExcludeService []PaymentMethod `json:"exclude_service,omitempty"`
}

type CreatePayoffRequest

type CreatePayoffRequest struct {
	UserID     string     `json:"user_id"`
	Service    string     `json:"service"`
	WalletTo   string     `json:"wallet_to"`
	Amount     float64    `json:"amount"`
	OrderID    string     `json:"order_id,omitempty"`
	Comment    string     `json:"comment,omitempty"`
	HookURL    string     `json:"hook_url,omitempty"`
	Subtract   int        `json:"subtract,omitempty"`
	PayoffData PayoffData `json:"payoff_data,omitempty"`
}

type Currency

type Currency string
const (
	CurrencyRUB        Currency = "RUB"
	CurrencyUSD        Currency = "USD"
	CurrencyEUR        Currency = "EUR"
	CurrencyUAH        Currency = "UAH"
	CurrencyKZT        Currency = "KZT"
	CurrencyBTC        Currency = "BTC"
	CurrencyLTC        Currency = "LTC"
	CurrencyUSDT_TRC20 Currency = "USDT_TRC20"
	CurrencyUSDT_ERC20 Currency = "USDT_ERC20"
	CurrencyTRX        Currency = "TRX"
	CurrencyTON        Currency = "TON"
	CurrencyDASH       Currency = "DASH"
	CurrencyETH        Currency = "ETH"
	CurrencyZCASH      Currency = "ZCASH"
	CurrencyBTC_CASH   Currency = "BTC_CASH"
)

type GetInvoiceInfoRequest

type GetInvoiceInfoRequest struct {
	ShopID    string `json:"shop_id"`
	InvoiceID string `json:"invoice_id,omitempty"`
	OrderID   string `json:"order_id,omitempty"`
}

type GetPaymentTariffsRequest

type GetPaymentTariffsRequest struct {
	ShopID string `json:"shop_id"`
}

type GetPayoffInfoRequest

type GetPayoffInfoRequest struct {
	UserID   string `json:"user_id"`
	PayoffID string `json:"id,omitempty"`
	OrderID  string `json:"order_id,omitempty"`
}

type GetSbpBankListRequest

type GetSbpBankListRequest struct {
	UserID string `json:"user_id"`
}

type H2HResponse

type H2HResponse struct {
	StepTwoType   string `json:"step_two_type"`
	Wallet        string `json:"wallet"`
	ReceiverName  string `json:"receiver_name"`
	Bank          string `json:"bank"`
	Amount        string `json:"amount"`
	TimeEnd       string `json:"time_end"`
	URL           string `json:"url"`
	Type          string `json:"type"`
	IsRedirect    bool   `json:"is_redirect"`
	Fingerprint   bool   `json:"fingerprint"`
	IsNeedGetInfo bool   `json:"is_need_get_info"`
}

type InvoiceInfoResponse

type InvoiceInfoResponse struct {
	InvoiceID             string   `json:"invoice_id"`
	OrderID               string   `json:"order_id"`
	ShopID                string   `json:"shop_id"`
	Status                string   `json:"status"`
	InvoiceAmount         float64  `json:"invoice_amount"`
	Credited              *float64 `json:"credited"`
	Currency              string   `json:"currency"`
	PayService            *string  `json:"pay_service"`
	PayerDetails          *string  `json:"payer_details"`
	CommissionAmount      float64  `json:"commission_amount"`
	CommissionPercent     float64  `json:"commission_percent"`
	ShopCommissionAmount  float64  `json:"shop_commission_amount"`
	UserCommissionAmount  float64  `json:"user_commission_amount"`
	UserCommissionPercent float64  `json:"user_commission_percent"`
	CustomField           string   `json:"custom_field"`
	CreatedAt             string   `json:"created_at"`
	ExpiredAt             string   `json:"expired_at"`
	PaidAt                string   `json:"paid_at"`
}

type InvoiceResponse

type InvoiceResponse struct {
	ID       string `json:"id"`
	Amount   string `json:"amount"`
	Currency string `json:"currency"`
	URL      string `json:"url"`
	Expired  string `json:"expired"`
}

type PaymentData

type PaymentData struct {
	Bank string `json:"bank"`
}

type PaymentMethod

type PaymentMethod string
const (
	PaymentMethodCard         PaymentMethod = "card"
	PaymentMethodMirCard      PaymentMethod = "mir_card"
	PaymentMethodQiwi         PaymentMethod = "qiwi"
	PaymentMethodPerfectMoney PaymentMethod = "perfect_money"
	PaymentMethodYoomoney     PaymentMethod = "yoomoney"
	PaymentMethodSbp          PaymentMethod = "sbp"
	PaymentMethodZcash        PaymentMethod = "zcash"
	PaymentMethodAdvcash      PaymentMethod = "advcash"
	PaymentMethodWebmoney     PaymentMethod = "webmoney"
	PaymentMethodGooglePay    PaymentMethod = "google_pay"
	PaymentMethodApplePay     PaymentMethod = "apple_pay"
	PaymentMethodBitcoin      PaymentMethod = "bitcoin"
	PaymentMethodEthereum     PaymentMethod = "ethereum"
	PaymentMethodDash         PaymentMethod = "dash"
	PaymentMethodLitecoin     PaymentMethod = "litecoin"
	PaymentMethodUsdtTrc20    PaymentMethod = "usdt_trc20"
	PaymentMethodUsdtErc20    PaymentMethod = "usdt_erc20"
	PaymentMethodTrx          PaymentMethod = "trx"
	PaymentMethodTon          PaymentMethod = "ton"
	PaymentMethodBitcoinCash  PaymentMethod = "bitcoin_cash"
	PaymentMethodP2PCard      PaymentMethod = "p2p_card"
	PaymentMethodP2PSbp       PaymentMethod = "p2p_sbp"
)

type PaymentTariffsResponse

type PaymentTariffsResponse struct {
	Tariffs []Tariff `json:"tariffs"`
}

type PayoffData

type PayoffData struct {
	SbpBankType string `json:"sbp_bank_type,omitempty"`
}

type PayoffInfoResponse

type PayoffInfoResponse struct {
	PayoffID          string  `json:"payoff_id"`
	Status            string  `json:"status"`
	OrderID           string  `json:"order_id"`
	Service           string  `json:"service"`
	Wallet            *string `json:"wallet"`
	Type              string  `json:"type"`
	Subtract          string  `json:"subtract"`
	Amount            float64 `json:"amount"`
	AmountWithdrawRub float64 `json:"amount_withdraw_rub"`
	CommissionRub     float64 `json:"commission_rub"`
	ReceiveCurrency   string  `json:"receive_currency"`
	AmountReceive     string  `json:"amount_receive"`
	Comment           *string `json:"comment"`
	CreatedAt         string  `json:"created_at"`
	PaidAt            string  `json:"paid_at"`
	ErrorMessage      string  `json:"error_message"`
}

type PayoffResponse

type PayoffResponse struct {
	PayoffID          string `json:"payoff_id"`
	AmountWithdrawRub string `json:"amount_withdraw_rub"`
	Balance           string `json:"balance"`
}

type SbpBankListResponse

type SbpBankListResponse struct {
	Banks []Bank `json:"banks"`
}

type Tariff

type Tariff struct {
	Percent      float64 `json:"percent"`
	Fix          float64 `json:"fix"`
	MinSum       float64 `json:"min_sum"`
	MaxSum       float64 `json:"max_sum"`
	ShopPercent  float64 `json:"shop_percent"`
	UserPercent  float64 `json:"user_percent"`
	Service      string  `json:"service"`
	ServiceLabel string  `json:"service_label"`
	Currency     string  `json:"currency"`
	Status       string  `json:"status"`
}

Jump to

Keyboard shortcuts

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