Files
sendico/api/payments/storage/quote/storage.go
2026-02-10 18:29:47 +01:00

35 lines
1.0 KiB
Go

package storage
import (
"context"
"github.com/tech/sendico/payments/storage/model"
"go.mongodb.org/mongo-driver/v2/bson"
)
type storageError string
func (e storageError) Error() string {
return string(e)
}
var (
// ErrQuoteNotFound signals that a stored quote does not exist or expired.
ErrQuoteNotFound = storageError("payments.storage.quote: quote not found")
// ErrDuplicateQuote signals that a quote reference already exists.
ErrDuplicateQuote = storageError("payments.storage.quote: duplicate quote")
)
// Repository exposes persistence primitives for quote records.
type Repository interface {
Ping(ctx context.Context) error
Quotes() QuotesStore
}
// QuotesStore manages temporary stored payment quotes.
type QuotesStore interface {
Create(ctx context.Context, quote *model.PaymentQuoteRecord) error
GetByRef(ctx context.Context, orgRef bson.ObjectID, quoteRef string) (*model.PaymentQuoteRecord, error)
GetByIdempotencyKey(ctx context.Context, orgRef bson.ObjectID, idempotencyKey string) (*model.PaymentQuoteRecord, error)
}