diff --git a/api/payments/orchestrator/internal/service/orchestrator/convert.go b/api/payments/orchestrator/internal/service/orchestrator/convert.go index 95d97ca..4108ac0 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/convert.go +++ b/api/payments/orchestrator/internal/service/orchestrator/convert.go @@ -20,13 +20,14 @@ func intentFromProto(src *orchestratorv1.PaymentIntent) model.PaymentIntent { return model.PaymentIntent{} } intent := model.PaymentIntent{ - Kind: modelKindFromProto(src.GetKind()), - Source: endpointFromProto(src.GetSource()), - Destination: endpointFromProto(src.GetDestination()), - Amount: cloneMoney(src.GetAmount()), - RequiresFX: src.GetRequiresFx(), - FeePolicy: src.GetFeePolicy(), - Attributes: cloneMetadata(src.GetAttributes()), + Kind: modelKindFromProto(src.GetKind()), + Source: endpointFromProto(src.GetSource()), + Destination: endpointFromProto(src.GetDestination()), + Amount: cloneMoney(src.GetAmount()), + RequiresFX: src.GetRequiresFx(), + FeePolicy: src.GetFeePolicy(), + SettlementMode: src.GetSettlementMode(), + Attributes: cloneMetadata(src.GetAttributes()), } if src.GetFx() != nil { intent.FX = fxIntentFromProto(src.GetFx()) @@ -153,13 +154,14 @@ func toProtoPayment(src *model.Payment) *orchestratorv1.Payment { func protoIntentFromModel(src model.PaymentIntent) *orchestratorv1.PaymentIntent { intent := &orchestratorv1.PaymentIntent{ - Kind: protoKindFromModel(src.Kind), - Source: protoEndpointFromModel(src.Source), - Destination: protoEndpointFromModel(src.Destination), - Amount: cloneMoney(src.Amount), - RequiresFx: src.RequiresFX, - FeePolicy: src.FeePolicy, - Attributes: cloneMetadata(src.Attributes), + Kind: protoKindFromModel(src.Kind), + Source: protoEndpointFromModel(src.Source), + Destination: protoEndpointFromModel(src.Destination), + Amount: cloneMoney(src.Amount), + RequiresFx: src.RequiresFX, + FeePolicy: src.FeePolicy, + SettlementMode: src.SettlementMode, + Attributes: cloneMetadata(src.Attributes), } if src.FX != nil { intent.Fx = protoFXIntentFromModel(src.FX) diff --git a/api/payments/orchestrator/internal/service/orchestrator/service_helpers_test.go b/api/payments/orchestrator/internal/service/orchestrator/service_helpers_test.go index ea777d4..f33f03d 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/service_helpers_test.go +++ b/api/payments/orchestrator/internal/service/orchestrator/service_helpers_test.go @@ -48,7 +48,8 @@ func TestRequireIdempotencyKey(t *testing.T) { func TestNewPayment(t *testing.T) { org := primitive.NewObjectID() intent := &orchestratorv1.PaymentIntent{ - Amount: &moneyv1.Money{Currency: "USD", Amount: "10"}, + Amount: &moneyv1.Money{Currency: "USD", Amount: "10"}, + SettlementMode: orchestratorv1.SettlementMode_SETTLEMENT_MODE_FIX_RECEIVED, } quote := &orchestratorv1.PaymentQuote{QuoteRef: "q1"} p := newPayment(org, intent, "idem", map[string]string{"k": "v"}, quote) @@ -58,6 +59,9 @@ func TestNewPayment(t *testing.T) { if p.Intent.Amount == nil || p.Intent.Amount.GetAmount() != "10" { t.Fatalf("intent not copied") } + if p.Intent.SettlementMode != orchestratorv1.SettlementMode_SETTLEMENT_MODE_FIX_RECEIVED { + t.Fatalf("settlement mode not preserved") + } if p.LastQuote == nil || p.LastQuote.QuoteRef != "q1" { t.Fatalf("quote not copied") } diff --git a/api/payments/orchestrator/storage/model/payment.go b/api/payments/orchestrator/storage/model/payment.go index 72a62f2..d4db40d 100644 --- a/api/payments/orchestrator/storage/model/payment.go +++ b/api/payments/orchestrator/storage/model/payment.go @@ -11,6 +11,7 @@ import ( moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1" chainv1 "github.com/tech/sendico/pkg/proto/gateway/chain/v1" oraclev1 "github.com/tech/sendico/pkg/proto/oracle/v1" + orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestrator/v1" ) // PaymentKind captures the orchestrator intent type. @@ -124,14 +125,15 @@ type FXIntent struct { // PaymentIntent models the requested payment operation. type PaymentIntent struct { - Kind PaymentKind `bson:"kind" json:"kind"` - Source PaymentEndpoint `bson:"source" json:"source"` - Destination PaymentEndpoint `bson:"destination" json:"destination"` - Amount *moneyv1.Money `bson:"amount" json:"amount"` - RequiresFX bool `bson:"requiresFx,omitempty" json:"requiresFx,omitempty"` - FX *FXIntent `bson:"fx,omitempty" json:"fx,omitempty"` - FeePolicy *feesv1.PolicyOverrides `bson:"feePolicy,omitempty" json:"feePolicy,omitempty"` - Attributes map[string]string `bson:"attributes,omitempty" json:"attributes,omitempty"` + Kind PaymentKind `bson:"kind" json:"kind"` + Source PaymentEndpoint `bson:"source" json:"source"` + Destination PaymentEndpoint `bson:"destination" json:"destination"` + Amount *moneyv1.Money `bson:"amount" json:"amount"` + RequiresFX bool `bson:"requiresFx,omitempty" json:"requiresFx,omitempty"` + FX *FXIntent `bson:"fx,omitempty" json:"fx,omitempty"` + FeePolicy *feesv1.PolicyOverrides `bson:"feePolicy,omitempty" json:"feePolicy,omitempty"` + SettlementMode orchestratorv1.SettlementMode `bson:"settlementMode,omitempty" json:"settlementMode,omitempty"` + Attributes map[string]string `bson:"attributes,omitempty" json:"attributes,omitempty"` } // PaymentQuoteSnapshot stores the latest quote info.