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
feat(platform): support payment create get tracker for platform (#10465)
Apoorv Dixit657e97b1db7e
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 75bb0eded3..b66f17bf7c 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -27908,14 +27908,6 @@"description": "Allowed Payment Method Types for a given PaymentIntent","nullable": true},- "ephemeral_key": {- "allOf": [- {- "$ref": "#/components/schemas/EphemeralKeyCreateResponse"- }- ],- "nullable": true- },"manual_retry_allowed": {"type": "boolean","description": "If true the payment can be retried with same or different payment method which means the confirm call can be made again.",@@ -29501,14 +29493,6 @@"description": "Allowed Payment Method Types for a given PaymentIntent","nullable": true},- "ephemeral_key": {- "allOf": [- {- "$ref": "#/components/schemas/EphemeralKeyCreateResponse"- }- ],- "nullable": true- },"manual_retry_allowed": {"type": "boolean","description": "If true the payment can be retried with same or different payment method which means the confirm call can be made again.",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 468959d940..c89864755b 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -84,7 +84,7 @@ use crate::{},};#[cfg(feature = "v1")]-use crate::{disputes, ephemeral_key::EphemeralKeyCreateResponse, refunds, ValidateFieldAndGet};+use crate::{disputes, refunds, ValidateFieldAndGet};#[derive(Clone, Copy, Debug, Eq, PartialEq)]pub enum PaymentOp {@@ -7125,10 +7125,6 @@ pub struct PaymentsResponse {#[smithy(value_type = "Option<Vec<PaymentMethodType>>")]pub allowed_payment_method_types: Option<serde_json::Value>,- /// ephemeral_key for the customer_id mentioned- #[smithy(value_type = "Option<EphemeralKeyCreateResponse>")]- pub ephemeral_key: Option<EphemeralKeyCreateResponse>,-/// If true the payment can be retried with same or different payment method which means the confirm call can be made again.#[smithy(value_type = "Option<bool>")]pub manual_retry_allowed: Option<bool>,diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex 2ed212f022..461ab2b211 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -975,12 +975,23 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {// This supports changing the business profile by passing in the profile_idlet business_profile_id_update = if let Some(ref profile_id) = self.default_profile {+ let merchant_account = db+ .find_merchant_account_by_merchant_id(merchant_id, key_store)+ .await+ .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;++ let platform = domain::Platform::new(+ merchant_account.clone(),+ key_store.clone(),+ merchant_account,+ key_store.clone(),+ );+// Validate whether profile_id passed in request is valid and is linked to the merchantcore_utils::validate_and_get_business_profile(state.store.as_ref(),- key_store,+ platform.get_processor(),Some(profile_id),- merchant_id,).await?.map(|business_profile| Some(business_profile.get_id().to_owned()))@@ -2169,9 +2180,8 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -2380,9 +2390,8 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -2447,7 +2456,7 @@ pub async fn create_connector(helpers::validate_business_details(req.business_country,req.business_label.as_ref(),- &platform,+ platform.get_processor(),)?;let business_profile = reqdiff --git a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rsindex e93a2b425b..85bc8b0f65 100644--- a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs+++ b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs@@ -108,7 +108,7 @@ pub async fn construct_fulfillment_router_data<'a>(payment_method_balance: None,connector_request_reference_id: core_utils::get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),payment_intent,payment_attempt,&connector_id,diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rsindex 0b93618b20..3a03b6ced8 100644--- a/crates/router/src/core/payment_link.rs+++ b/crates/router/src/core/payment_link.rs@@ -616,10 +616,16 @@ pub fn extract_payment_link_config(pub fn get_payment_link_config_based_on_priority(payment_create_link_config: Option<api_models::payments::PaymentCreatePaymentLinkConfig>,business_link_config: Option<diesel_models::business_profile::BusinessPaymentLinkConfig>,- merchant_name: String,+ processor: &domain::Processor,default_domain_name: String,payment_link_config_id: Option<String>,) -> Result<(PaymentLinkConfig, String), error_stack::Report<errors::ApiErrorResponse>> {+ let merchant_name = processor+ .get_account()+ .merchant_name+ .clone()+ .map(|name| name.into_inner().peek().to_owned())+ .unwrap_or_default();let (domain_name, business_theme_configs, allowed_domains, branding_visibility) =if let Some(ref business_config) = business_link_config {(diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex fe6df6f323..9a3a6dd1b5 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -4281,9 +4281,8 @@ pub async fn list_customer_payment_method(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),profile_id.as_ref(),- platform.get_processor().get_account().get_id(),).await?;diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 90494f2984..8cce6cc29c 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -46,7 +46,7 @@ use common_utils::{id_type, pii,types::{AmountConvertor, MinorUnit, Surcharge},};-use diesel_models::{ephemeral_key, fraud_check::FraudCheck, refund as diesel_refund};+use diesel_models::{fraud_check::FraudCheck, refund as diesel_refund};use error_stack::{report, ResultExt};use events::EventInfo;use futures::future::join_all;@@ -7974,7 +7974,6 @@ wherepub connector_customer_id: Option<String>,pub recurring_mandate_payment_data:Option<hyperswitch_domain_models::router_data::RecurringMandatePaymentData>,- pub ephemeral_key: Option<ephemeral_key::EphemeralKey>,pub redirect_response: Option<api_models::payments::RedirectResponse>,pub surcharge_details: Option<types::SurchargeDetails>,pub frm_message: Option<FraudCheck>,@@ -11500,7 +11499,6 @@ pub trait OperationSessionGetters<F> {fn get_token(&self) -> Option<&str>;fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData>;fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse>;- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey>;fn get_setup_mandate(&self) -> Option<&MandateData>;fn get_poll_config(&self) -> Option<router_types::PollConfig>;fn get_authentication(@@ -11682,10 +11680,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {self.payment_link_data.clone()}- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {- self.ephemeral_key.clone()- }-fn get_setup_mandate(&self) -> Option<&MandateData> {self.setup_mandate.as_ref()}@@ -12035,10 +12029,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {todo!()}- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {- todo!()- }-fn get_setup_mandate(&self) -> Option<&MandateData> {todo!()}@@ -12347,10 +12337,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {todo!()}- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {- todo!()- }-fn get_setup_mandate(&self) -> Option<&MandateData> {todo!()}@@ -12658,10 +12644,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {todo!()}- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {- todo!()- }-fn get_setup_mandate(&self) -> Option<&MandateData> {todo!()}@@ -12965,10 +12947,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentCaptureData<F> {todo!()}- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {- todo!()- }-fn get_setup_mandate(&self) -> Option<&MandateData> {todo!()}@@ -13268,10 +13246,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentAttemptListData<F> {todo!()}- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {- todo!()- }-fn get_setup_mandate(&self) -> Option<&MandateData> {todo!()}@@ -13439,10 +13413,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentCancelData<F> {todo!()}- fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {- todo!()- }-fn get_setup_mandate(&self) -> Option<&MandateData> {todo!()}diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 0e5c4dcd2c..d522d942ec 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -4008,10 +4008,9 @@ pub async fn verify_payment_intent_time_and_client_secret(pub fn validate_business_details(business_country: Option<api_enums::CountryAlpha2>,business_label: Option<&String>,- platform: &domain::Platform,+ processor: &domain::Processor,) -> RouterResult<()> {- let primary_business_details = platform- .get_processor()+ let primary_business_details = processor.get_account().primary_business_details.clone()@@ -4319,9 +4318,10 @@ mod tests {#[instrument(skip_all)]pub async fn insert_merchant_connector_creds_to_config(db: &dyn StorageInterface,- merchant_id: &id_type::MerchantId,+ processor: &domain::Processor,merchant_connector_details: admin::MerchantConnectorDetailsWrap,) -> RouterResult<()> {+ let merchant_id = processor.get_account().get_id();if let Some(encoded_data) = merchant_connector_details.encoded_data {let redis = &db.get_redis_conn()@@ -7867,16 +7867,16 @@ pub async fn is_merchant_eligible_authentication_service(pub async fn validate_allowed_payment_method_types_request(state: &SessionState,profile_id: &id_type::ProfileId,- platform: &domain::Platform,+ processor: &domain::Processor,allowed_payment_method_types: Option<Vec<common_enums::PaymentMethodType>>,) -> CustomResult<(), errors::ApiErrorResponse> {if let Some(allowed_payment_method_types) = allowed_payment_method_types {let db = &*state.store;let all_connector_accounts = db.find_merchant_connector_account_by_merchant_id_and_disabled_list(- platform.get_processor().get_account().get_id(),+ processor.get_account().get_id(),false,- platform.get_processor().get_key_store(),+ processor.get_key_store(),).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -7932,7 +7932,7 @@ pub async fn validate_allowed_payment_method_types_request(1,router_env::metric_attributes!(("merchant_id",- platform.get_processor().get_account().get_id().clone()+ processor.get_account().get_id().clone())),);}diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rsindex ae476e22aa..9970a12325 100644--- a/crates/router/src/core/payments/operations/payment_approve.rs+++ b/crates/router/src/core/payments/operations/payment_approve.rs@@ -184,7 +184,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRpm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rsindex 4483eb1061..aba829f58a 100644--- a/crates/router/src/core/payments/operations/payment_cancel.rs+++ b/crates/router/src/core/payments/operations/payment_cancel.rs@@ -135,7 +135,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),mcd,).await@@ -194,7 +194,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRepm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rsindex 9148b599ee..fd428c9046 100644--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs@@ -177,7 +177,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPopm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rsindex 16e6484173..8ea5a30567 100644--- a/crates/router/src/core/payments/operations/payment_capture.rs+++ b/crates/router/src/core/payments/operations/payment_capture.rs@@ -191,7 +191,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),mcd,).await@@ -250,7 +250,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymenpm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 8a25482ca9..b0f9a73814 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -343,7 +343,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>pm_token: None,connector_customer_id: None,recurring_mandate_payment_data,- ephemeral_key: None,multiple_capture_data: None,redirect_response,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 4da89b20a4..f47f753f23 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -256,9 +256,9 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.in_current_span(),);- let m_merchant_id = merchant_id.clone();let store = state.clone().store;let m_request_merchant_connector_details = request.merchant_connector_details.clone();+ let m_processor = platform.get_processor().clone();let config_update_fut = tokio::spawn(async move {@@ -266,7 +266,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(store.as_ref(),- &m_merchant_id,+ &m_processor,mcd,).await@@ -810,7 +810,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>pm_token: None,connector_customer_id: None,recurring_mandate_payment_data,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 06b58c81f5..8c31e19811 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -14,10 +14,7 @@ use common_utils::{MinorUnit,},};-use diesel_models::{- ephemeral_key,- payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId,-};+use diesel_models::payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId;use error_stack::{self, ResultExt};use hyperswitch_domain_models::{mandates::MandateDetails,@@ -29,6 +26,7 @@ use hyperswitch_domain_models::{use masking::{ExposeInterface, PeekInterface, Secret};use router_derive::PaymentOperation;use router_env::{instrument, logger, tracing};+use storage_impl::platform_wrapper;use time::PrimitiveDateTime;use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};@@ -81,10 +79,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>) -> RouterResult<operations::GetTrackerResponse<'a, F, api::PaymentsRequest, PaymentData<F>>>{let db = &*state.store;- let ephemeral_key = Self::get_ephemeral_key(request, state, platform).await;- let merchant_id = platform.get_processor().get_account().get_id();- let storage_scheme = platform.get_processor().get_account().storage_scheme;-let money @ (amount, currency) = payments_create_request_validation(request)?;let payment_id = payment_id@@ -95,7 +89,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>helpers::validate_business_details(request.business_country,request.business_label.as_ref(),- platform,+ platform.get_processor(),)?;// If profile id is not passed, get it from the business_country and business_label@@ -103,7 +97,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>let profile_id = core_utils::get_profile_id_from_business_details(request.business_country,request.business_label.as_ref(),- platform,+ platform.get_processor(),request.profile_id.as_ref(),&*state.store,true,@@ -123,16 +117,16 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>let business_profile = if let Some(business_profile) =core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- merchant_id,).await?{business_profile} else {- db.find_business_profile_by_profile_id(- platform.get_processor().get_key_store(),+ platform_wrapper::business_profile::find_business_profile_by_profile_id(+ state.store.as_ref(),+ platform.get_processor(),&profile_id,).await@@ -177,7 +171,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>helpers::validate_allowed_payment_method_types_request(state,&profile_id,- platform,+ platform.get_processor(),request.allowed_payment_method_types.clone(),).await?;@@ -188,7 +182,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>state,request.shipping.as_ref(),None,- merchant_id,+ platform.get_processor().get_account().get_id(),customer_details.customer_id.as_ref(),platform.get_processor().get_key_store(),&payment_id,@@ -200,7 +194,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>state,request.billing.as_ref(),None,- merchant_id,+ platform.get_processor().get_account().get_id(),customer_details.customer_id.as_ref(),platform.get_processor().get_key_store(),&payment_id,@@ -216,7 +210,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.as_ref().and_then(|pmd| pmd.billing.as_ref()),None,- merchant_id,+ platform.get_processor().get_account().get_id(),customer_details.customer_id.as_ref(),platform.get_processor().get_key_store(),&payment_id,@@ -236,7 +230,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>let attempt_id = if core_utils::is_merchant_enabled_for_payment_id_as_connector_request_id(&state.conf,- merchant_id,+ platform.get_processor(),) {payment_id.get_string_repr().to_string()} else {@@ -254,21 +248,13 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>let payment_link_data = match request.payment_link {Some(true) => {- let merchant_name = platform- .get_processor()- .get_account()- .merchant_name- .clone()- .map(|name| name.into_inner().peek().to_owned())- .unwrap_or_default();-let default_domain_name = state.base_url.clone();let (payment_link_config, domain_name) =payment_link::get_payment_link_config_based_on_priority(request.payment_link_config.clone(),business_profile.payment_link_config.clone(),- merchant_name,+ platform.get_processor(),default_domain_name,request.payment_link_config_id.clone(),)?;@@ -276,7 +262,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>create_payment_link(request,payment_link_config,- merchant_id,+ platform.get_processor(),payment_id.clone(),db,amount,@@ -314,8 +300,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>let (payment_attempt_new, additional_payment_data) = Self::make_payment_attempt(&payment_id,- merchant_id,- &platform.get_processor().get_account().organization_id,+ platform,money,payment_method,payment_method_type,@@ -326,23 +311,20 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.as_ref().map(|address| address.address_id.clone()),&payment_method_info,- platform.get_processor().get_key_store(),profile_id,&customer_acceptance,- platform.get_processor().get_account().storage_scheme,).await?;- let payment_intent = db- .insert_payment_intent(- payment_intent_new,- platform.get_processor().get_key_store(),- storage_scheme,- )- .await- .to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {- payment_id: payment_id.clone(),- })?;+ let payment_intent = platform_wrapper::payment_intent::insert_payment_intent(+ state.store.as_ref(),+ platform.get_processor(),+ payment_intent_new,+ )+ .await+ .to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {+ payment_id: payment_id.clone(),+ })?;if let Some(order_details) = &request.order_details {helpers::validate_order_details_amount(@@ -353,24 +335,26 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>}#[cfg(feature = "v1")]- let mut payment_attempt = db- .insert_payment_attempt(- payment_attempt_new,- storage_scheme,- platform.get_processor().get_key_store(),- )- .await- .to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {- payment_id: payment_id.clone(),- })?;+ let mut payment_attempt = platform_wrapper::payment_attempt::insert_payment_attempt(+ state.store.as_ref(),+ platform.get_processor(),+ payment_attempt_new,+ )+ .await+ .to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {+ payment_id: payment_id.clone(),+ })?;#[cfg(feature = "v2")]- let payment_attempt = db- .insert_payment_attempt(merchant_key_store, payment_attempt_new, storage_scheme)- .await- .to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {- payment_id: payment_id.clone(),- })?;+ let payment_attempt = platform_wrapper::payment_attempt::insert_payment_attempt(+ state.store.as_ref(),+ platform.get_processor(),+ payment_attempt_new,+ )+ .await+ .to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {+ payment_id: payment_id.clone(),+ })?;let mandate_details_present = payment_attempt.mandate_details.is_some();@@ -392,7 +376,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>}).async_and_then(|mandate_id| async {let mandate = db- .find_mandate_by_merchant_id_mandate_id(merchant_id, mandate_id, storage_scheme)+ .find_mandate_by_merchant_id_mandate_id(platform.get_processor().get_account().get_id(), mandate_id, platform.get_processor().get_account().storage_scheme).await.to_not_found_response(errors::ApiErrorResponse::MandateNotFound);Some(mandate.and_then(|mandate_obj| {@@ -479,7 +463,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),mcd,).await@@ -609,7 +593,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>pm_token: None,connector_customer_id: None,recurring_mandate_payment_data,- ephemeral_key,multiple_capture_data: None,redirect_response: None,surcharge_details,@@ -1127,8 +1110,7 @@ impl PaymentCreate {#[allow(clippy::too_many_arguments)]pub async fn make_payment_attempt(payment_id: &common_utils::id_type::PaymentId,- merchant_id: &common_utils::id_type::MerchantId,- organization_id: &common_utils::id_type::OrganizationId,+ platform: &domain::Platform,money: (api::Amount, enums::Currency),payment_method: Option<enums::PaymentMethod>,payment_method_type: Option<enums::PaymentMethodType>,@@ -1137,10 +1119,8 @@ impl PaymentCreate {state: &SessionState,optional_payment_method_billing_address_id: Option<String>,payment_method_info: &Option<domain::PaymentMethod>,- key_store: &domain::MerchantKeyStore,profile_id: common_utils::id_type::ProfileId,customer_acceptance: &Option<common_payments_types::CustomerAcceptance>,- storage_scheme: enums::MerchantStorageScheme,) -> RouterResult<(PaymentAttempt,Option<api_models::payments::AdditionalPaymentData>,@@ -1255,7 +1235,7 @@ impl PaymentCreate {.attach_printable("Failed to encode additional pm data")?;let attempt_id = if core_utils::is_merchant_enabled_for_payment_id_as_connector_request_id(&state.conf,- merchant_id,+ platform.get_processor(),) {payment_id.get_string_repr().to_owned()} else {@@ -1306,14 +1286,14 @@ impl PaymentCreate {state,Some(addr.get_inner()),None,- merchant_id,+ platform.get_processor().get_account().get_id(),payment_method_info.as_ref().map(|pmd_info| pmd_info.customer_id.clone()).as_ref(),- key_store,+ platform.get_processor().get_key_store(),payment_id,- storage_scheme,+ platform.get_processor().get_account().storage_scheme,).await})@@ -1334,7 +1314,7 @@ impl PaymentCreate {Ok((PaymentAttempt {payment_id: payment_id.to_owned(),- merchant_id: merchant_id.to_owned(),+ merchant_id: platform.get_provider().get_account().get_id().clone(),attempt_id,status,currency,@@ -1399,7 +1379,7 @@ impl PaymentCreate {.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to serialize customer_acceptance")?.map(Secret::new),- organization_id: organization_id.clone(),+ organization_id: platform.get_processor().get_account().organization_id.clone(),profile_id,connector_mandate_detail: None,request_extended_authorization: None,@@ -1407,7 +1387,7 @@ impl PaymentCreate {extended_authorization_last_applied_at: None,capture_before: None,card_discovery: None,- processor_merchant_id: merchant_id.to_owned(),+ processor_merchant_id: platform.get_processor().get_account().get_id().clone(),created_by: None,setup_future_usage_applied: request.setup_future_usage,routing_approach: Some(common_enums::RoutingApproach::default()),@@ -1522,6 +1502,7 @@ impl PaymentCreate {.key.get_inner().peek();+let identifier =Identifier::Merchant(platform.get_processor().get_key_store().merchant_id.clone());let key_manager_state: KeyManagerState = state.into();@@ -1588,7 +1569,7 @@ impl PaymentCreate {Ok(storage::PaymentIntent {payment_id: payment_id.to_owned(),- merchant_id: platform.get_processor().get_account().get_id().to_owned(),+ merchant_id: platform.get_provider().get_account().get_id().to_owned(),status,amount: MinorUnit::from(amount),currency,@@ -1676,36 +1657,6 @@ impl PaymentCreate {.clone(),})}-- #[instrument(skip_all)]- pub async fn get_ephemeral_key(- request: &api::PaymentsRequest,- state: &SessionState,- platform: &domain::Platform,- ) -> Option<ephemeral_key::EphemeralKey> {- match request.get_customer_id() {- Some(customer_id) => helpers::make_ephemeral_key(- state.clone(),- customer_id.clone(),- platform- .get_processor()- .get_account()- .get_id()- .to_owned()- .clone(),- )- .await- .ok()- .and_then(|ek| {- if let services::ApplicationResponse::Json(ek) = ek {- Some(ek)- } else {- None- }- }),- None => None,- }- }}#[instrument(skip_all)]@@ -1721,7 +1672,7 @@ pub fn payments_create_request_validation(async fn create_payment_link(request: &api::PaymentsRequest,payment_link_config: api_models::admin::PaymentLinkConfig,- merchant_id: &common_utils::id_type::MerchantId,+ processor: &domain::Processor,payment_id: common_utils::id_type::PaymentId,db: &dyn StorageInterface,amount: api::Amount,@@ -1734,6 +1685,7 @@ async fn create_payment_link(let created_at @ last_modified_at = Some(common_utils::date_time::now());let payment_link_id = utils::generate_id(consts::ID_LENGTH, "plink");let locale_str = locale.unwrap_or("en".to_owned());+ let merchant_id = processor.get_account().get_id();let open_payment_link = format!("{}/payment_link/{}/{}?locale={}",domain_name,diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rsindex a6160c30f4..703181b0a9 100644--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs@@ -155,7 +155,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSesspm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex fbb335a2a9..7c69a1efb8 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -181,7 +181,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequestpm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex 5d7c260d9a..9baa93bf04 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -146,7 +146,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),mcd,).await@@ -205,7 +205,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionRpm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex 116ac5c228..9420969214 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -192,7 +192,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReqpm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex a9284007c3..b5f6209894 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -402,12 +402,8 @@ async fn get_tracker_for_sync<.merchant_connector_details.to_owned().async_map(|mcd| async {- helpers::insert_merchant_connector_creds_to_config(- db,- platform.get_processor().get_account().get_id(),- mcd,- )- .await+ helpers::insert_merchant_connector_creds_to_config(db, platform.get_processor(), mcd)+ .await}).await.transpose()?;@@ -529,7 +525,6 @@ async fn get_tracker_for_sync<pm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data,redirect_response: None,payment_link_data,diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex cc7430adfc..1ec208eeaa 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -408,7 +408,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.async_map(|mcd| async {helpers::insert_merchant_connector_creds_to_config(db,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),mcd,).await@@ -501,7 +501,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>pm_token: None,connector_customer_id: None,recurring_mandate_payment_data,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details,diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rsindex ab3fb387f0..c3ffdc6a30 100644--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs@@ -141,7 +141,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsUpdateMepm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rsindex fddfcc3eef..ec00b79464 100644--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs@@ -182,7 +182,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsExtendAupm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex 3286b90d53..adeac1e4a1 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -156,7 +156,6 @@ impl<F: Send + Clone + Sync>pm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rsindex 5054157ed0..e879e1838b 100644--- a/crates/router/src/core/payments/operations/tax_calculation.rs+++ b/crates/router/src/core/payments/operations/tax_calculation.rs@@ -171,7 +171,6 @@ impl<F: Send + Clone + Sync>pm_token: None,connector_customer_id: None,recurring_mandate_payment_data: None,- ephemeral_key: None,multiple_capture_data: None,redirect_response: None,surcharge_details: None,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 38f8b4433e..e19c4ba0fb 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -172,7 +172,7 @@ whererecurring_mandate_payment_data: None,connector_request_reference_id: core_utils::get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),&payment_data.payment_intent,&payment_data.payment_attempt,connector_id,@@ -1901,7 +1901,7 @@ whererecurring_mandate_payment_data: payment_data.recurring_mandate_payment_data,connector_request_reference_id: core_utils::get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),&payment_data.payment_intent,&payment_data.payment_attempt,connector_id,@@ -2099,7 +2099,7 @@ pub async fn construct_payment_router_data_for_update_metadata<'a>(recurring_mandate_payment_data: payment_data.recurring_mandate_payment_data,connector_request_reference_id: core_utils::get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),&payment_data.payment_intent,&payment_data.payment_attempt,connector_id,@@ -3946,9 +3946,6 @@ wherebusiness_label: payment_intent.business_label,business_sub_label: payment_attempt.business_sub_label,allowed_payment_method_types: payment_intent.allowed_payment_method_types,- ephemeral_key: payment_data- .get_ephemeral_key()- .map(ForeignFrom::foreign_from),manual_retry_allowed,connector_transaction_id,frm_message,@@ -4269,7 +4266,6 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Paypayment_experience: None,connector_label: None,allowed_payment_method_types: None,- ephemeral_key: None,manual_retry_allowed: None,frm_message: None,connector_metadata: None,diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex c1f9f509a0..1e220af3a8 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -2758,13 +2758,8 @@ pub async fn payout_create_db_entries(let customer_id = customer.map(|cust| cust.customer_id.clone());// Validate whether profile_id passed in request is valid and is linked to the merchant- let business_profile = validate_and_get_business_profile(- state,- platform.get_processor().get_key_store(),- profile_id,- merchant_id,- )- .await?;+ let business_profile =+ validate_and_get_business_profile(state, platform.get_processor(), profile_id).await?;let payout_link = match req.payout_link {Some(true) => Some(@@ -3081,13 +3076,8 @@ pub async fn make_payout_data(let profile_id = payout_attempt.profile_id.clone();// Validate whether profile_id passed in request is valid and is linked to the merchant- let business_profile = validate_and_get_business_profile(- state,- platform.get_processor().get_key_store(),- &profile_id,- merchant_id,- )- .await?;+ let business_profile =+ validate_and_get_business_profile(state, platform.get_processor(), &profile_id).await?;let payout_method_data_req = match req {payouts::PayoutRequest::PayoutCreateRequest(r) => r.payout_method_data.to_owned(),payouts::PayoutRequest::PayoutActionRequest(_) => {@@ -3243,23 +3233,17 @@ pub async fn add_external_account_addition_task(async fn validate_and_get_business_profile(state: &SessionState,- merchant_key_store: &domain::MerchantKeyStore,+ processor: &domain::Processor,profile_id: &id_type::ProfileId,- merchant_id: &id_type::MerchantId,) -> RouterResult<domain::Profile> {let db = &*state.store;- if let Some(business_profile) = core_utils::validate_and_get_business_profile(- db,- merchant_key_store,- Some(profile_id),- merchant_id,- )- .await?+ if let Some(business_profile) =+ core_utils::validate_and_get_business_profile(db, processor, Some(profile_id)).await?{Ok(business_profile)} else {- db.find_business_profile_by_profile_id(merchant_key_store, profile_id)+ db.find_business_profile_by_profile_id(processor.get_key_store(), profile_id).await.to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {id: profile_id.get_string_repr().to_owned(),diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rsindex 61872acc34..27adad356a 100644--- a/crates/router/src/core/payouts/helpers.rs+++ b/crates/router/src/core/payouts/helpers.rs@@ -922,9 +922,8 @@ pub async fn decide_payout_connector(// Validate and get the business_profile from payout_attemptlet business_profile = core_utils::validate_and_get_business_profile(state.store.as_ref(),- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&payout_attempt.profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rsindex ce73a119d0..31c841c0ff 100644--- a/crates/router/src/core/payouts/validator.rs+++ b/crates/router/src/core/payouts/validator.rs@@ -149,7 +149,7 @@ pub async fn validate_create_request(let profile_id = core_utils::get_profile_id_from_business_details(req.business_country,req.business_label.as_ref(),- platform,+ platform.get_processor(),req.profile_id.as_ref(),&*state.store,false,diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rsindex 5871d9938d..47316b529b 100644--- a/crates/router/src/core/refunds.rs+++ b/crates/router/src/core/refunds.rs@@ -120,7 +120,8 @@ pub async fn refund_create_core(req.merchant_connector_details.to_owned().async_map(|mcd| async {- helpers::insert_merchant_connector_creds_to_config(db, merchant_id, mcd).await+ helpers::insert_merchant_connector_creds_to_config(db, platform.get_processor(), mcd)+ .await}).await.transpose()?;@@ -697,7 +698,8 @@ pub async fn refund_retrieve_core(.merchant_connector_details.to_owned().async_map(|mcd| async {- helpers::insert_merchant_connector_creds_to_config(db, merchant_id, mcd).await+ helpers::insert_merchant_connector_creds_to_config(db, platform.get_processor(), mcd)+ .await}).await.transpose()?;diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rsindex c0e4d71273..35f9cdc754 100644--- a/crates/router/src/core/routing.rs+++ b/crates/router/src/core/routing.rs@@ -239,9 +239,8 @@ async fn build_list_routing_result(let hs_result_for_profile = hs_results.iter().filter(by_profile).cloned().collect();let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -275,9 +274,8 @@ pub async fn create_routing_algorithm_under_profile(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&request.profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;@@ -381,9 +379,8 @@ pub async fn create_routing_algorithm_under_profile(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;@@ -535,9 +532,8 @@ pub async fn link_routing_config_under_profile(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;@@ -600,9 +596,8 @@ pub async fn link_routing_config(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&routing_algorithm.profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -929,9 +924,8 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(.await?;let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&routing_algorithm.0.profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -967,9 +961,8 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&routing_algorithm.profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -998,9 +991,8 @@ pub async fn unlink_routing_config_under_profile(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;@@ -1061,9 +1053,8 @@ pub async fn unlink_routing_config(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?;@@ -1159,9 +1150,8 @@ pub async fn update_default_fallback_routing(let key_manager_state = &(&state).into();let profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;@@ -1292,9 +1282,8 @@ pub async fn retrieve_default_fallback_algorithm_for_profile(let db = state.store.as_ref();let profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;@@ -1347,9 +1336,8 @@ pub async fn retrieve_routing_config_under_profile(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")?;@@ -1393,9 +1381,8 @@ pub async fn retrieve_linked_routing_config(let business_profiles = if let Some(profile_id) = query_params.profile_id {core_utils::validate_and_get_business_profile(db,- merchant_key_store,+ platform.get_processor(),Some(&profile_id),- merchant_id,).await?.map(|profile| vec![profile])@@ -1601,9 +1588,8 @@ pub async fn update_default_routing_config_for_profile(let business_profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -1691,9 +1677,8 @@ pub async fn toggle_specific_dynamic_routing(let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -1764,9 +1749,8 @@ pub async fn create_specific_dynamic_routing(let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -1837,9 +1821,8 @@ pub async fn configure_dynamic_routing_volume_split(let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -1881,9 +1864,8 @@ pub async fn retrieve_dynamic_routing_volume_split(let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -2126,9 +2108,8 @@ pub async fn contract_based_dynamic_routing_setup(let business_profile: domain::Profile = core_utils::validate_and_get_business_profile(db,- platform.get_processor().get_key_store(),+ platform.get_processor(),Some(&profile_id),- platform.get_processor().get_account().get_id(),).await?.get_required_value("Profile")@@ -2594,14 +2575,11 @@ pub async fn migrate_rules_for_profile(let profile_id = query_params.profile_id.clone();let db = state.store.as_ref();- let merchant_key_store = platform.get_processor().get_key_store();- let merchant_id = platform.get_processor().get_account().get_id();let business_profile = core_utils::validate_and_get_business_profile(db,- merchant_key_store,+ platform.get_processor(),Some(&profile_id),- merchant_id,).await?.get_required_value("Profile")diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rsindex 3808d4dba5..05bd6dfd97 100644--- a/crates/router/src/core/unified_authentication_service.rs+++ b/crates/router/src/core/unified_authentication_service.rs@@ -673,7 +673,7 @@ pub async fn authentication_create_core(let profile_id = core_utils::get_profile_id_from_business_details(None,None,- &platform,+ platform.get_processor(),req.profile_id.as_ref(),db,true,@@ -1033,7 +1033,7 @@ pub async fn authentication_eligibility_core(let profile_id = core_utils::get_profile_id_from_business_details(None,None,- &platform,+ platform.get_processor(),req.profile_id.as_ref(),db,true,diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex c6ba3cb156..0cbaaedcb9 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -1018,7 +1018,7 @@ pub async fn construct_accept_dispute_router_data<'a>(preprocessing_id: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),payment_intent,payment_attempt,&dispute.connector,@@ -1125,7 +1125,7 @@ pub async fn construct_submit_evidence_router_data<'a>(payment_method_status: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),payment_intent,payment_attempt,connector_id,@@ -1240,7 +1240,7 @@ pub async fn construct_upload_file_router_data<'a>(payment_method_balance: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),payment_intent,payment_attempt,connector_id,@@ -1423,7 +1423,7 @@ pub async fn construct_dispute_sync_router_data<'a>(payment_method_balance: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),payment_intent,payment_attempt,connector_id,@@ -1552,7 +1552,7 @@ pub async fn construct_payments_dynamic_tax_calculation_router_data<F: Clone>(response: Err(ErrorResponse::default()),connector_request_reference_id: get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),payment_intent,payment_attempt,&merchant_connector_account.connector_name,@@ -1662,7 +1662,7 @@ pub async fn construct_defend_dispute_router_data<'a>(payment_method_balance: None,connector_request_reference_id: get_connector_request_reference_id(&state.conf,- platform.get_processor().get_account().get_id(),+ platform.get_processor(),payment_intent,payment_attempt,connector_id,@@ -1799,8 +1799,9 @@ pub async fn construct_retrieve_file_router_data<'a>(pub fn is_merchant_enabled_for_payment_id_as_connector_request_id(conf: &Settings,- merchant_id: &common_utils::id_type::MerchantId,+ processor: &domain::Processor,) -> bool {+ let merchant_id = processor.get_account().get_id();let config_map = &conf.connector_request_reference_id_config.merchant_ids_send_payment_id_as_connector_request_id;@@ -1810,13 +1811,13 @@ pub fn is_merchant_enabled_for_payment_id_as_connector_request_id(#[cfg(feature = "v1")]pub fn get_connector_request_reference_id(conf: &Settings,- merchant_id: &common_utils::id_type::MerchantId,+ processor: &domain::Processor,payment_intent: &hyperswitch_domain_models::payments::PaymentIntent,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,connector_name: &str,) -> CustomResult<String, errors::ApiErrorResponse> {let is_config_enabled_to_send_payment_id_as_connector_request_id =- is_merchant_enabled_for_payment_id_as_connector_request_id(conf, merchant_id);+ is_merchant_enabled_for_payment_id_as_connector_request_id(conf, processor);let connector_data = api::ConnectorData::get_connector_by_name(&conf.connectors,@@ -1930,15 +1931,14 @@ pub fn get_payout_connector_customer_id(/// Validate whether the profile_id exists and is associated with the merchant_idpub async fn validate_and_get_business_profile(db: &dyn StorageInterface,- merchant_key_store: &domain::MerchantKeyStore,+ processor: &domain::Processor,profile_id: Option<&common_utils::id_type::ProfileId>,- merchant_id: &common_utils::id_type::MerchantId,) -> RouterResult<Option<domain::Profile>> {profile_id.async_map(|profile_id| async {db.find_business_profile_by_merchant_id_profile_id(- merchant_key_store,- merchant_id,+ processor.get_key_store(),+ processor.get_account().get_id(),profile_id,).await@@ -1996,27 +1996,16 @@ pub fn get_connector_label(pub async fn get_profile_id_from_business_details(business_country: Option<api_models::enums::CountryAlpha2>,business_label: Option<&String>,- platform: &domain::Platform,+ processor: &domain::Processor,request_profile_id: Option<&common_utils::id_type::ProfileId>,db: &dyn StorageInterface,should_validate: bool,) -> RouterResult<common_utils::id_type::ProfileId> {- match request_profile_id.or(platform- .get_processor()- .get_account()- .default_profile- .as_ref())- {+ match request_profile_id.or(processor.get_account().default_profile.as_ref()) {Some(profile_id) => {// Check whether this business profile belongs to the merchantif should_validate {- let _ = validate_and_get_business_profile(- db,- platform.get_processor().get_key_store(),- Some(profile_id),- platform.get_processor().get_account().get_id(),- )- .await?;+ let _ = validate_and_get_business_profile(db, processor, Some(profile_id)).await?;}Ok(profile_id.clone())}@@ -2025,9 +2014,9 @@ pub async fn get_profile_id_from_business_details(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 {diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex 4e9b715487..9411743ea1 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -1353,7 +1353,6 @@ mod tests {business_label: None,business_sub_label: None,allowed_payment_method_types: None,- ephemeral_key: None,manual_retry_allowed: None,connector_transaction_id: None,frm_message: None,diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rsindex b2d43ff610..b1d132f325 100644--- a/crates/router/src/utils/user/sample_data.rs+++ b/crates/router/src/utils/user/sample_data.rs@@ -76,7 +76,7 @@ pub async fn generate_sample_data(let profile_id = crate::core::utils::get_profile_id_from_business_details(business_country_default,business_label_default.as_ref(),- &platform,+ platform.get_processor(),req.profile_id.as_ref(),&*state.store,false,diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex 049de18982..a2ada433d7 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -421,7 +421,6 @@ async fn payments_create_core() {business_label: None,business_sub_label: None,allowed_payment_method_types: None,- ephemeral_key: None,manual_retry_allowed: None,connector_transaction_id: None,frm_message: None,@@ -714,7 +713,6 @@ async fn payments_create_core_adyen_no_redirect() {business_label: None,business_sub_label: None,allowed_payment_method_types: None,- ephemeral_key: None,manual_retry_allowed: None,connector_transaction_id: None,frm_message: None,diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex 36fa5a3e75..805fa97e92 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -181,7 +181,6 @@ async fn payments_create_core() {business_label: None,business_sub_label: None,allowed_payment_method_types: None,- ephemeral_key: None,manual_retry_allowed: None,connector_transaction_id: None,frm_message: None,@@ -483,7 +482,6 @@ async fn payments_create_core_adyen_no_redirect() {business_label: None,business_sub_label: None,allowed_payment_method_types: None,- ephemeral_key: None,manual_retry_allowed: None,connector_transaction_id: None,frm_message: None,diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rsindex de48c8c5f8..469f7bb43f 100644--- a/crates/storage_impl/src/lib.rs+++ b/crates/storage_impl/src/lib.rs@@ -32,6 +32,7 @@ pub mod payment_method;pub mod payments;#[cfg(feature = "payouts")]pub mod payouts;+pub mod platform_wrapper;pub mod redis;pub mod refund;mod reverse_lookup;diff --git a/crates/storage_impl/src/platform_wrapper.rs b/crates/storage_impl/src/platform_wrapper.rsnew file mode 100644index 0000000000..9591d8d295--- /dev/null+++ b/crates/storage_impl/src/platform_wrapper.rs@@ -0,0 +1,20 @@+/// Platform wrapper for database operations+///+/// Purpose: Prevent mixing Provider and Processor credentials when making DB calls.+///+/// Use wrappers when:+/// - You have Platform and need DB calls+/// - Multiple credentials needed (key_store, merchant_id, storage_scheme)+///+/// Direct DB calls are OK when no wrapper is needed:+/// - Function already has Provider or Processor directly+/// - All credentials are bundled in the context+/// - Working with a deprecated module that still uses Processor+///+/// Never mix Provider and Processor credentials or pass Platform to wrappers.+/// Extract the specific context (Provider/Processor) and pass that instead.+///+// TODO: Remove wrappers and migrate to DB interface with typed parameters (ProviderMerchantId, ProcessorMerchantId, etc.) once the platform stabilizes+pub mod business_profile;+pub mod payment_attempt;+pub mod payment_intent;diff --git a/crates/storage_impl/src/platform_wrapper/business_profile.rs b/crates/storage_impl/src/platform_wrapper/business_profile.rsnew file mode 100644index 0000000000..2a88812af8--- /dev/null+++ b/crates/storage_impl/src/platform_wrapper/business_profile.rs@@ -0,0 +1,20 @@+use common_utils::errors::CustomResult;+use hyperswitch_domain_models::{+ business_profile::{Profile, ProfileInterface},+ platform::Processor,+};++use crate::StorageError;++pub async fn find_business_profile_by_profile_id<S>(+ store: &S,+ processor: &Processor,+ profile_id: &common_utils::id_type::ProfileId,+) -> CustomResult<Profile, StorageError>+where+ S: ProfileInterface<Error = StorageError> + ?Sized,+{+ store+ .find_business_profile_by_profile_id(processor.get_key_store(), profile_id)+ .await+}diff --git a/crates/storage_impl/src/platform_wrapper/payment_attempt.rs b/crates/storage_impl/src/platform_wrapper/payment_attempt.rsnew file mode 100644index 0000000000..a0c6d97cbf--- /dev/null+++ b/crates/storage_impl/src/platform_wrapper/payment_attempt.rs@@ -0,0 +1,43 @@+use common_utils::errors::CustomResult;+use hyperswitch_domain_models::{+ payments::payment_attempt::{PaymentAttempt, PaymentAttemptInterface},+ platform::Processor,+};++use crate::StorageError;++#[cfg(feature = "v1")]+pub async fn insert_payment_attempt<S>(+ store: &S,+ processor: &Processor,+ payment_attempt: PaymentAttempt,+) -> CustomResult<PaymentAttempt, StorageError>+where+ S: PaymentAttemptInterface<Error = StorageError> + ?Sized,+{+ store+ .insert_payment_attempt(+ payment_attempt,+ processor.get_account().storage_scheme,+ processor.get_key_store(),+ )+ .await+}++#[cfg(feature = "v2")]+pub async fn insert_payment_attempt<S>(+ store: &S,+ processor: &Processor,+ payment_attempt: PaymentAttempt,+) -> CustomResult<PaymentAttempt, StorageError>+where+ S: PaymentAttemptInterface<Error = StorageError> + ?Sized,+{+ store+ .insert_payment_attempt(+ processor.get_key_store(),+ payment_attempt,+ processor.get_account().storage_scheme,+ )+ .await+}diff --git a/crates/storage_impl/src/platform_wrapper/payment_intent.rs b/crates/storage_impl/src/platform_wrapper/payment_intent.rsnew file mode 100644index 0000000000..959c7179fd--- /dev/null+++ b/crates/storage_impl/src/platform_wrapper/payment_intent.rs@@ -0,0 +1,24 @@+use common_utils::errors::CustomResult;+use hyperswitch_domain_models::{+ payments::{payment_intent::PaymentIntentInterface, PaymentIntent},+ platform::Processor,+};++use crate::StorageError;++pub async fn insert_payment_intent<S>(+ store: &S,+ processor: &Processor,+ payment_intent: PaymentIntent,+) -> CustomResult<PaymentIntent, StorageError>+where+ S: PaymentIntentInterface<Error = StorageError> + ?Sized,+{+ store+ .insert_payment_intent(+ payment_intent,+ processor.get_key_store(),+ processor.get_account().storage_scheme,+ )+ .await+}