tg fizx
This commit is contained in:
@@ -406,6 +406,7 @@ func (s *Service) buildConfirmationRequest(intent *model.PaymentGatewayIntent) (
|
|||||||
Rail: rail,
|
Rail: rail,
|
||||||
OperationRef: intent.OperationRef,
|
OperationRef: intent.OperationRef,
|
||||||
IntentRef: intent.IntentRef,
|
IntentRef: intent.IntentRef,
|
||||||
|
PaymentRef: intent.PaymentRef,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,6 +531,7 @@ func paymentRecordFromIntent(intent *model.PaymentGatewayIntent, confirmReq *mod
|
|||||||
record.RequestedMoney = intent.RequestedMoney
|
record.RequestedMoney = intent.RequestedMoney
|
||||||
record.IntentRef = intent.IntentRef
|
record.IntentRef = intent.IntentRef
|
||||||
record.OperationRef = intent.OperationRef
|
record.OperationRef = intent.OperationRef
|
||||||
|
record.PaymentRef = intent.PaymentRef
|
||||||
}
|
}
|
||||||
if confirmReq != nil {
|
if confirmReq != nil {
|
||||||
record.IdempotencyKey = strings.TrimSpace(confirmReq.RequestID)
|
record.IdempotencyKey = strings.TrimSpace(confirmReq.RequestID)
|
||||||
@@ -539,6 +541,7 @@ func paymentRecordFromIntent(intent *model.PaymentGatewayIntent, confirmReq *mod
|
|||||||
record.RequestedMoney = confirmReq.RequestedMoney
|
record.RequestedMoney = confirmReq.RequestedMoney
|
||||||
record.IntentRef = strings.TrimSpace(confirmReq.IntentRef)
|
record.IntentRef = strings.TrimSpace(confirmReq.IntentRef)
|
||||||
record.OperationRef = strings.TrimSpace(confirmReq.OperationRef)
|
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.
|
// ExpiresAt is not used to derive an "expired" status — it can be kept for informational purposes only.
|
||||||
if confirmReq.TimeoutSeconds > 0 {
|
if confirmReq.TimeoutSeconds > 0 {
|
||||||
record.ExpiresAt = time.Now().Add(time.Duration(confirmReq.TimeoutSeconds) * time.Second)
|
record.ExpiresAt = time.Now().Add(time.Duration(confirmReq.TimeoutSeconds) * time.Second)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package orchestrator
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tech/sendico/payments/orchestrator/storage/model"
|
"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(
|
func (p *paymentExecutor) executeSendStep(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
payment *model.Payment,
|
payment *model.Payment,
|
||||||
@@ -268,6 +287,15 @@ func (p *paymentExecutor) executeSendStep(
|
|||||||
logger.Warn("Invalid provider settlement amount", zap.Error(err))
|
logger.Warn("Invalid provider settlement amount", zap.Error(err))
|
||||||
return false, 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() {
|
if !p.deps.railGateways.available() {
|
||||||
logger.Warn("Rail gateway unavailable")
|
logger.Warn("Rail gateway unavailable")
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ type ConfirmationRequest struct {
|
|||||||
Rail string `bson:"rail,omitempty" json:"rail,omitempty"`
|
Rail string `bson:"rail,omitempty" json:"rail,omitempty"`
|
||||||
OperationRef string `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
|
OperationRef string `bson:"operationRef,omitempty" json:"operation_ref,omitempty"`
|
||||||
IntentRef string `bson:"intentRef,omitempty" json:"intent_ref,omitempty"`
|
IntentRef string `bson:"intentRef,omitempty" json:"intent_ref,omitempty"`
|
||||||
|
PaymentRef string `bson:"paymentRef,omitempty" json:"payment_ref,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfirmationResult struct {
|
type ConfirmationResult struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user