feat(router): add confirm flag in kafka payment intent events (#8432)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sai Harsha Vardhan
2025-06-24 14:04:48 +05:30
committed by GitHub
parent 62ec934cf8
commit bc767b9131
5 changed files with 41 additions and 2 deletions

View File

@ -52,6 +52,25 @@ pub struct KeyManagerState {
pub infra_values: Option<serde_json::Value>, 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 { pub trait GetKeymanagerTenant {
fn get_tenant_id(&self, state: &KeyManagerState) -> id_type::TenantId; fn get_tenant_id(&self, state: &KeyManagerState) -> id_type::TenantId;
} }

View File

@ -241,6 +241,7 @@ pub struct PaymentIntentUpdateFields {
pub tax_details: Option<diesel_models::TaxDetails>, pub tax_details: Option<diesel_models::TaxDetails>,
pub force_3ds_challenge: Option<bool>, pub force_3ds_challenge: Option<bool>,
pub is_iframe_redirection_enabled: Option<bool>, pub is_iframe_redirection_enabled: Option<bool>,
pub is_confirm_operation: bool,
} }
#[cfg(feature = "v1")] #[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")] #[cfg(feature = "v2")]
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
pub enum PaymentIntentUpdate { pub enum PaymentIntentUpdate {
@ -366,6 +377,13 @@ pub enum PaymentIntentUpdate {
UpdateIntent(Box<PaymentIntentUpdateFields>), UpdateIntent(Box<PaymentIntentUpdateFields>),
} }
#[cfg(feature = "v2")]
impl PaymentIntentUpdate {
pub fn is_confirm_operation(&self) -> bool {
matches!(self, Self::ConfirmIntent { .. })
}
}
#[cfg(feature = "v1")] #[cfg(feature = "v1")]
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct PaymentIntentUpdateInternal { pub struct PaymentIntentUpdateInternal {

View File

@ -1987,6 +1987,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
is_iframe_redirection_enabled: payment_data is_iframe_redirection_enabled: payment_data
.payment_intent .payment_intent
.is_iframe_redirection_enabled, .is_iframe_redirection_enabled,
is_confirm_operation: true, // Indicates that this is a confirm operation
})), })),
&m_key_store, &m_key_store,
storage_scheme, storage_scheme,

View File

@ -941,6 +941,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
is_iframe_redirection_enabled: payment_data is_iframe_redirection_enabled: payment_data
.payment_intent .payment_intent
.is_iframe_redirection_enabled, .is_iframe_redirection_enabled,
is_confirm_operation: false, // this is not a confirm operation
})), })),
key_store, key_store,
storage_scheme, storage_scheme,

View File

@ -1854,7 +1854,7 @@ impl PaymentIntentInterface for KafkaStore {
.update_payment_intent( .update_payment_intent(
state, state,
this.clone(), this.clone(),
payment_intent, payment_intent.clone(),
key_store, key_store,
storage_scheme, storage_scheme,
) )
@ -1866,7 +1866,7 @@ impl PaymentIntentInterface for KafkaStore {
&intent, &intent,
Some(this), Some(this),
self.tenant_id.clone(), self.tenant_id.clone(),
state.infra_values.clone(), state.add_confirm_value_in_infra_values(payment_intent.is_confirm_operation()),
) )
.await .await
{ {