Implement yookassa client
This commit is contained in:
6
internal/models/error.go
Normal file
6
internal/models/error.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package models
|
||||
|
||||
type ErrorResp struct {
|
||||
Status int `json:"status"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
@@ -39,14 +39,69 @@ func (r *PayoutType) UnmarshalText(text []byte) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
type PayoutStatus int64
|
||||
|
||||
const (
|
||||
StatusCreated PayoutStatus = iota
|
||||
StatusCanceled
|
||||
StatusPending
|
||||
StatusSucceeded
|
||||
StatusFailed
|
||||
)
|
||||
|
||||
func (r PayoutStatus) String() string {
|
||||
switch r {
|
||||
case StatusCreated:
|
||||
return "created"
|
||||
case StatusCanceled:
|
||||
return "canceled"
|
||||
case StatusPending:
|
||||
return "pending"
|
||||
case StatusSucceeded:
|
||||
return "succeeded"
|
||||
case StatusFailed:
|
||||
return "failed"
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (r PayoutStatus) MarshalText() (text []byte, err error) {
|
||||
return []byte(r.String()), nil
|
||||
}
|
||||
|
||||
func (r *PayoutStatus) UnmarshalText(text []byte) (err error) {
|
||||
s := strings.ToLower(string(text))
|
||||
switch s {
|
||||
case "canceled":
|
||||
*r = StatusCanceled
|
||||
case "created":
|
||||
*r = StatusCreated
|
||||
case "pending":
|
||||
*r = StatusPending
|
||||
case "succeeded":
|
||||
*r = StatusSucceeded
|
||||
case "failed":
|
||||
*r = StatusFailed
|
||||
default:
|
||||
err = fmt.Errorf("invalid payment type: %s", s)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
type SBPBank struct {
|
||||
BankID string `json:"bank_id"`
|
||||
Name string `json:"name"`
|
||||
Bic string `json:"bic"`
|
||||
}
|
||||
|
||||
type PayoutReq struct {
|
||||
PayoutType PayoutType `json:"payout_type"`
|
||||
AccountNumber string `json:"account_number"`
|
||||
BankID string `json:"bank_id"`
|
||||
Amount float32 `json:"amount"`
|
||||
}
|
||||
|
||||
type PayoutResp struct {
|
||||
Result string `json:"result"`
|
||||
PayoutID string `json:"payout_id,omitempty"`
|
||||
ErrorReason string `json:"error_reason,omitempty"`
|
||||
ID string `json:"payout_id,omitempty"`
|
||||
Status PayoutStatus `json:"payout_status,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user