payment quotation v2 + payment orchestration v2 draft
This commit is contained in:
@@ -83,7 +83,6 @@ func selectGatewayForActions(ctx context.Context, registry GatewayRegistry, rail
|
||||
network = strings.ToUpper(strings.TrimSpace(network))
|
||||
|
||||
eligible := make([]*model.GatewayInstanceDescriptor, 0)
|
||||
var lastErr error
|
||||
for _, entry := range all {
|
||||
if entry == nil || !entry.IsEnabled {
|
||||
continue
|
||||
@@ -94,7 +93,6 @@ func selectGatewayForActions(ctx context.Context, registry GatewayRegistry, rail
|
||||
ok := true
|
||||
for _, action := range actions {
|
||||
if err := isGatewayEligible(entry, rail, network, currency, action, dir, amt); err != nil {
|
||||
lastErr = err
|
||||
ok = false
|
||||
break
|
||||
}
|
||||
@@ -106,10 +104,11 @@ func selectGatewayForActions(ctx context.Context, registry GatewayRegistry, rail
|
||||
}
|
||||
|
||||
if len(eligible) == 0 {
|
||||
if lastErr != nil {
|
||||
return nil, merrors.NoData("no eligible gateway instance found: " + lastErr.Error())
|
||||
action := model.RailOperationUnspecified
|
||||
if len(actions) > 0 {
|
||||
action = actions[0]
|
||||
}
|
||||
return nil, merrors.NoData("no eligible gateway instance found")
|
||||
return nil, merrors.NoData(model.NoEligibleGatewayMessage(network, currency, action, toGatewayDirection(dir)))
|
||||
}
|
||||
sort.Slice(eligible, func(i, j int) bool {
|
||||
return eligible[i].ID < eligible[j].ID
|
||||
@@ -124,6 +123,17 @@ func selectGatewayForActions(ctx context.Context, registry GatewayRegistry, rail
|
||||
return eligible[0], nil
|
||||
}
|
||||
|
||||
func toGatewayDirection(dir plan.SendDirection) model.GatewayDirection {
|
||||
switch dir {
|
||||
case plan.SendDirectionOut:
|
||||
return model.GatewayDirectionOut
|
||||
case plan.SendDirectionIn:
|
||||
return model.GatewayDirectionIn
|
||||
default:
|
||||
return model.GatewayDirectionAny
|
||||
}
|
||||
}
|
||||
|
||||
func railActionNames(actions []model.RailOperation) []string {
|
||||
if len(actions) == 0 {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user