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

@@ -406,6 +406,7 @@ func (s *Service) buildConfirmationRequest(intent *model.PaymentGatewayIntent) (
Rail: rail,
OperationRef: intent.OperationRef,
IntentRef: intent.IntentRef,
PaymentRef: intent.PaymentRef,
}, nil
}
@@ -530,6 +531,7 @@ func paymentRecordFromIntent(intent *model.PaymentGatewayIntent, confirmReq *mod
record.RequestedMoney = intent.RequestedMoney
record.IntentRef = intent.IntentRef
record.OperationRef = intent.OperationRef
record.PaymentRef = intent.PaymentRef
}
if confirmReq != nil {
record.IdempotencyKey = strings.TrimSpace(confirmReq.RequestID)
@@ -539,6 +541,7 @@ func paymentRecordFromIntent(intent *model.PaymentGatewayIntent, confirmReq *mod
record.RequestedMoney = confirmReq.RequestedMoney
record.IntentRef = strings.TrimSpace(confirmReq.IntentRef)
record.OperationRef = strings.TrimSpace(confirmReq.OperationRef)
record.PaymentRef = confirmReq.PaymentRef
// ExpiresAt is not used to derive an "expired" status — it can be kept for informational purposes only.
if confirmReq.TimeoutSeconds > 0 {
record.ExpiresAt = time.Now().Add(time.Duration(confirmReq.TimeoutSeconds) * time.Second)

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")

View File

@@ -23,6 +23,7 @@ type ConfirmationRequest struct {
Rail string `bson:"rail,omitempty" json:"rail,omitempty"`
OperationRef string `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
IntentRef string `bson:"intentRef,omitempty" json:"intent_ref,omitempty"`
PaymentRef string `bson:"paymentRef,omitempty" json:"payment_ref,omitempty"`
}
type ConfirmationResult struct {