Implement yookassa client
This commit is contained in:
@@ -1,61 +1,9 @@
|
||||
package orm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
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 Payout struct {
|
||||
gorm.Model
|
||||
|
||||
@@ -69,6 +17,6 @@ type Payout struct {
|
||||
AccountNumber string
|
||||
Amount float32
|
||||
Currency string
|
||||
Status PayoutStatus
|
||||
Status string
|
||||
Test bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user