service backend
This commit is contained in:
37
api/payments/orchestrator/storage/storage.go
Normal file
37
api/payments/orchestrator/storage/storage.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tech/sendico/payments/orchestrator/storage/model"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type storageError string
|
||||
|
||||
func (e storageError) Error() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
var (
|
||||
// ErrPaymentNotFound signals that a payment record does not exist.
|
||||
ErrPaymentNotFound = storageError("payments.orchestrator.storage: payment not found")
|
||||
// ErrDuplicatePayment signals that idempotency constraints were violated.
|
||||
ErrDuplicatePayment = storageError("payments.orchestrator.storage: duplicate payment")
|
||||
)
|
||||
|
||||
// Repository exposes persistence primitives for the orchestrator domain.
|
||||
type Repository interface {
|
||||
Ping(ctx context.Context) error
|
||||
Payments() PaymentsStore
|
||||
}
|
||||
|
||||
// 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 primitive.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)
|
||||
}
|
||||
Reference in New Issue
Block a user