52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package yookassa
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"payouts/internal/models"
|
|
"payouts/internal/service/database/orm"
|
|
"payouts/internal/service/yookassa/config"
|
|
)
|
|
|
|
type yookassaService struct {
|
|
conf config.YooKassa
|
|
ctx context.Context
|
|
}
|
|
|
|
func NewYookassaService(conf config.YooKassa) (Service, error) {
|
|
|
|
svc := &yookassaService{
|
|
conf: conf,
|
|
ctx: context.Background(),
|
|
}
|
|
return svc, nil
|
|
}
|
|
|
|
func (y *yookassaService) getParams(options ...Optional) *params {
|
|
params := ¶ms{
|
|
ctx: y.ctx,
|
|
}
|
|
for _, opt := range options {
|
|
opt(params)
|
|
}
|
|
return params
|
|
}
|
|
|
|
// CreatePayout implements [Service].
|
|
func (y *yookassaService) CreatePayout(req models.PayoutReq, userSession *orm.User, idempotenceKey string, opts ...Optional) (models.PayoutResp, error) {
|
|
// params := y.getParams(opts...)
|
|
|
|
switch req.PayoutType {
|
|
case models.TypeSBP:
|
|
case models.TypeYooMoney:
|
|
default:
|
|
return models.PayoutResp{Result: "failed", ErrorReason: "unsupported payout type"}, errors.New("unsupported payout type")
|
|
}
|
|
return models.PayoutResp{}, nil
|
|
}
|
|
|
|
// GetConfig implements [Service].
|
|
func (y *yookassaService) GetConfig() config.YooKassa {
|
|
return y.conf
|
|
}
|