new settlement flow

This commit is contained in:
Stephan D
2026-01-20 22:29:30 +01:00
parent ae6c617136
commit e0d7320fad
42 changed files with 428 additions and 73 deletions

View File

@@ -9,11 +9,13 @@ import (
"github.com/tech/sendico/gateway/tgsettle/storage"
storagemodel "github.com/tech/sendico/gateway/tgsettle/storage/model"
envelope "github.com/tech/sendico/pkg/messaging/envelope"
mloggerfactory "github.com/tech/sendico/pkg/mlogger/factory"
"github.com/tech/sendico/pkg/model"
notification "github.com/tech/sendico/pkg/model/notification"
"github.com/tech/sendico/pkg/mservice"
mloggerfactory "github.com/tech/sendico/pkg/mlogger/factory"
paymenttypes "github.com/tech/sendico/pkg/payments/types"
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
chainv1 "github.com/tech/sendico/pkg/proto/gateway/chain/v1"
)
type fakePaymentsStore struct {
@@ -147,6 +149,25 @@ func TestOnIntentCreatesConfirmationRequest(t *testing.T) {
}
}
func TestIntentFromSubmitTransferUsesSourceMoney(t *testing.T) {
req := &chainv1.SubmitTransferRequest{
IdempotencyKey: "idem-1",
ClientReference: "pi-1",
Amount: &moneyv1.Money{Amount: "10.00", Currency: "EUR"},
Metadata: map[string]string{
metadataSourceAmount: "12.34",
metadataSourceCurrency: "USD",
},
}
intent, err := intentFromSubmitTransfer(req, "provider_settlement", "")
if err != nil {
t.Fatalf("intentFromSubmitTransfer error: %v", err)
}
if intent.RequestedMoney == nil || intent.RequestedMoney.Amount != "12.34" || intent.RequestedMoney.Currency != "USD" {
t.Fatalf("expected source money override, got: %#v", intent.RequestedMoney)
}
}
func TestConfirmationResultPersistsExecutionAndReply(t *testing.T) {
logger := mloggerfactory.NewLogger(false)
repo := &fakeRepo{payments: &fakePaymentsStore{}, tg: &fakeTelegramStore{}}