Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(kafka): fix kafka timestamps sent from application (#4709)

Sampras Lopesc778af26ddb4
diff --git a/crates/router/src/services/kafka.rs b/crates/router/src/services/kafka.rs
index 58657c59fd..6f2aa9fcd1 100644
--- a/crates/router/src/services/kafka.rs
+++ b/crates/router/src/services/kafka.rs
@@ -259,7 +259,7 @@ impl KafkaProducer {
.timestamp(
event
.creation_timestamp()
- .unwrap_or_else(|| OffsetDateTime::now_utc().unix_timestamp()),
+ .unwrap_or_else(|| OffsetDateTime::now_utc().unix_timestamp() * 1_000),
),
)
.map_err(|(error, record)| report!(error).attach_printable(format!("{record:?}")))
@@ -476,7 +476,7 @@ impl MessagingInterface for KafkaProducer {
.key(&data.identifier())
.payload(&json_data)
.timestamp(
- (timestamp.assume_utc().unix_timestamp_nanos() / 1_000)
+ (timestamp.assume_utc().unix_timestamp_nanos() / 1_000_000)
.to_i64()
.unwrap_or_else(|| {
// kafka producer accepts milliseconds
diff --git a/crates/router/src/services/kafka/dispute.rs b/crates/router/src/services/kafka/dispute.rs
index c01089855c..1950fb253a 100644
--- a/crates/router/src/services/kafka/dispute.rs
+++ b/crates/router/src/services/kafka/dispute.rs
@@ -70,10 +70,6 @@ impl<'a> super::KafkaMessage for KafkaDispute<'a> {
)
}
- fn creation_timestamp(&self) -> Option<i64> {
- Some(self.modified_at.unix_timestamp())
- }
-
fn event_type(&self) -> crate::events::EventType {
crate::events::EventType::Dispute
}
diff --git a/crates/router/src/services/kafka/payment_attempt.rs b/crates/router/src/services/kafka/payment_attempt.rs
index dfa7da0d0a..86ea378bfa 100644
--- a/crates/router/src/services/kafka/payment_attempt.rs
+++ b/crates/router/src/services/kafka/payment_attempt.rs
@@ -108,10 +108,6 @@ impl<'a> super::KafkaMessage for KafkaPaymentAttempt<'a> {
)
}
- fn creation_timestamp(&self) -> Option<i64> {
- Some(self.modified_at.unix_timestamp())
- }
-
fn event_type(&self) -> crate::events::EventType {
crate::events::EventType::PaymentAttempt
}
diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rs
index ad61e10295..bcdf23e794 100644
--- a/crates/router/src/services/kafka/payment_intent.rs
+++ b/crates/router/src/services/kafka/payment_intent.rs
@@ -66,10 +66,6 @@ impl<'a> super::KafkaMessage for KafkaPaymentIntent<'a> {
format!("{}_{}", self.merchant_id, self.payment_id)
}
- fn creation_timestamp(&self) -> Option<i64> {
- Some(self.modified_at.unix_timestamp())
- }
-
fn event_type(&self) -> crate::events::EventType {
crate::events::EventType::PaymentIntent
}
diff --git a/crates/router/src/services/kafka/payout.rs b/crates/router/src/services/kafka/payout.rs
index 6b25c724eb..a07b90ee28 100644
--- a/crates/router/src/services/kafka/payout.rs
+++ b/crates/router/src/services/kafka/payout.rs
@@ -80,10 +80,6 @@ impl<'a> super::KafkaMessage for KafkaPayout<'a> {
format!("{}_{}", self.merchant_id, self.payout_attempt_id)
}
- fn creation_timestamp(&self) -> Option<i64> {
- Some(self.last_modified_at.unix_timestamp())
- }
-
fn event_type(&self) -> crate::events::EventType {
crate::events::EventType::Payout
}