better logging + fixed tg messaging
This commit is contained in:
@@ -169,6 +169,8 @@ func (s *Service) SubmitTransfer(ctx context.Context, req *chainv1.SubmitTransfe
|
||||
zap.String("rail", intent.OutgoingLeg),
|
||||
zap.String("organization_ref", strings.TrimSpace(req.GetOrganizationRef())),
|
||||
zap.String("source_wallet_ref", strings.TrimSpace(req.GetSourceWalletRef())),
|
||||
zap.String("operation_ref", strings.TrimSpace(req.GetOperationRef())),
|
||||
zap.String("intent_ref", strings.TrimSpace(req.GetIntentRef())),
|
||||
}
|
||||
if intent.RequestedMoney != nil {
|
||||
logFields = append(logFields,
|
||||
@@ -243,6 +245,10 @@ func (s *Service) onIntent(ctx context.Context, intent *model.PaymentGatewayInte
|
||||
s.logger.Warn("Payment gateway intent rejected", zap.String("reason", "payment_intent_id is required"), zap.String("idempotency_key", intent.IdempotencyKey))
|
||||
return merrors.InvalidArgument("payment_intent_id is required", "payment_intent_id")
|
||||
}
|
||||
if intent.IntentRef == "" {
|
||||
s.logger.Warn("Payment gateway intent rejected", zap.String("reason", "payment_intent_ref is required"), zap.String("idempotency_key", intent.IdempotencyKey))
|
||||
return merrors.InvalidArgument("payment_intent_ref is required", "payment_intent_ref")
|
||||
}
|
||||
if intent.RequestedMoney == nil || strings.TrimSpace(intent.RequestedMoney.Amount) == "" || strings.TrimSpace(intent.RequestedMoney.Currency) == "" {
|
||||
s.logger.Warn("Payment gateway intent rejected", zap.String("reason", "requested_money is required"), zap.String("idempotency_key", intent.IdempotencyKey))
|
||||
return merrors.InvalidArgument("requested_money is required", "requested_money")
|
||||
@@ -274,7 +280,8 @@ func (s *Service) onIntent(ctx context.Context, intent *model.PaymentGatewayInte
|
||||
|
||||
record := paymentRecordFromIntent(intent, confirmReq)
|
||||
if err := s.updateTransferStatus(ctx, record); err != nil {
|
||||
s.logger.Warn("Failed to persist payment record", zap.Error(err), zap.String("idempotency_key", confirmReq.RequestID))
|
||||
s.logger.Warn("Failed to persist payment record", zap.Error(err),
|
||||
zap.String("idempotency_key", confirmReq.RequestID), zap.String("intent_ref", record.IntentRef))
|
||||
return err
|
||||
}
|
||||
if err := s.sendConfirmationRequest(confirmReq); err != nil {
|
||||
@@ -397,6 +404,8 @@ func (s *Service) buildConfirmationRequest(intent *model.PaymentGatewayIntent) (
|
||||
TimeoutSeconds: timeout,
|
||||
SourceService: string(mservice.PaymentGateway),
|
||||
Rail: rail,
|
||||
OperationRef: intent.OperationRef,
|
||||
IntentRef: intent.IntentRef,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -562,6 +571,10 @@ func intentFromSubmitTransfer(req *chainv1.SubmitTransferRequest, defaultRail, d
|
||||
if idempotencyKey == "" {
|
||||
return nil, merrors.InvalidArgument("submit_transfer: idempotency_key is required")
|
||||
}
|
||||
intentRef := strings.TrimSpace(req.GetIntentRef())
|
||||
if intentRef == "" {
|
||||
return nil, merrors.InvalidArgument("submit_transfer: intent_ref is required")
|
||||
}
|
||||
amount := req.GetAmount()
|
||||
if amount == nil {
|
||||
return nil, merrors.InvalidArgument("submit_transfer: amount is required")
|
||||
@@ -609,6 +622,7 @@ func intentFromSubmitTransfer(req *chainv1.SubmitTransferRequest, defaultRail, d
|
||||
OutgoingLeg: outgoingLeg,
|
||||
QuoteRef: quoteRef,
|
||||
RequestedMoney: requestedMoney,
|
||||
IntentRef: intentRef,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user