fixed payments access requireing organization reference

This commit is contained in:
Stephan D
2026-02-04 21:38:19 +01:00
parent ca0e45ee5f
commit bc0fd6ab2f
6 changed files with 25 additions and 17 deletions

View File

@@ -368,11 +368,12 @@ func (*Payment) Collection() string {
// PaymentFilter enables filtered queries.
type PaymentFilter struct {
States []PaymentState
SourceRef string
DestinationRef string
Cursor string
Limit int32
States []PaymentState
SourceRef string
OrganizationRef string
DestinationRef string
Cursor string
Limit int32
}
// PaymentList contains paginated results.

View File

@@ -200,6 +200,14 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
query = query.And(endpointFilter)
}
}
if ref := strings.TrimSpace(filter.OrganizationRef); ref != "" {
orgRef, err := bson.ObjectIDFromHex(ref)
if err != nil {
p.logger.Warn("Failed to decode organization reference", zap.Error(err), zap.String("provided_org_ref", ref))
return nil, err
}
query.And(repository.OrgFilter(orgRef))
}
if ref := strings.TrimSpace(filter.DestinationRef); ref != "" {
if endpointFilter := endpointQuery("intent.destination", ref); endpointFilter != nil {
@@ -223,6 +231,7 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
decoder := func(cur *mongo.Cursor) error {
item := &model.Payment{}
if err := cur.Decode(item); err != nil {
p.logger.Warn("Failed to decode item", zap.Error(err), zap.Any("item", cur.Current))
return err
}
payments = append(payments, item)