payment quotation v2 + payment orchestration v2 draft

This commit is contained in:
Stephan D
2026-02-24 13:01:35 +01:00
parent 0646f55189
commit 6444813f38
289 changed files with 17005 additions and 16065 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/tech/sendico/pkg/mlogger"
"github.com/tech/sendico/pkg/mservice"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
)
// Store implements storage.Repository backed by MongoDB.
@@ -23,6 +24,7 @@ type Store struct {
logger mlogger.Logger
ping func(context.Context) error
database *mongo.Database
payments storage.PaymentsStore
methods storage.PaymentMethodsStore
quotes quotestorage.QuotesStore
@@ -71,17 +73,18 @@ func New(logger mlogger.Logger, conn *db.MongoConnection, opts ...Option) (*Stor
plansRepo := repository.CreateMongoRepository(conn.Database(), (&model.PaymentPlanTemplate{}).Collection())
methodsRepo := repository.CreateMongoRepository(conn.Database(), mservice.PaymentMethods)
return newWithRepository(logger, conn.Ping, paymentsRepo, methodsRepo, quotesRepo, routesRepo, plansRepo, opts...)
return newWithRepository(logger, conn.Ping, conn.Database(), paymentsRepo, methodsRepo, quotesRepo, routesRepo, plansRepo, opts...)
}
// NewWithRepository constructs a payments repository using the provided primitives.
func NewWithRepository(logger mlogger.Logger, ping func(context.Context) error, paymentsRepo repository.Repository, quotesRepo repository.Repository, routesRepo repository.Repository, plansRepo repository.Repository, opts ...Option) (*Store, error) {
return newWithRepository(logger, ping, paymentsRepo, nil, quotesRepo, routesRepo, plansRepo, opts...)
return newWithRepository(logger, ping, nil, paymentsRepo, nil, quotesRepo, routesRepo, plansRepo, opts...)
}
func newWithRepository(
logger mlogger.Logger,
ping func(context.Context) error,
database *mongo.Database,
paymentsRepo, methodsRepo, quotesRepo, routesRepo, plansRepo repository.Repository,
opts ...Option,
) (*Store, error) {
@@ -147,6 +150,7 @@ func newWithRepository(
result := &Store{
logger: childLogger,
ping: ping,
database: database,
payments: paymentsStore,
methods: methodsStore,
quotes: quotesRepoStore.Quotes(),
@@ -190,4 +194,12 @@ func (s *Store) PlanTemplates() storage.PlanTemplatesStore {
return s.plans
}
// MongoDatabase returns underlying Mongo database when available.
func (s *Store) MongoDatabase() *mongo.Database {
if s == nil {
return nil
}
return s.database
}
var _ storage.Repository = (*Store)(nil)