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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(auth): restructure authentication to use unified Platform model with initiator tracking (#10746)
Sandeep Kumard4b19d8e9901
diff --git a/crates/hyperswitch_domain_models/src/platform.rs b/crates/hyperswitch_domain_models/src/platform.rsindex 49fcab756a..15b0658f38 100644--- a/crates/hyperswitch_domain_models/src/platform.rs+++ b/crates/hyperswitch_domain_models/src/platform.rs@@ -49,6 +49,19 @@ impl Processor {}}+/// Initiator = The entity that initiated the operation.+#[derive(Clone, Debug)]+pub enum Initiator {+ Api {+ merchant_id: common_utils::id_type::MerchantId,+ merchant_account_type: common_enums::MerchantAccountType,+ },+ Jwt {+ user_id: String,+ },+ Admin,+}+/// Platform holds both Provider and Processor together./// This struct makes it possible to distinguish the business owner for the org versus whose processor credentials are used for execution./// For a standard merchant flow, provider == processor.@@ -56,6 +69,7 @@ impl Processor {pub struct Platform {provider: Box<Provider>,processor: Box<Processor>,+ initiator: Option<Initiator>,}impl Platform {@@ -67,12 +81,14 @@ impl Platform {provider_key_store: MerchantKeyStore,processor_account: MerchantAccount,processor_key_store: MerchantKeyStore,+ initiator: Option<Initiator>,) -> Self {let provider = Provider::new(provider_account, provider_key_store);let processor = Processor::new(processor_account, processor_key_store);Self {provider: Box::new(provider),processor: Box::new(processor),+ initiator,}}@@ -85,4 +101,10 @@ impl Platform {pub fn get_processor(&self) -> &Processor {&self.processor}++ /// Returns a reference to the initiator.+ /// Returns None if the initiator is not known or not applicable.+ pub fn get_initiator(&self) -> Option<&Initiator> {+ self.initiator.as_ref()+ }}diff --git a/crates/router/src/analytics.rs b/crates/router/src/analytics.rsindex 817cacbf09..a09729b26c 100644--- a/crates/router/src/analytics.rs+++ b/crates/router/src/analytics.rs@@ -515,8 +515,8 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -565,7 +565,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -621,12 +621,14 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -676,8 +678,8 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -727,7 +729,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -783,12 +785,14 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -838,8 +842,8 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -889,7 +893,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -945,12 +949,14 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -1000,9 +1006,13 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- analytics::frm::get_metrics(&state.pool, auth.merchant_account.get_id(), req)- .await- .map(ApplicationResponse::Json)+ analytics::frm::get_metrics(+ &state.pool,+ auth.platform.get_processor().get_account().get_id(),+ req,+ )+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth {permission: Permission::MerchantAnalyticsRead,@@ -1037,7 +1047,7 @@ pub mod routes {|state, auth: AuthenticationData, req, _| async move {analytics::sdk_events::get_metrics(&state.pool,- &auth.merchant_account.publishable_key,+ &auth.platform.get_processor().get_account().publishable_key,req,).await@@ -1076,8 +1086,8 @@ pub mod routes {|state, auth: AuthenticationData, req, _| async move {analytics::active_payments::get_metrics(&state.pool,- &auth.merchant_account.publishable_key,- auth.merchant_account.get_id(),+ &auth.platform.get_processor().get_account().publishable_key,+ auth.platform.get_processor().get_account().get_id(),req,).await@@ -1114,8 +1124,8 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -1156,12 +1166,14 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -1202,7 +1214,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -1237,8 +1249,8 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -1267,8 +1279,8 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),@@ -1299,7 +1311,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -1336,13 +1348,14 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;-+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -1373,7 +1386,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -1409,12 +1422,14 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -1448,7 +1463,7 @@ pub mod routes {analytics::payment_intents::get_filters(&state.pool,req,- auth.merchant_account.get_id(),+ auth.platform.get_processor().get_account().get_id(),).await.map(ApplicationResponse::Json)@@ -1480,8 +1495,8 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req: GetRefundFilterRequest, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -1511,7 +1526,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req: GetRefundFilterRequest, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -1547,12 +1562,14 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req: GetRefundFilterRequest, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -1582,9 +1599,13 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req: GetFrmFilterRequest, _| async move {- analytics::frm::get_filters(&state.pool, req, auth.merchant_account.get_id())- .await- .map(ApplicationResponse::Json)+ analytics::frm::get_filters(+ &state.pool,+ req,+ auth.platform.get_processor().get_account().get_id(),+ )+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth {permission: Permission::MerchantAnalyticsRead,@@ -1610,7 +1631,7 @@ pub mod routes {analytics::sdk_events::get_filters(&state.pool,req,- &auth.merchant_account.publishable_key,+ &auth.platform.get_processor().get_account().publishable_key,).await.map(ApplicationResponse::Json)@@ -1640,12 +1661,26 @@ pub mod routes {QueryType::Refund { payment_id, .. } => payment_id,QueryType::Dispute { payment_id, .. } => payment_id,};- utils::check_if_profile_id_is_present_in_payment_intent(payment_id, &state, &auth)- .await- .change_context(AnalyticsError::AccessForbiddenError)?;- api_events_core(&state.pool, req, auth.merchant_account.get_id())- .await- .map(ApplicationResponse::Json)+ #[cfg(feature = "v1")]+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ #[cfg(feature = "v2")]+ let profile_id = Some(auth.profile.get_id().clone());++ utils::check_if_profile_id_is_present_in_payment_intent(+ payment_id,+ &state,+ auth.platform.get_processor(),+ profile_id,+ )+ .await+ .change_context(AnalyticsError::AccessForbiddenError)?;+ api_events_core(+ &state.pool,+ req,+ auth.platform.get_processor().get_account().get_id(),+ )+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth {permission: Permission::ProfileAnalyticsRead,@@ -1669,16 +1704,25 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {+ #[cfg(feature = "v1")]+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ #[cfg(feature = "v2")]+ let profile_id = Some(auth.profile.get_id().clone());utils::check_if_profile_id_is_present_in_payment_intent(req.payment_id.clone(),&state,- &auth,+ auth.platform.get_processor(),+ profile_id,).await.change_context(AnalyticsError::AccessForbiddenError)?;- outgoing_webhook_events_core(&state.pool, req, auth.merchant_account.get_id())- .await- .map(ApplicationResponse::Json)+ outgoing_webhook_events_core(+ &state.pool,+ req,+ auth.platform.get_processor().get_account().get_id(),+ )+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth {permission: Permission::ProfileAnalyticsRead,@@ -1701,16 +1745,22 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());utils::check_if_profile_id_is_present_in_payment_intent(req.payment_id.clone(),&state,- &auth,+ auth.platform.get_processor(),+ profile_id,).await.change_context(AnalyticsError::AccessForbiddenError)?;- sdk_events_core(&state.pool, req, &auth.merchant_account.publishable_key)- .await- .map(ApplicationResponse::Json)+ sdk_events_core(+ &state.pool,+ req,+ &auth.platform.get_processor().get_account().publishable_key,+ )+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth {permission: Permission::ProfileAnalyticsRead,@@ -1741,8 +1791,8 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -1792,7 +1842,7 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: None,@@ -1841,12 +1891,14 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -1896,8 +1948,8 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -1946,7 +1998,7 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: None,@@ -1995,12 +2047,14 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -2051,8 +2105,8 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -2102,7 +2156,7 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: None,@@ -2150,12 +2204,14 @@ pub mod routes {let user_email = UserEmail::from_pii_email(user.email).change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -2206,8 +2262,8 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -2257,7 +2313,7 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: None,@@ -2305,12 +2361,14 @@ pub mod routes {let user_email = UserEmail::from_pii_email(user.email).change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -2361,8 +2419,8 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -2412,7 +2470,7 @@ pub mod routes {.change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let lambda_req = GenerateReportRequest {request: payload,merchant_id: None,@@ -2460,12 +2518,14 @@ pub mod routes {let user_email = UserEmail::from_pii_email(user.email).change_context(AnalyticsError::UnknownError)?.get_secret();- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let lambda_req = GenerateReportRequest {request: payload,merchant_id: Some(merchant_id.clone()),@@ -2519,7 +2579,7 @@ pub mod routes {|state, auth: AuthenticationData, req, _| async move {analytics::api_event::get_api_event_metrics(&state.pool,- auth.merchant_account.get_id(),+ auth.platform.get_processor().get_account().get_id(),req,).await@@ -2545,9 +2605,13 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- analytics::api_event::get_filters(&state.pool, req, auth.merchant_account.get_id())- .await- .map(ApplicationResponse::Json)+ analytics::api_event::get_filters(+ &state.pool,+ req,+ auth.platform.get_processor().get_account().get_id(),+ )+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth {permission: Permission::MerchantAnalyticsRead,@@ -2569,16 +2633,25 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {+ #[cfg(feature = "v1")]+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ #[cfg(feature = "v2")]+ let profile_id = Some(auth.profile.get_id().clone());utils::check_if_profile_id_is_present_in_payment_intent(req.payment_id.clone(),&state,- &auth,+ auth.platform.get_processor(),+ profile_id,).await.change_context(AnalyticsError::AccessForbiddenError)?;- connector_events_core(&state.pool, req, auth.merchant_account.get_id())- .await- .map(ApplicationResponse::Json)+ connector_events_core(+ &state.pool,+ req,+ auth.platform.get_processor().get_account().get_id(),+ )+ .await+ .map(ApplicationResponse::Json)},&auth::JWTAuth {permission: Permission::ProfileAnalyticsRead,@@ -2600,16 +2673,25 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {+ #[cfg(feature = "v1")]+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ #[cfg(feature = "v2")]+ let profile_id = Some(auth.profile.get_id().clone());utils::check_if_profile_id_is_present_in_payment_intent(req.payment_id.clone(),&state,- &auth,+ auth.platform.get_processor(),+ profile_id,).await.change_context(AnalyticsError::AccessForbiddenError)?;- routing_events_core(&state.pool, req, auth.merchant_account.get_id())- .await- .map(ApplicationResponse::Json)+ routing_events_core(+ &state.pool,+ req,+ auth.platform.get_processor().get_account().get_id(),+ )+ .await+ .map(ApplicationResponse::Json)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -2935,8 +3017,8 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -2966,12 +3048,14 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -3002,7 +3086,7 @@ pub mod routes {&req,json_payload.into_inner(),|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -3047,8 +3131,8 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -3088,12 +3172,14 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -3134,7 +3220,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -3170,8 +3256,8 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -3201,8 +3287,8 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let auth: AuthInfo = AuthInfo::MerchantLevel {org_id: org_id.clone(),merchant_ids: vec![merchant_id.clone()],@@ -3233,7 +3319,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -3270,12 +3356,14 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),@@ -3307,7 +3395,7 @@ pub mod routes {&req,payload,|state, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();let auth: AuthInfo = AuthInfo::OrgLevel {org_id: org_id.clone(),};@@ -3344,12 +3432,14 @@ pub mod routes {&req,payload,|state: crate::routes::SessionState, auth: AuthenticationData, req, _| async move {- let org_id = auth.merchant_account.get_org_id();- let merchant_id = auth.merchant_account.get_id();+ let org_id = auth.platform.get_processor().get_account().get_org_id();+ let merchant_id = auth.platform.get_processor().get_account().get_id();let profile_id = auth- .profile_id+ .profile.ok_or(report!(UserErrors::JwtProfileIdMissing))- .change_context(AnalyticsError::AccessForbiddenError)?;+ .change_context(AnalyticsError::AccessForbiddenError)?+ .get_id()+ .clone();let auth: AuthInfo = AuthInfo::ProfileLevel {org_id: org_id.clone(),merchant_id: merchant_id.clone(),diff --git a/crates/router/src/compatibility/stripe/customers.rs b/crates/router/src/compatibility/stripe/customers.rsindex 3d7ac7a5b6..1d6d3430a4 100644--- a/crates/router/src/compatibility/stripe/customers.rs+++ b/crates/router/src/compatibility/stripe/customers.rs@@ -14,10 +14,7 @@ use crate::{core::{api_locking, customers, payment_methods::cards},routes,services::{api, authentication as auth},- types::{- api::{customers as customer_types, payment_methods},- domain,- },+ types::api::{customers as customer_types, payment_methods},};#[cfg(feature = "v1")]#[instrument(skip_all, fields(flow = ?Flow::CustomersCreate))]@@ -53,8 +50,7 @@ pub async fn customer_create(&req,create_cust_req,|state, auth: auth::AuthenticationData, req, _| {- let platform: domain::Platform = auth.into();- customers::create_customer(state, platform.get_provider().clone(), req, None)+ customers::create_customer(state, auth.platform.get_provider().clone(), req, None)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: true,@@ -91,8 +87,12 @@ pub async fn customer_retrieve(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- let platform: domain::Platform = auth.into();- customers::retrieve_customer(state, platform.get_provider().clone(), None, customer_id)+ customers::retrieve_customer(+ state,+ auth.platform.get_provider().clone(),+ None,+ customer_id,+ )},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: true,@@ -143,8 +143,11 @@ pub async fn customer_update(&req,request_internal,|state, auth: auth::AuthenticationData, request_internal, _| {- let platform: domain::Platform = auth.into();- customers::update_customer(state, platform.get_provider().clone(), request_internal)+ customers::update_customer(+ state,+ auth.platform.get_provider().clone(),+ request_internal,+ )},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: true,@@ -181,8 +184,7 @@ pub async fn customer_delete(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- let platform: domain::Platform = auth.into();- customers::delete_customer(state, platform.get_provider().clone(), customer_id)+ customers::delete_customer(state, auth.platform.get_provider().clone(), customer_id)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: true,@@ -220,10 +222,9 @@ pub async fn list_customer_payment_method_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();cards::do_list_customer_pm_fetch_customer_if_not_passed(state,- platform,+ auth.platform,Some(req),Some(&customer_id),None,diff --git a/crates/router/src/compatibility/stripe/payment_intents.rs b/crates/router/src/compatibility/stripe/payment_intents.rsindex 95bcae519c..0f7f2af172 100644--- a/crates/router/src/compatibility/stripe/payment_intents.rs+++ b/crates/router/src/compatibility/stripe/payment_intents.rs@@ -72,7 +72,6 @@ pub async fn payment_intents_create(&req,create_payment_req,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.into();let eligible_connectors = req.connector.clone();payments::payments_core::<api_types::Authorize,@@ -84,7 +83,7 @@ pub async fn payment_intents_create(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentCreate,req,@@ -153,7 +152,6 @@ pub async fn payment_intents_retrieve(&req,payload,|state, auth, payload, req_state| {- let platform = auth.into();payments::payments_core::<api_types::PSync,api_types::PaymentsResponse,@@ -164,7 +162,7 @@ pub async fn payment_intents_retrieve(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentStatus,payload,@@ -238,7 +236,6 @@ pub async fn payment_intents_retrieve_with_gateway_creds(&req,payload,|state, auth, req, req_state| {- let platform = auth.into();payments::payments_core::<api_types::PSync,payment_types::PaymentsResponse,@@ -249,7 +246,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentStatus,req,@@ -319,7 +316,6 @@ pub async fn payment_intents_update(&req,payload,|state, auth, req, req_state| {- let platform = auth.into();let eligible_connectors = req.connector.clone();payments::payments_core::<api_types::Authorize,@@ -331,7 +327,7 @@ pub async fn payment_intents_update(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentUpdate,req,@@ -410,7 +406,6 @@ pub async fn payment_intents_confirm(&req,payload,|state, auth, req, req_state| {- let platform = auth.into();let eligible_connectors = req.connector.clone();payments::payments_core::<api_types::Authorize,@@ -422,7 +417,7 @@ pub async fn payment_intents_confirm(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentConfirm,req,@@ -483,7 +478,6 @@ pub async fn payment_intents_capture(&req,payload,|state, auth: auth::AuthenticationData, payload, req_state| {- let platform = auth.into();payments::payments_core::<api_types::Capture,api_types::PaymentsResponse,@@ -494,7 +488,7 @@ pub async fn payment_intents_capture(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentCapture,payload,@@ -567,7 +561,6 @@ pub async fn payment_intents_cancel(&req,payload,|state, auth, req, req_state| {- let platform = auth.into();payments::payments_core::<api_types::Void,api_types::PaymentsResponse,@@ -578,7 +571,7 @@ pub async fn payment_intents_cancel(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentCancel,req,@@ -622,8 +615,7 @@ pub async fn payment_intent_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payments::list_payments(state, platform, None, req)+ payments::list_payments(state, auth.platform, None, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,diff --git a/crates/router/src/compatibility/stripe/refunds.rs b/crates/router/src/compatibility/stripe/refunds.rsindex 2d50618168..ad646f282c 100644--- a/crates/router/src/compatibility/stripe/refunds.rs+++ b/crates/router/src/compatibility/stripe/refunds.rs@@ -50,8 +50,7 @@ pub async fn refund_create(&req,create_refund_req,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- refunds::refund_create_core(state, platform, None, req)+ refunds::refund_create_core(state, auth.platform, None, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -98,10 +97,9 @@ pub async fn refund_retrieve_with_gateway_creds(&req,refund_request,|state, auth: auth::AuthenticationData, refund_request, _| {- let platform = auth.into();refunds::refund_response_wrapper(state,- platform,+ auth.platform,None,refund_request,refunds::refund_retrieve_core_with_refund_id,@@ -145,10 +143,9 @@ pub async fn refund_retrieve(&req,refund_request,|state, auth: auth::AuthenticationData, refund_request, _| {- let platform = auth.into();refunds::refund_response_wrapper(state,- platform,+ auth.platform,None,refund_request,refunds::refund_retrieve_core_with_refund_id,@@ -189,8 +186,7 @@ pub async fn refund_update(&req,create_refund_update_req,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- refunds::refund_update_core(state, platform, req)+ refunds::refund_update_core(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,diff --git a/crates/router/src/compatibility/stripe/setup_intents.rs b/crates/router/src/compatibility/stripe/setup_intents.rsindex 4c47638c57..9ec104e80f 100644--- a/crates/router/src/compatibility/stripe/setup_intents.rs+++ b/crates/router/src/compatibility/stripe/setup_intents.rs@@ -59,7 +59,6 @@ pub async fn setup_intents_create(&req,create_payment_req,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.into();payments::payments_core::<api_types::SetupMandate,api_types::PaymentsResponse,@@ -70,7 +69,7 @@ pub async fn setup_intents_create(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentCreate,req,@@ -139,7 +138,6 @@ pub async fn setup_intents_retrieve(&req,payload,|state, auth, payload, req_state| {- let platform = auth.into();payments::payments_core::<api_types::PSync,api_types::PaymentsResponse,@@ -150,7 +148,7 @@ pub async fn setup_intents_retrieve(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentStatus,payload,@@ -221,7 +219,6 @@ pub async fn setup_intents_update(&req,payload,|state, auth, req, req_state| {- let platform = auth.into();payments::payments_core::<api_types::SetupMandate,api_types::PaymentsResponse,@@ -232,7 +229,7 @@ pub async fn setup_intents_update(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentUpdate,req,@@ -304,7 +301,6 @@ pub async fn setup_intents_confirm(&req,payload,|state, auth, req, req_state| {- let platform = auth.into();payments::payments_core::<api_types::SetupMandate,api_types::PaymentsResponse,@@ -315,7 +311,7 @@ pub async fn setup_intents_confirm(>(state,req_state,- platform,+ auth.platform,None,payments::PaymentConfirm,req,diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex bbdd6af762..06ecd103e8 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -261,6 +261,7 @@ pub async fn create_merchant_account(key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);add_publishable_key_to_decision_service(&state, &platform);@@ -985,6 +986,7 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {key_store.clone(),merchant_account,key_store.clone(),+ None,);// Validate whether profile_id passed in request is valid and is linked to the merchant@@ -2027,7 +2029,7 @@ trait MerchantConnectorAccountCreateBridge {async fn validate_and_get_business_profile(self,- platform: &domain::Platform,+ processor: &domain::Processor,db: &dyn StorageInterface,) -> RouterResult<domain::Profile>;}@@ -2172,22 +2174,19 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {async fn validate_and_get_business_profile(self,- platform: &domain::Platform,+ processor: &domain::Processor,db: &dyn StorageInterface,) -> RouterResult<domain::Profile> {let profile_id = self.profile_id;// Check whether this profile belongs to the merchant- let business_profile = core_utils::validate_and_get_business_profile(- db,- platform.get_processor(),- Some(&profile_id),- )- .await?- .get_required_value("Profile")- .change_context(errors::ApiErrorResponse::ProfileNotFound {- id: profile_id.get_string_repr().to_owned(),- })?;+ let business_profile =+ core_utils::validate_and_get_business_profile(db, processor, Some(&profile_id))+ .await?+ .get_required_value("Profile")+ .change_context(errors::ApiErrorResponse::ProfileNotFound {+ id: profile_id.get_string_repr().to_owned(),+ })?;Ok(business_profile)}@@ -2376,28 +2375,23 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {/// or return a `MissingRequiredField` errorasync fn validate_and_get_business_profile(self,- platform: &domain::Platform,+ processor: &domain::Processor,db: &dyn StorageInterface,) -> RouterResult<domain::Profile> {- match self.profile_id.or(platform- .get_processor()- .get_account()- .default_profile- .clone())+ match self+ .profile_id+ .or(processor.get_account().default_profile.clone()){Some(profile_id) => {// Check whether this business profile belongs to the merchant- let business_profile = core_utils::validate_and_get_business_profile(- db,- platform.get_processor(),- Some(&profile_id),- )- .await?- .get_required_value("Profile")- .change_context(errors::ApiErrorResponse::ProfileNotFound {- id: profile_id.get_string_repr().to_owned(),- })?;+ let business_profile =+ core_utils::validate_and_get_business_profile(db, processor, Some(&profile_id))+ .await?+ .get_required_value("Profile")+ .change_context(errors::ApiErrorResponse::ProfileNotFound {+ id: profile_id.get_string_repr().to_owned(),+ })?;Ok(business_profile)}@@ -2406,9 +2400,9 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {let profile_name = format!("{business_country}_{business_label}");let business_profile = db.find_business_profile_by_profile_name_merchant_id(- platform.get_processor().get_key_store(),+ processor.get_key_store(),&profile_name,- platform.get_processor().get_account().get_id(),+ processor.get_account().get_id(),).await.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {@@ -2428,7 +2422,7 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {pub async fn create_connector(state: SessionState,req: api::MerchantConnectorCreate,- platform: domain::Platform,+ processor: domain::Processor,auth_profile_id: Option<id_type::ProfileId>,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {let store = state.store.as_ref();@@ -2448,7 +2442,7 @@ pub async fn create_connector(connector_metadata: &req.metadata,};- let merchant_id = platform.get_processor().get_account().get_id();+ let merchant_id = processor.get_account().get_id();connector_metadata.validate_apple_pay_certificates_in_mca_metadata()?;@@ -2456,12 +2450,12 @@ pub async fn create_connector(helpers::validate_business_details(req.business_country,req.business_label.as_ref(),- platform.get_processor(),+ &processor,)?;let business_profile = req.clone()- .validate_and_get_business_profile(&platform, store)+ .validate_and_get_business_profile(&processor, store).await?;#[cfg(feature = "v2")]@@ -2471,7 +2465,7 @@ pub async fn create_connector(.update_revenue_recovery_algorithm_under_profile(store,key_manager_state,- platform.get_processor().get_key_store(),+ processor.get_key_store(),common_enums::RevenueRecoveryAlgorithmType::Monitoring,).await?;@@ -2484,7 +2478,7 @@ pub async fn create_connector(db: store,merchant_id,profile_id: business_profile.get_id(),- key_store: platform.get_processor().get_key_store(),+ key_store: processor.get_key_store(),};pm_auth_config_validation.validate_pm_auth_config().await?;@@ -2501,7 +2495,7 @@ pub async fn create_connector(.update_specific_fields_in_merchant(merchant_id,storage::MerchantAccountUpdate::ModifiedAtUpdate,- platform.get_processor().get_key_store(),+ processor.get_key_store(),).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -2511,7 +2505,7 @@ pub async fn create_connector(.clone().create_domain_model_from_request(&state,- platform.get_processor().get_key_store().clone(),+ processor.get_key_store().clone(),&business_profile,key_manager_state,)@@ -2521,7 +2515,7 @@ pub async fn create_connector(.store.insert_merchant_connector_account(merchant_connector_account.clone(),- platform.get_processor().get_key_store(),+ processor.get_key_store(),).await.to_duplicate_response(@@ -2557,7 +2551,7 @@ pub async fn create_connector(merchant_connector_id: &mca.get_id(),store,business_profile,- key_store: platform.get_processor().get_key_store().to_owned(),+ key_store: processor.get_key_store().to_owned(),key_manager_state,};@@ -2632,29 +2626,17 @@ async fn validate_pm_auth(#[cfg(feature = "v1")]pub async fn retrieve_connector(state: SessionState,- merchant_id: id_type::MerchantId,+ processor: domain::Processor,profile_id: Option<id_type::ProfileId>,merchant_connector_id: id_type::MerchantConnectorAccountId,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {let store = state.store.as_ref();- let key_store = store- .get_merchant_key_store_by_merchant_id(- &merchant_id,- &store.get_master_key().to_vec().into(),- )- .await- .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;-- let _merchant_account = store- .find_merchant_account_by_merchant_id(&merchant_id, &key_store)- .await- .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;let mca = store.find_by_merchant_connector_account_merchant_id_merchant_connector_id(- &merchant_id,+ processor.get_account().get_id(),&merchant_connector_id,- &key_store,+ processor.get_key_store(),).await.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {@@ -2670,15 +2652,15 @@ pub async fn retrieve_connector(#[cfg(feature = "v2")]pub async fn retrieve_connector(state: SessionState,- platform: domain::Platform,+ processor: domain::Processor,id: id_type::MerchantConnectorAccountId,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {let store = state.store.as_ref();- let merchant_id = platform.get_processor().get_account().get_id();+ let merchant_id = processor.get_account().get_id();let mca = store- .find_merchant_connector_account_by_id(&id, platform.get_processor().get_key_store())+ .find_merchant_connector_account_by_id(&id, processor.get_key_store()).await.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {id: id.clone().get_string_repr().to_string(),@@ -2704,12 +2686,12 @@ pub async fn retrieve_connector(#[cfg(all(feature = "olap", feature = "v2"))]pub async fn list_connectors_for_a_profile(state: SessionState,- key_store: domain::MerchantKeyStore,+ processor: domain::Processor,profile_id: id_type::ProfileId,) -> RouterResponse<Vec<api_models::admin::MerchantConnectorListResponse>> {let store = state.store.as_ref();let merchant_connector_accounts = store- .list_connector_account_by_profile_id(&profile_id, &key_store)+ .list_connector_account_by_profile_id(&profile_id, processor.get_key_store()).await.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?;let mut response = vec![];@@ -2723,29 +2705,16 @@ pub async fn list_connectors_for_a_profile(pub async fn list_payment_connectors(state: SessionState,- merchant_id: id_type::MerchantId,+ processor: domain::Processor,profile_id_list: Option<Vec<id_type::ProfileId>>,) -> RouterResponse<Vec<api_models::admin::MerchantConnectorListResponse>> {let store = state.store.as_ref();- let key_store = store- .get_merchant_key_store_by_merchant_id(- &merchant_id,- &store.get_master_key().to_vec().into(),- )- .await- .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;-- // Validate merchant account- store- .find_merchant_account_by_merchant_id(&merchant_id, &key_store)- .await- .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;let merchant_connector_accounts = store.find_merchant_connector_account_by_merchant_id_and_disabled_list(- &merchant_id,+ processor.get_account().get_id(),true,- &key_store,+ processor.get_key_store(),).await.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?;@@ -2793,6 +2762,7 @@ pub async fn update_connector(key_store.clone(),merchant_account,key_store.clone(),+ None,);let payment_connector = req.clone()@@ -3176,7 +3146,7 @@ trait ProfileCreateBridge {async fn create_domain_model_from_request(self,state: &SessionState,- platform: &domain::Platform,+ processor: &domain::Processor,) -> RouterResult<domain::Profile>;#[cfg(feature = "v2")]@@ -3195,7 +3165,7 @@ impl ProfileCreateBridge for api::ProfileCreate {async fn create_domain_model_from_request(self,state: &SessionState,- platform: &domain::Platform,+ processor: &domain::Processor,) -> RouterResult<domain::Profile> {use common_utils::ext_traits::AsyncExt;@@ -3227,11 +3197,7 @@ impl ProfileCreateBridge for api::ProfileCreate {let payment_response_hash_key = self.payment_response_hash_key- .or(platform- .get_processor()- .get_account()- .payment_response_hash_key- .clone())+ .or(processor.get_account().payment_response_hash_key.clone()).unwrap_or(common_utils::crypto::generate_cryptographically_secure_random_string(64));let payment_link_config = self.payment_link_config.map(ForeignInto::foreign_into);@@ -3239,11 +3205,7 @@ impl ProfileCreateBridge for api::ProfileCreate {let outgoing_webhook_custom_http_headers = self.outgoing_webhook_custom_http_headers.async_map(|headers| {- cards::create_encrypted_data(- &key_manager_state,- platform.get_processor().get_key_store(),- headers,- )+ cards::create_encrypted_data(&key_manager_state, processor.get_key_store(), headers)}).await.transpose()@@ -3262,12 +3224,7 @@ impl ProfileCreateBridge for api::ProfileCreate {}).transpose()?;- let key = platform- .get_processor()- .get_key_store()- .key- .clone()- .into_inner();+ let key = processor.get_key_store().key.clone().into_inner();let key_manager_state = state.into();let card_testing_secret_key = Some(Secret::new(utils::generate_id(@@ -3306,58 +3263,39 @@ impl ProfileCreateBridge for api::ProfileCreate {Ok(domain::Profile::from(domain::ProfileSetter {profile_id,- merchant_id: platform.get_processor().get_account().get_id().clone(),+ merchant_id: processor.get_account().get_id().clone(),profile_name,created_at: current_time,modified_at: current_time,return_url: self.return_url.map(|return_url| return_url.to_string())- .or(platform.get_processor().get_account().return_url.clone()),- enable_payment_response_hash: self.enable_payment_response_hash.unwrap_or(- platform- .get_processor()- .get_account()- .enable_payment_response_hash,- ),+ .or(processor.get_account().return_url.clone()),+ enable_payment_response_hash: self+ .enable_payment_response_hash+ .unwrap_or(processor.get_account().enable_payment_response_hash),payment_response_hash_key: Some(payment_response_hash_key),redirect_to_merchant_with_http_post: self.redirect_to_merchant_with_http_post- .unwrap_or(- platform- .get_processor()- .get_account()- .redirect_to_merchant_with_http_post,- ),- webhook_details: webhook_details.or(platform- .get_processor()- .get_account()- .webhook_details- .clone()),+ .unwrap_or(processor.get_account().redirect_to_merchant_with_http_post),+ webhook_details: webhook_details.or(processor.get_account().webhook_details.clone()),metadata: self.metadata,routing_algorithm: None,intent_fulfillment_time: self.intent_fulfillment_time.map(i64::from)- .or(platform- .get_processor()- .get_account()- .intent_fulfillment_time)+ .or(processor.get_account().intent_fulfillment_time).or(Some(common_utils::consts::DEFAULT_INTENT_FULFILLMENT_TIME)),- frm_routing_algorithm: self.frm_routing_algorithm.or(platform- .get_processor()- .get_account()+ frm_routing_algorithm: self.frm_routing_algorithm- .clone()),+ .or(processor.get_account().frm_routing_algorithm.clone()),#[cfg(feature = "payouts")]- payout_routing_algorithm: self.payout_routing_algorithm.or(platform- .get_processor()- .get_account()+ payout_routing_algorithm: self.payout_routing_algorithm- .clone()),+ .or(processor.get_account().payout_routing_algorithm.clone()),#[cfg(not(feature = "payouts"))]payout_routing_algorithm: None,- is_recon_enabled: platform.get_processor().get_account().is_recon_enabled,+ is_recon_enabled: processor.get_account().is_recon_enabled,applepay_verified_domains: self.applepay_verified_domains,payment_link_config,session_expiry: self@@ -3402,7 +3340,7 @@ impl ProfileCreateBridge for api::ProfileCreate {common_utils::type_name!(domain::Profile),domain_types::CryptoOperation::EncryptOptional(inner),km_types::Identifier::Merchant(- platform.get_processor().get_key_store().merchant_id.clone(),+ processor.get_key_store().merchant_id.clone(),),key.peek(),)@@ -3594,27 +3532,27 @@ impl ProfileCreateBridge for api::ProfileCreate {pub async fn create_profile(state: SessionState,request: api::ProfileCreate,- platform: domain::Platform,+ processor: domain::Processor,) -> RouterResponse<api_models::admin::ProfileResponse> {let db = state.store.as_ref();#[cfg(feature = "v1")]let business_profile = request- .create_domain_model_from_request(&state, &platform)+ .create_domain_model_from_request(&state, &processor).await?;#[cfg(feature = "v2")]let business_profile = request.create_domain_model_from_request(&state,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().get_id(),+ processor.get_key_store(),+ processor.get_account().get_id(),).await?;let profile_id = business_profile.get_id().to_owned();let business_profile = db- .insert_business_profile(platform.get_processor().get_key_store(), business_profile)+ .insert_business_profile(processor.get_key_store(), business_profile).await.to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError {message: format!(@@ -3625,17 +3563,12 @@ pub async fn create_profile(.attach_printable("Failed to insert Business profile because of duplication error")?;#[cfg(feature = "v1")]- if platform- .get_processor()- .get_account()- .default_profile- .is_some()- {+ if processor.get_account().default_profile.is_some() {let unset_default_profile = domain::MerchantAccountUpdate::UnsetDefaultProfile;db.update_merchant(- platform.get_processor().get_account().clone(),+ processor.get_account().clone(),unset_default_profile,- platform.get_processor().get_key_store(),+ processor.get_key_store(),).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rsindex be477f0707..f1306aef94 100644--- a/crates/router/src/core/disputes.rs+++ b/crates/router/src/core/disputes.rs@@ -211,7 +211,7 @@ pub async fn get_filters_for_disputes(let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =super::admin::list_payment_connectors(state,- platform.get_processor().get_account().get_id().to_owned(),+ platform.get_processor().clone(),profile_id_list,).await?diff --git a/crates/router/src/core/locker_migration.rs b/crates/router/src/core/locker_migration.rsindex 62bf2eeda4..fbdb5d8524 100644--- a/crates/router/src/core/locker_migration.rs+++ b/crates/router/src/core/locker_migration.rs@@ -67,6 +67,7 @@ pub async fn rust_locker_migration(key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);for customer in domain_customers {let result = dbdiff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 88d063c839..46c1ae7fb5 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -4078,8 +4078,7 @@ pub async fn payment_methods_session_confirm((Some(tokenization_data), Some(customer_id)) => {let tokenization_response = tokenization_core::create_vault_token_core(state.clone(),- &platform.get_provider().get_account().clone(),- &platform.get_provider().get_key_store().clone(),+ platform.get_provider().clone(),api_models::tokenization::GenericTokenizationRequest {customer_id: customer_id.clone(),token_request: tokenization_data,diff --git a/crates/router/src/core/payment_methods/tokenize/card_executor.rs b/crates/router/src/core/payment_methods/tokenize/card_executor.rsindex 2dac934ed9..7b4114d1d2 100644--- a/crates/router/src/core/payment_methods/tokenize/card_executor.rs+++ b/crates/router/src/core/payment_methods/tokenize/card_executor.rs@@ -580,6 +580,7 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {self.key_store.clone(),self.merchant_account.clone(),self.key_store.clone(),+ None,);PmCards {state: self.state,diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex a110ad4387..7b6166e825 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -8614,7 +8614,7 @@ pub async fn get_payment_filters(let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =super::admin::list_payment_connectors(state,- platform.get_processor().get_account().get_id().to_owned(),+ platform.get_processor().clone(),profile_id_list,).await?diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex e98b38bc3e..0cf5998196 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -1000,12 +1000,7 @@ pub async fn get_payout_filters_core(platform: domain::Platform,) -> RouterResponse<api::PayoutListFiltersV2> {let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =- super::admin::list_payment_connectors(- state,- platform.get_processor().get_account().get_id().to_owned(),- None,- )- .await?+ super::admin::list_payment_connectors(state, platform.get_processor().clone(), None).await?{data} else {diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rsindex 84985af849..bf2bae528a 100644--- a/crates/router/src/core/pm_auth.rs+++ b/crates/router/src/core/pm_auth.rs@@ -809,6 +809,7 @@ pub async fn retrieve_payment_method_from_auth_service(key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let bank_account_creds = get_bank_account_creds(connector,diff --git a/crates/router/src/core/recon.rs b/crates/router/src/core/recon.rsindex 967e4ed3d5..e01a193389 100644--- a/crates/router/src/core/recon.rs+++ b/crates/router/src/core/recon.rs@@ -147,7 +147,7 @@ pub async fn generate_recon_token(pub async fn recon_merchant_account_update(state: SessionState,- auth: authentication::AuthenticationData,+ processor: domain::Processor,req: recon_api::ReconUpdateMerchantRequest,) -> RouterResponse<api_types::MerchantAccountResponse> {let db = &*state.store;@@ -155,13 +155,13 @@ pub async fn recon_merchant_account_update(let updated_merchant_account = storage::MerchantAccountUpdate::ReconUpdate {recon_status: req.recon_status,};- let merchant_id = auth.merchant_account.get_id().clone();+ let merchant_id = processor.get_account().get_id().clone();let updated_merchant_account = db.update_merchant(- auth.merchant_account.clone(),+ processor.get_account().clone(),updated_merchant_account,- &auth.key_store,+ processor.get_key_store(),).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -177,7 +177,7 @@ pub async fn recon_merchant_account_update(&state.clone(),ThemeLineage::Merchant {tenant_id: state.tenant.tenant_id.clone(),- org_id: auth.merchant_account.get_org_id().clone(),+ org_id: processor.get_account().get_org_id().clone(),merchant_id: merchant_id.clone(),},)diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rsindex 272bb39e3d..bd8edcc69a 100644--- a/crates/router/src/core/refunds.rs+++ b/crates/router/src/core/refunds.rs@@ -1585,7 +1585,7 @@ pub async fn get_filters_for_refunds(let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =super::admin::list_payment_connectors(state,- platform.get_processor().get_account().get_id().to_owned(),+ platform.get_processor().clone(),profile_id_list,).await?@@ -1868,6 +1868,7 @@ pub async fn sync_refund_with_gateway_workflow(key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let response = Box::pin(refund_retrieve_core_with_internal_reference_id(state.clone(),@@ -1984,6 +1985,7 @@ pub async fn trigger_refund_execute_workflow(key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let refund = db.find_refund_by_internal_reference_id_merchant_id(diff --git a/crates/router/src/core/revenue_recovery.rs b/crates/router/src/core/revenue_recovery.rsindex 630cbb7d1f..48cbb6a187 100644--- a/crates/router/src/core/revenue_recovery.rs+++ b/crates/router/src/core/revenue_recovery.rs@@ -582,6 +582,7 @@ pub async fn perform_calculate_workflow(revenue_recovery_payment_data.key_store.clone(),revenue_recovery_payment_data.merchant_account.clone(),revenue_recovery_payment_data.key_store.clone(),+ None,);let retry_algorithm_type = match profile@@ -1128,6 +1129,7 @@ pub async fn resume_revenue_recovery_process_tracker(revenue_recovery_payment_data.key_store.clone(),revenue_recovery_payment_data.merchant_account.clone(),revenue_recovery_payment_data.key_store.clone(),+ None,);let create_intent_response = payments::payments_intent_core::<router_api_types::PaymentGetIntent,diff --git a/crates/router/src/core/revenue_recovery/api.rs b/crates/router/src/core/revenue_recovery/api.rsindex c3ee068dc9..4f34c7bcb5 100644--- a/crates/router/src/core/revenue_recovery/api.rs+++ b/crates/router/src/core/revenue_recovery/api.rs@@ -45,6 +45,7 @@ pub async fn call_psync_api(revenue_recovery_data.key_store.clone(),revenue_recovery_data.merchant_account.clone(),revenue_recovery_data.key_store.clone(),+ None,);// TODO : Use api handler instead of calling get_tracker and payments_operation_core// Get the tracker related information. This includes payment intent and payment attempt@@ -111,6 +112,7 @@ pub async fn call_proxy_api(revenue_recovery_payment_data.key_store.clone(),revenue_recovery_payment_data.merchant_account.clone(),revenue_recovery_payment_data.key_store.clone(),+ None,);// TODO : Use api handler instead of calling get_tracker and payments_operation_core@@ -162,6 +164,7 @@ pub async fn update_payment_intent_api(revenue_recovery_payment_data.key_store.clone(),revenue_recovery_payment_data.merchant_account.clone(),revenue_recovery_payment_data.key_store.clone(),+ None,);let (payment_data, _req, _) = payments::payments_intent_operation_core::<api_types::PaymentUpdateIntent,@@ -224,6 +227,7 @@ pub async fn record_internal_attempt_api(revenue_recovery_payment_data.key_store.clone(),revenue_recovery_payment_data.merchant_account.clone(),revenue_recovery_payment_data.key_store.clone(),+ None,);let attempt_response = Box::pin(payments::record_attempt_core(diff --git a/crates/router/src/core/tokenization.rs b/crates/router/src/core/tokenization.rsindex bb4e807366..12a4d90458 100644--- a/crates/router/src/core/tokenization.rs+++ b/crates/router/src/core/tokenization.rs@@ -33,8 +33,7 @@ use crate::{#[cfg(all(feature = "v2", feature = "tokenization_v2"))]pub async fn create_vault_token_core(state: SessionState,- merchant_account: &domain::MerchantAccount,- merchant_key_store: &domain::MerchantKeyStore,+ provider: domain::Provider,req: api_models::tokenization::GenericTokenizationRequest,) -> RouterResponse<api_models::tokenization::GenericTokenizationResponse> {// Generate a unique vault ID@@ -67,7 +66,7 @@ pub async fn create_vault_token_core(// Create new tokenization recordlet tokenization_new = hyperswitch_domain_models::tokenization::Tokenization {id: id_type::GlobalTokenId::generate(&state.conf.cell_information.id),- merchant_id: merchant_account.get_id().clone(),+ merchant_id: provider.get_account().get_id().clone(),customer_id: customer_id.clone(),locker_id: stored_resp.vault_id.get_string_repr().to_string(),created_at: common_utils::date_time::now(),@@ -78,7 +77,7 @@ pub async fn create_vault_token_core(// Insert into databaselet tokenization = db- .insert_tokenization(tokenization_new, &(merchant_key_store.clone()))+ .insert_tokenization(tokenization_new, provider.get_key_store()).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to insert tokenization record")?;diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rsindex ded8b0dbd9..aef9951e2a 100644--- a/crates/router/src/core/user.rs+++ b/crates/router/src/core/user.rs@@ -3888,12 +3888,13 @@ pub async fn clone_connector(destination_key_store.clone(),destination_merchant_account.clone(),destination_key_store.clone(),+ None,);admin::create_connector(state,merchant_connector_create,- destination_context,+ destination_context.get_processor().clone(),Some(request.destination.profile_id),).awaitdiff --git a/crates/router/src/core/verification/utils.rs b/crates/router/src/core/verification/utils.rsindex be6ed9cebd..785861a533 100644--- a/crates/router/src/core/verification/utils.rs+++ b/crates/router/src/core/verification/utils.rs@@ -8,8 +8,7 @@ use crate::{},logger,routes::SessionState,- services::authentication::AuthenticationData,- types::{self, storage},+ types::{self, domain, storage},};pub async fn check_existence_and_add_domain_to_db(@@ -131,7 +130,8 @@ pub fn log_applepay_verification_response_if_error(pub async fn check_if_profile_id_is_present_in_payment_intent(payment_id: PaymentId,state: &SessionState,- auth_data: &AuthenticationData,+ processor: &domain::Processor,+ profile_id: Option<common_utils::id_type::ProfileId>,) -> CustomResult<(), errors::ApiErrorResponse> {todo!()}@@ -140,18 +140,18 @@ pub async fn check_if_profile_id_is_present_in_payment_intent(pub async fn check_if_profile_id_is_present_in_payment_intent(payment_id: PaymentId,state: &SessionState,- auth_data: &AuthenticationData,+ processor: &domain::Processor,+ profile_id: Option<common_utils::id_type::ProfileId>,) -> CustomResult<(), errors::ApiErrorResponse> {let db = &*state.store;let payment_intent = db.find_payment_intent_by_payment_id_merchant_id(&payment_id,- auth_data.merchant_account.get_id(),- &auth_data.key_store,- auth_data.merchant_account.storage_scheme,+ processor.get_account().get_id(),+ processor.get_key_store(),+ processor.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::Unauthorized)?;-- utils::validate_profile_id_from_auth_layer(auth_data.profile_id.clone(), &payment_intent)+ utils::validate_profile_id_from_auth_layer(profile_id, &payment_intent)}diff --git a/crates/router/src/core/webhooks/network_tokenization_incoming.rs b/crates/router/src/core/webhooks/network_tokenization_incoming.rsindex 77a83c7b03..1d28241f29 100644--- a/crates/router/src/core/webhooks/network_tokenization_incoming.rs+++ b/crates/router/src/core/webhooks/network_tokenization_incoming.rs@@ -436,6 +436,7 @@ pub async fn fetch_merchant_account_for_network_token_webhooks(key_store.clone(),merchant_account,key_store,+ None,);Ok(platform)diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex bea1dbdc75..86b679279f 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -1329,6 +1329,7 @@ mod tests {merchant_key_store.clone(),merchant_account.clone(),merchant_key_store.clone(),+ None,);let merchant_id = merchant_id.clone(); // Clone merchant_id to avoid movediff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rsindex 553e97139d..63bf64e708 100644--- a/crates/router/src/routes/admin.rs+++ b/crates/router/src/routes/admin.rs@@ -522,8 +522,12 @@ pub async fn connector_create(&req,payload,|state, auth_data, req, _| {- let platform = auth_data.clone().into();- create_connector(state, req, platform, auth_data.profile_id)+ create_connector(+ state,+ req,+ auth_data.platform.get_processor().clone(),+ auth_data.profile.map(|profile| profile.get_id().clone()),+ )},auth::auth_type(&auth::ApiKeyAuthWithMerchantIdFromRoute(merchant_id.clone()),@@ -555,8 +559,7 @@ pub async fn connector_create(&req,payload,|state, auth_data: auth::AuthenticationData, req, _| {- let platform = auth_data.into();- create_connector(state, req, platform, None)+ create_connector(state, req, auth_data.platform.get_processor().clone(), None)},auth::auth_type(&auth::AdminApiAuthWithMerchantIdFromHeader,@@ -598,8 +601,8 @@ pub async fn connector_retrieve(|state, auth, req, _| {retrieve_connector(state,- auth.merchant_account.get_id().clone(),- auth.profile_id,+ auth.platform.get_processor().clone(),+ auth.profile.map(|profile| profile.get_id().clone()),req.merchant_connector_id,)},@@ -638,8 +641,7 @@ pub async fn connector_retrieve(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- retrieve_connector(state, platform, req.id.clone())+ retrieve_connector(state, auth.platform.get_processor().clone(), req.id.clone())},auth::auth_type(&auth::AdminApiAuthWithMerchantIdFromHeader,@@ -668,8 +670,12 @@ pub async fn connector_list(state,&req,profile_id.to_owned(),- |state, auth::AuthenticationData { key_store, .. }, _, _| {- list_connectors_for_a_profile(state, key_store, profile_id.clone())+ |state, auth: auth::AuthenticationData, _, _| {+ list_connectors_for_a_profile(+ state,+ auth.platform.get_processor().clone(),+ profile_id.clone(),+ )},auth::auth_type(&auth::AdminApiAuthWithMerchantIdFromHeader,@@ -702,7 +708,7 @@ pub async fn connector_list(&req,merchant_id.to_owned(),|state, auth, _, _| {- list_payment_connectors(state, auth.merchant_account.get_id().clone(), None)+ list_payment_connectors(state, auth.platform.get_processor().clone(), None)},auth::auth_type(&auth::ApiKeyAuthWithMerchantIdFromRoute(merchant_id.clone()),@@ -738,8 +744,8 @@ pub async fn connector_list_profile(|state, auth, _, _| {list_payment_connectors(state,- auth.merchant_account.get_id().clone(),- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform.get_processor().clone(),+ auth.profile.map(|profile| vec![profile.get_id().clone()]),)},auth::auth_type(@@ -780,8 +786,8 @@ pub async fn connector_update(|state, auth, req, _| {update_connector(state,- auth.merchant_account.get_id().clone(),- auth.profile_id,+ auth.platform.get_processor().get_account().get_id().clone(),+ auth.profile.map(|profile| profile.get_id().clone()),&merchant_connector_id,req,)@@ -892,8 +898,7 @@ pub async fn connector_delete(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- delete_connector(state, platform, req.id)+ delete_connector(state, auth.platform, req.id)},auth::auth_type(&auth::AdminApiAuthWithMerchantIdFromHeader,diff --git a/crates/router/src/routes/api_keys.rs b/crates/router/src/routes/api_keys.rsindex e6ad485e2a..1abca9b8d7 100644--- a/crates/router/src/routes/api_keys.rs+++ b/crates/router/src/routes/api_keys.rs@@ -25,8 +25,9 @@ pub async fn api_key_create(state,&req,payload,- |state, auth_data, payload, _| async {- api_keys::create_api_key(state, payload, auth_data.key_store).await+ |state, auth_data, payload, _| {+ let key_store = auth_data.platform.get_processor().get_key_store().clone();+ async move { api_keys::create_api_key(state, payload, key_store).await }},auth::auth_type(&auth::PlatformOrgAdminAuthWithMerchantIdFromRoute {diff --git a/crates/router/src/routes/authentication.rs b/crates/router/src/routes/authentication.rsindex f2bde907e0..10eb6cfec4 100644--- a/crates/router/src/routes/authentication.rs+++ b/crates/router/src/routes/authentication.rs@@ -29,8 +29,7 @@ pub async fn authentication_create(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- unified_authentication_service::authentication_create_core(state, platform, req)+ unified_authentication_service::authentication_create_core(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -67,10 +66,9 @@ pub async fn authentication_eligibility(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();unified_authentication_service::authentication_eligibility_core(state,- platform,+ auth.platform,req,authentication_id.clone(),)@@ -109,9 +107,11 @@ pub async fn authentication_authenticate(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();unified_authentication_service::authentication_authenticate_core(- state, platform, req, auth_flow,+ state,+ auth.platform,+ req,+ auth_flow,)},&*auth,@@ -148,9 +148,11 @@ pub async fn authentication_eligibility_check(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();unified_authentication_service::authentication_eligibility_check_core(- state, platform, req, auth_flow,+ state,+ auth.platform,+ req,+ auth_flow,)},&*auth,@@ -176,9 +178,10 @@ pub async fn authentication_retrieve_eligibility_check(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();unified_authentication_service::authentication_retrieve_eligibility_check_core(- state, platform, req,+ state,+ auth.platform,+ req,)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -220,9 +223,11 @@ pub async fn authentication_sync(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();unified_authentication_service::authentication_sync_core(- state, platform, auth_flow, req,+ state,+ auth.platform,+ auth_flow,+ req,)},&*auth,@@ -251,8 +256,7 @@ pub async fn authentication_sync_post_update(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- unified_authentication_service::authentication_post_sync_core(state, platform, req)+ unified_authentication_service::authentication_post_sync_core(state, auth.platform, req)},&auth::MerchantIdAuth(merchant_id),api_locking::LockAction::NotApplicable,@@ -289,8 +293,7 @@ pub async fn authentication_session_token(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- unified_authentication_service::authentication_session_core(state, platform, req)+ unified_authentication_service::authentication_session_core(state, auth.platform, req)},&*auth,api_locking::LockAction::NotApplicable,diff --git a/crates/router/src/routes/blocklist.rs b/crates/router/src/routes/blocklist.rsindex 9e7f5e17af..a1cbbd95fe 100644--- a/crates/router/src/routes/blocklist.rs+++ b/crates/router/src/routes/blocklist.rs@@ -33,8 +33,7 @@ pub async fn add_entry_to_blocklist(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, body, _| {- let platform = auth.into();- blocklist::add_entry_to_blocklist(state, platform, body)+ blocklist::add_entry_to_blocklist(state, auth.platform, body)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -75,8 +74,7 @@ pub async fn remove_entry_from_blocklist(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, body, _| {- let platform = auth.into();- blocklist::remove_entry_from_blocklist(state, platform, body)+ blocklist::remove_entry_from_blocklist(state, auth.platform, body)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -132,8 +130,7 @@ pub async fn list_blocked_payment_methods(&req,payload,|state, auth: auth::AuthenticationData, query, _| {- let platform = auth.into();- blocklist::list_blocklist_entries(state, platform, query)+ blocklist::list_blocklist_entries(state, auth.platform, query)},auth::auth_type(&*auth_type,@@ -173,8 +170,7 @@ pub async fn toggle_blocklist_guard(&req,query_payload.into_inner(),|state, auth: auth::AuthenticationData, query, _| {- let platform = auth.into();- blocklist::toggle_blocklist_guard(state, platform, query)+ blocklist::toggle_blocklist_guard(state, auth.platform, query)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {diff --git a/crates/router/src/routes/cards_info.rs b/crates/router/src/routes/cards_info.rsindex c13830380e..f534f49dda 100644--- a/crates/router/src/routes/cards_info.rs+++ b/crates/router/src/routes/cards_info.rs@@ -52,10 +52,7 @@ pub async fn card_iin_info(state,&req,payload,- |state, auth, req, _| {- let platform = auth.into();- cards_info::retrieve_card_info(state, platform, req)- },+ |state, auth, req, _| cards_info::retrieve_card_info(state, auth.platform, req),&*auth,api_locking::LockAction::NotApplicable,))diff --git a/crates/router/src/routes/customers.rs b/crates/router/src/routes/customers.rsindex 8fda3ba685..380b979fe5 100644--- a/crates/router/src/routes/customers.rs+++ b/crates/router/src/routes/customers.rs@@ -6,7 +6,7 @@ use super::app::AppState;use crate::{core::{api_locking, customers::*},services::{api, authentication as auth, authorization::permissions::Permission},- types::{api::customers, domain},+ types::api::customers,};#[cfg(feature = "v2")]#[instrument(skip_all, fields(flow = ?Flow::CustomersCreate))]@@ -22,8 +22,7 @@ pub async fn customers_create(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform: domain::Platform = auth.into();- create_customer(state, platform.get_provider().clone(), req, None)+ create_customer(state, auth.platform.get_provider().clone(), req, None)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -53,8 +52,7 @@ pub async fn customers_create(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform: domain::Platform = auth.into();- create_customer(state, platform.get_provider().clone(), req, None)+ create_customer(state, auth.platform.get_provider().clone(), req, None)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -103,11 +101,11 @@ pub async fn customers_retrieve(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- let platform: domain::Platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());retrieve_customer(state,- platform.get_provider().clone(),- auth.profile_id,+ auth.platform.get_provider().clone(),+ profile_id,customer_id,)},@@ -154,8 +152,7 @@ pub async fn customers_retrieve(&req,id,|state, auth: auth::AuthenticationData, id, _| {- let platform: domain::Platform = auth.into();- retrieve_customer(state, platform.get_provider().clone(), id)+ retrieve_customer(state, auth.platform.get_provider().clone(), id)},auth,api_locking::LockAction::NotApplicable,@@ -178,8 +175,7 @@ pub async fn customers_list(&req,payload,|state, auth: auth::AuthenticationData, request, _| {- let platform: domain::Platform = auth.into();- list_customers(state, platform.get_provider().clone(), None, request)+ list_customers(state, auth.platform.get_provider().clone(), None, request)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -211,8 +207,7 @@ pub async fn customers_list(&req,payload,|state, auth: auth::AuthenticationData, request, _| {- let platform: domain::Platform = auth.into();- list_customers(state, platform.get_provider().clone(), None, request)+ list_customers(state, auth.platform.get_provider().clone(), None, request)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -245,8 +240,7 @@ pub async fn customers_list_with_count(&req,payload,|state, auth: auth::AuthenticationData, request, _| {- let platform: domain::Platform = auth.into();- list_customers_with_count(state, platform.get_provider().clone(), request)+ list_customers_with_count(state, auth.platform.get_provider().clone(), request)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -278,8 +272,7 @@ pub async fn customers_list_with_count(&req,payload,|state, auth: auth::AuthenticationData, request, _| {- let platform: domain::Platform = auth.into();- list_customers_with_count(state, platform.get_provider().clone(), request)+ list_customers_with_count(state, auth.platform.get_provider().clone(), request)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -318,8 +311,11 @@ pub async fn customers_update(&req,request_internal,|state, auth: auth::AuthenticationData, request_internal, _| {- let platform: domain::Platform = auth.into();- update_customer(state, platform.get_provider().clone(), request_internal)+ update_customer(+ state,+ auth.platform.get_provider().clone(),+ request_internal,+ )},auth::auth_type(&auth::ApiKeyAuth {@@ -355,8 +351,11 @@ pub async fn customers_update(&req,request_internal,|state, auth: auth::AuthenticationData, request_internal, _| {- let platform: domain::Platform = auth.into();- update_customer(state, platform.get_provider().clone(), request_internal)+ update_customer(+ state,+ auth.platform.get_provider().clone(),+ request_internal,+ )},auth::auth_type(&auth::V2ApiKeyAuth {@@ -389,8 +388,7 @@ pub async fn customers_delete(&req,id,|state, auth: auth::AuthenticationData, id, _| {- let platform: domain::Platform = auth.into();- delete_customer(state, platform.get_provider().clone(), id)+ delete_customer(state, auth.platform.get_provider().clone(), id)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -423,8 +421,7 @@ pub async fn customers_delete(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- let platform: domain::Platform = auth.into();- delete_customer(state, platform.get_provider().clone(), customer_id)+ delete_customer(state, auth.platform.get_provider().clone(), customer_id)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -457,8 +454,7 @@ pub async fn get_customer_mandates(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- let platform = auth.into();- crate::core::mandate::get_customer_mandates(state, platform, customer_id)+ crate::core::mandate::get_customer_mandates(state, auth.platform, customer_id)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {diff --git a/crates/router/src/routes/disputes.rs b/crates/router/src/routes/disputes.rsindex f25dfb3887..0806f13581 100644--- a/crates/router/src/routes/disputes.rs+++ b/crates/router/src/routes/disputes.rs@@ -48,8 +48,8 @@ pub async fn retrieve_dispute(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();- disputes::retrieve_dispute(state, platform, auth.profile_id, req)+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ disputes::retrieve_dispute(state, auth.platform, profile_id, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -84,8 +84,7 @@ pub async fn fetch_disputes(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- disputes::connector_sync_disputes(state, platform, connector_id.clone(), req)+ disputes::connector_sync_disputes(state, auth.platform, connector_id.clone(), req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -140,8 +139,7 @@ pub async fn retrieve_disputes_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- disputes::retrieve_disputes_list(state, platform, None, req)+ disputes::retrieve_disputes_list(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -197,11 +195,10 @@ pub async fn retrieve_disputes_list_profile(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();disputes::retrieve_disputes_list(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -241,8 +238,7 @@ pub async fn get_disputes_filters(state: web::Data<AppState>, req: HttpRequest)&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- disputes::get_filters_for_disputes(state, platform, None)+ disputes::get_filters_for_disputes(state, auth.platform, None)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -283,11 +279,10 @@ pub async fn get_disputes_filters_profile(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.clone().into();disputes::get_filters_for_disputes(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),)},auth::auth_type(@@ -337,8 +332,8 @@ pub async fn accept_dispute(&req,dispute_id,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();- disputes::accept_dispute(state, platform, auth.profile_id, req)+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ disputes::accept_dispute(state, auth.platform, profile_id, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -382,8 +377,8 @@ pub async fn submit_dispute_evidence(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();- disputes::submit_evidence(state, platform, auth.profile_id, req)+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ disputes::submit_evidence(state, auth.platform, profile_id, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -434,8 +429,8 @@ pub async fn attach_dispute_evidence(&req,attach_evidence_request,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();- disputes::attach_evidence(state, platform, auth.profile_id, req)+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ disputes::attach_evidence(state, auth.platform, profile_id, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -484,8 +479,8 @@ pub async fn retrieve_dispute_evidence(&req,dispute_id,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();- disputes::retrieve_dispute_evidence(state, platform, auth.profile_id, req)+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ disputes::retrieve_dispute_evidence(state, auth.platform, profile_id, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -530,8 +525,7 @@ pub async fn delete_dispute_evidence(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- disputes::delete_evidence(state, platform, req)+ disputes::delete_evidence(state, auth.platform, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -563,8 +557,7 @@ pub async fn get_disputes_aggregate(&req,query_param,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- disputes::get_aggregates_for_disputes(state, platform, None, req)+ disputes::get_aggregates_for_disputes(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -597,11 +590,10 @@ pub async fn get_disputes_aggregate_profile(&req,query_param,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();disputes::get_aggregates_for_disputes(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},diff --git a/crates/router/src/routes/ephemeral_key.rs b/crates/router/src/routes/ephemeral_key.rsindex 38e756775e..ae39636d4f 100644--- a/crates/router/src/routes/ephemeral_key.rs+++ b/crates/router/src/routes/ephemeral_key.rs@@ -27,7 +27,11 @@ pub async fn ephemeral_key_create(helpers::make_ephemeral_key(state,payload.customer_id,- auth.merchant_account.get_id().to_owned(),+ auth.platform+ .get_processor()+ .get_account()+ .get_id()+ .to_owned(),)},&auth::HeaderAuth(auth::ApiKeyAuth {@@ -78,11 +82,10 @@ pub async fn client_secret_create(&req,payload,|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();helpers::make_client_secret(state,payload.resource_id.to_owned(),- platform,+ auth.platform,req.headers(),)},diff --git a/crates/router/src/routes/files.rs b/crates/router/src/routes/files.rsindex d06a7cf00b..ce30c3b970 100644--- a/crates/router/src/routes/files.rs+++ b/crates/router/src/routes/files.rs@@ -47,8 +47,7 @@ pub async fn files_create(&req,create_file_request,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- files_create_core(state, platform, req)+ files_create_core(state, auth.platform, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -97,8 +96,7 @@ pub async fn files_delete(&req,file_id,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- files_delete_core(state, platform, req)+ files_delete_core(state, auth.platform, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -149,8 +147,7 @@ pub async fn files_retrieve(&req,file_id,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- files_retrieve_core(state, platform, req)+ files_retrieve_core(state, auth.platform, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {diff --git a/crates/router/src/routes/fraud_check.rs b/crates/router/src/routes/fraud_check.rsindex 0f094b06ef..4dc649838e 100644--- a/crates/router/src/routes/fraud_check.rs+++ b/crates/router/src/routes/fraud_check.rs@@ -20,8 +20,7 @@ pub async fn frm_fulfillment(&req,json_payload.into_inner(),|state, auth: services::authentication::AuthenticationData, req, _| {- let platform = auth.into();- frm_core::frm_fulfillment_core(state, platform, req)+ frm_core::frm_fulfillment_core(state, auth.platform, req)},&services::authentication::ApiKeyAuth {is_connected_allowed: false,diff --git a/crates/router/src/routes/mandates.rs b/crates/router/src/routes/mandates.rsindex 767fc1f1e0..d1666653a8 100644--- a/crates/router/src/routes/mandates.rs+++ b/crates/router/src/routes/mandates.rs@@ -28,8 +28,7 @@ pub async fn get_mandate(&req,mandate_id,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- mandate::get_mandate(state, platform, req)+ mandate::get_mandate(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -57,8 +56,7 @@ pub async fn revoke_mandate(&req,mandate_id,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- mandate::revoke_mandate(state, platform, req)+ mandate::revoke_mandate(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -83,8 +81,7 @@ pub async fn retrieve_mandates_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- mandate::retrieve_mandates_list(state, platform, req)+ mandate::retrieve_mandates_list(state, auth.platform, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {diff --git a/crates/router/src/routes/payment_link.rs b/crates/router/src/routes/payment_link.rsindex fe810fbd0c..3971ae0623 100644--- a/crates/router/src/routes/payment_link.rs+++ b/crates/router/src/routes/payment_link.rs@@ -60,10 +60,9 @@ pub async fn initiate_payment_link(&req,payload.clone(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();initiate_payment_link_flow(state,- platform,+ auth.platform,payload.merchant_id.clone(),payload.payment_id.clone(),)@@ -95,10 +94,9 @@ pub async fn initiate_secure_payment_link(&req,payload.clone(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();initiate_secure_payment_link_flow(state,- platform,+ auth.platform,payload.merchant_id.clone(),payload.payment_id.clone(),headers,@@ -127,7 +125,11 @@ pub async fn payments_link_list(&req,payload,|state, auth: auth::AuthenticationData, payload, _| {- list_payment_link(state, auth.merchant_account, payload)+ list_payment_link(+ state,+ auth.platform.get_processor().get_account().clone(),+ payload,+ )},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -159,10 +161,9 @@ pub async fn payment_link_status(&req,payload.clone(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();get_payment_link_status(state,- platform,+ auth.platform,payload.merchant_id.clone(),payload.payment_id.clone(),)diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rsindex 17c172a829..21adab0414 100644--- a/crates/router/src/routes/payment_methods.rs+++ b/crates/router/src/routes/payment_methods.rs@@ -52,11 +52,10 @@ pub async fn create_payment_method_api(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| async move {- let platform: domain::Platform = auth.into();Box::pin(cards::get_client_secret_or_add_payment_method(&state,req,- platform.get_provider(),+ auth.platform.get_provider(),)).await},@@ -84,12 +83,11 @@ pub async fn create_payment_method_api(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, req_state| async move {- let platform = auth.clone().into();Box::pin(payment_methods_routes::create_payment_method(&state,&req_state,req,- &platform,+ &auth.platform,&auth.profile,)).await@@ -118,11 +116,10 @@ pub async fn create_payment_method_intent_api(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| async move {- let platform: domain::Platform = auth.into();Box::pin(payment_methods_routes::payment_method_intent_create(&state,req,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),)).await},@@ -179,10 +176,9 @@ pub async fn payment_method_update_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payment_methods_routes::update_payment_method(state,- platform,+ auth.platform,auth.profile,req,&payment_method_id,@@ -216,11 +212,10 @@ pub async fn payment_method_retrieve_api(&req,payload,|state, auth: auth::AuthenticationData, pm, _| {- let platform: domain::Platform = auth.into();payment_methods_routes::retrieve_payment_method(state,pm,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),)},&auth::V2ApiKeyAuth {@@ -251,8 +246,7 @@ pub async fn payment_method_delete_api(&req,payload,|state, auth: auth::AuthenticationData, pm, _| {- let platform = auth.clone().into();- payment_methods_routes::delete_payment_method(state, pm, platform, auth.profile)+ payment_methods_routes::delete_payment_method(state, pm, auth.platform, auth.profile)},&auth::V2ApiKeyAuth {is_connected_allowed: false,@@ -283,6 +277,7 @@ pub async fn migrate_payment_method_api(key_store.clone(),merchant_account,key_store,+ None,);Box::pin(migrate_payment_method(&(&state).into(),@@ -355,6 +350,7 @@ pub async fn migrate_payment_methods(key_store.clone(),merchant_account,key_store,+ None,);let mut mca_cache = HashMap::new();@@ -441,6 +437,7 @@ pub async fn update_payment_methods(key_store.clone(),merchant_account,key_store,+ None,);Box::pin(update_migration::update_payment_methods(&state,@@ -506,6 +503,7 @@ pub async fn payment_methods_batch_retrieve_api(key_store.clone(),merchant_account,key_store,+ None,);let responses = batch_retrieve::retrieve_payment_method_data(@@ -553,11 +551,10 @@ pub async fn save_payment_method_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform: domain::Platform = auth.into();Box::pin(cards::add_payment_method_data(state,req,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),pm_id.clone(),))},@@ -594,8 +591,7 @@ pub async fn list_payment_method_api(payload,|state, auth: auth::AuthenticationData, req, _| {// TODO (#7195): Fill platform_merchant_account in the client secret auth and pass it here.- let platform = auth.into();- cards::list_payment_methods(state, platform, req)+ cards::list_payment_methods(state, auth.platform, req)},&*auth,api_locking::LockAction::NotApplicable,@@ -632,10 +628,9 @@ pub async fn list_customer_payment_method_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();cards::do_list_customer_pm_fetch_customer_if_not_passed(state,- platform,+ auth.platform,Some(req),Some(&customer_id),None,@@ -678,10 +673,9 @@ pub async fn list_customer_payment_method_api_client(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();cards::do_list_customer_pm_fetch_customer_if_not_passed(state,- platform,+ auth.platform,Some(req),None,is_ephemeral_auth.then_some(api_key).flatten(),@@ -707,8 +701,7 @@ pub async fn initiate_pm_collect_link_flow(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payment_methods_routes::initiate_pm_collect_link(state, platform, req)+ payment_methods_routes::initiate_pm_collect_link(state, auth.platform, req)},&auth::ApiKeyAuth {is_connected_allowed: true,@@ -737,10 +730,9 @@ pub async fn list_customer_payment_method_api(&req,payload,|state, auth: auth::AuthenticationData, _, _| {- let platform: domain::Platform = auth.into();payment_methods_routes::list_saved_payment_methods_for_customer(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),customer_id.clone(),)},@@ -777,10 +769,9 @@ pub async fn get_payment_method_token_data(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform: domain::Platform = auth.clone().into();payment_methods_routes::get_token_data_for_payment_method(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),auth.profile,req,payment_method_id.clone(),@@ -815,10 +806,9 @@ pub async fn get_total_payment_method_count(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform: domain::Platform = auth.into();payment_methods_routes::get_total_saved_payment_methods_for_merchant(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),)},auth::auth_type(@@ -856,10 +846,9 @@ pub async fn render_pm_collect_link(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform: domain::Platform = auth.into();payment_methods_routes::render_pm_collect_link(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),req,)},@@ -888,10 +877,9 @@ pub async fn payment_method_retrieve_api(&req,payload,|state, auth: auth::AuthenticationData, pm, _| async move {- let platform: domain::Platform = auth.into();cards::PmCards {state: &state,- provider: platform.get_provider(),+ provider: auth.platform.get_provider(),}.retrieve_payment_method(pm).await@@ -933,10 +921,9 @@ pub async fn payment_method_update_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform: domain::Platform = auth.into();cards::update_customer_payment_method(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),req,&payment_method_id,None,@@ -975,10 +962,9 @@ pub async fn payment_method_delete_api(&req,pm,|state, auth: auth::AuthenticationData, req, _| async move {- let platform: domain::Platform = auth.into();cards::PmCards {state: &state,- provider: platform.get_provider(),+ provider: auth.platform.get_provider(),}.delete_payment_method(req).await@@ -1007,7 +993,7 @@ pub async fn list_countries_currencies_for_connector_payment_method(cards::list_countries_currencies_for_connector_payment_method(state,req,- auth.profile_id,+ auth.profile.map(|profile| profile.get_id().clone()),)},#[cfg(not(feature = "release"))]@@ -1097,13 +1083,12 @@ pub async fn default_payment_method_set_api(&req,payload,|state, auth: auth::AuthenticationData, default_payment_method, _| async move {- let platform: domain::Platform = auth.into();cards::PmCards {state: &state,- provider: platform.get_provider(),+ provider: auth.platform.get_provider(),}.set_default_payment_method(- platform.get_provider().get_account().get_id(),+ auth.platform.get_provider().get_account().get_id(),customer_id,default_payment_method.payment_method_id,)@@ -1238,6 +1223,7 @@ pub async fn tokenize_card_api(key_store.clone(),merchant_account,key_store,+ None,);let res = Box::pin(cards::tokenize_card_flow(&state,@@ -1287,6 +1273,7 @@ pub async fn tokenize_card_using_pm_api(key_store.clone(),merchant_account,key_store,+ None,);let res = Box::pin(cards::tokenize_card_flow(&state,@@ -1330,6 +1317,7 @@ pub async fn tokenize_card_batch_api(key_store.clone(),merchant_account,key_store,+ None,);Box::pin(tokenize::tokenize_cards(&state,@@ -1361,10 +1349,9 @@ pub async fn payment_methods_session_create(&req,payload,|state, auth: auth::AuthenticationData, request, _| async move {- let platform: domain::Platform = auth.into();payment_methods_routes::payment_methods_session_create(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),request,).await@@ -1397,10 +1384,9 @@ pub async fn payment_methods_session_update(|state, auth: auth::AuthenticationData, req, _| {let value = payment_method_session_id.clone();async move {- let platform: domain::Platform = auth.into();payment_methods_routes::payment_methods_session_update(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),value.clone(),req,)@@ -1432,10 +1418,9 @@ pub async fn payment_methods_session_retrieve(&req,payment_method_session_id.clone(),|state, auth: auth::AuthenticationData, payment_method_session_id, _| async move {- let platform: domain::Platform = auth.into();payment_methods_routes::payment_methods_session_retrieve(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),payment_method_session_id,).await@@ -1473,10 +1458,9 @@ pub async fn payment_method_session_list_payment_methods(&req,payment_method_session_id.clone(),|state, auth: auth::AuthenticationData, payment_method_session_id, _| {- let platform: domain::Platform = auth.clone().into();payment_methods_routes::list_payment_methods_for_session(state,- platform,+ auth.platform,auth.profile,payment_method_session_id,)@@ -1533,11 +1517,10 @@ pub async fn payment_method_session_confirm(&req,request,|state, auth: auth::AuthenticationData, request, req_state| {- let platform = auth.clone().into();payment_methods_routes::payment_methods_session_confirm(state,req_state,- platform,+ auth.platform,auth.profile,request.payment_method_session_id,request.request,@@ -1578,10 +1561,9 @@ pub async fn payment_method_session_update_saved_payment_method(&req,request,|state, auth: auth::AuthenticationData, request, _| {- let platform = auth.clone().into();payment_methods_routes::payment_methods_session_update_payment_method(state,- platform,+ auth.platform,auth.profile,request.payment_method_session_id,request.request,@@ -1622,10 +1604,9 @@ pub async fn payment_method_session_delete_saved_payment_method(&req,request,|state, auth: auth::AuthenticationData, request, _| {- let platform = auth.clone().into();payment_methods_routes::payment_methods_session_delete_payment_method(state,- platform,+ auth.platform,auth.profile,request.request.payment_method_id,request.payment_method_session_id,@@ -1657,10 +1638,9 @@ pub async fn network_token_status_check_api(&req,payment_method_id,|state, auth: auth::AuthenticationData, payment_method_id, _| {- let platform: domain::Platform = auth.into();payment_methods_routes::check_network_token_status(state,- platform.get_provider().clone(),+ auth.platform.get_provider().clone(),payment_method_id,)},diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rsindex 774eccd49d..701fa4ebfb 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -116,13 +116,12 @@ pub async fn payments_create(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();authorize_verify_select::<_>(payments::PaymentCreate,state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),header_payload.clone(),req,api::AuthFlow::Client,@@ -148,11 +147,10 @@ pub async fn recovery_payments_create(&req.clone(),payload,|state, auth: auth::AuthenticationData, req_payload, req_state| {- let platform = auth.clone().into();recovery::custom_revenue_recovery_core(state.to_owned(),req_state,- platform,+ auth.platform,auth.profile,req_payload,)@@ -191,8 +189,6 @@ pub async fn payments_create_intent(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();-payments::payments_intent_core::<api_types::PaymentCreateIntent,payment_types::PaymentsIntentResponse,@@ -202,7 +198,7 @@ pub async fn payments_create_intent(>(state,req_state,- platform,+ auth.platform,auth.profile,payments::operations::PaymentIntentCreate,req,@@ -261,7 +257,6 @@ pub async fn payments_get_intent(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_intent_core::<api_types::PaymentGetIntent,payment_types::PaymentsIntentResponse,@@ -271,7 +266,7 @@ pub async fn payments_get_intent(>(state,req_state,- platform,+ auth.platform,auth.profile,payments::operations::PaymentGetIntent,req,@@ -327,11 +322,10 @@ pub async fn revenue_recovery_get_intent(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::revenue_recovery_get_intent_core(state,req_state,- platform,+ auth.platform,auth.profile,req,global_payment_id.clone(),@@ -383,8 +377,6 @@ pub async fn list_payment_attempts(&req,payload.clone(),|session_state, auth, req_payload, req_state| {- let platform = auth.clone().into();-payments::payments_list_attempts_using_payment_intent_id::<payments::operations::PaymentGetListAttempts,api_models::payments::PaymentAttemptListResponse,@@ -396,7 +388,7 @@ pub async fn list_payment_attempts(>(session_state,req_state,- platform,+ auth.platform,auth.profile,payments::operations::PaymentGetListAttempts,payload.clone(),@@ -461,11 +453,10 @@ pub async fn payments_create_and_confirm_intent(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, request, req_state| {- let platform = auth.clone().into();payments::payments_create_and_confirm_intent(state,req_state,- platform,+ auth.platform,auth.profile,request,header_payload.clone(),@@ -508,7 +499,6 @@ pub async fn payments_update_intent(&req,internal_payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_intent_core::<api_types::PaymentUpdateIntent,payment_types::PaymentsIntentResponse,@@ -518,7 +508,7 @@ pub async fn payments_update_intent(>(state,req_state,- platform,+ auth.platform,auth.profile,payments::operations::PaymentUpdateIntent,req.payload,@@ -563,7 +553,6 @@ pub async fn payments_start(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::Authorize,payment_types::PaymentsResponse,@@ -574,8 +563,8 @@ pub async fn payments_start(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::operations::PaymentStart,req,api::AuthFlow::Client,@@ -648,7 +637,6 @@ pub async fn payments_retrieve(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::PSync,payment_types::PaymentsResponse,@@ -659,8 +647,8 @@ pub async fn payments_retrieve(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentStatus,req,auth_flow,@@ -724,7 +712,6 @@ pub async fn payments_retrieve_with_gateway_creds(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::PSync,payment_types::PaymentsResponse,@@ -735,8 +722,8 @@ pub async fn payments_retrieve_with_gateway_creds(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentStatus,req,api::AuthFlow::Merchant,@@ -799,13 +786,12 @@ pub async fn payments_update(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();authorize_verify_select::<_>(payments::PaymentUpdate,state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),HeaderPayload::default(),req,auth_flow,@@ -848,7 +834,6 @@ pub async fn payments_post_session_tokens(&req,payload,|state, auth, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::PostSessionTokens,payment_types::PaymentsPostSessionTokensResponse,@@ -859,8 +844,8 @@ pub async fn payments_post_session_tokens(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentPostSessionTokens,req,api::AuthFlow::Client,@@ -910,7 +895,6 @@ pub async fn payments_update_metadata(&req,payload,|state, auth, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::UpdateMetadata,payment_types::PaymentsUpdateMetadataResponse,@@ -921,8 +905,8 @@ pub async fn payments_update_metadata(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentUpdateMetadata,req,api::AuthFlow::Client,@@ -1001,13 +985,12 @@ pub async fn payments_confirm(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();authorize_verify_select::<_>(payments::PaymentConfirm,state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),header_payload.clone(),req,auth_flow,@@ -1044,7 +1027,6 @@ pub async fn payments_capture(&req,payload,|state, auth: auth::AuthenticationData, payload, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::Capture,payment_types::PaymentsResponse,@@ -1055,8 +1037,8 @@ pub async fn payments_capture(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentCapture,payload,api::AuthFlow::Merchant,@@ -1107,7 +1089,6 @@ pub async fn payments_dynamic_tax_calculation(&req,payload,|state, auth: auth::AuthenticationData, payload, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::SdkSessionUpdate,payment_types::PaymentsDynamicTaxCalculationResponse,@@ -1118,8 +1099,8 @@ pub async fn payments_dynamic_tax_calculation(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentSessionUpdate,payload,api::AuthFlow::Client,@@ -1175,7 +1156,6 @@ pub async fn payments_connector_session(let payment_id = req.global_payment_id;let request = req.payload;let operation = payments::operations::PaymentSessionIntent;- let platform = auth.clone().into();payments::payments_session_core::<api_types::Session,payment_types::PaymentsSessionResponse,@@ -1186,7 +1166,7 @@ pub async fn payments_connector_session(>(state,req_state,- platform,+ auth.platform,auth.profile,operation,request,@@ -1234,7 +1214,6 @@ pub async fn payments_connector_session(&req,payload,|state, auth: auth::AuthenticationData, payload, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::Session,payment_types::PaymentsSessionResponse,@@ -1245,8 +1224,8 @@ pub async fn payments_connector_session(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentSession,payload,api::AuthFlow::Client,@@ -1299,12 +1278,11 @@ pub async fn payments_redirect_response(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.into();<payments::PaymentRedirectSync as PaymentRedirectFlow>::handle_payments_redirect_response(&payments::PaymentRedirectSync {},state,req_state,- platform,+ auth.platform,req,)},@@ -1348,12 +1326,11 @@ pub async fn payments_redirect_response_with_creds_identifier(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.into();<payments::PaymentRedirectSync as PaymentRedirectFlow>::handle_payments_redirect_response(&payments::PaymentRedirectSync {},state,req_state,- platform,+ auth.platform,req,)},@@ -1397,12 +1374,11 @@ pub async fn payments_complete_authorize_redirect(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.into();<payments::PaymentRedirectCompleteAuthorize as PaymentRedirectFlow>::handle_payments_redirect_response(&payments::PaymentRedirectCompleteAuthorize {},state,req_state,- platform,+ auth.platform,req,)},@@ -1447,12 +1423,11 @@ pub async fn payments_complete_authorize_redirect_with_creds_identifier(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.into();<payments::PaymentRedirectCompleteAuthorize as PaymentRedirectFlow>::handle_payments_redirect_response(&payments::PaymentRedirectCompleteAuthorize {},state,req_state,- platform,+ auth.platform,req,)},@@ -1507,7 +1482,6 @@ pub async fn payments_complete_authorize(&req,payload,|state, auth: auth::AuthenticationData, _req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::CompleteAuthorize,payment_types::PaymentsResponse,@@ -1518,8 +1492,8 @@ pub async fn payments_complete_authorize(>(state.clone(),req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::operations::payment_complete_authorize::CompleteAuthorize,payment_confirm_req.clone(),auth_flow,@@ -1557,7 +1531,6 @@ pub async fn payments_cancel(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::Void,payment_types::PaymentsResponse,@@ -1568,8 +1541,8 @@ pub async fn payments_cancel(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentCancel,req,api::AuthFlow::Merchant,@@ -1625,7 +1598,6 @@ pub async fn payments_cancel(let request = req.payload;let operation = payments::operations::payment_cancel_v2::PaymentsCancel;- let platform = auth.clone().into();Box::pin(payments::payments_core::<hyperswitch_domain_models::router_flow_types::Void,@@ -1639,7 +1611,7 @@ pub async fn payments_cancel(>(state,req_state,- platform,+ auth.platform,auth.profile,operation,request,@@ -1686,7 +1658,6 @@ pub async fn payments_cancel_post_capture(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::PostCaptureVoid,payment_types::PaymentsResponse,@@ -1697,8 +1668,8 @@ pub async fn payments_cancel_post_capture(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentCancelPostCapture,req,api::AuthFlow::Merchant,@@ -1732,8 +1703,7 @@ pub async fn payments_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payments::list_payments(state, platform, None, req)+ payments::list_payments(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -1765,8 +1735,7 @@ pub async fn revenue_recovery_invoices_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payments::revenue_recovery_list_payments(state, platform, req)+ payments::revenue_recovery_list_payments(state, auth.platform, req)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -1797,8 +1766,7 @@ pub async fn payments_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payments::list_payments(state, platform, req)+ payments::list_payments(state, auth.platform, req)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -1830,11 +1798,10 @@ pub async fn profile_payments_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payments::list_payments(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -1868,8 +1835,7 @@ pub async fn payments_list_by_filter(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payments::apply_filters_on_payments(state, platform, None, req)+ payments::apply_filters_on_payments(state, auth.platform, None, req)},&auth::JWTAuth {permission: Permission::MerchantPaymentRead,@@ -1894,11 +1860,10 @@ pub async fn profile_payments_list_by_filter(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payments::apply_filters_on_payments(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -1925,8 +1890,7 @@ pub async fn get_filters_for_payments(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payments::get_filters_for_payments(state, platform, req)+ payments::get_filters_for_payments(state, auth.platform, req)},&auth::JWTAuth {permission: Permission::MerchantPaymentRead,@@ -1949,8 +1913,7 @@ pub async fn get_payment_filters(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- payments::get_payment_filters(state, platform, None)+ payments::get_payment_filters(state, auth.platform, None)},&auth::JWTAuth {permission: Permission::MerchantPaymentRead,@@ -1973,10 +1936,9 @@ pub async fn get_payment_filters_profile(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.clone().into();payments::get_payment_filters(state,- platform,+ auth.platform,Some(vec![auth.profile.get_id().clone()]),)},@@ -2001,11 +1963,10 @@ pub async fn get_payment_filters_profile(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.clone().into();payments::get_payment_filters(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),)},&auth::JWTAuth {@@ -2031,8 +1992,7 @@ pub async fn get_payments_aggregates(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payments::get_aggregates_for_payments(state, platform, None, req)+ payments::get_aggregates_for_payments(state, auth.platform, None, req)},&auth::JWTAuth {permission: Permission::MerchantPaymentRead,@@ -2066,7 +2026,6 @@ pub async fn payments_approve(&http_req,payload.clone(),|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::Capture,payment_types::PaymentsResponse,@@ -2077,8 +2036,8 @@ pub async fn payments_approve(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentApprove,payment_types::PaymentsCaptureRequest {payment_id: req.payment_id,@@ -2136,7 +2095,6 @@ pub async fn payments_reject(&http_req,payload.clone(),|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::Void,payment_types::PaymentsResponse,@@ -2147,8 +2105,8 @@ pub async fn payments_reject(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentReject,payment_types::PaymentsCancelRequest {payment_id: req.payment_id,@@ -2318,7 +2276,6 @@ pub async fn payments_incremental_authorization(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::IncrementalAuthorization,payment_types::PaymentsResponse,@@ -2329,8 +2286,8 @@ pub async fn payments_incremental_authorization(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentIncrementalAuthorization,req,api::AuthFlow::Merchant,@@ -2369,7 +2326,6 @@ pub async fn payments_extend_authorization(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.clone().into();payments::payments_core::<api_types::ExtendAuthorization,payment_types::PaymentsResponse,@@ -2380,8 +2336,8 @@ pub async fn payments_extend_authorization(>(state,req_state,- platform,- auth.profile_id,+ auth.platform,+ auth.profile.map(|profile| profile.get_id().clone()),payments::PaymentExtendAuthorization,req,api::AuthFlow::Merchant,@@ -2422,10 +2378,9 @@ pub async fn payments_external_authentication(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();payments::payment_external_authentication::<hyperswitch_domain_models::router_flow_types::Authenticate,- >(state, platform, req)+ >(state, auth.platform, req)},&auth::HeaderAuth(auth::PublishableKeyAuth {is_connected_allowed: false,@@ -2471,12 +2426,11 @@ pub async fn post_3ds_payments_authorize(&req,payload,|state, auth: auth::AuthenticationData, req, req_state| {- let platform = auth.into();<payments::PaymentAuthenticateCompleteAuthorize as PaymentRedirectFlow>::handle_payments_redirect_response(&payments::PaymentAuthenticateCompleteAuthorize {},state,req_state,- platform,+ auth.platform,req,)},@@ -2532,10 +2486,13 @@ pub async fn retrieve_extended_card_info(&req,payment_id,|state, auth: auth::AuthenticationData, payment_id, _| {- let platform: domain::Platform = auth.into();payments::get_extended_card_info(state,- platform.get_processor().get_account().get_id().to_owned(),+ auth.platform+ .get_provider()+ .get_account()+ .get_id()+ .to_owned(),payment_id,)},@@ -2578,8 +2535,7 @@ pub async fn payments_submit_eligibility(&http_req,payment_id,|state, auth: auth::AuthenticationData, payment_id, _| {- let platform = auth.into();- payments::payments_submit_eligibility(state, platform, payload.clone(), payment_id)+ payments::payments_submit_eligibility(state, auth.platform, payload.clone(), payment_id)},&*auth_type,api_locking::LockAction::NotApplicable,@@ -3003,11 +2959,10 @@ pub async fn get_payments_aggregates_profile(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payments::get_aggregates_for_payments(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -3033,10 +2988,9 @@ pub async fn get_payments_aggregates_profile(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payments::get_aggregates_for_payments(state,- platform,+ auth.platform,Some(vec![auth.profile.get_id().clone()]),req,)@@ -3125,10 +3079,9 @@ pub async fn payments_start_redirection(&req,payment_start_redirection_request.clone(),|state, auth: auth::AuthenticationData, _req, req_state| async {- let platform = auth.into();payments::payment_start_redirection(state,- platform,+ auth.platform,payment_start_redirection_request.clone(),).await@@ -3185,12 +3138,10 @@ pub async fn payment_confirm_intent(let payment_id = req.global_payment_id;let request = req.payload;- let platform = auth.clone().into();-Box::pin(payments::payments_execute_wrapper(state,req_state,- platform,+ auth.platform,auth.profile,request,header_payload.clone(),@@ -3240,11 +3191,10 @@ pub async fn payments_apply_pm_data(let payment_id = req.global_payment_id;let request = req.payload;- let platform = auth.clone().into();Box::pin(payment_method_balance::payments_check_and_apply_pm_data_core(state,- platform,+ auth.platform,auth.profile,req_state,request,@@ -3313,7 +3263,6 @@ pub async fn proxy_confirm_intent(// Define the operation for proxy payments intentlet operation = payments::operations::proxy_payments_intent::PaymentProxyIntent;- let platform = auth.clone().into();// Call the core proxy logicBox::pin(payments::proxy_for_payments_core::<api_types::Authorize,@@ -3325,7 +3274,7 @@ pub async fn proxy_confirm_intent(>(state,req_state,- platform,+ auth.platform,auth.profile,operation,request,@@ -3389,7 +3338,6 @@ pub async fn confirm_intent_with_external_vault_proxy(// Define the operation for proxy payments intentlet operation = payments::operations::external_vault_proxy_payment_intent::ExternalVaultProxyPaymentIntent;- let platform = auth.clone().into();// Call the core proxy logicBox::pin(payments::external_vault_proxy_for_payments_core::<api_types::ExternalVaultProxy,@@ -3401,7 +3349,7 @@ pub async fn confirm_intent_with_external_vault_proxy(>(state,req_state,- platform,+ auth.platform,auth.profile,operation,request,@@ -3477,7 +3425,6 @@ pub async fn payment_status(let operation = payments::operations::PaymentGet;- let platform = auth.clone().into();Box::pin(payments::payments_core::<api_types::PSync,api_models::payments::PaymentsResponse,@@ -3488,7 +3435,7 @@ pub async fn payment_status(>(state,req_state,- platform,+ auth.platform,auth.profile,operation,request,@@ -3578,7 +3525,6 @@ pub async fn payments_status_with_gateway_creds(let operation = payments::operations::PaymentGet;- let platform = auth.clone().into();Box::pin(payments::payments_core::<api_types::PSync,api_models::payments::PaymentsResponse,@@ -3589,7 +3535,7 @@ pub async fn payments_status_with_gateway_creds(>(state,req_state,- platform,+ auth.platform,auth.profile,operation,request,@@ -3628,10 +3574,9 @@ pub async fn payment_get_intent_using_merchant_reference_id(&req,(),|state, auth: auth::AuthenticationData, _, req_state| async {- let platform = auth.clone().into();Box::pin(payments::payments_get_intent_using_merchant_reference(state,- platform,+ auth.platform,auth.profile,req_state,&merchant_reference_id,@@ -3680,12 +3625,11 @@ pub async fn payments_finish_redirection(&req,payload,|state, auth, req, req_state| {- let platform = auth.clone().into();<payments::PaymentRedirectSync as PaymentRedirectFlow>::handle_payments_redirect_response(&payments::PaymentRedirectSync {},state,req_state,- platform,+ auth.platform,auth.profile,req,)@@ -3737,7 +3681,6 @@ pub async fn payments_capture(let request = req.payload;let operation = payments::operations::payment_capture_v2::PaymentsCapture;- let platform = auth.clone().into();Box::pin(payments::payments_core::<api_types::Capture,@@ -3749,7 +3692,7 @@ pub async fn payments_capture(>(state,req_state,- platform,+ auth.platform,auth.profile,operation,request,@@ -3806,10 +3749,9 @@ pub async fn list_payment_methods(&req,internal_payload,|state, auth, req, _| {- let platform = auth.clone().into();payments::payment_methods::list_payment_methods(state,- platform,+ auth.platform,auth.profile,req.global_payment_id,req.payload,diff --git a/crates/router/src/routes/payout_link.rs b/crates/router/src/routes/payout_link.rsindex 788ea336b4..e222a9d382 100644--- a/crates/router/src/routes/payout_link.rs+++ b/crates/router/src/routes/payout_link.rs@@ -31,10 +31,7 @@ pub async fn render_payout_link(state,&req,payload.clone(),- |state, auth, req, _| {- let platform = auth.into();- initiate_payout_link(state, platform, req, headers)- },+ |state, auth, req, _| initiate_payout_link(state, auth.platform, req, headers),&auth::MerchantIdAuth(merchant_id),api_locking::LockAction::NotApplicable,))diff --git a/crates/router/src/routes/payouts.rs b/crates/router/src/routes/payouts.rsindex 49ac8adec8..b1eabeec61 100644--- a/crates/router/src/routes/payouts.rs+++ b/crates/router/src/routes/payouts.rs@@ -53,8 +53,7 @@ pub async fn payouts_create(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payouts_create_core(state, platform, req)+ payouts_create_core(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -87,8 +86,8 @@ pub async fn payouts_retrieve(&req,payout_retrieve_request,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();- payouts_retrieve_core(state, platform, auth.profile_id, req)+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ payouts_retrieve_core(state, auth.platform, profile_id, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -133,8 +132,7 @@ pub async fn payouts_update(&req,payout_update_payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payouts_update_core(state, platform, req)+ payouts_update_core(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -179,10 +177,7 @@ pub async fn payouts_confirm(state,&req,payload,- |state, auth, req, _| {- let platform = auth.into();- payouts_confirm_core(state, platform, req)- },+ |state, auth, req, _| payouts_confirm_core(state, auth.platform, req),&*auth_type,api_locking::LockAction::NotApplicable,))@@ -207,8 +202,7 @@ pub async fn payouts_cancel(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payouts_cancel_core(state, platform, req)+ payouts_cancel_core(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -236,8 +230,7 @@ pub async fn payouts_fulfill(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payouts_fulfill_core(state, platform, req)+ payouts_fulfill_core(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -265,8 +258,7 @@ pub async fn payouts_list(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payouts_list_core(state, platform, None, req)+ payouts_list_core(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -300,11 +292,10 @@ pub async fn payouts_list_profile(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payouts_list_core(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -340,8 +331,7 @@ pub async fn payouts_list_by_filter(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payouts_filtered_list_core(state, platform, None, req)+ payouts_filtered_list_core(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -375,11 +365,10 @@ pub async fn payouts_list_by_filter_profile(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payouts_filtered_list_core(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -415,8 +404,7 @@ pub async fn payouts_list_available_filters_for_merchant(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payouts_list_available_filters_core(state, platform, None, req)+ payouts_list_available_filters_core(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -450,11 +438,10 @@ pub async fn payouts_list_available_filters_for_profile(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();payouts_list_available_filters_core(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -495,10 +482,7 @@ pub async fn get_payout_filters(state: web::Data<AppState>, req: HttpRequest) ->state,&req,(),- |state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- get_payout_filters_core(state, platform)- },+ |state, auth: auth::AuthenticationData, _, _| get_payout_filters_core(state, auth.platform),auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -584,8 +568,7 @@ pub async fn get_payouts_aggregates(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- get_aggregates_for_payouts(state, platform, None, req)+ get_aggregates_for_payouts(state, auth.platform, None, req)},&auth::JWTAuth {permission: Permission::MerchantPayoutRead,@@ -610,11 +593,10 @@ pub async fn get_payouts_aggregates_profile(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();get_aggregates_for_payouts(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},diff --git a/crates/router/src/routes/pm_auth.rs b/crates/router/src/routes/pm_auth.rsindex 8e86524a9e..92359a7c1b 100644--- a/crates/router/src/routes/pm_auth.rs+++ b/crates/router/src/routes/pm_auth.rs@@ -42,10 +42,9 @@ pub async fn link_token_create(&req,payload,|state, auth, payload, _| {- let platform = auth.into();crate::core::pm_auth::create_link_token(state,- platform,+ auth.platform,payload,Some(header_payload.clone()),)@@ -80,8 +79,7 @@ pub async fn exchange_token(&req,payload,|state, auth, payload, _| {- let platform = auth.into();- crate::core::pm_auth::exchange_token_core(state, platform, payload)+ crate::core::pm_auth::exchange_token_core(state, auth.platform, payload)},&*auth,api_locking::LockAction::NotApplicable,diff --git a/crates/router/src/routes/poll.rs b/crates/router/src/routes/poll.rsindex 321fd64e2e..290c185217 100644--- a/crates/router/src/routes/poll.rs+++ b/crates/router/src/routes/poll.rs@@ -39,10 +39,7 @@ pub async fn retrieve_poll_status(state,&req,poll_id,- |state, auth, req, _| {- let platform = auth.into();- poll::retrieve_poll_status(state, req, platform)- },+ |state, auth, req, _| poll::retrieve_poll_status(state, req, auth.platform),&auth::HeaderAuth(auth::PublishableKeyAuth {is_connected_allowed: false,is_platform_allowed: false,diff --git a/crates/router/src/routes/profile_acquirer.rs b/crates/router/src/routes/profile_acquirer.rsindex b2834c4a0a..cf5483ffd2 100644--- a/crates/router/src/routes/profile_acquirer.rs+++ b/crates/router/src/routes/profile_acquirer.rs@@ -24,8 +24,7 @@ pub async fn create_profile_acquirer(&req,payload,|state: super::SessionState, auth_data, req, _| {- let platform = auth_data.into();- crate::core::profile_acquirer::create_profile_acquirer(state, req, platform)+ crate::core::profile_acquirer::create_profile_acquirer(state, req, auth_data.platform)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -63,13 +62,12 @@ pub async fn profile_acquirer_update(&req,payload,|state: super::SessionState, auth_data, req, _| {- let platform = auth_data.into();crate::core::profile_acquirer::update_profile_acquirer_config(state,profile_id.clone(),profile_acquirer_id.clone(),req,- platform,+ auth_data.platform,)},auth::auth_type(diff --git a/crates/router/src/routes/profiles.rs b/crates/router/src/routes/profiles.rsindex 640c72f274..1caef3d458 100644--- a/crates/router/src/routes/profiles.rs+++ b/crates/router/src/routes/profiles.rs@@ -50,8 +50,7 @@ pub async fn profile_create(&req,payload,|state, auth_data, req, _| {- let platform = auth_data.into();- create_profile(state, req, platform)+ create_profile(state, req, auth_data.platform.get_processor().clone())},auth::auth_type(&auth::ApiKeyAuthWithMerchantIdFromRoute(merchant_id.clone()),@@ -105,8 +104,9 @@ pub async fn profile_create(key_store.clone(),merchant_account,key_store,+ None,);- create_profile(state, req, platform)+ create_profile(state, req, platform.get_processor().clone())},auth::auth_type(&auth::AdminApiAuthWithMerchantIdFromHeader,@@ -142,8 +142,13 @@ pub async fn profile_retrieve(retrieve_profile(state,profile_id,- auth_data.merchant_account.get_id().clone(),- auth_data.key_store,+ auth_data+ .platform+ .get_processor()+ .get_account()+ .get_id()+ .clone(),+ auth_data.platform.get_processor().get_key_store().clone(),)},auth::auth_type(@@ -249,8 +254,13 @@ pub async fn profile_update(update_profile(state,&profile_id,- auth_data.merchant_account.get_id().clone(),- auth_data.key_store,+ auth_data+ .platform+ .get_processor()+ .get_account()+ .get_id()+ .clone(),+ auth_data.platform.get_processor().get_key_store().clone(),req,)},@@ -363,7 +373,13 @@ pub async fn profiles_list(state,&req,merchant_id.clone(),- |state, auth, _, _| list_profile(state, auth.merchant_account.get_id().clone(), None),+ |state, auth, _, _| {+ list_profile(+ state,+ auth.platform.get_processor().get_account().get_id().clone(),+ None,+ )+ },auth::auth_type(&auth::ApiKeyAuthWithMerchantIdFromRoute(merchant_id.clone()),&auth::JWTAuthMerchantFromRoute {@@ -426,8 +442,8 @@ pub async fn profiles_list_at_profile_level(|state, auth, _, _| {list_profile(state,- auth.merchant_account.get_id().clone(),- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform.get_processor().get_account().get_id().clone(),+ auth.profile.map(|profile| vec![profile.get_id().clone()]),)},auth::auth_type(@@ -522,8 +538,8 @@ pub async fn payment_connector_list_profile(|state, auth, _, _| {list_payment_connectors(state,- auth.merchant_account.get_id().clone(),- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform.get_processor().clone(),+ auth.profile.map(|profile| vec![profile.get_id().clone()]),)},auth::auth_type(diff --git a/crates/router/src/routes/proxy.rs b/crates/router/src/routes/proxy.rsindex ed7668cd13..d51b2941df 100644--- a/crates/router/src/routes/proxy.rs+++ b/crates/router/src/routes/proxy.rs@@ -22,8 +22,7 @@ pub async fn proxy(&req,payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- proxy::proxy_core(state, platform, req)+ proxy::proxy_core(state, auth.platform, req)},&auth::V2ApiKeyAuth {is_connected_allowed: false,diff --git a/crates/router/src/routes/recon.rs b/crates/router/src/routes/recon.rsindex cfd076c710..a5320c5b61 100644--- a/crates/router/src/routes/recon.rs+++ b/crates/router/src/routes/recon.rs@@ -22,7 +22,9 @@ pub async fn update_merchant(state,&req,json_payload.into_inner(),- |state, auth, req, _| recon::recon_merchant_account_update(state, auth, req),+ |state, auth: authentication::AuthenticationData, req, _| {+ recon::recon_merchant_account_update(state, auth.platform.get_processor().clone(), req)+ },&authentication::AdminApiAuthWithMerchantIdFromRoute(merchant_id),api_locking::LockAction::NotApplicable,))diff --git a/crates/router/src/routes/recovery_webhooks.rs b/crates/router/src/routes/recovery_webhooks.rsindex 1281e17f75..303083b3a8 100644--- a/crates/router/src/routes/recovery_webhooks.rs+++ b/crates/router/src/routes/recovery_webhooks.rs@@ -31,13 +31,12 @@ pub async fn recovery_receive_incoming_webhook<W: types::OutgoingWebhookType>(&req,(),|state, auth, _, req_state| {- let platform = auth.clone().into();webhooks::incoming_webhooks_wrapper::<W>(&flow,state.to_owned(),req_state,&req,- platform,+ auth.platform,auth.profile,&connector_id,body.clone(),diff --git a/crates/router/src/routes/refunds.rs b/crates/router/src/routes/refunds.rsindex cda82c8b28..036f259af6 100644--- a/crates/router/src/routes/refunds.rs+++ b/crates/router/src/routes/refunds.rs@@ -61,8 +61,8 @@ pub async fn refunds_create(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();- refund_create_core(state, platform, auth.profile_id, req)+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());+ refund_create_core(state, auth.platform, profile_id, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -121,8 +121,7 @@ pub async fn refunds_create(&req,internal_refund_create_payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- refund_create_core(state, platform, req.payload, global_refund_id.clone())+ refund_create_core(state, auth.platform, req.payload, global_refund_id.clone())},auth_type,api_locking::LockAction::NotApplicable,@@ -161,11 +160,11 @@ pub async fn refunds_retrieve(&req,refund_request,|state, auth: auth::AuthenticationData, refund_request, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());refund_response_wrapper(state,- platform,- auth.profile_id,+ auth.platform,+ profile_id,refund_request,refund_retrieve_core_with_refund_id,)@@ -212,8 +211,7 @@ pub async fn refunds_retrieve(&req,refund_request,|state, auth: auth::AuthenticationData, refund_request, _| {- let platform = auth.clone().into();- refund_retrieve_core_with_refund_id(state, platform, auth.profile, refund_request)+ refund_retrieve_core_with_refund_id(state, auth.platform, auth.profile, refund_request)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -273,8 +271,7 @@ pub async fn refunds_retrieve_with_gateway_creds(&req,refund_request,|state, auth: auth::AuthenticationData, refund_request, _| {- let platform = auth.clone().into();- refund_retrieve_core_with_refund_id(state, platform, auth.profile, refund_request)+ refund_retrieve_core_with_refund_id(state, auth.platform, auth.profile, refund_request)},auth_type,api_locking::LockAction::NotApplicable,@@ -306,11 +303,11 @@ pub async fn refunds_retrieve_with_body(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());refund_response_wrapper(state,- platform,- auth.profile_id,+ auth.platform,+ profile_id,req,refund_retrieve_core_with_refund_id,)@@ -345,8 +342,7 @@ pub async fn refunds_update(&req,refund_update_req,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- refund_update_core(state, platform, req)+ refund_update_core(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,@@ -382,7 +378,7 @@ pub async fn refunds_metadata_update(|state, auth: auth::AuthenticationData, req, _| {refund_metadata_update_core(state,- auth.merchant_account,+ auth.platform.get_processor().get_account().clone(),req.payload,global_refund_id.clone(),)@@ -413,8 +409,7 @@ pub async fn refunds_list(&req,payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- refund_list(state, platform, None, req)+ refund_list(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -445,7 +440,12 @@ pub async fn refunds_list(&req,payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- refund_list(state, auth.merchant_account, auth.profile, req)+ refund_list(+ state,+ auth.platform.get_processor().get_account().clone(),+ auth.profile,+ req,+ )},auth::auth_type(&auth::V2ApiKeyAuth {@@ -479,11 +479,10 @@ pub async fn refunds_list_profile(&req,payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();refund_list(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},@@ -519,8 +518,7 @@ pub async fn refunds_filter_list(&req,payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- refund_filter_list(state, platform, req)+ refund_filter_list(state, auth.platform, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -550,8 +548,7 @@ pub async fn get_refunds_filters(state: web::Data<AppState>, req: HttpRequest) -&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- get_filters_for_refunds(state, platform, None)+ get_filters_for_refunds(state, auth.platform, None)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -584,11 +581,10 @@ pub async fn get_refunds_filters_profile(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.clone().into();get_filters_for_refunds(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),)},auth::auth_type(@@ -621,8 +617,7 @@ pub async fn get_refunds_aggregates(&req,query_params,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- get_aggregates_for_refunds(state, platform, None, req)+ get_aggregates_for_refunds(state, auth.platform, None, req)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -677,11 +672,10 @@ pub async fn get_refunds_aggregate_profile(&req,query_params,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();get_aggregates_for_refunds(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),req,)},diff --git a/crates/router/src/routes/relay.rs b/crates/router/src/routes/relay.rsindex a03acb23b5..973b6575b8 100644--- a/crates/router/src/routes/relay.rs+++ b/crates/router/src/routes/relay.rs@@ -22,12 +22,11 @@ pub async fn relay(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();relay::relay_flow_decider(state,- platform,+ auth.platform,#[cfg(feature = "v1")]- auth.profile_id,+ auth.profile.map(|profile| profile.get_id().clone()),#[cfg(feature = "v2")]Some(auth.profile.get_id().clone()),req,@@ -61,12 +60,11 @@ pub async fn relay_retrieve(&req,relay_retrieve_request,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.clone().into();relay::relay_retrieve(state,- platform,+ auth.platform,#[cfg(feature = "v1")]- auth.profile_id,+ auth.profile.map(|profile| profile.get_id().clone()),#[cfg(feature = "v2")]Some(auth.profile.get_id().clone()),req,diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rsindex ea7413c6de..c2e096da82 100644--- a/crates/router/src/routes/routing.rs+++ b/crates/router/src/routes/routing.rs@@ -46,11 +46,11 @@ pub async fn routing_create_config(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());routing::create_routing_algorithm_under_profile(state,- platform,- auth.profile_id,+ auth.platform,+ profile_id,payload.clone(),transaction_type.or(payload.transaction_type)@@ -87,10 +87,9 @@ pub async fn routing_create_config(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.clone().into();routing::create_routing_algorithm_under_profile(state,- platform,+ auth.platform,Some(auth.profile.get_id().clone()),payload,transaction_type,@@ -132,11 +131,11 @@ pub async fn routing_link_config(&req,path.into_inner(),|state, auth: auth::AuthenticationData, algorithm, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());routing::link_routing_config(state,- platform,- auth.profile_id,+ auth.platform,+ profile_id,algorithm,transaction_type.or(json_payload.transaction_type)@@ -179,10 +178,9 @@ pub async fn routing_link_config(&req,wrapper.clone(),|state, auth: auth::AuthenticationData, wrapper, _| {- let platform = auth.into();routing::link_routing_config_under_profile(state,- platform,+ auth.platform,wrapper.profile_id,wrapper.algorithm_id.routing_algorithm_id,transaction_type,@@ -225,11 +223,11 @@ pub async fn routing_retrieve_config(&req,algorithm_id,|state, auth: auth::AuthenticationData, algorithm_id, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());routing::retrieve_routing_algorithm_from_algorithm_id(state,- platform,- auth.profile_id,+ auth.platform,+ profile_id,algorithm_id,)},@@ -263,10 +261,9 @@ pub async fn routing_retrieve_config(&req,algorithm_id,|state, auth: auth::AuthenticationData, algorithm_id, _| {- let platform = auth.clone().into();routing::retrieve_routing_algorithm_from_algorithm_id(state,- platform,+ auth.platform,Some(auth.profile.get_id().clone()),algorithm_id,)@@ -306,10 +303,9 @@ pub async fn list_routing_configs(&req,query.into_inner(),|state, auth: auth::AuthenticationData, query_params, _| {- let platform = auth.into();routing::retrieve_merchant_routing_dictionary(state,- platform,+ auth.platform,None,query_params.clone(),transaction_type@@ -347,11 +343,10 @@ pub async fn list_routing_configs_for_profile(&req,query.into_inner(),|state, auth: auth::AuthenticationData, query_params, _| {- let platform = auth.clone().into();routing::retrieve_merchant_routing_dictionary(state,- platform,- auth.profile_id.map(|profile_id| vec![profile_id]),+ auth.platform,+ auth.profile.map(|profile| vec![profile.get_id().clone()]),query_params.clone(),transaction_type.or(query_params.transaction_type)@@ -389,8 +384,12 @@ pub async fn routing_unlink_config(&req,path.clone(),|state, auth: auth::AuthenticationData, path, _| {- let platform = auth.into();- routing::unlink_routing_config_under_profile(state, platform, path, transaction_type)+ routing::unlink_routing_config_under_profile(+ state,+ auth.platform,+ path,+ transaction_type,+ )},#[cfg(not(feature = "release"))]auth::auth_type(@@ -429,12 +428,12 @@ pub async fn routing_unlink_config(&req,payload.into_inner(),|state, auth: auth::AuthenticationData, payload_req, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());routing::unlink_routing_config(state,- platform,+ auth.platform,payload_req.clone(),- auth.profile_id,+ profile_id,transaction_type.or(payload_req.transaction_type).unwrap_or(enums::TransactionType::Payment),@@ -473,10 +472,9 @@ pub async fn routing_update_default_config(&req,wrapper,|state, auth: auth::AuthenticationData, wrapper, _| {- let platform = auth.into();routing::update_default_fallback_routing(state,- platform,+ auth.platform,wrapper.profile_id,wrapper.connectors,)@@ -515,10 +513,9 @@ pub async fn routing_update_default_config(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, updated_config, _| {- let platform = auth.into();routing::update_default_routing_config(state,- platform,+ auth.platform,updated_config,transaction_type,)@@ -552,8 +549,11 @@ pub async fn routing_retrieve_default_config(&req,path.clone(),|state, auth: auth::AuthenticationData, profile_id, _| {- let platform = auth.into();- routing::retrieve_default_fallback_algorithm_for_profile(state, platform, profile_id)+ routing::retrieve_default_fallback_algorithm_for_profile(+ state,+ auth.platform,+ profile_id,+ )},#[cfg(not(feature = "release"))]auth::auth_type(@@ -590,11 +590,11 @@ pub async fn routing_retrieve_default_config(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());routing::retrieve_default_routing_config(state,- auth.profile_id,- platform,+ profile_id,+ auth.platform,transaction_type,)},@@ -627,10 +627,9 @@ pub async fn upsert_surcharge_decision_manager_config(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, update_decision, _| {- let platform = auth.into();surcharge_decision_config::upsert_surcharge_decision_config(state,- platform,+ auth.platform,update_decision,)},@@ -666,8 +665,7 @@ pub async fn delete_surcharge_decision_manager_config(&req,(),|state, auth: auth::AuthenticationData, (), _| {- let platform = auth.into();- surcharge_decision_config::delete_surcharge_decision_config(state, platform)+ surcharge_decision_config::delete_surcharge_decision_config(state, auth.platform)},#[cfg(not(feature = "release"))]auth::auth_type(@@ -702,8 +700,7 @@ pub async fn retrieve_surcharge_decision_manager_config(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- surcharge_decision_config::retrieve_surcharge_decision_config(state, platform)+ surcharge_decision_config::retrieve_surcharge_decision_config(state, auth.platform)},#[cfg(not(feature = "release"))]auth::auth_type(@@ -739,8 +736,7 @@ pub async fn upsert_decision_manager_config(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, update_decision, _| {- let platform = auth.into();- conditional_config::upsert_conditional_config(state, platform, update_decision)+ conditional_config::upsert_conditional_config(state, auth.platform, update_decision)},#[cfg(not(feature = "release"))]auth::auth_type(@@ -778,7 +774,7 @@ pub async fn upsert_decision_manager_config(|state, auth: auth::AuthenticationData, update_decision, _| {conditional_config::upsert_conditional_config(state,- auth.key_store,+ auth.platform.get_processor().get_key_store().clone(),update_decision,auth.profile,)@@ -816,8 +812,7 @@ pub async fn delete_decision_manager_config(&req,(),|state, auth: auth::AuthenticationData, (), _| {- let platform = auth.into();- conditional_config::delete_conditional_config(state, platform)+ conditional_config::delete_conditional_config(state, auth.platform)},#[cfg(not(feature = "release"))]auth::auth_type(@@ -853,7 +848,11 @@ pub async fn retrieve_decision_manager_config(&req,(),|state, auth: auth::AuthenticationData, _, _| {- conditional_config::retrieve_conditional_config(state, auth.key_store, auth.profile)+ conditional_config::retrieve_conditional_config(+ state,+ auth.platform.get_processor().get_key_store().clone(),+ auth.profile,+ )},#[cfg(not(feature = "release"))]auth::auth_type(@@ -889,8 +888,7 @@ pub async fn retrieve_decision_manager_config(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- conditional_config::retrieve_conditional_config(state, platform)+ conditional_config::retrieve_conditional_config(state, auth.platform)},#[cfg(not(feature = "release"))]auth::auth_type(@@ -930,11 +928,11 @@ pub async fn routing_retrieve_linked_config(&req,query.clone(),|state, auth: AuthenticationData, query_params, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());routing::retrieve_linked_routing_config(state,- platform,- auth.profile_id,+ auth.platform,+ profile_id,query_params,transaction_type.or(query.transaction_type)@@ -962,11 +960,11 @@ pub async fn routing_retrieve_linked_config(&req,query.clone(),|state, auth: AuthenticationData, query_params, _| {- let platform = auth.clone().into();+ let profile_id = auth.profile.map(|profile| profile.get_id().clone());routing::retrieve_linked_routing_config(state,- platform,- auth.profile_id,+ auth.platform,+ profile_id,query_params,transaction_type.or(query.transaction_type)@@ -1010,10 +1008,9 @@ pub async fn routing_retrieve_linked_config(&req,wrapper.clone(),|state, auth: AuthenticationData, wrapper, _| {- let platform = auth.into();routing::retrieve_routing_config_under_profile(state,- platform,+ auth.platform,wrapper.routing_query,wrapper.profile_id,transaction_type,@@ -1054,8 +1051,11 @@ pub async fn routing_retrieve_default_config_for_profiles(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- routing::retrieve_default_routing_config_for_profiles(state, platform, transaction_type)+ routing::retrieve_default_routing_config_for_profiles(+ state,+ auth.platform,+ transaction_type,+ )},#[cfg(not(feature = "release"))]auth::auth_type(@@ -1103,10 +1103,9 @@ pub async fn routing_update_default_config_for_profile(&req,routing_payload_wrapper.clone(),|state, auth: auth::AuthenticationData, wrapper, _| {- let platform = auth.into();routing::update_default_routing_config_for_profile(state,- platform,+ auth.platform,wrapper.updated_config,wrapper.profile_id,transaction_type,@@ -1156,10 +1155,9 @@ pub async fn create_success_based_routing(auth: auth::AuthenticationData,wrapper: routing_types::CreateDynamicRoutingWrapper,_| {- let platform = auth.into();routing::create_specific_dynamic_routing(state,- platform,+ auth.platform,wrapper.feature_to_enable,wrapper.profile_id,api_models::routing::DynamicRoutingType::SuccessRateBasedRouting,@@ -1294,10 +1292,9 @@ pub async fn contract_based_routing_setup_config(auth: auth::AuthenticationData,wrapper: routing_types::ContractBasedRoutingSetupPayloadWrapper,_| async move {- let platform = auth.into();Box::pin(routing::contract_based_dynamic_routing_setup(state,- platform,+ auth.platform,wrapper.profile_id,wrapper.features_to_enable,wrapper.config,@@ -1343,11 +1340,10 @@ pub async fn contract_based_routing_update_configs(auth: auth::AuthenticationData,wrapper: routing_types::ContractBasedRoutingPayloadWrapper,_| async {- let platform = auth.into();Box::pin(routing::contract_based_routing_update_configs(state,wrapper.updated_config,- platform,+ auth.platform,wrapper.algorithm_id,wrapper.profile_id,))@@ -1397,10 +1393,9 @@ pub async fn create_elimination_routing(auth: auth::AuthenticationData,wrapper: routing_types::CreateDynamicRoutingWrapper,_| {- let platform = auth.into();routing::create_specific_dynamic_routing(state,- platform,+ auth.platform,wrapper.feature_to_enable,wrapper.profile_id,api_models::routing::DynamicRoutingType::EliminationRouting,@@ -1450,10 +1445,9 @@ pub async fn set_dynamic_routing_volume_split(auth: auth::AuthenticationData,payload: api_models::routing::RoutingVolumeSplitWrapper,_| {- let platform = auth.into();routing::configure_dynamic_routing_volume_split(state,- platform,+ auth.platform,payload.profile_id,payload.routing_info,)@@ -1490,8 +1484,7 @@ pub async fn get_dynamic_routing_volume_split(&req,payload.clone(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();- routing::retrieve_dynamic_routing_volume_split(state, platform, payload.profile_id)+ routing::retrieve_dynamic_routing_volume_split(state, auth.platform, payload.profile_id)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {@@ -1572,6 +1565,7 @@ pub async fn migrate_routing_rules_for_profile(key_store.clone(),merchant_account,key_store,+ None,);let res = Box::pin(routing::migrate_rules_for_profile(state,diff --git a/crates/router/src/routes/subscription.rs b/crates/router/src/routes/subscription.rsindex 89a094c641..e94d7f8588 100644--- a/crates/router/src/routes/subscription.rs+++ b/crates/router/src/routes/subscription.rs@@ -67,10 +67,9 @@ pub async fn create_subscription(&req,json_payload.into_inner(),move |state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();subscriptions::create_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),payload.clone(),)@@ -109,10 +108,9 @@ pub async fn pause_subscription(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();subscriptions::pause_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),subscription_id.clone(),payload.clone(),@@ -146,10 +144,9 @@ pub async fn resume_subscription(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();subscriptions::resume_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),subscription_id.clone(),payload.clone(),@@ -183,10 +180,9 @@ pub async fn cancel_subscription(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();subscriptions::cancel_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),subscription_id.clone(),payload.clone(),@@ -230,10 +226,9 @@ pub async fn confirm_subscription(&req,payload,|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();subscriptions::confirm_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),payload.clone(),subscription_id.clone(),@@ -277,8 +272,12 @@ pub async fn get_subscription_items(&req,payload,|state, auth: auth::AuthenticationData, query, _| {- let platform = auth.into();- subscriptions::get_subscription_items(state.into(), platform, profile_id.clone(), query)+ subscriptions::get_subscription_items(+ state.into(),+ auth.platform,+ profile_id.clone(),+ query,+ )},auth::auth_type(&*auth_type,@@ -312,10 +311,9 @@ pub async fn get_subscription(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();subscriptions::get_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),subscription_id.clone(),)@@ -352,10 +350,9 @@ pub async fn create_and_confirm_subscription(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();subscriptions::create_and_confirm_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),payload.clone(),)@@ -401,8 +398,7 @@ pub async fn get_estimate(&req,query.into_inner(),|state, auth: auth::AuthenticationData, query, _| {- let platform = auth.into();- subscriptions::get_estimate(state.into(), platform, profile_id.clone(), query)+ subscriptions::get_estimate(state.into(), auth.platform, profile_id.clone(), query)},&*auth_type,api_locking::LockAction::NotApplicable,@@ -429,10 +425,9 @@ pub async fn update_subscription(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, payload, _| {- let platform = auth.into();subscriptions::update_subscription(state.into(),- platform,+ auth.platform,profile_id.clone(),subscription_id.clone(),payload.clone(),@@ -466,10 +461,9 @@ pub async fn list_subscriptions(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();subscriptions::list_subscriptions(state.into(),- platform,+ auth.platform,profile_id.clone(),query.clone(),)diff --git a/crates/router/src/routes/three_ds_decision_rule.rs b/crates/router/src/routes/three_ds_decision_rule.rsindex 927f785828..dab8a8ca7f 100644--- a/crates/router/src/routes/three_ds_decision_rule.rs+++ b/crates/router/src/routes/three_ds_decision_rule.rs@@ -22,8 +22,7 @@ pub async fn execute_decision_rule(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- three_ds_decision_rule_core::execute_three_ds_decision_rule(state, platform, req)+ three_ds_decision_rule_core::execute_three_ds_decision_rule(state, auth.platform, req)},&auth::HeaderAuth(auth::ApiKeyAuth {is_connected_allowed: false,diff --git a/crates/router/src/routes/tokenization.rs b/crates/router/src/routes/tokenization.rsindex c5673773b4..1ed44ce660 100644--- a/crates/router/src/routes/tokenization.rs+++ b/crates/router/src/routes/tokenization.rs@@ -48,8 +48,7 @@ pub async fn create_token_vault_api(|state, auth: auth::AuthenticationData, request, _| async move {tokenization::create_vault_token_core(state,- &auth.merchant_account,- &auth.key_store,+ auth.platform.get_provider().clone(),request,).await@@ -88,8 +87,7 @@ pub async fn delete_tokenized_data_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- tokenization::delete_tokenized_data_core(state, platform, &token_id, req)+ tokenization::delete_tokenized_data_core(state, auth.platform, &token_id, req)},auth::api_or_client_auth(&auth::V2ApiKeyAuth {diff --git a/crates/router/src/routes/verification.rs b/crates/router/src/routes/verification.rsindex 71b3c12dd7..0cb7d55c5b 100644--- a/crates/router/src/routes/verification.rs+++ b/crates/router/src/routes/verification.rs@@ -28,7 +28,7 @@ pub async fn apple_pay_merchant_registration(state.clone(),body,merchant_id.clone(),- auth.profile_id,+ auth.profile.map(|profile| profile.get_id().clone()),)},auth::auth_type(diff --git a/crates/router/src/routes/verify_connector.rs b/crates/router/src/routes/verify_connector.rsindex 76e10652a3..b7d44fd012 100644--- a/crates/router/src/routes/verify_connector.rs+++ b/crates/router/src/routes/verify_connector.rs@@ -22,7 +22,11 @@ pub async fn payment_connector_verify(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| {- verify_connector::verify_connector_credentials(state, req, auth.profile_id)+ verify_connector::verify_connector_credentials(+ state,+ req,+ auth.profile.map(|profile| profile.get_id().clone()),+ )},&auth::JWTAuth {permission: Permission::MerchantConnectorWrite,diff --git a/crates/router/src/routes/webhooks.rs b/crates/router/src/routes/webhooks.rsindex b4da2727ab..8e60338e75 100644--- a/crates/router/src/routes/webhooks.rs+++ b/crates/router/src/routes/webhooks.rs@@ -27,13 +27,12 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(&req,(),|state, auth, _, req_state| {- let platform = auth.into();webhooks::incoming_webhooks_wrapper::<W>(&flow,state.to_owned(),req_state,&req,- platform,+ auth.platform,&connector_id_or_name,body.clone(),false,@@ -66,13 +65,12 @@ pub async fn receive_incoming_relay_webhook<W: types::OutgoingWebhookType>(&req,(),|state, auth, _, req_state| {- let platform = auth.into();webhooks::incoming_webhooks_wrapper::<W>(&flow,state.to_owned(),req_state,&req,- platform,+ auth.platform,connector_id.get_string_repr(),body.clone(),is_relay_webhook,@@ -106,13 +104,12 @@ pub async fn receive_incoming_relay_webhook<W: types::OutgoingWebhookType>(&req,(),|state, auth, _, req_state| {- let platform = auth.clone().into();webhooks::incoming_webhooks_wrapper::<W>(&flow,state.to_owned(),req_state,&req,- platform,+ auth.platform,auth.profile,&connector_id,body.clone(),@@ -149,13 +146,12 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(&req,(),|state, auth, _, req_state| {- let platform = auth.clone().into();webhooks::incoming_webhooks_wrapper::<W>(&flow,state.to_owned(),req_state,&req,- platform,+ auth.platform,auth.profile,&connector_id,body.clone(),diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rsindex e69de3ed28..ddb8153528 100644--- a/crates/router/src/services/authentication.rs+++ b/crates/router/src/services/authentication.rs@@ -62,19 +62,15 @@ mod detached;#[cfg(feature = "v1")]#[derive(Clone, Debug)]pub struct AuthenticationData {- pub merchant_account: domain::MerchantAccount,- pub platform_account_with_key_store: Option<PlatformAccountWithKeyStore>,- pub key_store: domain::MerchantKeyStore,- pub profile_id: Option<id_type::ProfileId>,+ pub platform: domain::Platform,+ pub profile: Option<domain::Profile>,}#[cfg(feature = "v2")]#[derive(Clone, Debug)]pub struct AuthenticationData {- pub merchant_account: domain::MerchantAccount,- pub key_store: domain::MerchantKeyStore,+ pub platform: domain::Platform,pub profile: domain::Profile,- pub platform_account_with_key_store: Option<PlatformAccountWithKeyStore>,}#[derive(Clone, Debug)]@@ -83,31 +79,6 @@ pub struct PlatformAccountWithKeyStore {key_store: domain::MerchantKeyStore,}-impl From<AuthenticationData> for domain::Platform {- fn from(val: AuthenticationData) -> Self {- match val.platform_account_with_key_store {- Some(platform_account_with_key_store) => {- // Platform / provider merchant is different from processor- Self::new(- platform_account_with_key_store.account,- platform_account_with_key_store.key_store,- val.merchant_account,- val.key_store,- )- }- None => {- // Standard merchant - same provider and processor- Self::new(- val.merchant_account.clone(),- val.key_store.clone(),- val.merchant_account,- val.key_store,- )- }- }- }-}-#[derive(Clone, Debug)]pub struct AuthenticationDataWithoutProfile {pub merchant_account: domain::MerchantAccount,@@ -352,36 +323,6 @@ pub struct SinglePurposeOrLoginToken {pub tenant_id: Option<id_type::TenantId>,}-pub trait AuthInfo {- fn get_merchant_id(&self) -> Option<&id_type::MerchantId>;-}--impl AuthInfo for () {- fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {- None- }-}--#[cfg(feature = "v1")]-impl AuthInfo for AuthenticationData {- fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {- Some(self.merchant_account.get_id())- }-}--#[cfg(feature = "v2")]-impl AuthInfo for AuthenticationData {- fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {- Some(self.merchant_account.get_id())- }-}--impl AuthInfo for AuthenticationDataWithMultipleProfiles {- fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {- Some(self.merchant_account.get_id())- }-}-#[async_trait]pub trait AuthenticateAndFetch<T, A>where@@ -625,21 +566,15 @@ whereself.is_platform_allowed,)?;- let (merchant, key_store, platform_account_with_key_store) =- resolve_merchant_accounts_and_key_stores(- state,- request_headers,- initiator_merchant.clone(),- key_store,- )- .await?;-- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store,+ let platform = resolve_platform(+ state,+ request_headers,+ initiator_merchant.clone(),key_store,- profile,- };+ )+ .await?;++ let auth = AuthenticationData { platform, profile };Ok((auth.clone(),AuthenticationType::ApiKey {@@ -726,20 +661,30 @@ whereself.is_platform_allowed,)?;- let (merchant, key_store, platform_account_with_key_store) =- resolve_merchant_accounts_and_key_stores(- state,- request_headers,- initiator_merchant.clone(),- key_store,- )- .await?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store,- key_store,- profile_id,+ let platform = resolve_platform(+ state,+ request_headers,+ initiator_merchant.clone(),+ key_store.clone(),+ )+ .await?;++ let profile = match profile_id {+ Some(profile_id) => {+ let profile = state+ .store()+ .find_business_profile_by_profile_id(+ platform.get_processor().get_key_store(),+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ Some(profile)+ }+ None => None,};++ let auth = AuthenticationData { platform, profile };Ok((auth.clone(),AuthenticationType::ApiKey {@@ -772,7 +717,7 @@ wherestate: &A,) -> RouterResult<(AuthenticationData, AuthenticationType)> {let api_auth = ApiKeyAuth {- is_connected_allowed: false,+ is_connected_allowed: true,is_platform_allowed: false,};let (auth_data, auth_type) = api_auth@@ -780,7 +725,10 @@ where.await?;let merchant_id_from_route = self.0.clone();- let merchant_id_from_api_key = auth_data.merchant_account.get_id();+ let merchant_id_from_api_key = auth_type+ .get_merchant_id()+ .ok_or(report!(errors::ApiErrorResponse::Unauthorized))+ .attach_printable("Merchant ID not found in API key authentication type")?;if merchant_id_from_route != *merchant_id_from_api_key {return Err(report!(errors::ApiErrorResponse::Unauthorized)).attach_printable(@@ -880,12 +828,15 @@ where.attach_printable("Platform authentication check failed"));}- if let Some(ref organization_id) = self.organization_id {- if organization_id != merchant_account.get_org_id() {- return Err(report!(errors::ApiErrorResponse::Unauthorized))- .attach_printable("Organization ID does not match");- }- }+ fp_utils::when(+ self.organization_id+ .as_ref()+ .is_some_and(|org_id| org_id != merchant_account.get_org_id()),+ || {+ Err(report!(errors::ApiErrorResponse::Unauthorized))+ .attach_printable("Organization ID does not match")+ },+ )?;Ok((Some(AuthenticationDataWithOrg {@@ -950,39 +901,50 @@ where.change_context(errors::ApiErrorResponse::Unauthorized).attach_printable("Failed to fetch merchant key store for the merchant id")?;- let merchant_account = state+ let initiator_merchant_account = state.store().find_merchant_account_by_merchant_id(&stored_api_key.merchant_id, &key_store).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized).attach_printable("Merchant account not found")?;- if !(state.conf().platform.enabled && merchant_account.is_platform_account()) {+ if !(state.conf().platform.enabled && initiator_merchant_account.is_platform_account()) {return Err(report!(errors::ApiErrorResponse::Unauthorized).attach_printable("Platform authentication check failed"));}- if let Some(ref organization_id) = self.organization_id {- if organization_id != merchant_account.get_org_id() {- return Err(report!(errors::ApiErrorResponse::Unauthorized))- .attach_printable("Organization ID does not match");- }- }+ fp_utils::when(+ self.organization_id+ .as_ref()+ .is_some_and(|org_id| org_id != initiator_merchant_account.get_org_id()),+ || {+ Err(report!(errors::ApiErrorResponse::Unauthorized))+ .attach_printable("Organization ID does not match")+ },+ )?;- let auth = AuthenticationData {- merchant_account: merchant_account.clone(),- platform_account_with_key_store: Some(PlatformAccountWithKeyStore {- account: merchant_account.clone(),- key_store: key_store.clone(),- }),+ let initiator = Some(domain::Initiator::Api {+ merchant_id: initiator_merchant_account.get_id().clone(),+ merchant_account_type: initiator_merchant_account.merchant_account_type,+ });++ let platform = domain::Platform::new(+ initiator_merchant_account.clone(),+ key_store.clone(),+ initiator_merchant_account.clone(),key_store,- profile_id: None,+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: None,};Ok((auth.clone(),AuthenticationType::ApiKey {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: initiator_merchant_account.get_id().clone(),key_id: stored_api_key.key_id,},))@@ -1099,14 +1061,22 @@ where.attach_printable("Route merchant not under same org as platform merchant");}+ let initiator = Some(domain::Initiator::Api {+ merchant_id: platform_merchant.get_id().clone(),+ merchant_account_type: platform_merchant.merchant_account_type,+ });++ let platform = domain::Platform::new(+ platform_merchant.clone(),+ platform_key_store.clone(),+ route_merchant,+ route_key_store,+ initiator,+ );+let auth = AuthenticationData {- merchant_account: route_merchant,- platform_account_with_key_store: Some(PlatformAccountWithKeyStore {- account: platform_merchant.clone(),- key_store: platform_key_store.clone(),- }),- key_store: route_key_store,- profile_id: None,+ platform,+ profile: None,};Ok((@@ -1201,9 +1171,9 @@ where).await?;Ok((- auth.clone(),+ auth,AuthenticationType::ApiKey {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: merchant_id.clone(),key_id,},))@@ -1223,9 +1193,9 @@ where).await?;Ok((- auth.clone(),+ auth,AuthenticationType::PublishableKey {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: merchant_id.clone(),},))}@@ -1274,17 +1244,18 @@ wherelet profile = state.store()- .find_business_profile_by_profile_id(&auth_data.key_store, &profile_id)+ .find_business_profile_by_profile_id(+ auth_data.platform.get_processor().get_key_store(),+ &profile_id,+ ).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth_data_v2 = AuthenticationData {- merchant_account: auth_data.merchant_account,- platform_account_with_key_store: auth_data.platform_account_with_key_store,- key_store: auth_data.key_store,+ let auth = AuthenticationData {+ platform: auth_data.platform,profile,};- Ok((auth_data_v2, auth_type))+ Ok((auth, auth_type))}}@@ -1324,22 +1295,25 @@ whereis_platform_allowed,)?;- let (merchant, key_store, platform_account_with_key_store) =- resolve_merchant_accounts_and_key_stores(- state,- request_headers,- initiator_merchant,- key_store,- )- .await?;+ let platform = resolve_platform(state, request_headers, initiator_merchant, key_store).await?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store,- key_store,- profile_id,+ let profile = match profile_id {+ Some(profile_id) => {+ let profile = state+ .store()+ .find_business_profile_by_profile_id(+ platform.get_processor().get_key_store(),+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ Some(profile)+ }+ None => None,};+ let auth = AuthenticationData { platform, profile };+Ok(auth)}@@ -1619,11 +1593,19 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let initiator = Some(domain::Initiator::Admin);++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: None,+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: None,};Ok((@@ -1675,13 +1657,17 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,+ let initiator = Some(domain::Initiator::Admin);++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );+ let auth = AuthenticationData { platform, profile };Ok((auth,AuthenticationType::AdminApiAuthWithMerchantId { merchant_id },@@ -1809,15 +1795,18 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- if let Some(ref organization_id) = self.organization_id {- if organization_id != merchant.get_org_id() {- return Err(+ fp_utils::when(+ self.organization_id+ .as_ref()+ .is_some_and(|org_id| org_id != merchant.get_org_id()),+ || {+ Err(report!(errors::ApiErrorResponse::Unauthorized).attach_printable("Organization ID from request and merchant account does not match",),- );- }- }+ )+ },+ )?;if fallback_merchant_ids.merchant_ids@@ -1888,11 +1877,20 @@ whereif request_api_key == admin_api_key.peek() {let (key_store, merchant) =Self::fetch_merchant_key_store_and_account(&merchant_id_from_route, state).await?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,++ let initiator = Some(domain::Initiator::Admin);++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: None,+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: None,};return Ok((auth,@@ -1901,6 +1899,7 @@ where},));}+let Some(fallback_merchant_ids) = conf.fallback_merchant_ids_api_key_auth.as_ref() else {return Err(report!(errors::ApiErrorResponse::Unauthorized)).attach_printable("Api Key Authentication Failure: fallback merchant set not configured",@@ -1933,22 +1932,33 @@ where.merchant_ids.contains(&stored_api_key.merchant_id){- let (_, api_key_merchant) =+ let (api_key_store, api_key_merchant) =Self::fetch_merchant_key_store_and_account(&stored_api_key.merchant_id, state).await?;let (route_key_store, route_merchant) =Self::fetch_merchant_key_store_and_account(&merchant_id_from_route, state).await?;if api_key_merchant.get_org_id() == route_merchant.get_org_id() {+ let initiator = Some(domain::Initiator::Api {+ merchant_id: api_key_merchant.get_id().clone(),+ merchant_account_type: api_key_merchant.merchant_account_type,+ });++ let platform = domain::Platform::new(+ api_key_merchant.clone(),+ api_key_store.clone(),+ route_merchant,+ route_key_store,+ initiator,+ );+let auth = AuthenticationData {- merchant_account: route_merchant,- platform_account_with_key_store: None,- key_store: route_key_store,- profile_id: None,+ platform,+ profile: None,};return Ok((- auth.clone(),+ auth,AuthenticationType::MerchantId {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: api_key_merchant.get_id().clone(),},));}@@ -2102,11 +2112,19 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let initiator = Some(domain::Initiator::Admin);++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: None,+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: None,};Ok((auth,@@ -2159,12 +2177,17 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,+ let initiator = Some(domain::Initiator::Admin);++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );++ let auth = AuthenticationData { platform, profile };Ok((auth,AuthenticationType::AdminApiAuthWithMerchantId { merchant_id },@@ -2283,16 +2306,27 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let initiator = Some(domain::Initiator::Api {+ merchant_id: merchant.get_id().clone(),+ merchant_account_type: merchant.merchant_account_type,+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: None,+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: None,};Ok((auth.clone(),AuthenticationType::MerchantId {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: self.0.clone(),},))}@@ -2342,16 +2376,24 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,+ let initiator = Some(domain::Initiator::Api {+ merchant_id: merchant.get_id().clone(),+ merchant_account_type: merchant.merchant_account_type,+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant.clone(),key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );++ let auth = AuthenticationData { platform, profile };Ok((auth.clone(),AuthenticationType::MerchantId {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: merchant.get_id().clone(),},))}@@ -2408,7 +2450,8 @@ where).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let _profile = state++ let profile = state.store().find_business_profile_by_merchant_id_profile_id(&key_store,@@ -2417,21 +2460,34 @@ where).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+let merchant = state.store().find_merchant_account_by_merchant_id(&merchant_id, &key_store).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,++ let initiator = Some(domain::Initiator::Api {+ merchant_id: merchant.get_id().clone(),+ merchant_account_type: merchant.merchant_account_type,+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: Some(profile_id.clone()),- platform_account_with_key_store: None,+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: Some(profile),};Ok((auth.clone(),AuthenticationType::InternalMerchantIdProfileId {- merchant_id,+ merchant_id: merchant_id.clone(),profile_id: Some(profile_id),},))@@ -2490,16 +2546,24 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,+ let initiator = Some(domain::Initiator::Api {+ merchant_id: merchant.get_id().clone(),+ merchant_account_type: merchant.merchant_account_type,+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant.clone(),key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );++ let auth = AuthenticationData { platform, profile };Ok((auth.clone(),AuthenticationType::MerchantId {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: merchant.get_id().clone(),},))}@@ -2543,16 +2607,24 @@ whereid: self.profile_id.get_string_repr().to_owned(),})?;- let merchant_id = merchant_account.get_id().clone();+ let initiator = Some(domain::Initiator::Api {+ merchant_id: merchant_account.get_id().clone(),+ merchant_account_type: merchant_account.merchant_account_type,+ });++ let platform = domain::Platform::new(+ merchant_account.clone(),+ key_store.clone(),+ merchant_account.clone(),+ key_store,+ initiator,+ );Ok((- AuthenticationData {- merchant_account,- key_store,- profile,- platform_account_with_key_store: None,+ AuthenticationData { platform, profile },+ AuthenticationType::PublishableKey {+ merchant_id: merchant_account.get_id().clone(),},- AuthenticationType::PublishableKey { merchant_id },))}}@@ -2648,21 +2720,15 @@ whereself.is_platform_allowed,)?;- let (merchant, key_store, platform_account_with_key_store) =- resolve_merchant_accounts_and_key_stores(- state,- request_headers,- initiator_merchant.clone(),- key_store,- )- .await?;-- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store,+ let platform = resolve_platform(+ state,+ request_headers,+ initiator_merchant.clone(),key_store,- profile,- };+ )+ .await?;++ let auth = AuthenticationData { platform, profile };Ok((auth.clone(),AuthenticationType::ApiKey {@@ -2766,14 +2832,27 @@ where.find_business_profile_by_merchant_id_profile_id(&key_store, &merchant_id, &profile_id).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Api {+ merchant_id: merchant_account.get_id().clone(),+ merchant_account_type: merchant_account.merchant_account_type,+ });++ let platform = domain::Platform::new(+ merchant_account.clone(),+ key_store.clone(),+ merchant_account.clone(),+ key_store,+ initiator,+ );++ let auth = AuthenticationData { platform, profile };+Ok((- AuthenticationData {- merchant_account,- key_store,- profile,- platform_account_with_key_store: None,+ auth,+ AuthenticationType::PublishableKey {+ merchant_id: merchant_id.clone(),},- AuthenticationType::PublishableKey { merchant_id },))}}@@ -2869,23 +2948,20 @@ whereself.is_platform_allowed,)?;- // Resolve merchant relationships using existing function- let (merchant, key_store, platform_account_with_key_store) =- resolve_merchant_accounts_and_key_stores(- state,- request_headers,- initiator_merchant.clone(),- key_store,- )- .await?;+ let platform = resolve_platform(+ state,+ request_headers,+ initiator_merchant.clone(),+ key_store,+ )+ .await?;+ let auth = AuthenticationData {+ platform,+ profile: None,+ };Ok((- AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store,- key_store,- profile_id: None,- },+ auth,AuthenticationType::PublishableKey {merchant_id: initiator_merchant.get_id().clone(),},@@ -2925,33 +3001,28 @@ whereself.is_platform_allowed,)?;- // Resolve merchant relationships using existing function- let (merchant, key_store, platform_account_with_key_store) =- resolve_merchant_accounts_and_key_stores(- state,- request_headers,- initiator_merchant.clone(),- key_store,- )- .await?;+ let platform = resolve_platform(+ state,+ request_headers,+ initiator_merchant.clone(),+ key_store,+ )+ .await?;// Find and validate profile after merchant resolutionlet profile = state.store().find_business_profile_by_merchant_id_profile_id(- &key_store,- merchant.get_id(),+ platform.get_processor().get_key_store(),+ platform.get_processor().get_account().get_id(),&profile_id,).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let auth = AuthenticationData { platform, profile };Ok((- AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store,- key_store,- profile,- },+ auth,AuthenticationType::PublishableKey {merchant_id: initiator_merchant.get_id().clone(),},@@ -3266,11 +3337,31 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ &key_store,+ &payload.merchant_id,+ &payload.profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: Some(payload.profile_id),+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: Some(profile),};Ok((@@ -3383,12 +3474,19 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let auth = AuthenticationData {- merchant_account: merchant,+ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );++ let auth = AuthenticationData { platform, profile };Ok((auth,@@ -3539,16 +3637,36 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ &key_store,+ &payload.merchant_id,+ &payload.profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: Some(payload.profile_id),+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: Some(profile),};Ok((auth.clone(),AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: payload.merchant_id,user_id: Some(payload.user_id),},))@@ -3606,16 +3724,23 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let auth = AuthenticationData {- merchant_account: merchant,+ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );++ let auth = AuthenticationData { platform, profile };Ok((- auth.clone(),+ auth,AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: payload.merchant_id,user_id: Some(payload.user_id),},))@@ -3731,17 +3856,37 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ &key_store,+ &payload.merchant_id,+ &payload.profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: Some(payload.profile_id),+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: Some(profile),};Ok((auth.clone(),AuthenticationType::MerchantJwtWithProfileId {- merchant_id: auth.merchant_account.get_id().clone(),- profile_id: auth.profile_id.clone(),+ merchant_id: payload.merchant_id,+ profile_id: Some(payload.profile_id),user_id: payload.user_id,},))@@ -3793,24 +3938,45 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- if payload.profile_id != self.profile_id {- return Err(report!(errors::ApiErrorResponse::InvalidJwtToken));- } else {- // if both of them are same then proceed with the profile id present in the request- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,- key_store,- profile_id: Some(self.profile_id.clone()),- };- Ok((- auth.clone(),- AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.get_id().clone(),- user_id: Some(payload.user_id),- },- ))- }+ fp_utils::when(payload.profile_id != self.profile_id, || {+ Err(report!(errors::ApiErrorResponse::InvalidJwtToken))+ .attach_printable("Profile id in JWT does not match profile id in route")+ })?;++ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ &key_store,+ &payload.merchant_id,+ &payload.profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ // If both of them are same then proceed with the profile id present in the request+ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,+ key_store,+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: Some(profile),+ };+ Ok((+ auth.clone(),+ AuthenticationType::MerchantJwt {+ merchant_id: payload.merchant_id,+ user_id: Some(payload.user_id),+ },+ ))}}@@ -3862,16 +4028,23 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let auth = AuthenticationData {- merchant_account: merchant,+ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );++ let auth = AuthenticationData { platform, profile };Ok((auth.clone(),AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: payload.merchant_id,user_id: Some(payload.user_id),},))@@ -3946,17 +4119,36 @@ where.await.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let merchant_id = merchant.get_id().clone();- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,++ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ &key_store,+ &payload.merchant_id,+ &payload.profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: Some(payload.profile_id),+ initiator,+ );+ let auth = AuthenticationData {+ platform,+ profile: Some(profile),};Ok((auth,AuthenticationType::MerchantJwt {- merchant_id,+ merchant_id: payload.merchant_id,user_id: Some(payload.user_id),},))@@ -4014,17 +4206,24 @@ where.await.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;- let merchant_id = merchant.get_id().clone();- let auth = AuthenticationData {- merchant_account: merchant,++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile,- platform_account_with_key_store: None,- };+ initiator,+ );++ let auth = AuthenticationData { platform, profile };Ok((auth,AuthenticationType::MerchantJwt {- merchant_id,+ merchant_id: payload.merchant_id,user_id: Some(payload.user_id),},))@@ -4072,16 +4271,35 @@ where.await.change_context(errors::ApiErrorResponse::InvalidJwtToken)?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ &key_store,+ &payload.merchant_id,+ &payload.profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: Some(payload.profile_id),+ initiator,+ );+ let auth = AuthenticationData {+ platform,+ profile: Some(profile),};Ok(((auth.clone(), payload.user_id.clone()),AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: payload.merchant_id,user_id: None,},))@@ -4206,16 +4424,36 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationData {- merchant_account: merchant,- platform_account_with_key_store: None,+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ &key_store,+ &payload.merchant_id,+ &payload.profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let initiator = Some(domain::Initiator::Jwt {+ user_id: payload.user_id.clone(),+ });++ let platform = domain::Platform::new(+ merchant.clone(),+ key_store.clone(),+ merchant,key_store,- profile_id: Some(payload.profile_id),+ initiator,+ );++ let auth = AuthenticationData {+ platform,+ profile: Some(profile),};Ok((- auth.clone(),+ auth,AuthenticationType::MerchantJwt {- merchant_id: auth.merchant_account.get_id().clone(),+ merchant_id: payload.merchant_id,user_id: Some(payload.user_id),},))@@ -4821,16 +5059,12 @@ where}/// Resolves processor and provider merchant accounts-async fn resolve_merchant_accounts_and_key_stores<A>(+async fn resolve_platform<A>(state: &A,request_headers: &HeaderMap,initiator_merchant_account: domain::MerchantAccount,merchant_key_store: domain::MerchantKeyStore,-) -> RouterResult<(- domain::MerchantAccount,- domain::MerchantKeyStore,- Option<PlatformAccountWithKeyStore>,-)>+) -> RouterResult<domain::Platform>whereA: SessionStateInfo + Sync,{@@ -4866,7 +5100,7 @@ whereprocessor_merchant_account,processor_key_store,Some(PlatformAccountWithKeyStore {- account: initiator_merchant_account,+ account: initiator_merchant_account.clone(),key_store: merchant_key_store,}),)@@ -4890,7 +5124,7 @@ whereget_platform_account_and_key_store(state, &initiator_merchant_account).await?;(- initiator_merchant_account,+ initiator_merchant_account.clone(),merchant_key_store,Some(PlatformAccountWithKeyStore {account: platform_account,@@ -4913,14 +5147,33 @@ where},)?;- (initiator_merchant_account, merchant_key_store, None)+ (initiator_merchant_account.clone(), merchant_key_store, None)}};- Ok((- processor_merchant_account,- processor_key_store,- platform_account_with_key_store,- ))++ let initiator = Some(domain::Initiator::Api {+ merchant_id: initiator_merchant_account.get_id().clone(),+ merchant_account_type: initiator_merchant_account.merchant_account_type,+ });++ let platform = match platform_account_with_key_store {+ Some(platform_account) => domain::Platform::new(+ platform_account.account,+ platform_account.key_store,+ processor_merchant_account,+ processor_key_store,+ initiator,+ ),+ None => domain::Platform::new(+ processor_merchant_account.clone(),+ processor_key_store.clone(),+ processor_merchant_account,+ processor_key_store,+ initiator,+ ),+ };++ Ok(platform)}/// Fetches the platform merchant account and key storediff --git a/crates/router/src/types/api/mandates.rs b/crates/router/src/types/api/mandates.rsindex d90b5a12d4..0425c75c8f 100644--- a/crates/router/src/types/api/mandates.rs+++ b/crates/router/src/types/api/mandates.rs@@ -82,6 +82,7 @@ impl MandateResponseExt for MandateResponse {key_store.clone(),merchant_account.clone(),key_store,+ None,);payment_methods::cards::PmCards {state,diff --git a/crates/router/src/types/domain.rs b/crates/router/src/types/domain.rsindex 91ea4f7163..a6a45b06e6 100644--- a/crates/router/src/types/domain.rs+++ b/crates/router/src/types/domain.rs@@ -25,7 +25,7 @@ mod business_profile {}mod platform {- pub use hyperswitch_domain_models::platform::{Platform, Processor, Provider};+ pub use hyperswitch_domain_models::platform::{Initiator, Platform, Processor, Provider};}mod customers {pub use hyperswitch_domain_models::customer::*;diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rsindex ab0e1cbba6..6a1f4efdca 100644--- a/crates/router/src/types/domain/user.rs+++ b/crates/router/src/types/domain/user.rs@@ -615,12 +615,13 @@ impl NewUserMerchant {merchant_key_store.clone(),merchant_account.clone(),merchant_key_store.clone(),+ None,);Box::pin(admin::create_profile(state,profile_create_request,- platform,+ platform.get_processor().clone(),)).await.change_context(UserErrors::InternalServerError)diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rsindex 253d1c4a40..4893b3a7fd 100644--- a/crates/router/src/utils.rs+++ b/crates/router/src/utils.rs@@ -1394,6 +1394,7 @@ pub async fn trigger_subscriptions_outgoing_webhook(key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let cloned_state = state.clone();diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rsindex b1d132f325..d956bc7f5f 100644--- a/crates/router/src/utils/user/sample_data.rs+++ b/crates/router/src/utils/user/sample_data.rs@@ -61,6 +61,7 @@ pub async fn generate_sample_data(key_store.clone(),merchant_from_db.clone(),key_store,+ None,);#[cfg(feature = "v1")]let (profile_id_result, business_country_default, business_label_default) = {diff --git a/crates/router/src/workflows/attach_payout_account_workflow.rs b/crates/router/src/workflows/attach_payout_account_workflow.rsindex 2a07ce20ac..55898ee670 100644--- a/crates/router/src/workflows/attach_payout_account_workflow.rs+++ b/crates/router/src/workflows/attach_payout_account_workflow.rs@@ -52,6 +52,7 @@ impl ProcessTrackerWorkflow<SessionState> for AttachPayoutAccountWorkflow {key_store.clone(),merchant_account,key_store,+ None,);let mut payout_data = Box::pin(payouts::make_payout_data(state,diff --git a/crates/router/src/workflows/dispute_list.rs b/crates/router/src/workflows/dispute_list.rsindex 2f2ffb9c50..33d575758f 100644--- a/crates/router/src/workflows/dispute_list.rs+++ b/crates/router/src/workflows/dispute_list.rs@@ -60,6 +60,7 @@ impl ProcessTrackerWorkflow<SessionState> for DisputeListWorkflow {key_store.clone(),merchant_account,key_store,+ None,);let business_profile = statediff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rsindex 46c026878b..85e2011485 100644--- a/crates/router/src/workflows/outgoing_webhook_retry.rs+++ b/crates/router/src/workflows/outgoing_webhook_retry.rs@@ -157,6 +157,7 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);// TODO: Add request state for the PT flows as welllet (content, event_type) = Box::pin(get_outgoing_webhook_content_and_event_type(@@ -377,6 +378,7 @@ async fn get_outgoing_webhook_content_and_event_type(key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);match tracking_data.event_class {diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rsindex d9213bcc99..63b8179f91 100644--- a/crates/router/src/workflows/payment_sync.rs+++ b/crates/router/src/workflows/payment_sync.rs@@ -77,6 +77,7 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);// TODO: Add support for ReqState in PT flowslet (mut payment_data, _, customer, _, _) =diff --git a/crates/router/src/workflows/process_dispute.rs b/crates/router/src/workflows/process_dispute.rsindex 8da1df0fb7..748e727614 100644--- a/crates/router/src/workflows/process_dispute.rs+++ b/crates/router/src/workflows/process_dispute.rs@@ -58,6 +58,7 @@ impl ProcessTrackerWorkflow<SessionState> for ProcessDisputeWorkflow {key_store.clone(),merchant_account,key_store,+ None,);let payment_attempt = get_payment_attempt_from_object_reference_id(diff --git a/crates/router/src/workflows/revenue_recovery.rs b/crates/router/src/workflows/revenue_recovery.rsindex 56f63dcb26..cc03c63d06 100644--- a/crates/router/src/workflows/revenue_recovery.rs+++ b/crates/router/src/workflows/revenue_recovery.rs@@ -120,6 +120,7 @@ impl ProcessTrackerWorkflow<SessionState> for ExecutePcrWorkflow {revenue_recovery_payment_data.key_store.clone(),revenue_recovery_payment_data.merchant_account.clone(),revenue_recovery_payment_data.key_store.clone(),+ None,);let (payment_data, _, _) = payments::payments_intent_operation_core::<api_types::PaymentGetIntent,diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex 0f12abdcad..9a95902e59 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -316,6 +316,7 @@ async fn payments_create_core() {key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let payment_id =id_type::PaymentId::try_from(Cow::Borrowed("pay_mbabizu24mvu3mela5njyhpit10")).unwrap();@@ -612,6 +613,7 @@ async fn payments_create_core_adyen_no_redirect() {key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let req = api::PaymentsRequest {diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex 2656b7dee2..f61ade3090 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -76,6 +76,7 @@ async fn payments_create_core() {key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let payment_id =id_type::PaymentId::try_from(Cow::Borrowed("pay_mbabizu24mvu3mela5njyhpit10")).unwrap();@@ -380,6 +381,7 @@ async fn payments_create_core_adyen_no_redirect() {key_store.clone(),merchant_account.clone(),key_store.clone(),+ None,);let req = api::PaymentsRequest {