yookassa

package module
v0.0.0-...-d946e7f Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 8 Imported by: 0

README

Yookassa Go Client

Made for Yookassa API

WARNING!!!

This is the very early version of client. Client's interface is a subject of active changes.

Documentation

Index

Constants

View Source
const (
	StatusPending  = "pending"
	StatusWaiting  = "waiting_for_capture"
	SatusSucceeded = "succeeded"
	StatusCanceled = "canceled"
)
View Source
const (
	ConfirmationRedirect = "redirect"
	ConfirmationQR       = "qr"
	ConfirmationEmbeded  = "embedded"
	ConfirmationExternal = "external"
)
View Source
const (
	PaymentByBankCard           = "bank_card"
	PaymentByApplePay           = "apple_pay"
	PaymentByGooglePay          = "google_pay"
	PaymentByYooMoney           = "yoo_money"
	PaymentByQIWI               = "qiwi"
	PaymentByWebmoney           = "webmoney"
	PaymentBySberOnline         = "sberbank"
	PaymentBySberBusinessOnline = "b2b_sberbank"
	PaymentByAlfaClick          = "alfabank"
	PaymentByTinkoff            = "tinkoff_bank"
	PaymentByMobileBalance      = "mobile_balance"
	PaymentByCash               = "cash"
	PaymentByInstallments       = "installments"

	VATUntaxed    = "untaxed"
	VATCalculated = "calculated"
	VATMixed      = "mixed"
)
View Source
const (
	EventWaitingForCapture = "payment.waiting_for_capture"
	EventPaymentSucceeded  = "payment.succeeded"
	EventPaymentCancelled  = "payment.canceled"
	EventRefundSucceeded   = "refund.succeeded"
)

Variables

This section is empty.

Functions

func NewIdempotenceKey

func NewIdempotenceKey() (string, error)

NewIdempotenceKey generates a new V4 UUID to use as indepotency key as recommended in https://yookassa.ru/developers/using-api/basics.

func WithBaseURL

func WithBaseURL(url string) func(*Client)

func WithHTTPClient

func WithHTTPClient(client *http.Client) func(*Client)

Types

type AirlineTicketData

type AirlineTicketData struct {
	TicketNumber     string                       `json:"ticket_number,omitempty"`
	BookingReference string                       `json:"booking_reference,omitempty"`
	Passengers       []AirlineTocketPassengerData `json:"passengers,omitempty"`
	Legs             []AirlineTicketLegData       `json:"legs"`
}

type AirlineTicketLegData

type AirlineTicketLegData struct {
	DepartureAirport   string    `json:"departure_airport"`
	DepartureDate      time.Time `json:"departure_date"`
	DestinationAirport string    `json:"destination_airport"`
	CarrierCode        string    `json:"carrier_code"`
}

type AirlineTocketPassengerData

type AirlineTocketPassengerData struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

type AlfaClickPaymentDetails

type AlfaClickPaymentDetails struct {
	Login string `json:"login"`
	// contains filtered or unexported fields
}

type AlfaClickPaymentRequestData

type AlfaClickPaymentRequestData struct {
	Login string
}

func (*AlfaClickPaymentRequestData) MarshalJSON

func (p *AlfaClickPaymentRequestData) MarshalJSON() ([]byte, error)

type Amount

type Amount struct {
	Value    string
	Currency string
}

type ApplePayPaymentRequestData

type ApplePayPaymentRequestData struct {
	Token string
}

func (*ApplePayPaymentRequestData) MarshalJSON

func (p *ApplePayPaymentRequestData) MarshalJSON() ([]byte, error)

type AuthorizationDetails

type AuthorizationDetails struct {
	RRN      string `json:"rrn"`
	AuthCode string `json:"auth_code"`
}

type BankCardData

type BankCardData struct {
	Number      string `json:"number"`
	ExpiryYear  string `json:"expiry_year"`
	ExpiryMonth string `json:"expiry_month"`
	CSC         string `json:"csc,omitempty"`
	Cardholder  string `json:"cardholder,omitempty"`
}

type BankCardInfo

type BankCardInfo struct {
	First6        string `json:"first_6,omitempty"`
	Last4         string `json:"last_4"`
	ExpiryYear    string `json:"expiry_year"`
	ExpiryMonth   string `json:"expiry_month"`
	Type          string `json:"type"`
	IssuerCountry string `json:"issuer_country"`
	IssuerName    string `json:"issuer_name"`
	Source        string `json:"source"`
}

type BankCardPaymentDetails

type BankCardPaymentDetails struct {
	Card BankCardInfo `json:"card"`
}

type BankCardPaymentRequestData

type BankCardPaymentRequestData struct {
	Card BankCardData
}

func (*BankCardPaymentRequestData) MarshalJSON

func (p *BankCardPaymentRequestData) MarshalJSON() ([]byte, error)

type CancellationDetails

type CancellationDetails struct {
	Party  string `json:"party"`
	Reason string `json:"reason"`
}

type Client

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

func New

func New(id, key string, opts ...func(c *Client)) *Client

func (*Client) CreatePayment

func (c *Client) CreatePayment(k string, p *PaymentRequest) (*PaymentResponse, error)

CreatePayment sends the new payment request with specific indepotence key `k`.

func (*Client) CreatePaymentContext

func (c *Client) CreatePaymentContext(ctx context.Context, k string, p *PaymentRequest) (*PaymentResponse, error)

CreatePaymentContext sends the new payment request with specific indepotence key `k`.

func (*Client) FetchPaymentInfo

func (c *Client) FetchPaymentInfo(id string) (*PaymentResponse, error)

func (*Client) FetchPaymentInfoContext

func (c *Client) FetchPaymentInfoContext(ctx context.Context, id string) (*PaymentResponse, error)

type Confirmation

type Confirmation struct {
	Type   string `json:"type"`
	Locale string `json:"locale,omitempty"`
}

type ConfirmationInfo

type ConfirmationInfo struct {
	Type    string      `json:"type"`
	Details interface{} `json:"details,omitempty"`
}

func (*ConfirmationInfo) UnmarshalJSON

func (c *ConfirmationInfo) UnmarshalJSON(data []byte) error

type CustomerInfo

type CustomerInfo struct {
	FullName string `json:"full_name,omitempty"`
	INN      string `json:"inn,omitempty"`
	Email    string `json:"email,omitempty"`
	Phone    string `json:"phone,omitempty"`
}

type EmbededConfirmationDetails

type EmbededConfirmationDetails struct {
	Type              string `json:"type"`
	ConfirmationToken string `json:"confirmation_token"`
}

type Event

type Event struct {
	Type   string           `json:"type"`
	Name   string           `json:"event"`
	Object *PaymentResponse `json:"object"`
}

type GooglePayPaymentRequestData

type GooglePayPaymentRequestData struct {
	Token string
}

func (*GooglePayPaymentRequestData) MarshalJSON

func (p *GooglePayPaymentRequestData) MarshalJSON() ([]byte, error)

type PayerBankDetails

type PayerBankDetails struct {
	FullName   string `json:"full_name"`
	ShortName  string `json:"short_name"`
	Address    string `json:"address"`
	INN        string `json:"inn"`
	KPP        string `json:"kpp"`
	BankName   string `json:"bank_name"`
	BankBranch string `json:"bank_branch"`
	BankBIK    string `json:"bank_bik"`
	Account    string `json:"account"`
}

type PaymentError

type PaymentError struct {
	InternalError error
}

func NewPaymentError

func NewPaymentError(err error) *PaymentError

func (*PaymentError) Error

func (e *PaymentError) Error() string

func (*PaymentError) Is

func (e *PaymentError) Is(err error) bool

type PaymentMethod

type PaymentMethod struct {
	ID      string      `json:"id"`
	Type    string      `json:"type"`
	Saved   bool        `json:"saved"`
	Details interface{} `json:"details"`
}

func (*PaymentMethod) UnmarshalJSON

func (m *PaymentMethod) UnmarshalJSON(data []byte) error

type PaymentRequest

type PaymentRequest struct {
	Amount            Amount                 `json:"amount"`
	Description       string                 `json:"description,omitempty"`
	Receipt           *ReceiptRequestData    `json:"receipt,omitempty"`
	Recipient         *RecipientRequest      `json:"recipient,omitempty"`
	PaymentToken      string                 `json:"payment_token,omitempty"`
	PaymentMethodID   string                 `json:"payment_method_id,omitempty"`
	PaymentMethodData *PaymentMethod         `json:"payment_method_data,omitempty"`
	Confirmation      interface{}            `json:"confirmation"`
	SavePaymentMethod bool                   `json:"save_payment_method,omitempty"`
	Capture           bool                   `json:"capture,omitempty"`
	ClientIP          string                 `json:"client_ip,omitempty"`
	Metadata          map[string]interface{} `json:"metadata,omitempty"`
	AirlineTicket     *AirlineTicketData     `json:"airline,omitempty"`
	Transfers         []TransferRequestData  `json:"transfers,omitempty"`
}

type PaymentResponse

type PaymentResponse struct {
	ID                   string                `json:"id"`
	Status               string                `json:"status"`
	Test                 bool                  `json:"test"`
	Paid                 bool                  `json:"paid"`
	Refundable           bool                  `json:"refundable"`
	Amount               Amount                `json:"amount"`
	IncomeAmount         *Amount               `json:"income_amount,omitempty"`
	RefundedAmount       *Amount               `json:"refunded_amount,omitempty"`
	Created              time.Time             `json:"created_at"`
	Captured             time.Time             `json:"captured_at"`
	Expires              time.Time             `json:"expires_at"`
	Description          string                `json:"description"`
	Recipient            Recipient             `json:"recipient"`
	PaymentMethod        PaymentMethod         `json:"payment_method"`
	ReceiptRegistration  string                `json:"receipt_registration,omitempty"`
	AuthorizationDetails *AuthorizationDetails `json:"authorization_details,omitempty"`
	CancellationDetails  *CancellationDetails  `json:"cancellation_details,omitempty"`
	Confirmation         ConfirmationInfo      `json:"confirmation"`
	Transfers            []TransferDetails     `json:"transfers,omitempty"`

	// Max 16 keys
	// Max key name length 32
	// Max key value length 512
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

type PhoneNumberPaymentRequestData

type PhoneNumberPaymentRequestData struct {
	Type  string `json:"type"`
	Phone string `json:"phone"`
}

type QRCodeConfirmationDetails

type QRCodeConfirmationDetails struct {
	Type             string `json:"type"`
	ConfirmationData string `json:"confirmation_data"`
}

type ReceiptRequestData

type ReceiptRequestData struct {
	Customer CustomerInfo `json:"customer"`
}

type Recipient

type Recipient struct {
	AccountID string `json:"account_id"`
	GatewayID string `json:"gateway_id"`
}

type RecipientRequest

type RecipientRequest struct {
	GatewayID string `json:"gateway_id"`
}

type RedirectConfirmation

type RedirectConfirmation struct {
	ReturnURL string `json:"return_url"`
	Locale    string `json:"locale,omitempty"`
	Enforce   bool   `json:"enforce,omitempty"`
}

func (*RedirectConfirmation) MarshalJSON

func (c *RedirectConfirmation) MarshalJSON() ([]byte, error)

type RedirectConfirmationDetails

type RedirectConfirmationDetails struct {
	Type            string `json:"type"`
	Enforce         bool   `json:"enforce"`
	ConfirmationURL string `json:"confirmation_url"`
	ReturnURL       string `json:"return_url"`
}

type SberBusinessOnlinePaymentDetails

type SberBusinessOnlinePaymentDetails struct {
	PaymentPurpose   string           `json:"payment_purpose"` // Max 210 symbols
	PayerBankDetails PayerBankDetails `json:"payer_bank_details"`
}

type SberBusinessOnlinePaymentRequestDate

type SberBusinessOnlinePaymentRequestDate struct {
	PaymentPurpose string
	VATData        VATData
}

func (*SberBusinessOnlinePaymentRequestDate) MarshalJSON

func (p *SberBusinessOnlinePaymentRequestDate) MarshalJSON() ([]byte, error)

type SberOnlinePaymentDetails

type SberOnlinePaymentDetails struct {
	Phone string `json:"phone"`
}

type SimplePaymentRequestData

type SimplePaymentRequestData struct {
	Type string `json:"type"`
}

type TransferDetails

type TransferDetails struct {
	AccountID         string `json:"account_id"`
	Status            string `json:"status"`
	Amount            Amount `json:"amount"`
	PlatformFeeAmount Amount `json:"platform_fee_amount"`
}

type TransferRequestData

type TransferRequestData struct {
	AccountID         string `json:"account_id"`
	Amount            Amount `json:"amount"`
	PlatformFeeAmount Amount `json:"platform_fee_amount"`
}

type VATData

type VATData struct {
	Type   string `json:"type"`
	Amount Amount `json:"amount"`
	Rate   string `json:"rate"`
}

type YooMoneyPaymentDetails

type YooMoneyPaymentDetails struct {
	AccountNumber string `json:"account_number"`
}

Jump to

Keyboard shortcuts

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