funpay

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-funpay-api

Клиент на Go для продавца funpay.com. Это не платёжный сервис с funpay.readme.io и не бот.

go get github.com/Zoomish/go-funpay-api

Нужен Go 1.26.

golden_key — секрет сессии. Библиотека не пишет его в текст ошибок.

Сейчас в пакете каркас: funpay.New, сборка URL, транспорт и ошибки. Методов площадки ещё нет.

c, err := funpay.New(funpay.Options{
    GoldenKey: key,
    UserAgent: "MyService/1.0",
    Locale:    funpay.LocaleRU,
})

Прокси и таймаут задаются своим http.Client в Options.HTTPClient.

Documentation

Overview

Пакет funpay — HTTP-клиент продавца funpay.com.

Вызовите New с Options: обязательны GoldenKey и UserAgent. DefaultBaseURL используется, если BaseURL пуст. Локаль по умолчанию LocaleRU. Для LocaleEN и LocaleUK префикс локали добавляется к путям страниц и не добавляется к путям /api/ и /runner/. Локаль и BaseURL после New не меняются.

Деньги — тип Money. Minor хранит сотые доли единицы валюты, без float64.

Ответ 403 — ErrForbidden. Уход на /account/login — ErrUnauthenticated. Ответ 429 повторяется с экспоненциальной паузой не длиннее 30 секунд, затем возвращается RateLimitedError (ErrRateLimited). JSON-объект с полем error или errors при HTTP 200 — APIError.

golden_key не попадает в текст ошибок.

Index

Constants

View Source
const (
	DefaultBaseURL = "https://funpay.com"
)

Variables

View Source
var (
	ErrGoldenKeyRequired = errors.New("funpay: golden key is required")
	ErrUserAgentRequired = errors.New("funpay: user agent is required")
	ErrLocale            = errors.New("funpay: unsupported locale")
	ErrBaseURL           = errors.New("funpay: base url")

	ErrUnauthenticated = errors.New("funpay: unauthenticated")
	ErrForbidden       = errors.New("funpay: forbidden")
	ErrRateLimited     = errors.New("funpay: rate limited")
	ErrParse           = errors.New("funpay: parse")
	ErrBodyTooLarge    = errors.New("funpay: response body exceeds 8MiB")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status  int
	Code    string
	Message string
}

APIError — JSON-объект с полем error или errors при HTTP 200.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client ходит на funpay.com от имени одного продавца. BaseURL, локаль, User-Agent и golden_key после New не меняются.

func New

func New(opts Options) (*Client, error)

New проверяет опции и кладёт golden_key в cookie jar клиента. Переданный HTTPClient сохраняется. Jar создаётся только если его ещё нет. Уже существующий jar не заменяется: в него добавляется cookie golden_key.

type Locale

type Locale string

Locale — язык страниц funpay.com.

const (
	LocaleRU Locale = "ru"
	LocaleEN Locale = "en"
	LocaleUK Locale = "uk"
)

type Money

type Money struct {
	Minor    int64
	Currency string
}

Money — сумма в младших единицах валюты. Minor равен числу сотых: 1 250,50 ₽ это Minor 125050 и Currency "RUB".

type Options

type Options struct {
	HTTPClient *http.Client
	BaseURL    string
	GoldenKey  string
	UserAgent  string
	Locale     Locale

	// MaxRetries — сколько раз повторить запрос после 429.
	// nil означает 2. Указатель на 0 отключает повтор.
	MaxRetries *int

	RetryBackoffMin time.Duration
	RetryBackoffMax time.Duration
}

Options задаёт клиент. GoldenKey и UserAgent обязательны. Ноль в длительностях паузы означает значение по умолчанию: 1s и 30s. Потолок паузы 30s действует даже если RetryBackoffMax больше.

type RateLimitedError

type RateLimitedError struct {
	RetryAfter time.Duration
}

RateLimitedError возвращается, когда повтор после 429 исчерпан или отключён. Unwrap даёт ErrRateLimited.

func (*RateLimitedError) Error

func (e *RateLimitedError) Error() string

func (*RateLimitedError) Unwrap

func (e *RateLimitedError) Unwrap() error

type StatusError

type StatusError struct {
	Status int
}

StatusError — ответ не 2xx, который не сведён к 403, 429 или уходу на логин.

func (*StatusError) Error

func (e *StatusError) Error() string

func (*StatusError) Is

func (e *StatusError) Is(target error) bool

Jump to

Keyboard shortcuts

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