package storage import ( "context" "github.com/tech/sendico/payments/storage/model" quotestorage "github.com/tech/sendico/payments/storage/quote" "go.mongodb.org/mongo-driver/v2/bson" ) type storageError string func (e storageError) Error() string { return string(e) } var ( // ErrPaymentNotFound signals that a payment record does not exist. ErrPaymentNotFound = storageError("payments.storage: payment not found") // ErrDuplicatePayment signals that idempotency constraints were violated. ErrDuplicatePayment = storageError("payments.storage: duplicate payment") // ErrRouteNotFound signals that a payment route record does not exist. ErrRouteNotFound = storageError("payments.storage: route not found") // ErrDuplicateRoute signals that a route already exists for the same transition. ErrDuplicateRoute = storageError("payments.storage: duplicate route") // ErrPlanTemplateNotFound signals that a plan template record does not exist. ErrPlanTemplateNotFound = storageError("payments.storage: plan template not found") // ErrDuplicatePlanTemplate signals that a plan template already exists for the same transition. ErrDuplicatePlanTemplate = storageError("payments.storage: duplicate plan template") ) var ( // Deprecated: use quote/storage.ErrQuoteNotFound. ErrQuoteNotFound = quotestorage.ErrQuoteNotFound // Deprecated: use quote/storage.ErrDuplicateQuote. ErrDuplicateQuote = quotestorage.ErrDuplicateQuote ) // Repository exposes persistence primitives for the payments domain. type Repository interface { Ping(ctx context.Context) error Payments() PaymentsStore Quotes() quotestorage.QuotesStore Routes() RoutesStore PlanTemplates() PlanTemplatesStore } // PaymentsStore manages payment lifecycle state. type PaymentsStore interface { Create(ctx context.Context, payment *model.Payment) error Update(ctx context.Context, payment *model.Payment) error GetByPaymentRef(ctx context.Context, paymentRef string) (*model.Payment, error) GetByIdempotencyKey(ctx context.Context, orgRef bson.ObjectID, idempotencyKey string) (*model.Payment, error) GetByChainTransferRef(ctx context.Context, transferRef string) (*model.Payment, error) List(ctx context.Context, filter *model.PaymentFilter) (*model.PaymentList, error) } // Deprecated: use quote/storage.QuotesStore. type QuotesStore = quotestorage.QuotesStore // RoutesStore manages allowed routing transitions. type RoutesStore interface { Create(ctx context.Context, route *model.PaymentRoute) error Update(ctx context.Context, route *model.PaymentRoute) error GetByID(ctx context.Context, id bson.ObjectID) (*model.PaymentRoute, error) List(ctx context.Context, filter *model.PaymentRouteFilter) (*model.PaymentRouteList, error) } // PlanTemplatesStore manages orchestration plan templates. type PlanTemplatesStore interface { Create(ctx context.Context, template *model.PaymentPlanTemplate) error Update(ctx context.Context, template *model.PaymentPlanTemplate) error GetByID(ctx context.Context, id bson.ObjectID) (*model.PaymentPlanTemplate, error) List(ctx context.Context, filter *model.PaymentPlanTemplateFilter) (*model.PaymentPlanTemplateList, error) }