51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package plan
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/shopspring/decimal"
|
|
"github.com/tech/sendico/payments/storage/model"
|
|
)
|
|
|
|
// RouteStore exposes routing definitions for plan construction.
|
|
type RouteStore interface {
|
|
List(ctx context.Context, filter *model.PaymentRouteFilter) (*model.PaymentRouteList, error)
|
|
}
|
|
|
|
// GatewayRegistry exposes gateway instances for capability-based selection.
|
|
type GatewayRegistry interface {
|
|
List(ctx context.Context) ([]*model.GatewayInstanceDescriptor, error)
|
|
}
|
|
|
|
type SendDirection = sendDirection
|
|
|
|
const (
|
|
SendDirectionAny SendDirection = sendDirectionAny
|
|
SendDirectionOut SendDirection = sendDirectionOut
|
|
SendDirectionIn SendDirection = sendDirectionIn
|
|
)
|
|
|
|
func RailFromEndpoint(endpoint model.PaymentEndpoint, attrs map[string]string, isSource bool) (model.Rail, string, error) {
|
|
return railFromEndpoint(endpoint, attrs, isSource)
|
|
}
|
|
|
|
func ResolveRouteNetwork(attrs map[string]string, sourceNetwork, destNetwork string) (string, error) {
|
|
return resolveRouteNetwork(attrs, sourceNetwork, destNetwork)
|
|
}
|
|
|
|
func SendDirectionForRail(rail model.Rail) SendDirection {
|
|
return sendDirectionForRail(rail)
|
|
}
|
|
|
|
func IsGatewayEligible(gw *model.GatewayInstanceDescriptor, rail model.Rail, network, currency string, action model.RailOperation, dir SendDirection, amount decimal.Decimal) error {
|
|
return model.IsGatewayEligible(gw, rail, network, currency, action, toGatewayDirection(sendDirection(dir)), amount)
|
|
}
|
|
|
|
func ParseRailValue(value string) model.Rail {
|
|
return parseRailValue(value)
|
|
}
|
|
|
|
func NetworkFromEndpoint(endpoint model.PaymentEndpoint) string {
|
|
return networkFromEndpoint(endpoint)
|
|
}
|