fixed payments access requireing organization reference #419
@@ -404,8 +404,9 @@ func filterFromProto(req *orchestratorv1.ListPaymentsRequest) *model.PaymentFilt
|
|||||||
return &model.PaymentFilter{}
|
return &model.PaymentFilter{}
|
||||||
}
|
}
|
||||||
filter := &model.PaymentFilter{
|
filter := &model.PaymentFilter{
|
||||||
SourceRef: strings.TrimSpace(req.GetSourceRef()),
|
SourceRef: strings.TrimSpace(req.GetSourceRef()),
|
||||||
DestinationRef: strings.TrimSpace(req.GetDestinationRef()),
|
DestinationRef: strings.TrimSpace(req.GetDestinationRef()),
|
||||||
|
OrganizationRef: strings.TrimSpace(req.GetOrganizationRef()),
|
||||||
}
|
}
|
||||||
if req.GetPage() != nil {
|
if req.GetPage() != nil {
|
||||||
filter.Cursor = strings.TrimSpace(req.GetPage().GetCursor())
|
filter.Cursor = strings.TrimSpace(req.GetPage().GetCursor())
|
||||||
|
|||||||
@@ -53,13 +53,11 @@ func (p *paymentExecutor) buildProviderSettlementTransferRequest(payment *model.
|
|||||||
if strings.TrimSpace(metadata[providerSettlementMetaOutgoingLeg]) == "" {
|
if strings.TrimSpace(metadata[providerSettlementMetaOutgoingLeg]) == "" {
|
||||||
metadata[providerSettlementMetaOutgoingLeg] = strings.ToLower(strings.TrimSpace(string(step.Rail)))
|
metadata[providerSettlementMetaOutgoingLeg] = strings.ToLower(strings.TrimSpace(string(step.Rail)))
|
||||||
}
|
}
|
||||||
if amount != nil {
|
if strings.TrimSpace(metadata[providerSettlementMetaSourceAmount]) == "" {
|
||||||
if strings.TrimSpace(metadata[providerSettlementMetaSourceAmount]) == "" {
|
metadata[providerSettlementMetaSourceAmount] = strings.TrimSpace(amount.Amount)
|
||||||
metadata[providerSettlementMetaSourceAmount] = strings.TrimSpace(amount.Amount)
|
}
|
||||||
}
|
if strings.TrimSpace(metadata[providerSettlementMetaSourceCurrency]) == "" {
|
||||||
if strings.TrimSpace(metadata[providerSettlementMetaSourceCurrency]) == "" {
|
metadata[providerSettlementMetaSourceCurrency] = strings.TrimSpace(amount.Currency)
|
||||||
metadata[providerSettlementMetaSourceCurrency] = strings.TrimSpace(amount.Currency)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceWalletRef := ""
|
sourceWalletRef := ""
|
||||||
|
|||||||
@@ -368,11 +368,12 @@ func (*Payment) Collection() string {
|
|||||||
|
|
||||||
// PaymentFilter enables filtered queries.
|
// PaymentFilter enables filtered queries.
|
||||||
type PaymentFilter struct {
|
type PaymentFilter struct {
|
||||||
States []PaymentState
|
States []PaymentState
|
||||||
SourceRef string
|
SourceRef string
|
||||||
DestinationRef string
|
OrganizationRef string
|
||||||
Cursor string
|
DestinationRef string
|
||||||
Limit int32
|
Cursor string
|
||||||
|
Limit int32
|
||||||
}
|
}
|
||||||
|
|
||||||
// PaymentList contains paginated results.
|
// PaymentList contains paginated results.
|
||||||
|
|||||||
@@ -200,6 +200,14 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
|
|||||||
query = query.And(endpointFilter)
|
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 ref := strings.TrimSpace(filter.DestinationRef); ref != "" {
|
||||||
if endpointFilter := endpointQuery("intent.destination", ref); endpointFilter != nil {
|
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 {
|
decoder := func(cur *mongo.Cursor) error {
|
||||||
item := &model.Payment{}
|
item := &model.Payment{}
|
||||||
if err := cur.Decode(item); err != nil {
|
if err := cur.Decode(item); err != nil {
|
||||||
|
p.logger.Warn("Failed to decode item", zap.Error(err), zap.Any("item", cur.Current))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
payments = append(payments, item)
|
payments = append(payments, item)
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ message ListPaymentsRequest {
|
|||||||
string source_ref = 3;
|
string source_ref = 3;
|
||||||
string destination_ref = 4;
|
string destination_ref = 4;
|
||||||
common.pagination.v1.CursorPageRequest page = 5;
|
common.pagination.v1.CursorPageRequest page = 5;
|
||||||
|
string organization_ref = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListPaymentsResponse {
|
message ListPaymentsResponse {
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ func (a *PaymentAPI) listPayments(r *http.Request, account *model.Account, token
|
|||||||
}
|
}
|
||||||
|
|
||||||
req := &orchestratorv1.ListPaymentsRequest{
|
req := &orchestratorv1.ListPaymentsRequest{
|
||||||
Meta: &orchestratorv1.RequestMeta{
|
OrganizationRef: orgRef.Hex(),
|
||||||
OrganizationRef: orgRef.Hex(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if page, err := listPaymentsPage(r); err != nil {
|
if page, err := listPaymentsPage(r); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user