44 lines
776 B
Go
44 lines
776 B
Go
package yookassa
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.uber.org/fx"
|
|
|
|
"payouts/internal/config"
|
|
"payouts/internal/models"
|
|
"payouts/internal/service/database/orm"
|
|
yookassaConf "payouts/internal/service/yookassa/config"
|
|
)
|
|
|
|
var Module = fx.Options(
|
|
fx.Provide(New),
|
|
)
|
|
|
|
type params struct {
|
|
ctx context.Context
|
|
}
|
|
type Optional func(*params)
|
|
|
|
func WithContext(ctx context.Context) Optional {
|
|
return func(p *params) {
|
|
p.ctx = ctx
|
|
}
|
|
}
|
|
|
|
type Service interface {
|
|
GetSbpBanks(...Optional) ([]models.SBPBank, error)
|
|
CreatePayout(models.PayoutReq, *orm.User, string, ...Optional) (*models.PayoutResp, error)
|
|
GetConfig() yookassaConf.YooKassa
|
|
}
|
|
|
|
type Param struct {
|
|
fx.In
|
|
|
|
AppConfig *config.App
|
|
}
|
|
|
|
func New(p Param) (Service, error) {
|
|
return NewYookassaService(p.AppConfig.YooKassa)
|
|
}
|