feat(commerce): add TransferService interface and WithTransferService option
This commit is contained in:
parent
6a468e5ffb
commit
31833c01f1
1 changed files with 15 additions and 0 deletions
|
|
@ -136,6 +136,11 @@ type SellerSale struct {
|
|||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
// TransferService abstracts the payout transfer provider (v0.603)
|
||||
type TransferService interface {
|
||||
CreateTransfer(ctx context.Context, sellerUserID uuid.UUID, amount int64, currency, orderID string) error
|
||||
}
|
||||
|
||||
// Service implémente MarketplaceService
|
||||
type Service struct {
|
||||
db *gorm.DB
|
||||
|
|
@ -144,6 +149,8 @@ type Service struct {
|
|||
paymentProvider PaymentProvider
|
||||
hyperswitchEnabled bool
|
||||
checkoutSuccessURL string
|
||||
transferService TransferService
|
||||
platformFeeRate float64
|
||||
}
|
||||
|
||||
// ServiceOption configures the marketplace Service.
|
||||
|
|
@ -162,6 +169,14 @@ func WithHyperswitchConfig(enabled bool, checkoutSuccessURL string) ServiceOptio
|
|||
}
|
||||
}
|
||||
|
||||
// WithTransferService injects the payout transfer service and platform fee rate (v0.603)
|
||||
func WithTransferService(ts TransferService, feeRate float64) ServiceOption {
|
||||
return func(s *Service) {
|
||||
s.transferService = ts
|
||||
s.platformFeeRate = feeRate
|
||||
}
|
||||
}
|
||||
|
||||
// NewService creates a new Marketplace service instance
|
||||
func NewService(db *gorm.DB, logger *zap.Logger, storage StorageService, opts ...ServiceOption) *Service {
|
||||
s := &Service{
|
||||
|
|
|
|||
Loading…
Reference in a new issue