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

fix(router): Rename payment_session to client_session (#11692)

Anurag Thakur42509f79db15
diff --git a/crates/common_utils/src/id_type.rs b/crates/common_utils/src/id_type.rs
index 6f775ad393..6a7df2e282 100644
--- a/crates/common_utils/src/id_type.rs
+++ b/crates/common_utils/src/id_type.rs
@@ -5,6 +5,7 @@ mod api_key;
mod authentication;
mod card_issuer;
mod client_secret;
+mod client_session;
mod customer;
#[cfg(feature = "v2")]
mod global_id;
@@ -13,7 +14,6 @@ mod merchant;
mod merchant_connector_account;
mod organization;
mod payment;
-mod payment_session;
mod payout;
mod profile;
mod profile_acquirer;
@@ -51,13 +51,13 @@ pub use self::{
authentication::AuthenticationId,
card_issuer::CardIssuerId,
client_secret::ClientSecretId,
+ client_session::ClientSessionId,
customer::CustomerId,
invoice::InvoiceId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,
payment::{PaymentId, PaymentReferenceId, PaymentResourceId},
- payment_session::PaymentSessionId,
profile::ProfileId,
profile_acquirer::ProfileAcquirerId,
refunds::RefundReferenceId,
diff --git a/crates/common_utils/src/id_type/client_session.rs b/crates/common_utils/src/id_type/client_session.rs
new file mode 100644
index 0000000000..70dfe4fe5a
--- /dev/null
+++ b/crates/common_utils/src/id_type/client_session.rs
@@ -0,0 +1,10 @@
+crate::id_type!(
+ ClientSessionId,
+ "A type for client_session_id that can be used for payment sessions"
+);
+crate::impl_id_type_methods!(ClientSessionId, "client_session_id");
+
+// This is to display the `ClientSessionId` as ClientSessionId(abcd)
+crate::impl_debug_id_type!(ClientSessionId);
+crate::impl_generate_id_id_type!(ClientSessionId, "client_sess");
+crate::impl_try_from_cow_str_id_type!(ClientSessionId, "client_session_id");
diff --git a/crates/common_utils/src/id_type/payment_session.rs b/crates/common_utils/src/id_type/payment_session.rs
deleted file mode 100644
index eb4d278c25..0000000000
--- a/crates/common_utils/src/id_type/payment_session.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-crate::id_type!(
- PaymentSessionId,
- "A type for payment_session_id that can be used for payment sessions"
-);
-crate::impl_id_type_methods!(PaymentSessionId, "payment_session_id");
-
-// This is to display the `PaymentSessionId` as PaymentSessionId(abcd)
-crate::impl_debug_id_type!(PaymentSessionId);
-crate::impl_generate_id_id_type!(PaymentSessionId, "pay_sess");
-crate::impl_try_from_cow_str_id_type!(PaymentSessionId, "payment_session_id");
diff --git a/crates/hyperswitch_domain_models/src/sdk_auth.rs b/crates/hyperswitch_domain_models/src/sdk_auth.rs
index 6ab6cdd6d3..621abed211 100644
--- a/crates/hyperswitch_domain_models/src/sdk_auth.rs
+++ b/crates/hyperswitch_domain_models/src/sdk_auth.rs
@@ -49,7 +49,7 @@ impl From<SdkAuthorizationContext> for Option<SdkAuthorization> {
client_secret: input.client_secret,
customer_id: input.customer_id,
payment_method_session_id: input.payment_method_session_id,
- payment_session_id: None,
+ client_session_id: None,
})
}
Initiator::Admin | Initiator::Jwt { .. } | Initiator::EmbeddedToken { .. } => None, // SDK authorization is only applicable for API initiators
@@ -83,8 +83,12 @@ pub struct SdkAuthorization {
#[cfg(feature = "v2")]
pub payment_method_session_id: Option<id_type::GlobalPaymentMethodSessionId>,
- /// Payment Session ID for SDK authorization validation
- pub payment_session_id: Option<id_type::PaymentSessionId>,
+ /// Client Session ID for SDK authorization validation
+ pub client_session_id: Option<id_type::ClientSessionId>,
+
+ /// Payment ID for the payment/session (v1 only)
+ #[cfg(feature = "v1")]
+ pub payment_id: Option<id_type::PaymentId>,
}
impl SdkAuthorization {
@@ -108,9 +112,13 @@ impl SdkAuthorization {
self.payment_method_session_id
.as_ref()
.map(|id| format!("payment_method_session_id={}", id.get_string_repr())),
- self.payment_session_id
+ self.client_session_id
.as_ref()
- .map(|id| format!("payment_session_id={}", id.get_string_repr())),
+ .map(|id| format!("client_session_id={}", id.get_string_repr())),
+ #[cfg(feature = "v1")]
+ self.payment_id
+ .as_ref()
+ .map(|id| format!("payment_id={}", id.get_string_repr())),
]
.into_iter()
.flatten()
@@ -209,17 +217,27 @@ impl SdkAuthorization {
)
},
),
- payment_session_id: parts
- .get("payment_session_id")
- .map(|payment_session_id| {
- id_type::PaymentSessionId::try_from(std::borrow::Cow::from(
- payment_session_id.to_string(),
+ client_session_id: parts
+ .get("client_session_id")
+ .map(|client_session_id| {
+ id_type::ClientSessionId::try_from(std::borrow::Cow::from(
+ client_session_id.to_string(),
))
.change_context(ValidationError::InvalidValue {
- message: "Invalid payment_session_id format".to_string(),
+ message: "Invalid client_session_id format".to_string(),
})
})
.transpose()?,
+ #[cfg(feature = "v1")]
+ payment_id: parts
+ .get("payment_id")
+ .map(|payment_id| {
+ id_type::PaymentId::try_from(std::borrow::Cow::from(payment_id.to_string()))
+ .change_context(ValidationError::InvalidValue {
+ message: "Invalid payment_id format".to_string(),
+ })
+ })
+ .transpose()?,
})
}
}
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index 1092a646d3..e6b0d19fb1 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -220,8 +220,8 @@ pub const AUTHENTICATION_SERVICE_ELIGIBLE_CONFIG: &str =
/// Payment flow identifier used for performing GSM operations
pub const PAYMENT_FLOW_STR: &str = "Payment";
-/// Redis key prefix for payment session storage
-pub(crate) const PAYMENT_SESSION_KEY_PREFIX: &str = "payment_session";
+/// Redis key prefix for client session storage
+pub(crate) const CLIENT_SESSION_KEY_PREFIX: &str = "client_session";
/// Default subflow identifier used for performing GSM operations
pub const DEFAULT_SUBFLOW_STR: &str = "sub_flow";
@@ -361,8 +361,8 @@ pub mod superposition {
pub const DYNAMIC_FIELDS: &str = "dynamic_fields";
/// payout sync tracker configuration key
pub const PAYOUT_TRACKER_MAPPING: &str = "payout_tracker_mapping";
- /// payment session validation enabled configuration key
- pub const PAYMENT_SESSION_VALIDATION_ENABLED: &str = "payment_session_validation_enabled";
+ /// client session validation enabled configuration key
+ pub const CLIENT_SESSION_VALIDATION_ENABLED: &str = "client_session_validation_enabled";
}
#[cfg(test)]
diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rs
index 7921fe6f60..2a85da3d71 100644
--- a/crates/router/src/core/configs/dimension_config.rs
+++ b/crates/router/src/core/configs/dimension_config.rs
@@ -167,15 +167,15 @@ config! {
}
config! {
- superposition_key = PAYMENT_SESSION_VALIDATION_ENABLED,
+ superposition_key = CLIENT_SESSION_VALIDATION_ENABLED,
output = bool,
default = true,
requires = DimensionsWithMerchantId,
targeting_key = id_type::PaymentId
}
-impl DatabaseBackedConfig for PaymentSessionValidationEnabled {
- const KEY: &'static str = "payment_session_validation_enabled";
+impl DatabaseBackedConfig for ClientSessionValidationEnabled {
+ const KEY: &'static str = "client_session_validation_enabled";
fn db_key(_dimensions: &impl super::dimension_state::DimensionsBase) -> Option<String> {
None
}
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 3df8baebea..6eda385161 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -7,7 +7,7 @@ pub mod helpers;
pub mod operations;
pub mod session_token;
-pub mod payment_session;
+pub mod client_session;
#[cfg(feature = "retry")]
pub mod retry;
pub mod routing;
@@ -8385,7 +8385,7 @@ where
pub is_manual_retry_enabled: Option<bool>,
pub is_l2_l3_enabled: bool,
pub external_authentication_data: Option<api_models::payments::ExternalThreeDsData>,
- pub payment_session_id: Option<id_type::PaymentSessionId>,
+ pub client_session_id: Option<id_type::ClientSessionId>,
}
#[cfg(feature = "v1")]
@@ -11928,7 +11928,7 @@ pub trait OperationSessionGetters<F> {
fn get_is_manual_retry_enabled(&self) -> Option<bool>;
#[cfg(feature = "v1")]
- fn get_payment_session_id(&self) -> Option<id_type::PaymentSessionId>;
+ fn get_client_session_id(&self) -> Option<id_type::ClientSessionId>;
#[cfg(feature = "v1")]
fn get_installment_details(&self) -> Option<&common_types::payments::InstallmentData>;
@@ -12180,8 +12180,8 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {
}
#[cfg(feature = "v1")]
- fn get_payment_session_id(&self) -> Option<id_type::PaymentSessionId> {
- self.payment_session_id.clone()
+ fn get_client_session_id(&self) -> Option<id_type::ClientSessionId> {
+ self.client_session_id.clone()
}
// #[cfg(feature = "v2")]
diff --git a/crates/router/src/core/payments/payment_session.rs b/crates/router/src/core/payments/client_session.rs
similarity index 77%
rename from crates/router/src/core/payments/payment_session.rs
rename to crates/router/src/core/payments/client_session.rs
index 2102842ca0..1bbac65a5a 100644
--- a/crates/router/src/core/payments/payment_session.rs
+++ b/crates/router/src/core/payments/client_session.rs
@@ -1,4 +1,4 @@
-//! Core payment session ID management for SDK authorization.
+//! Core client session ID management for SDK authorization.
use common_utils::{
errors::CustomResult,
@@ -11,11 +11,11 @@ use time::{Duration, PrimitiveDateTime};
use crate::{consts, db::errors, routes::app::SessionStateInfo};
-/// Payment session data structure stored in Redis
+/// Client session data structure stored in Redis
#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct PaymentSessionData {
+pub struct ClientSessionData {
/// SDK auth session ID
- pub payment_session_id: id_type::PaymentSessionId,
+ pub client_session_id: id_type::ClientSessionId,
/// Session creation time
pub created_at: PrimitiveDateTime,
/// Session expiry time
@@ -29,23 +29,23 @@ pub struct SessionInvalidationReport {
pub session_existed: bool,
}
-/// Manager for payment session Redis operations
-pub struct PaymentSessionManager;
+/// Manager for client session Redis operations
+pub struct ClientSessionManager;
-impl PaymentSessionManager {
- /// Generate Redis key in format: payment_session:{processor_merchant_id}:{payment_id}
+impl ClientSessionManager {
+ /// Generate Redis key in format: client_session:{processor_merchant_id}:{payment_id}
/// We have a unique constraint on (processor_merchant_id, payment_id), so using them
/// for creating the redis key
fn get_session_key(processor_merchant_id: &MerchantId, payment_id: &PaymentId) -> String {
format!(
"{}:{}:{}",
- consts::PAYMENT_SESSION_KEY_PREFIX,
+ consts::CLIENT_SESSION_KEY_PREFIX,
processor_merchant_id.get_string_repr(),
payment_id.get_string_repr()
)
}
- /// Create a new payment session and store in Redis with TTL
+ /// Create a new client session and store in Redis with TTL
///
/// # Arguments
/// * `state` - Application state with Redis connection
@@ -64,7 +64,7 @@ impl PaymentSessionManager {
processor_merchant_id: &MerchantId,
payment_id: &PaymentId,
session_expiry: Option<PrimitiveDateTime>,
- ) -> CustomResult<id_type::PaymentSessionId, errors::ApiErrorResponse>
+ ) -> CustomResult<id_type::ClientSessionId, errors::ApiErrorResponse>
where
S: SessionStateInfo + Sync,
{
@@ -76,7 +76,7 @@ impl PaymentSessionManager {
let session_expiry = session_expiry.unwrap_or_else(Self::get_default_session_expiry);
// Generate a unique session ID
- let payment_session_id = id_type::PaymentSessionId::generate();
+ let client_session_id = id_type::ClientSessionId::generate();
let key = Self::get_session_key(processor_merchant_id, payment_id);
@@ -93,8 +93,8 @@ impl PaymentSessionManager {
}?;
// Create session data structure
- let session_data = PaymentSessionData {
- payment_session_id: payment_session_id.clone(),
+ let session_data = ClientSessionData {
+ client_session_id: client_session_id.clone(),
created_at: now,
expires_at: session_expiry,
};
@@ -109,13 +109,13 @@ impl PaymentSessionManager {
processor_merchant_id = %processor_merchant_id.get_string_repr(),
payment_id = %payment_id.get_string_repr(),
ttl_seconds,
- "Created payment session"
+ "Created client session"
);
- Ok(payment_session_id)
+ Ok(client_session_id)
}
- /// Get payment session data from Redis
+ /// Get client session data from Redis
///
/// # Arguments
/// * `state` - Application state with Redis connection
@@ -129,7 +129,7 @@ impl PaymentSessionManager {
state: &S,
processor_merchant_id: &MerchantId,
payment_id: &PaymentId,
- ) -> CustomResult<Option<PaymentSessionData>, errors::ApiErrorResponse>
+ ) -> CustomResult<Option<ClientSessionData>, errors::ApiErrorResponse>
where
S: SessionStateInfo + Sync,
{
@@ -141,14 +141,14 @@ impl PaymentSessionManager {
let key = Self::get_session_key(processor_merchant_id, payment_id);
match redis_conn
- .get_and_deserialize_key::<PaymentSessionData>(&key.into(), "PaymentSessionData")
+ .get_and_deserialize_key::<ClientSessionData>(&key.into(), "ClientSessionData")
.await
{
Ok(session_data) => {
logger::debug!(
processor_merchant_id = %processor_merchant_id.get_string_repr(),
payment_id = %payment_id.get_string_repr(),
- "Retrieved payment session"
+ "Retrieved client session"
);
Ok(Some(session_data))
}
@@ -158,7 +158,7 @@ impl PaymentSessionManager {
logger::debug!(
processor_merchant_id = %processor_merchant_id.get_string_repr(),
payment_id = %payment_id.get_string_repr(),
- "No payment session found"
+ "No client session found"
);
Ok(None)
} else {
@@ -183,37 +183,45 @@ impl PaymentSessionManager {
state: &S,
processor_merchant_id: &MerchantId,
payment_id: &PaymentId,
- payment_session_id: &id_type::PaymentSessionId,
+ client_session_id: &id_type::ClientSessionId,
) -> CustomResult<bool, errors::ApiErrorResponse>
where
S: SessionStateInfo + Sync,
{
let session = Self::get_session(state, processor_merchant_id, payment_id)
.await
- .attach_printable("Unable to retrieve payment session")?;
+ .attach_printable("Unable to retrieve client session")?;
match session {
Some(data) => {
- let is_valid = &data.payment_session_id == payment_session_id;
- logger::debug!(
- processor_merchant_id = %processor_merchant_id.get_string_repr(),
- payment_id = %payment_id.get_string_repr(),
- "Validated payment session"
- );
+ let is_valid = &data.client_session_id == client_session_id;
+ if !is_valid {
+ logger::error!(
+ processor_merchant_id = %processor_merchant_id.get_string_repr(),
+ payment_id = %payment_id.get_string_repr(),
+ "Invalid client session ID"
+ );
+ } else {
+ logger::debug!(
+ processor_merchant_id = %processor_merchant_id.get_string_repr(),
+ payment_id = %payment_id.get_string_repr(),
+ "Validated client session"
+ );
+ }
Ok(is_valid)
}
None => {
logger::error!(
processor_merchant_id = %processor_merchant_id.get_string_repr(),
payment_id = %payment_id.get_string_repr(),
- "Payment session not found for validation"
+ "Client session not found for validation"
);
Ok(false)
}
}
}
- /// Recreate payment session (invalidate old + create new)
+ /// Recreate client session (invalidate old + create new)
///
/// Convenience method that combines invalidate_session and create_session
/// for payment update scenarios.
@@ -232,10 +240,7 @@ impl PaymentSessionManager {
processor_merchant_id: &MerchantId,
payment_id: &PaymentId,
session_expiry: Option<PrimitiveDateTime>,
- ) -> CustomResult<
- (id_type::PaymentSessionId, SessionInvalidationReport),
- errors::ApiErrorResponse,
- >
+ ) -> CustomResult<(id_type::ClientSessionId, SessionInvalidationReport), errors::ApiErrorResponse>
where
S: SessionStateInfo + Sync,
{
@@ -260,7 +265,7 @@ impl PaymentSessionManager {
processor_merchant_id = %processor_merchant_id.get_string_repr(),
payment_id = %payment_id.get_string_repr(),
session_existed = report.session_existed,
- "Recreated payment session"
+ "Recreated client session"
);
Ok((new_session_id, report))
diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs
index e63f6414e6..4844cb2573 100644
--- a/crates/router/src/core/payments/operations/payment_approve.rs
+++ b/crates/router/src/core/payments/operations/payment_approve.rs
@@ -202,7 +202,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index 6a0c7075e0..51677b5576 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -214,7 +214,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
index 43bbe2ee2a..4108a16ba0 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
@@ -197,7 +197,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs
index 8cfe418c47..da525e7e8b 100644
--- a/crates/router/src/core/payments/operations/payment_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_capture.rs
@@ -270,7 +270,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index b72b16f00b..248abd32da 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -376,7 +376,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
is_manual_retry_enabled: None,
is_l2_l3_enabled: business_profile.is_l2_l3_enabled,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let customer_details = Some(CustomerDetails {
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 8799222373..a5a4af16ef 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -942,7 +942,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
is_manual_retry_enabled: business_profile.is_manual_retry_enabled,
is_l2_l3_enabled: business_profile.is_l2_l3_enabled,
external_authentication_data: request.three_ds_data.clone(),
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 6b77f5dbc7..b616ca762a 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -37,7 +37,7 @@ use crate::{
payment_link,
payment_methods::transformers as pm_transformers,
payments::{
- self, helpers, operations, payment_session::PaymentSessionManager, CustomerDetails,
+ self, client_session::ClientSessionManager, helpers, operations, CustomerDetails,
PaymentAddress, PaymentData,
},
utils as core_utils,
@@ -628,22 +628,22 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let unified_address = address.unify_with_payment_method_data_billing(add);
- // Check if payment session validation is enabled
+ // Check if client session validation is enabled
let dimensions = Dimensions::new()
.with_merchant_id(platform.get_processor().get_account().get_id().clone());
let session_validation_enabled = dimensions
- .get_payment_session_validation_enabled(
+ .get_client_session_validation_enabled(
state.store.as_ref(),
state.superposition_service.as_deref(),
None,
)
.await;
- // Generate payment session for the payment only if validation is enabled
- let payment_session_id = if session_validation_enabled {
+ // Generate client session for the payment only if validation is enabled
+ let client_session_id = if session_validation_enabled {
Some(
- PaymentSessionManager::create_session(
+ ClientSessionManager::create_session(
state,
platform.get_processor().get_account().get_id(),
&payment_id,
@@ -651,7 +651,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to create payment session")?,
+ .attach_printable("Failed to create client session")?,
)
} else {
None
@@ -705,7 +705,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
is_manual_retry_enabled: None,
is_l2_l3_enabled: business_profile.is_l2_l3_enabled,
external_authentication_data: request.three_ds_data.clone(),
- payment_session_id,
+ client_session_id,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
index 128b9a54f3..8e6eb07c05 100644
--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
@@ -182,7 +182,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSess
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
diff --git a/crates/router/src/core/payments/operations/payment_recurrence.rs b/crates/router/src/core/payments/operations/payment_recurrence.rs
index df337e54fb..51d6b3a115 100644
--- a/crates/router/src/core/payments/operations/payment_recurrence.rs
+++ b/crates/router/src/core/payments/operations/payment_recurrence.rs
@@ -386,7 +386,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
is_manual_retry_enabled: business_profile.is_manual_retry_enabled,
is_l2_l3_enabled: business_profile.is_l2_l3_enabled,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs
index 7e8987bc0e..f341ea33cf 100644
--- a/crates/router/src/core/payments/operations/payment_reject.rs
+++ b/crates/router/src/core/payments/operations/payment_reject.rs
@@ -201,7 +201,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index e5cd8d5141..aac497e201 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -227,7 +227,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index 46283c4709..f449e146a8 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -223,7 +223,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index c11ed06235..1077e875dc 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -567,7 +567,7 @@ async fn get_tracker_for_sync<
is_manual_retry_enabled: business_profile.is_manual_retry_enabled,
is_l2_l3_enabled: business_profile.is_l2_l3_enabled,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index 1002696295..0871ade56e 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -24,7 +24,7 @@ use crate::{
mandate::helpers as m_helpers,
payment_methods::cards::create_encrypted_data,
payments::{
- self, helpers, operations, payment_session::PaymentSessionManager, CustomerDetails,
+ self, client_session::ClientSessionManager, helpers, operations, CustomerDetails,
PaymentAddress, PaymentData,
},
utils as core_utils,
@@ -566,7 +566,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
is_manual_retry_enabled: None,
is_l2_l3_enabled: business_profile.is_l2_l3_enabled,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
@@ -1085,11 +1085,11 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
let processor_merchant_id = processor.get_account().get_id().clone();
let payment_id = payment_data.payment_intent.payment_id.clone();
- // Check if payment session validation is enabled
+ // Check if client session validation is enabled
let dimensions = Dimensions::new().with_merchant_id(processor_merchant_id.clone());
let session_validation_enabled = dimensions
- .get_payment_session_validation_enabled(
+ .get_client_session_validation_enabled(
state.store.as_ref(),
state.superposition_service.as_deref(),
None,
@@ -1098,8 +1098,8 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
// Recreate session only if validation is enabled
if session_validation_enabled {
- let (new_payment_session_id, invalidation_report) =
- PaymentSessionManager::recreate_session(
+ let (new_client_session_id, invalidation_report) =
+ ClientSessionManager::recreate_session(
state,
&processor_merchant_id,
&payment_id,
@@ -1107,16 +1107,16 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to refresh payment session during payment update")?;
+ .attach_printable("Failed to refresh client session during payment update")?;
services::logger::debug!(
payment_id = %payment_id.get_string_repr(),
session_existed = invalidation_report.session_existed,
- "Payment session recreated during update"
+ "Client session recreated during update"
);
// Update payment_data with new session_id
- payment_data.payment_session_id = Some(new_payment_session_id);
+ payment_data.client_session_id = Some(new_client_session_id);
}
let amount = payment_data.amount;
diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rs
index 407afdb024..62b927e533 100644
--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs
+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs
@@ -188,7 +188,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsUpdateMe
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
index 982ddb2784..a22ae1d762 100644
--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
@@ -203,7 +203,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsExtendAu
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
index d2e832dc0a..7f66a407b5 100644
--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
@@ -182,7 +182,7 @@ impl<F: Send + Clone + Sync>
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs
index 90e52ea34a..48096e828c 100644
--- a/crates/router/src/core/payments/operations/tax_calculation.rs
+++ b/crates/router/src/core/payments/operations/tax_calculation.rs
@@ -198,7 +198,7 @@ impl<F: Send + Clone + Sync>
is_manual_retry_enabled: None,
is_l2_l3_enabled: false,
external_authentication_data: None,
- payment_session_id: None,
+ client_session_id: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index ce778b1070..1344f52b42 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -3986,7 +3986,8 @@ where
.clone()
.get_required_value("client_secret")?,
customer_id: payment_intent.customer_id.clone(),
- payment_session_id: payment_data.get_payment_session_id(),
+ client_session_id: payment_data.get_client_session_id(),
+ payment_id: Some(payment_intent.payment_id.clone()),
};
let sdk_authorization = sdk_auth_data
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 4a96fb33de..c235db6ccc 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -53,7 +53,7 @@ use crate::{
SDK_AUTH_INVALID_SESSION_TOTAL, SDK_AUTH_LEGACY_FLOW_TOTAL,
SDK_AUTH_SESSION_VALIDATED_TOTAL,
},
- payments::payment_session::PaymentSessionManager,
+ payments::client_session::ClientSessionManager,
},
headers,
routes::app::SessionStateInfo,
@@ -3436,14 +3436,14 @@ where
)
.await?;
- // Taking processor_merchant_id for payment session validation as we have a unique constraint on (processor_merchant_id, payment_id)
+ // Taking processor_merchant_id for client session validation as we have a unique constraint on (processor_merchant_id, payment_id)
let processor_merchant_id = platform.get_processor().get_account().get_id();
- // Check if payment session validation is enabled
+ // Check if client session validation is enabled
let dimensions = Dimensions::new().with_merchant_id(processor_merchant_id.clone());
let session_validation_enabled = dimensions
- .get_payment_session_validation_enabled(
+ .get_client_session_validation_enabled(
state.store().as_ref(),
state.superposition_service().as_deref(),
None,
@@ -3452,8 +3452,8 @@ where
// Validate session_id if present and validation is enabled
if session_validation_enabled {
- match sdk_auth.payment_session_id {
- Some(payment_session_id) => {
+ match sdk_auth.client_session_id {
+ Some(client_session_id) => {
let payment_id =
crate::core::payments::helpers::get_payment_id_from_client_secret(
&client_secret,
@@ -3464,15 +3464,15 @@ where
.attach_printable("Invalid payment_id in client_secret")?;
// Validate session
- PaymentSessionManager::validate_session(
+ ClientSessionManager::validate_session(
state,
processor_merchant_id,
&payment_id,
- &payment_session_id,
+ &client_session_id,
)
.await
.change_context(errors::ApiErrorResponse::Unauthorized)
- .attach_printable("Failed to validate payment session")?
+ .attach_printable("Failed to validate client session")?
.then_some(())
.ok_or_else(|| {
SDK_AUTH_INVALID_SESSION_TOTAL.add(
@@ -3508,7 +3508,7 @@ where
}
}
} else {
- logger::info!("Payment session validation is disabled");
+ logger::info!("Client session validation is disabled");
}
let profile = state