fixed rail & operation names
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package plan
|
||||
|
||||
import (
|
||||
"github.com/tech/sendico/pkg/discovery"
|
||||
"strings"
|
||||
|
||||
"github.com/tech/sendico/payments/storage/model"
|
||||
@@ -9,24 +10,24 @@ import (
|
||||
|
||||
func railFromEndpoint(endpoint model.PaymentEndpoint, attrs map[string]string, isSource bool) (model.Rail, string, error) {
|
||||
override := railOverrideFromAttributes(attrs, isSource)
|
||||
if override != model.RailUnspecified {
|
||||
if override != discovery.RailUnspecified {
|
||||
return override, networkFromEndpoint(endpoint), nil
|
||||
}
|
||||
switch endpoint.Type {
|
||||
case model.EndpointTypeLedger:
|
||||
return model.RailLedger, "", nil
|
||||
return discovery.RailLedger, "", nil
|
||||
case model.EndpointTypeManagedWallet, model.EndpointTypeExternalChain:
|
||||
return model.RailCrypto, networkFromEndpoint(endpoint), nil
|
||||
return discovery.RailCrypto, networkFromEndpoint(endpoint), nil
|
||||
case model.EndpointTypeCard:
|
||||
return model.RailCardPayout, "", nil
|
||||
return discovery.RailCardPayout, "", nil
|
||||
default:
|
||||
return model.RailUnspecified, "", merrors.InvalidArgument("plan builder: unsupported payment endpoint")
|
||||
return discovery.RailUnspecified, "", merrors.InvalidArgument("plan builder: unsupported payment endpoint")
|
||||
}
|
||||
}
|
||||
|
||||
func railOverrideFromAttributes(attrs map[string]string, isSource bool) model.Rail {
|
||||
if len(attrs) == 0 {
|
||||
return model.RailUnspecified
|
||||
return discovery.RailUnspecified
|
||||
}
|
||||
keys := []string{"source_rail", "sourceRail"}
|
||||
if !isSource {
|
||||
@@ -41,45 +42,45 @@ func railOverrideFromAttributes(attrs map[string]string, isSource bool) model.Ra
|
||||
continue
|
||||
}
|
||||
rail := parseRailValue(value)
|
||||
if rail != model.RailUnspecified {
|
||||
if rail != discovery.RailUnspecified {
|
||||
return rail
|
||||
}
|
||||
}
|
||||
return model.RailUnspecified
|
||||
return discovery.RailUnspecified
|
||||
}
|
||||
|
||||
func parseRailValue(value string) model.Rail {
|
||||
val := strings.ToUpper(strings.TrimSpace(value))
|
||||
switch val {
|
||||
case string(model.RailCrypto):
|
||||
return model.RailCrypto
|
||||
case string(model.RailProviderSettlement):
|
||||
return model.RailProviderSettlement
|
||||
case string(model.RailLedger):
|
||||
return model.RailLedger
|
||||
case string(model.RailCardPayout):
|
||||
return model.RailCardPayout
|
||||
case string(model.RailFiatOnRamp):
|
||||
return model.RailFiatOnRamp
|
||||
case string(discovery.RailCrypto):
|
||||
return discovery.RailCrypto
|
||||
case string(discovery.RailProviderSettlement):
|
||||
return discovery.RailProviderSettlement
|
||||
case string(discovery.RailLedger):
|
||||
return discovery.RailLedger
|
||||
case string(discovery.RailCardPayout):
|
||||
return discovery.RailCardPayout
|
||||
case string(discovery.RailFiatOnRamp):
|
||||
return discovery.RailFiatOnRamp
|
||||
default:
|
||||
return model.RailUnspecified
|
||||
return discovery.RailUnspecified
|
||||
}
|
||||
}
|
||||
|
||||
func gatewayNetworkForRail(rail model.Rail, sourceRail, destRail model.Rail, sourceNetwork, destNetwork string) string {
|
||||
switch rail {
|
||||
case model.RailCrypto:
|
||||
if sourceRail == model.RailCrypto {
|
||||
case discovery.RailCrypto:
|
||||
if sourceRail == discovery.RailCrypto {
|
||||
return strings.ToUpper(strings.TrimSpace(sourceNetwork))
|
||||
}
|
||||
if destRail == model.RailCrypto {
|
||||
if destRail == discovery.RailCrypto {
|
||||
return strings.ToUpper(strings.TrimSpace(destNetwork))
|
||||
}
|
||||
case model.RailFiatOnRamp:
|
||||
if sourceRail == model.RailFiatOnRamp {
|
||||
case discovery.RailFiatOnRamp:
|
||||
if sourceRail == discovery.RailFiatOnRamp {
|
||||
return strings.ToUpper(strings.TrimSpace(sourceNetwork))
|
||||
}
|
||||
if destRail == model.RailFiatOnRamp {
|
||||
if destRail == discovery.RailFiatOnRamp {
|
||||
return strings.ToUpper(strings.TrimSpace(destNetwork))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package plan
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tech/sendico/pkg/discovery"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -73,7 +74,7 @@ const (
|
||||
|
||||
func sendDirectionForRail(rail model.Rail) sendDirection {
|
||||
switch rail {
|
||||
case model.RailFiatOnRamp:
|
||||
case discovery.RailFiatOnRamp:
|
||||
return sendDirectionIn
|
||||
default:
|
||||
return sendDirectionOut
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package plan
|
||||
|
||||
import (
|
||||
"github.com/tech/sendico/pkg/discovery"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/payments/storage/model"
|
||||
@@ -15,8 +16,8 @@ func buildFXConversionPlan(payment *model.Payment) (*model.PaymentPlan, error) {
|
||||
}
|
||||
step := &model.PaymentStep{
|
||||
StepID: "fx_convert",
|
||||
Rail: model.RailLedger,
|
||||
Action: model.RailOperationFXConvert,
|
||||
Rail: discovery.RailLedger,
|
||||
Action: discovery.RailOperationFXConvert,
|
||||
ReportVisibility: model.ReportVisibilityUser,
|
||||
CommitPolicy: model.CommitPolicyImmediate,
|
||||
Amount: cloneMoney(payment.Intent.Amount),
|
||||
|
||||
Reference in New Issue
Block a user