This commit is contained in:
Stephan D
2026-02-03 16:10:47 +01:00
parent 446d4d737c
commit bbf781bba3
3 changed files with 32 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ package orchestrator
import (
"context"
"fmt"
"math/big"
"strings"
"github.com/tech/sendico/payments/orchestrator/storage/model"
@@ -139,6 +141,23 @@ func (p *paymentExecutor) executePlanStep(
}
}
func sub(a, b string) (string, error) {
ra, ok := new(big.Rat).SetString(a)
if !ok {
return "", fmt.Errorf("invalid number: %s", a)
}
rb, ok := new(big.Rat).SetString(b)
if !ok {
return "", fmt.Errorf("invalid number: %s", b)
}
ra.Sub(ra, rb)
// 2 знака после запятой (как у тебя)
return ra.FloatString(2), nil
}
func (p *paymentExecutor) executeSendStep(
ctx context.Context,
payment *model.Payment,
@@ -268,6 +287,15 @@ func (p *paymentExecutor) executeSendStep(
logger.Warn("Invalid provider settlement amount", zap.Error(err))
return false, err
}
fee, err := requireMoney(cloneMoney(payment.LastQuote.ExpectedFeeTotal), "provider settlement amount")
if err != nil {
logger.Warn("Invalid provider settlement amount", zap.Error(err))
return false, err
}
if fee.Currency != amount.Currency {
logger.Warn("Fee and amount currencies do not match")
return false, merrors.DataConflict("settlement payment: currencies mismatch")
}
if !p.deps.railGateways.available() {
logger.Warn("Rail gateway unavailable")