Bug: Add profile_id in kafka and clickhouse



Add profile_id in kafka topic `payment-intent` and clickhouse table payment-intent.
diff --git a/crates/analytics/docs/clickhouse/scripts/payment_intents.sql b/crates/analytics/docs/clickhouse/scripts/payment_intents.sql
index 6889a1ff79d..09101e9aa2d 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 d1bd5b2a549..3296956797b 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 cce53cbd596..f5186a0b2bb 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,

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->


### Additional Changes

- [ ] This PR modifies the API contract
- [x] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
To add profile_id.
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?
By making a payment can see the profile_id is added in kafka topic `hyperswitch-payment-intent-events` and same in clickhouse table. Can also test in loki topic and clickhouse-sbx
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
<img width="1728" alt="Screenshot 2024-08-08 at 5 15 37 PM" src="https://github.com/user-attachments/assets/88b13327-4a16-4cff-9782-4fa76c7fd3fa">
<img width="1728" alt="Screenshot 2024-08-08 at 5 09 28 PM" src="https://github.com/user-attachments/assets/97a000c5-0323-4002-9001-83a4b83e96e0">


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
