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(router): add confirm flag in kafka payment intent events (#8432)

Sai Harsha Vardhanbc767b9131e2
diff --git a/crates/common_utils/src/types/keymanager.rs b/crates/common_utils/src/types/keymanager.rs
index 5ce98112b7..993eb9d211 100644
--- a/crates/common_utils/src/types/keymanager.rs
+++ b/crates/common_utils/src/types/keymanager.rs
@@ -52,6 +52,25 @@ pub struct KeyManagerState {
pub infra_values: Option<serde_json::Value>,
}
+impl KeyManagerState {
+ pub fn add_confirm_value_in_infra_values(
+ &self,
+ is_confirm_operation: bool,
+ ) -> Option<serde_json::Value> {
+ self.infra_values.clone().map(|mut infra_values| {
+ if is_confirm_operation {
+ infra_values.as_object_mut().map(|obj| {
+ obj.insert(
+ "is_confirm_operation".to_string(),
+ serde_json::Value::Bool(true),
+ )
+ });
+ }
+ infra_values
+ })
+ }
+}
+
pub trait GetKeymanagerTenant {
fn get_tenant_id(&self, state: &KeyManagerState) -> id_type::TenantId;
}
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index 67a6ef6a79..f22a3698db 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -241,6 +241,7 @@ pub struct PaymentIntentUpdateFields {
pub tax_details: Option<diesel_models::TaxDetails>,
pub force_3ds_challenge: Option<bool>,
pub is_iframe_redirection_enabled: Option<bool>,
+ pub is_confirm_operation: bool,
}
#[cfg(feature = "v1")]
@@ -324,6 +325,16 @@ pub enum PaymentIntentUpdate {
},
}
+#[cfg(feature = "v1")]
+impl PaymentIntentUpdate {
+ pub fn is_confirm_operation(&self) -> bool {
+ match self {
+ Self::Update(value) => value.is_confirm_operation,
+ _ => false,
+ }
+ }
+}
+
#[cfg(feature = "v2")]
#[derive(Debug, Clone, Serialize)]
pub enum PaymentIntentUpdate {
@@ -366,6 +377,13 @@ pub enum PaymentIntentUpdate {
UpdateIntent(Box<PaymentIntentUpdateFields>),
}
+#[cfg(feature = "v2")]
+impl PaymentIntentUpdate {
+ pub fn is_confirm_operation(&self) -> bool {
+ matches!(self, Self::ConfirmIntent { .. })
+ }
+}
+
#[cfg(feature = "v1")]
#[derive(Clone, Debug, Default)]
pub struct PaymentIntentUpdateInternal {
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index fe4e63232b..11f73b2300 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1987,6 +1987,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
is_iframe_redirection_enabled: payment_data
.payment_intent
.is_iframe_redirection_enabled,
+ is_confirm_operation: true, // Indicates that this is a confirm operation
})),
&m_key_store,
storage_scheme,
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index eaae951491..b42bdd12ff 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -941,6 +941,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
is_iframe_redirection_enabled: payment_data
.payment_intent
.is_iframe_redirection_enabled,
+ is_confirm_operation: false, // this is not a confirm operation
})),
key_store,
storage_scheme,
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index 7eef89c34e..4265f60c7d 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -1854,7 +1854,7 @@ impl PaymentIntentInterface for KafkaStore {
.update_payment_intent(
state,
this.clone(),
- payment_intent,
+ payment_intent.clone(),
key_store,
storage_scheme,
)
@@ -1866,7 +1866,7 @@ impl PaymentIntentInterface for KafkaStore {
&intent,
Some(this),
self.tenant_id.clone(),
- state.infra_values.clone(),
+ state.add_confirm_value_in_infra_values(payment_intent.is_confirm_operation()),
)
.await
{