add pluggable PayBridge and Dojo payment flow with CMS credentials

This commit is contained in:
2026-07-06 10:29:39 +01:00
parent f5ff78e60e
commit 8ecdfd8cf7
26 changed files with 1526 additions and 75 deletions
+42
View File
@@ -0,0 +1,42 @@
package paymentsvc
import (
"context"
"errors"
"sync"
)
var ErrPaymentInProgress = errors.New("payment is already in progress")
type Provider interface {
Sale(ctx context.Context, req SaleRequest) (*Result, error)
}
type Service struct {
provider Provider
mu sync.Mutex
busy bool
}
func NewService(provider Provider) *Service {
return &Service{provider: provider}
}
func (s *Service) Sale(ctx context.Context, req SaleRequest) (*Result, error) {
s.mu.Lock()
if s.busy {
s.mu.Unlock()
return nil, ErrPaymentInProgress
}
s.busy = true
s.mu.Unlock()
defer func() {
s.mu.Lock()
s.busy = false
s.mu.Unlock()
}()
return s.provider.Sale(ctx, req)
}