feat(commerce): add TransferService interface and WithTransferService option

This commit is contained in:
senke 2026-02-23 22:55:18 +01:00
parent 6a468e5ffb
commit 31833c01f1

View file

@ -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{