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

feat(events): add profile_id in payment_intents events and clickhouse (#5573)

Abhishek Kanojia76b14601c843
diff --git a/crates/analytics/docs/clickhouse/scripts/payment_intents.sql b/crates/analytics/docs/clickhouse/scripts/payment_intents.sql
index 6889a1ff79..09101e9aa2 100644
--- a/crates/analytics/docs/clickhouse/scripts/payment_intents.sql
+++ b/crates/analytics/docs/clickhouse/scripts/payment_intents.sql
@@ -19,6 +19,7 @@ CREATE TABLE payment_intents_queue
`business_country` LowCardinality(String),
`business_label` String,
`attempt_count` UInt8,
+ `profile_id` Nullable(String),
`modified_at` DateTime CODEC(T64, LZ4),
`created_at` DateTime CODEC(T64, LZ4),
`last_synced` Nullable(DateTime) CODEC(T64, LZ4),
@@ -50,6 +51,7 @@ CREATE TABLE payment_intents
`business_country` LowCardinality(String),
`business_label` String,
`attempt_count` UInt8,
+ `profile_id` Nullable(String),
`modified_at` DateTime DEFAULT now() CODEC(T64, LZ4),
`created_at` DateTime DEFAULT now() CODEC(T64, LZ4),
`last_synced` Nullable(DateTime) CODEC(T64, LZ4),
@@ -86,6 +88,7 @@ CREATE MATERIALIZED VIEW payment_intents_mv TO payment_intents
`business_country` LowCardinality(String),
`business_label` String,
`attempt_count` UInt8,
+ `profile_id` Nullable(String),
`modified_at` DateTime64(3),
`created_at` DateTime64(3),
`last_synced` Nullable(DateTime64(3)),
@@ -112,6 +115,7 @@ SELECT
business_country,
business_label,
attempt_count,
+ profile_id,
modified_at,
created_at,
last_synced,
diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rs
index d1bd5b2a54..3296956797 100644
--- a/crates/router/src/services/kafka/payment_intent.rs
+++ b/crates/router/src/services/kafka/payment_intent.rs
@@ -33,6 +33,7 @@ pub struct KafkaPaymentIntent<'a> {
pub business_country: Option<storage_enums::CountryAlpha2>,
pub business_label: Option<&'a String>,
pub attempt_count: i16,
+ pub profile_id: Option<&'a String>,
pub payment_confirm_source: Option<storage_enums::PaymentSource>,
pub billing_details: Option<Encryptable<Secret<Value>>>,
pub shipping_details: Option<Encryptable<Secret<Value>>>,
@@ -67,6 +68,7 @@ impl<'a> KafkaPaymentIntent<'a> {
business_country: intent.business_country,
business_label: intent.business_label.as_ref(),
attempt_count: intent.attempt_count,
+ profile_id: intent.profile_id.as_ref(),
payment_confirm_source: intent.payment_confirm_source,
// TODO: use typed information here to avoid PII logging
billing_details: None,
diff --git a/crates/router/src/services/kafka/payment_intent_event.rs b/crates/router/src/services/kafka/payment_intent_event.rs
index cce53cbd59..f5186a0b2b 100644
--- a/crates/router/src/services/kafka/payment_intent_event.rs
+++ b/crates/router/src/services/kafka/payment_intent_event.rs
@@ -34,6 +34,7 @@ pub struct KafkaPaymentIntentEvent<'a> {
pub business_country: Option<storage_enums::CountryAlpha2>,
pub business_label: Option<&'a String>,
pub attempt_count: i16,
+ pub profile_id: Option<&'a String>,
pub payment_confirm_source: Option<storage_enums::PaymentSource>,
pub billing_details: Option<Encryptable<Secret<Value>>>,
pub shipping_details: Option<Encryptable<Secret<Value>>>,
@@ -68,6 +69,7 @@ impl<'a> KafkaPaymentIntentEvent<'a> {
business_country: intent.business_country,
business_label: intent.business_label.as_ref(),
attempt_count: intent.attempt_count,
+ profile_id: intent.profile_id.as_ref(),
payment_confirm_source: intent.payment_confirm_source,
// TODO: use typed information here to avoid PII logging
billing_details: None,