72 lines
2.2 KiB
Go
72 lines
2.2 KiB
Go
package yookassa
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"payouts/internal/models"
|
|
)
|
|
|
|
type SBPBankResponse struct {
|
|
Type string `json:"type"`
|
|
Items []models.SBPBank `json:"items"`
|
|
}
|
|
|
|
type Amount struct {
|
|
Value string `json:"value"`
|
|
Currency string `json:"currency"`
|
|
}
|
|
|
|
type Card struct {
|
|
Number string `json:"number"`
|
|
First6 string `json:"first6"`
|
|
Last4 string `json:"last4"`
|
|
CardType string `json:"card_type"`
|
|
IssuerCountry string `json:"issuer_country"`
|
|
IssuerName string `json:"issuer_name"`
|
|
}
|
|
|
|
type PayoutDestination struct {
|
|
Type models.PayoutType `json:"type"`
|
|
AccountNumber string `json:"account_number"`
|
|
Phone string `json:"phone"`
|
|
BankID string `json:"bank_id"`
|
|
RecipientChecked bool `json:"recipient_checked,omitempty"`
|
|
Card Card `json:"card,omitzero"`
|
|
}
|
|
|
|
type Metadata map[string]any
|
|
|
|
type PayoutRequest struct {
|
|
Amount Amount `json:"amount"`
|
|
PayoutDestinationData PayoutDestination `json:"payout_destination_data"`
|
|
Description string `json:"description"`
|
|
Metadata Metadata `json:"metadata"`
|
|
Test bool `json:"test"`
|
|
}
|
|
|
|
type PayoutResponse struct {
|
|
ID string `json:"id"`
|
|
Status models.PayoutStatus `json:"status"`
|
|
Amount Amount `json:"amount"`
|
|
PayoutDestination PayoutDestination `json:"payout_destination"`
|
|
Description string `json:"description"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
SucceededAt time.Time `json:"succeeded_at"`
|
|
Metadata Metadata `json:"metadata"`
|
|
Test bool `json:"test"`
|
|
}
|
|
|
|
type Error struct {
|
|
Type string `json:"type"`
|
|
ID string `json:"id"`
|
|
Description string `json:"description"`
|
|
Parameter string `json:"parameter"`
|
|
Code string `json:"code"`
|
|
Status int `json:"status"`
|
|
}
|
|
|
|
func (e *Error) Error() string {
|
|
return fmt.Sprintf("yookassa error. status %d (%s). %s %s", e.Status, e.Code, e.Description, e.Parameter)
|
|
}
|