mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
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:
committed by
GitHub
parent
62ec934cf8
commit
bc767b9131
@ -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;
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user