Merge pull request 'fixed dropping of settlement mode' (#108) from settlement-106 into main
Some checks failed
ci/woodpecker/push/fx_oracle Pipeline is pending
ci/woodpecker/push/ledger Pipeline is pending
ci/woodpecker/push/mntx_gateway Pipeline is pending
ci/woodpecker/push/nats Pipeline is pending
ci/woodpecker/push/notification Pipeline is pending
ci/woodpecker/push/payments_orchestrator Pipeline is pending
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline failed
ci/woodpecker/push/frontend Pipeline failed

Reviewed-on: #108
This commit was merged in pull request #108.
This commit is contained in:
2025-12-12 13:19:29 +00:00
3 changed files with 31 additions and 23 deletions

View File

@@ -20,13 +20,14 @@ func intentFromProto(src *orchestratorv1.PaymentIntent) model.PaymentIntent {
return model.PaymentIntent{} return model.PaymentIntent{}
} }
intent := model.PaymentIntent{ intent := model.PaymentIntent{
Kind: modelKindFromProto(src.GetKind()), Kind: modelKindFromProto(src.GetKind()),
Source: endpointFromProto(src.GetSource()), Source: endpointFromProto(src.GetSource()),
Destination: endpointFromProto(src.GetDestination()), Destination: endpointFromProto(src.GetDestination()),
Amount: cloneMoney(src.GetAmount()), Amount: cloneMoney(src.GetAmount()),
RequiresFX: src.GetRequiresFx(), RequiresFX: src.GetRequiresFx(),
FeePolicy: src.GetFeePolicy(), FeePolicy: src.GetFeePolicy(),
Attributes: cloneMetadata(src.GetAttributes()), SettlementMode: src.GetSettlementMode(),
Attributes: cloneMetadata(src.GetAttributes()),
} }
if src.GetFx() != nil { if src.GetFx() != nil {
intent.FX = fxIntentFromProto(src.GetFx()) intent.FX = fxIntentFromProto(src.GetFx())
@@ -153,13 +154,14 @@ func toProtoPayment(src *model.Payment) *orchestratorv1.Payment {
func protoIntentFromModel(src model.PaymentIntent) *orchestratorv1.PaymentIntent { func protoIntentFromModel(src model.PaymentIntent) *orchestratorv1.PaymentIntent {
intent := &orchestratorv1.PaymentIntent{ intent := &orchestratorv1.PaymentIntent{
Kind: protoKindFromModel(src.Kind), Kind: protoKindFromModel(src.Kind),
Source: protoEndpointFromModel(src.Source), Source: protoEndpointFromModel(src.Source),
Destination: protoEndpointFromModel(src.Destination), Destination: protoEndpointFromModel(src.Destination),
Amount: cloneMoney(src.Amount), Amount: cloneMoney(src.Amount),
RequiresFx: src.RequiresFX, RequiresFx: src.RequiresFX,
FeePolicy: src.FeePolicy, FeePolicy: src.FeePolicy,
Attributes: cloneMetadata(src.Attributes), SettlementMode: src.SettlementMode,
Attributes: cloneMetadata(src.Attributes),
} }
if src.FX != nil { if src.FX != nil {
intent.Fx = protoFXIntentFromModel(src.FX) intent.Fx = protoFXIntentFromModel(src.FX)

View File

@@ -48,7 +48,8 @@ func TestRequireIdempotencyKey(t *testing.T) {
func TestNewPayment(t *testing.T) { func TestNewPayment(t *testing.T) {
org := primitive.NewObjectID() org := primitive.NewObjectID()
intent := &orchestratorv1.PaymentIntent{ 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"} quote := &orchestratorv1.PaymentQuote{QuoteRef: "q1"}
p := newPayment(org, intent, "idem", map[string]string{"k": "v"}, quote) 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" { if p.Intent.Amount == nil || p.Intent.Amount.GetAmount() != "10" {
t.Fatalf("intent not copied") 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" { if p.LastQuote == nil || p.LastQuote.QuoteRef != "q1" {
t.Fatalf("quote not copied") t.Fatalf("quote not copied")
} }

View File

@@ -11,6 +11,7 @@ import (
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1" moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
chainv1 "github.com/tech/sendico/pkg/proto/gateway/chain/v1" chainv1 "github.com/tech/sendico/pkg/proto/gateway/chain/v1"
oraclev1 "github.com/tech/sendico/pkg/proto/oracle/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. // PaymentKind captures the orchestrator intent type.
@@ -124,14 +125,15 @@ type FXIntent struct {
// PaymentIntent models the requested payment operation. // PaymentIntent models the requested payment operation.
type PaymentIntent struct { type PaymentIntent struct {
Kind PaymentKind `bson:"kind" json:"kind"` Kind PaymentKind `bson:"kind" json:"kind"`
Source PaymentEndpoint `bson:"source" json:"source"` Source PaymentEndpoint `bson:"source" json:"source"`
Destination PaymentEndpoint `bson:"destination" json:"destination"` Destination PaymentEndpoint `bson:"destination" json:"destination"`
Amount *moneyv1.Money `bson:"amount" json:"amount"` Amount *moneyv1.Money `bson:"amount" json:"amount"`
RequiresFX bool `bson:"requiresFx,omitempty" json:"requiresFx,omitempty"` RequiresFX bool `bson:"requiresFx,omitempty" json:"requiresFx,omitempty"`
FX *FXIntent `bson:"fx,omitempty" json:"fx,omitempty"` FX *FXIntent `bson:"fx,omitempty" json:"fx,omitempty"`
FeePolicy *feesv1.PolicyOverrides `bson:"feePolicy,omitempty" json:"feePolicy,omitempty"` FeePolicy *feesv1.PolicyOverrides `bson:"feePolicy,omitempty" json:"feePolicy,omitempty"`
Attributes map[string]string `bson:"attributes,omitempty" json:"attributes,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. // PaymentQuoteSnapshot stores the latest quote info.