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): implement payment method sharing model for platform-connected setup (#10458)
Sandeep Kumar9e57ada31181
diff --git a/crates/payment_methods/src/core/migration/payment_methods.rs b/crates/payment_methods/src/core/migration/payment_methods.rsindex 8ab78ceff4..f2c39db6ab 100644--- a/crates/payment_methods/src/core/migration/payment_methods.rs+++ b/crates/payment_methods/src/core/migration/payment_methods.rs@@ -93,7 +93,7 @@ pub async fn migrate_payment_method(get_client_secret_or_add_payment_method_for_migration(state,payment_method_create_request,- platform,+ platform.get_provider(),&mut migration_status,controller,)@@ -105,7 +105,7 @@ pub async fn migrate_payment_method(state,&req,merchant_id.to_owned(),- platform,+ platform.get_provider(),card_bin_details.clone(),should_require_connector_mandate_details,&mut migration_status,@@ -134,7 +134,7 @@ pub async fn migrate_payment_method(controller.save_network_token_and_update_payment_method(&req,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),network_token_data,network_token_requestor_ref_id,pm_id,@@ -385,11 +385,11 @@ implpub async fn get_client_secret_or_add_payment_method_for_migration(state: &state::PaymentMethodsState,req: pm_api::PaymentMethodCreate,- platform: &platform::Platform,+ provider: &platform::Provider,migration_status: &mut migration::RecordMigrationStatusBuilder,controller: &dyn PaymentMethodsController,) -> CustomResult<ApplicationResponse<pm_api::PaymentMethodResponse>, errors::ApiErrorResponse> {- let merchant_id = platform.get_processor().get_account().get_id();+ let merchant_id = provider.get_account().get_id();let customer_id = req.customer_id.clone().get_required_value("customer_id")?;#[cfg(not(feature = "payouts"))]@@ -402,11 +402,7 @@ pub async fn get_client_secret_or_add_payment_method_for_migration(.billing.clone().async_map(|billing| {- create_encrypted_data(- key_manager_state,- platform.get_processor().get_key_store(),- billing,- )+ create_encrypted_data(key_manager_state, provider.get_key_store(), billing)}).await.transpose()@@ -490,7 +486,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(state: &state::PaymentMethodsState,req: &pm_api::PaymentMethodMigrate,merchant_id: id_type::MerchantId,- platform: &platform::Platform,+ provider: &platform::Provider,card: pm_api::CardDetailFromLocker,should_require_connector_mandate_details: bool,migration_status: &mut migration::RecordMigrationStatusBuilder,@@ -531,11 +527,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(.billing.clone().async_map(|billing| {- create_encrypted_data(- key_manager_state,- platform.get_processor().get_key_store(),- billing,- )+ create_encrypted_data(key_manager_state, provider.get_key_store(), billing)}).await.transpose()@@ -546,8 +538,8 @@ pub async fn skip_locker_call_and_migrate_payment_method(.find_customer_by_customer_id_merchant_id(&customer_id,&merchant_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;@@ -559,7 +551,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(let payment_method_data_encrypted: Option<Encryptable<Secret<serde_json::Value>>> = Some(create_encrypted_data(&state.into(),- platform.get_processor().get_key_store(),+ provider.get_key_store(),payment_method_card_details,).await@@ -578,7 +570,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(let response = db.insert_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),domain_pm::PaymentMethod {customer_id: customer_id.to_owned(),merchant_id: merchant_id.to_owned(),@@ -618,7 +610,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(created_by: None,last_modified_by: None,},- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -659,7 +651,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(_state: state::PaymentMethodsState,_req: &pm_api::PaymentMethodMigrate,_merchant_id: id_type::MerchantId,- _platform: &platform::Platform,+ _provider: &platform::Provider,_card: pm_api::CardDetailFromLocker,) -> CustomResult<ApplicationResponse<pm_api::PaymentMethodResponse>, errors::ApiErrorResponse> {todo!()diff --git a/crates/router/src/compatibility/stripe/customers.rs b/crates/router/src/compatibility/stripe/customers.rsindex f0a57cf590..3d7ac7a5b6 100644--- a/crates/router/src/compatibility/stripe/customers.rs+++ b/crates/router/src/compatibility/stripe/customers.rs@@ -57,8 +57,8 @@ pub async fn customer_create(customers::create_customer(state, platform.get_provider().clone(), req, None)},&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),api_locking::LockAction::NotApplicable,))@@ -95,8 +95,8 @@ pub async fn customer_retrieve(customers::retrieve_customer(state, platform.get_provider().clone(), None, customer_id)},&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),api_locking::LockAction::NotApplicable,))@@ -147,8 +147,8 @@ pub async fn customer_update(customers::update_customer(state, platform.get_provider().clone(), request_internal)},&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),api_locking::LockAction::NotApplicable,))@@ -181,12 +181,12 @@ pub async fn customer_delete(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- let platform = auth.into();- customers::delete_customer(state, platform, customer_id)+ let platform: domain::Platform = auth.into();+ customers::delete_customer(state, platform.get_provider().clone(), customer_id)},&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),api_locking::LockAction::NotApplicable,))@@ -230,8 +230,8 @@ pub async fn list_customer_payment_method_api()},&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),api_locking::LockAction::NotApplicable,))diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex 82403c8871..bb1189acfa 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -635,12 +635,12 @@ pub async fn list_customers_with_count(#[instrument(skip_all)]pub async fn delete_customer(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,id: id_type::GlobalCustomerId,) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {let db = &*state.store;let key_manager_state = &(&state).into();- id.redact_customer_details_and_generate_response(db, &platform, key_manager_state, &state)+ id.redact_customer_details_and_generate_response(db, &provider, key_manager_state, &state).await}@@ -650,15 +650,15 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {async fn redact_customer_details_and_generate_response<'a>(&'a self,db: &'a dyn StorageInterface,- platform: &'a domain::Platform,+ provider: &'a domain::Provider,key_manager_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {let customer_orig = db.find_customer_by_global_id(self,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.switch()?;@@ -674,11 +674,7 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {}match db- .find_payment_method_list_by_global_customer_id(- platform.get_processor().get_key_store(),- self,- None,- )+ .find_payment_method_list_by_global_customer_id(provider.get_key_store(), self, None).await{// check this in review@@ -688,7 +684,7 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {cards::delete_card_by_locker_id(state,self,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),).await.switch()?;@@ -717,15 +713,9 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {}};- let key = platform- .get_processor()- .get_key_store()- .key- .get_inner()- .peek();+ let key = provider.get_key_store().key.get_inner().peek();- let identifier =- Identifier::Merchant(platform.get_processor().get_key_store().merchant_id.clone());+ let identifier = Identifier::Merchant(provider.get_key_store().merchant_id.clone());let redacted_encrypted_value: Encryptable<Secret<_>> = types::crypto_operation(key_manager_state,type_name!(storage::Address),@@ -766,8 +756,8 @@ impl CustomerDeleteBridge for id_type::GlobalCustomerId {self,customer_orig,updated_customer,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.switch()?;@@ -789,7 +779,7 @@ trait CustomerDeleteBridge {async fn redact_customer_details_and_generate_response<'a>(&'a self,db: &'a dyn StorageInterface,- platform: &'a domain::Platform,+ provider: &'a domain::Provider,key_manager_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomerResponse<customers::CustomerDeleteResponse>;@@ -799,13 +789,13 @@ trait CustomerDeleteBridge {#[instrument(skip_all)]pub async fn delete_customer(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,customer_id: id_type::CustomerId,) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {let db = &*state.store;let key_manager_state = &(&state).into();customer_id- .redact_customer_details_and_generate_response(db, &platform, key_manager_state, &state)+ .redact_customer_details_and_generate_response(db, &provider, key_manager_state, &state).await}@@ -815,25 +805,22 @@ impl CustomerDeleteBridge for id_type::CustomerId {async fn redact_customer_details_and_generate_response<'a>(&'a self,db: &'a dyn StorageInterface,- platform: &'a domain::Platform,+ provider: &'a domain::Provider,key_manager_state: &'a KeyManagerState,state: &'a SessionState,) -> errors::CustomerResponse<customers::CustomerDeleteResponse> {let customer_orig = db.find_customer_by_customer_id_merchant_id(self,- platform.get_processor().get_account().get_id(),- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_account().get_id(),+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.switch()?;let customer_mandates = db- .find_mandate_by_merchant_id_customer_id(- platform.get_processor().get_account().get_id(),- self,- )+ .find_mandate_by_merchant_id_customer_id(provider.get_account().get_id(), self).await.switch()?;@@ -845,9 +832,9 @@ impl CustomerDeleteBridge for id_type::CustomerId {match db.find_payment_method_by_customer_id_merchant_id_list(- platform.get_processor().get_key_store(),+ provider.get_key_store(),self,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),None,).await@@ -856,10 +843,10 @@ impl CustomerDeleteBridge for id_type::CustomerId {Ok(customer_payment_methods) => {for pm in customer_payment_methods.into_iter() {if pm.get_payment_method_type() == Some(enums::PaymentMethod::Card) {- cards::PmCards { state, platform }+ cards::PmCards { state, provider }.delete_card_from_locker(self,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),pm.locker_id.as_ref().unwrap_or(&pm.payment_method_id),).await@@ -870,11 +857,11 @@ impl CustomerDeleteBridge for id_type::CustomerId {network_tokenization::delete_network_token_from_locker_and_token_service(state,self,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),pm.payment_method_id.clone(),pm.network_token_locker_id,network_token_ref_id,- platform,+ provider,).await.switch()?;@@ -882,8 +869,8 @@ impl CustomerDeleteBridge for id_type::CustomerId {}db.delete_payment_method_by_merchant_id_payment_method_id(- platform.get_processor().get_key_store(),- platform.get_processor().get_account().get_id(),+ provider.get_key_store(),+ provider.get_account().get_id(),&pm.payment_method_id,).await@@ -906,14 +893,8 @@ impl CustomerDeleteBridge for id_type::CustomerId {}};- let key = platform- .get_processor()- .get_key_store()- .key- .get_inner()- .peek();- let identifier =- Identifier::Merchant(platform.get_processor().get_key_store().merchant_id.clone());+ let key = provider.get_key_store().key.get_inner().peek();+ let identifier = Identifier::Merchant(provider.get_key_store().merchant_id.clone());let redacted_encrypted_value: Encryptable<Secret<_>> = types::crypto_operation(key_manager_state,type_name!(storage::Address),@@ -945,11 +926,7 @@ impl CustomerDeleteBridge for id_type::CustomerId {last_name: Some(redacted_encrypted_value.clone()),phone_number: Some(redacted_encrypted_value.clone()),country_code: Some(REDACTED.to_string()),- updated_by: platform- .get_processor()- .get_account()- .storage_scheme- .to_string(),+ updated_by: provider.get_account().storage_scheme.to_string(),email: Some(redacted_encrypted_email),origin_zip: Some(redacted_encrypted_value.clone()),};@@ -957,9 +934,9 @@ impl CustomerDeleteBridge for id_type::CustomerId {match db.update_address_by_merchant_id_customer_id(self,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),update_address,- platform.get_processor().get_key_store(),+ provider.get_key_store(),).await{@@ -1001,11 +978,11 @@ impl CustomerDeleteBridge for id_type::CustomerId {db.update_customer_by_customer_id_merchant_id(self.clone(),- platform.get_processor().get_account().get_id().to_owned(),+ provider.get_account().get_id().to_owned(),customer_orig,updated_customer,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.switch()?;diff --git a/crates/router/src/core/locker_migration.rs b/crates/router/src/core/locker_migration.rsindex 0fd70b4495..19572729e1 100644--- a/crates/router/src/core/locker_migration.rs+++ b/crates/router/src/core/locker_migration.rs@@ -165,7 +165,7 @@ pub async fn call_to_locker(let add_card_result = cards::PmCards{state,- platform,+ provider: platform.get_provider(),}.add_card_hs(pm_create,&card_details,diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 0e99e477f7..75a4b2f6c5 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -278,7 +278,7 @@ pub async fn render_pm_collect_link(#[cfg(feature = "v1")]pub async fn render_pm_collect_link(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,req: payment_methods::PaymentMethodCollectLinkRenderRequest,) -> RouterResponse<services::GenericLinkFormData> {let db: &dyn StorageInterface = &*state.store;@@ -340,8 +340,8 @@ pub async fn render_pm_collect_link(.find_customer_by_customer_id_merchant_id(&customer_id,&req.merchant_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InvalidRequestData {@@ -356,13 +356,7 @@ pub async fn render_pm_collect_link())?;let js_data = payment_methods::PaymentMethodCollectLinkDetails {- publishable_key: Secret::new(- platform- .get_processor()- .get_account()- .clone()- .publishable_key,- ),+ publishable_key: Secret::new(provider.get_account().clone().publishable_key),client_secret: link_data.client_secret.clone(),pm_collect_link_id: pm_collect_link.link_id,customer_id: customer.customer_id,@@ -906,14 +900,14 @@ pub async fn create_payment_method_core(req.validate()?;let db = &*state.store;- let merchant_id = platform.get_processor().get_account().get_id();+ let merchant_id = platform.get_provider().get_account().get_id();let customer_id = req.customer_id.to_owned();let key_manager_state = &(state).into();db.find_customer_by_global_id(&customer_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)@@ -925,7 +919,7 @@ pub async fn create_payment_method_core(.async_map(|billing| {cards::create_encrypted_data(key_manager_state,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),billing,)})@@ -998,8 +992,8 @@ pub async fn create_payment_method_card_core(customer_id,payment_method_id,merchant_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,payment_method_billing_address,).await@@ -1041,7 +1035,7 @@ pub async fn create_payment_method_card_core(let pm_update = create_pm_additional_data_update(Some(&payment_method_data),state,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),Some(vault_id.get_string_repr().clone()),fingerprint_id,&payment_method,@@ -1056,10 +1050,10 @@ pub async fn create_payment_method_card_core(let payment_method = db.update_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),payment_method,pm_update,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1076,10 +1070,10 @@ pub async fn create_payment_method_card_core(};db.update_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),payment_method,pm_update,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1128,7 +1122,7 @@ pub async fn create_payment_method_proxy_card_core(.async_map(|payment_method_data| {cards::create_encrypted_data(key_manager_state,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),payment_method_data,)})@@ -1149,7 +1143,7 @@ pub async fn create_payment_method_proxy_card_core(.async_map(|external_vault_token_data| {cards::create_encrypted_data(key_manager_state,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),external_vault_token_data,)})@@ -1175,8 +1169,8 @@ pub async fn create_payment_method_proxy_card_core(payment_method_id,external_vault_source,merchant_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,req.payment_method_type,req.payment_method_subtype,payment_method_billing_address,@@ -1256,7 +1250,7 @@ pub async fn network_tokenize_and_vault_the_pmd(let key_manager_state = &(state).into();let network_token_pmd = cards::create_encrypted_data(key_manager_state,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),network_token_vaulting_data.get_payment_methods_data(),).await@@ -1517,17 +1511,17 @@ impl PaymentMethodExt for payment_methods::PaymentMethodCreateData {pub async fn payment_method_intent_create(state: &SessionState,req: api::PaymentMethodIntentCreate,- platform: &domain::Platform,+ provider: domain::Provider,) -> RouterResponse<api::PaymentMethodResponse> {let db = &*state.store;- let merchant_id = platform.get_processor().get_account().get_id();+ let merchant_id = provider.get_account().get_id();let customer_id = req.customer_id.to_owned();let key_manager_state = &(state).into();db.find_customer_by_global_id(&customer_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)@@ -1537,11 +1531,7 @@ pub async fn payment_method_intent_create(.billing.clone().async_map(|billing| {- cards::create_encrypted_data(- key_manager_state,- platform.get_processor().get_key_store(),- billing,- )+ cards::create_encrypted_data(key_manager_state, provider.get_key_store(), billing)}).await.transpose()@@ -1567,8 +1557,8 @@ pub async fn payment_method_intent_create(&customer_id,payment_method_id,merchant_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,payment_method_billing_address,).await@@ -1605,7 +1595,7 @@ pub async fn list_payment_methods_for_session(let payment_method_session = db.get_payment_methods_session(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&payment_method_session_id,).await@@ -1624,7 +1614,8 @@ pub async fn list_payment_methods_for_session(let customer_payment_methods = match payment_method_session.customer_id {Some(customer_id) => {- list_customer_payment_methods_core(&state, &platform, &customer_id).await?+ list_customer_payment_methods_core(&state, platform.get_provider(), &customer_id)+ .await?}None => Vec::new(),};@@ -1644,11 +1635,11 @@ pub async fn list_payment_methods_for_session(#[instrument(skip_all)]pub async fn list_saved_payment_methods_for_customer(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,customer_id: id_type::GlobalCustomerId,) -> RouterResponse<payment_methods::CustomerPaymentMethodsListResponse> {let customer_payment_methods =- list_payment_methods_core(&state, &platform, &customer_id).await?;+ list_payment_methods_core(&state, &provider, &customer_id).await?;Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(customer_payment_methods,@@ -1659,8 +1650,7 @@ pub async fn list_saved_payment_methods_for_customer(#[instrument(skip_all)]pub async fn get_token_data_for_payment_method(state: SessionState,- merchant_account: domain::MerchantAccount,- key_store: domain::MerchantKeyStore,+ provider: domain::Provider,profile: domain::Profile,request: payment_methods::GetTokenDataRequest,payment_method_id: id_type::GlobalPaymentMethodId,@@ -1669,9 +1659,9 @@ pub async fn get_token_data_for_payment_method(let payment_method = db.find_payment_method(- &key_store,+ provider.get_key_store(),&payment_method_id,- merchant_account.storage_scheme,+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -1752,9 +1742,9 @@ pub async fn generate_token_data_response(#[instrument(skip_all)]pub async fn get_total_saved_payment_methods_for_merchant(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,) -> RouterResponse<api::TotalPaymentMethodCountResponse> {- let total_payment_method_count = get_total_payment_method_count_core(&state, &platform).await?;+ let total_payment_method_count = get_total_payment_method_count_core(&state, &provider).await?;Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(total_payment_method_count,@@ -2253,7 +2243,7 @@ pub async fn vault_payment_method_internal(// throw back error if payment method is duplicatedwhen(db.find_payment_method_by_fingerprint_id(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&fingerprint_id_from_vault,).await@@ -2591,7 +2581,7 @@ pub async fn vault_payment_method(vault_payment_method_external(state,&payment_method_custom_data,- platform.get_processor().get_account(),+ platform.get_provider().get_account(),merchant_connector_account,).await@@ -2713,19 +2703,19 @@ fn get_pm_list_token_data(#[cfg(all(feature = "v2", feature = "olap"))]pub async fn list_payment_methods_core(state: &SessionState,- platform: &domain::Platform,+ provider: &domain::Provider,customer_id: &id_type::GlobalCustomerId,) -> RouterResult<payment_methods::CustomerPaymentMethodsListResponse> {let db = &*state.store;let saved_payment_methods = db.find_payment_method_by_global_customer_id_merchant_id_status(- platform.get_processor().get_key_store(),+ provider.get_key_store(),customer_id,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),common_enums::PaymentMethodStatus::Active,None,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -2746,19 +2736,19 @@ pub async fn list_payment_methods_core(#[cfg(all(feature = "v2", feature = "oltp"))]pub async fn list_customer_payment_methods_core(state: &SessionState,- platform: &domain::Platform,+ provider: &domain::Provider,customer_id: &id_type::GlobalCustomerId,) -> RouterResult<Vec<payment_methods::CustomerPaymentMethodResponseItem>> {let db = &*state.store;let saved_payment_methods = db.find_payment_method_by_global_customer_id_merchant_id_status(- platform.get_processor().get_key_store(),+ provider.get_key_store(),customer_id,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),common_enums::PaymentMethodStatus::Active,None,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -2812,13 +2802,13 @@ pub async fn list_customer_payment_methods_core(#[cfg(all(feature = "v2", feature = "olap"))]pub async fn get_total_payment_method_count_core(state: &SessionState,- platform: &domain::Platform,+ provider: &domain::Provider,) -> RouterResult<api::TotalPaymentMethodCountResponse> {let db = &*state.store;let total_count = db.get_payment_method_count_by_merchant_id_status(- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),common_enums::PaymentMethodStatus::Active,).await@@ -2835,7 +2825,7 @@ pub async fn get_total_payment_method_count_core(pub async fn retrieve_payment_method(state: SessionState,pm: api::PaymentMethodId,- platform: domain::Platform,+ provider: domain::Provider,) -> RouterResponse<api::PaymentMethodResponse> {let db = state.store.as_ref();let pm_id = id_type::GlobalPaymentMethodId::generate_from_string(pm.payment_method_id)@@ -2844,9 +2834,9 @@ pub async fn retrieve_payment_method(let payment_method = db.find_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),&pm_id,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -2927,9 +2917,9 @@ pub async fn update_payment_method_core(let payment_method = db.find_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),payment_method_id,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -2989,7 +2979,7 @@ pub async fn update_payment_method_core(let pm_update = create_pm_additional_data_update(vault_request_data.as_ref(),state,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),vault_id,fingerprint_id,&payment_method,@@ -3004,10 +2994,10 @@ pub async fn update_payment_method_core(let payment_method = db.update_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),payment_method,pm_update,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -3048,9 +3038,9 @@ pub async fn delete_payment_method_core(let payment_method = db.find_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&pm_id,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -3063,8 +3053,8 @@ pub async fn delete_payment_method_core(let _customer = db.find_customer_by_global_id(&payment_method.customer_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::InternalServerError)@@ -3077,10 +3067,10 @@ pub async fn delete_payment_method_core(};db.update_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),payment_method.clone(),pm_update,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -3210,7 +3200,7 @@ impl EncryptableData for payment_methods::PaymentMethodsSessionUpdateRequest {#[cfg(feature = "v2")]pub async fn payment_methods_session_create(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,request: payment_methods::PaymentMethodSessionRequest,) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> {let db = state.store.as_ref();@@ -3219,8 +3209,8 @@ pub async fn payment_methods_session_create(if let (Some(customer_id)) = &request.customer_id {db.find_customer_by_global_id(customer_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;@@ -3232,7 +3222,7 @@ pub async fn payment_methods_session_create(.attach_printable("Unable to generate GlobalPaymentMethodSessionId")?;let encrypted_data = request- .encrypt_data(key_manager_state, platform.get_processor().get_key_store())+ .encrypt_data(key_manager_state, provider.get_key_store()).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encrypt payment methods session data")?;@@ -3258,7 +3248,7 @@ pub async fn payment_methods_session_create(let client_secret = payment_helpers::create_client_secret(&state,- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),util_types::authentication::ResourceId::PaymentMethodSession(payment_methods_session_id.clone(),),@@ -3283,7 +3273,7 @@ pub async fn payment_methods_session_create(};db.insert_payment_methods_session(- platform.get_processor().get_key_store(),+ provider.get_key_store(),payment_method_session_domain_model.clone(),expires_in,)@@ -3304,7 +3294,7 @@ pub async fn payment_methods_session_create(#[cfg(feature = "v2")]pub async fn payment_methods_session_update(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,payment_method_session_id: id_type::GlobalPaymentMethodSessionId,request: payment_methods::PaymentMethodsSessionUpdateRequest,) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> {@@ -3312,10 +3302,7 @@ pub async fn payment_methods_session_update(let key_manager_state = &(&state).into();let existing_payment_method_session_state = db- .get_payment_methods_session(- platform.get_processor().get_key_store(),- &payment_method_session_id,- )+ .get_payment_methods_session(provider.get_key_store(), &payment_method_session_id).await.to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError {message: "payment methods session does not exist or has expired".to_string(),@@ -3323,7 +3310,7 @@ pub async fn payment_methods_session_update(.attach_printable("Failed to retrieve payment methods session from db")?;let encrypted_data = request- .encrypt_data(key_manager_state, platform.get_processor().get_key_store())+ .encrypt_data(key_manager_state, provider.get_key_store()).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to encrypt payment methods session data")?;@@ -3349,7 +3336,7 @@ pub async fn payment_methods_session_update(let update_state_change = db.update_payment_method_session(- platform.get_processor().get_key_store(),+ provider.get_key_store(),&payment_method_session_id,payment_method_session_domain_model,existing_payment_method_session_state.clone(),@@ -3370,16 +3357,13 @@ pub async fn payment_methods_session_update(#[cfg(feature = "v2")]pub async fn payment_methods_session_retrieve(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,payment_method_session_id: id_type::GlobalPaymentMethodSessionId,) -> RouterResponse<payment_methods::PaymentMethodSessionResponse> {let db = state.store.as_ref();let payment_method_session_domain_model = db- .get_payment_methods_session(- platform.get_processor().get_key_store(),- &payment_method_session_id,- )+ .get_payment_methods_session(provider.get_key_store(), &payment_method_session_id).await.to_not_found_response(errors::ApiErrorResponse::GenericNotFoundError {message: "payment methods session does not exist or has expired".to_string(),@@ -3408,7 +3392,7 @@ pub async fn payment_methods_session_update_payment_method(// Validate if the session still existsdb.get_payment_methods_session(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&payment_method_session_id,).await@@ -3444,7 +3428,7 @@ pub async fn payment_methods_session_delete_payment_method(// Validate if the session still existsdb.get_payment_methods_session(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&payment_method_session_id,).await@@ -3552,7 +3536,7 @@ pub async fn payment_methods_session_confirm(// Validate if the session still existslet payment_method_session = db.get_payment_methods_session(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&payment_method_session_id,).await@@ -3631,13 +3615,13 @@ pub async fn payment_methods_session_confirm(create_payment_method_request.payment_method_data.clone(),request.payment_method_type,intent_fulfillment_time,- platform.get_processor().get_key_store().key.get_inner(),+ platform.get_provider().get_key_store().key.get_inner(),).await?;let payment_method_session = db.update_payment_method_session(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&payment_method_session_id,update_payment_method_session,payment_method_session,@@ -3692,8 +3676,8 @@ pub async fn payment_methods_session_confirm(Some(tokenization_data) => {let tokenization_response = tokenization_core::create_vault_token_core(state.clone(),- &platform.get_processor().get_account().clone(),- &platform.get_processor().get_key_store().clone(),+ &platform.get_provider().get_account().clone(),+ &platform.get_provider().get_key_store().clone(),api_models::tokenization::GenericTokenizationRequest {customer_id: customer_id.clone(),token_request: tokenization_data,@@ -3849,7 +3833,7 @@ async fn create_single_use_tokenization_flow(let mut router_data =types::RouterData::<api::PaymentMethodToken, _, types::PaymentsResponseData> {flow: std::marker::PhantomData,- merchant_id: platform.get_processor().get_account().get_id().clone(),+ merchant_id: platform.get_provider().get_account().get_id().clone(),customer_id: None,connector_customer: None,connector: merchant_connector_account_details@@ -3988,12 +3972,12 @@ async fn get_single_use_token_from_store(#[instrument(skip_all)]async fn fetch_payment_method(state: &SessionState,- platform: &domain::Platform,+ provider: &domain::Provider,payment_method_id: &id_type::GlobalPaymentMethodId,) -> RouterResult<domain::PaymentMethod> {let db = &state.store;- let merchant_account = platform.get_processor().get_account();- let key_store = platform.get_processor().get_key_store();+ let merchant_account = provider.get_account();+ let key_store = provider.get_key_store();db.find_payment_method(key_store,@@ -4008,11 +3992,11 @@ async fn fetch_payment_method(#[cfg(feature = "v2")]pub async fn check_network_token_status(state: SessionState,- platform: domain::Platform,+ provider: domain::Provider,payment_method_id: id_type::GlobalPaymentMethodId,) -> RouterResponse<payment_methods::NetworkTokenStatusCheckResponse> {// Retrieve the payment method from the database- let payment_method = fetch_payment_method(&state, &platform, &payment_method_id).await?;+ let payment_method = fetch_payment_method(&state, &provider, &payment_method_id).await?;// Call the network token status check functionlet network_token_status_check_response = if payment_method.statusdiff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 9a3a6dd1b5..31a138bee3 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -113,7 +113,7 @@ use crate::{};pub struct PmCards<'a> {pub state: &'a routes::SessionState,- pub platform: &'a domain::Platform,+ pub provider: &'a domain::Provider,}#[async_trait::async_trait]@@ -146,8 +146,8 @@ impl PaymentMethodsController for PmCards<'_> {.find_customer_by_customer_id_merchant_id(customer_id,merchant_id,- self.platform.get_processor().get_key_store(),- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_key_store(),+ self.provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;@@ -161,7 +161,7 @@ impl PaymentMethodsController for PmCards<'_> {let response = db.insert_payment_method(- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),domain::PaymentMethod {customer_id: customer_id.to_owned(),merchant_id: merchant_id.to_owned(),@@ -202,7 +202,7 @@ impl PaymentMethodsController for PmCards<'_> {created_by: None,last_modified_by: None,},- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -280,7 +280,7 @@ impl PaymentMethodsController for PmCards<'_> {.find_payment_method(key_store,&payment_method_id,- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await;@@ -291,7 +291,7 @@ impl PaymentMethodsController for PmCards<'_> {.find_payment_method_by_locker_id(key_store,&payment_method_id,- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await;@@ -317,7 +317,7 @@ impl PaymentMethodsController for PmCards<'_> {resp,&req,key_store,- self.platform.get_processor().get_account().get_id(),+ self.provider.get_account().get_id(),customer_id,resp.metadata.clone().map(|val| val.expose()),None,@@ -425,7 +425,7 @@ impl PaymentMethodsController for PmCards<'_> {.find_payment_method(key_store,&pm_id,- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -437,7 +437,7 @@ impl PaymentMethodsController for PmCards<'_> {key_store,existing_pm,pm_update,- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -585,12 +585,7 @@ impl PaymentMethodsController for PmCards<'_> {let payload =payment_methods::StoreLockerReq::LockerGeneric(payment_methods::StoreGenericReq {- merchant_id: self- .platform- .get_processor()- .get_account()- .get_id()- .to_owned(),+ merchant_id: self.provider.get_account().get_id().to_owned(),merchant_customer_id: customer_id.to_owned(),enc_data,ttl: self.state.conf.locker.ttl_for_storage_in_secs,@@ -606,7 +601,7 @@ impl PaymentMethodsController for PmCards<'_> {bank.clone(),store_resp.card_reference,req,- self.platform.get_processor().get_account().get_id(),+ self.provider.get_account().get_id(),);Ok((payment_method_resp, store_resp.duplication_check))}@@ -698,12 +693,7 @@ impl PaymentMethodsController for PmCards<'_> {errors::VaultError,> {let payload = payment_methods::StoreLockerReq::LockerCard(payment_methods::StoreCardReq {- merchant_id: self- .platform- .get_processor()- .get_account()- .get_id()- .to_owned(),+ merchant_id: self.provider.get_account().get_id().to_owned(),merchant_customer_id: customer_id.to_owned(),requestor_card_reference: card_reference.map(str::to_string),card: Card {@@ -725,7 +715,7 @@ impl PaymentMethodsController for PmCards<'_> {card.clone(),store_card_payload.card_reference,req,- self.platform.get_processor().get_account().get_id(),+ self.provider.get_account().get_id(),);Ok((payment_method_resp, store_card_payload.duplication_check))}@@ -797,17 +787,17 @@ impl PaymentMethodsController for PmCards<'_> {.find_customer_by_customer_id_merchant_id(customer_id,merchant_id,- self.platform.get_processor().get_key_store(),- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_key_store(),+ self.provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;// check for the presence of payment_methodlet payment_method = db.find_payment_method(- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),&payment_method_id,- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -848,8 +838,8 @@ impl PaymentMethodsController for PmCards<'_> {merchant_id.to_owned(),customer,customer_update,- self.platform.get_processor().get_key_store(),- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_key_store(),+ self.provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -918,9 +908,9 @@ impl PaymentMethodsController for PmCards<'_> {let db = self.state.store.as_ref();let pm = db.find_payment_method(- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),&pm.payment_method_id,- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -976,9 +966,9 @@ impl PaymentMethodsController for PmCards<'_> {let db = self.state.store.as_ref();let key = db.find_payment_method(- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),pm_id.payment_method_id.as_str(),- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -986,9 +976,9 @@ impl PaymentMethodsController for PmCards<'_> {let customer = db.find_customer_by_customer_id_merchant_id(&key.customer_id,- self.platform.get_processor().get_account().get_id(),- self.platform.get_processor().get_key_store(),- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().get_id(),+ self.provider.get_key_store(),+ self.provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::InternalServerError)@@ -1012,7 +1002,7 @@ impl PaymentMethodsController for PmCards<'_> {key.payment_method_id.clone(),key.network_token_locker_id,network_token_ref_id,- self.platform,+ self.provider,).await?;@@ -1032,8 +1022,8 @@ impl PaymentMethodsController for PmCards<'_> {}db.delete_payment_method_by_merchant_id_payment_method_id(- self.platform.get_processor().get_key_store(),- self.platform.get_processor().get_account().get_id(),+ self.provider.get_key_store(),+ self.provider.get_account().get_id(),pm_id.payment_method_id.as_str(),).await@@ -1049,8 +1039,8 @@ impl PaymentMethodsController for PmCards<'_> {key.merchant_id,customer,customer_update,- self.platform.get_processor().get_key_store(),- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_key_store(),+ self.provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1073,7 +1063,7 @@ impl PaymentMethodsController for PmCards<'_> {) -> errors::RouterResponse<api::PaymentMethodResponse> {req.validate()?;let db = &*self.state.store;- let merchant_id = self.platform.get_processor().get_account().get_id();+ let merchant_id = self.provider.get_account().get_id();let customer_id = req.customer_id.clone().get_required_value("customer_id")?;let payment_method = req.payment_method.get_required_value("payment_method")?;let key_manager_state = self.state.into();@@ -1081,11 +1071,7 @@ impl PaymentMethodsController for PmCards<'_> {.billing.clone().async_map(|billing| {- create_encrypted_data(- &key_manager_state,- self.platform.get_processor().get_key_store(),- billing,- )+ create_encrypted_data(&key_manager_state, self.provider.get_key_store(), billing)}).await.transpose()@@ -1104,7 +1090,7 @@ impl PaymentMethodsController for PmCards<'_> {Some(bank) => self.add_bank_to_locker(req.clone(),- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),&bank,&customer_id,)@@ -1150,7 +1136,7 @@ impl PaymentMethodsController for PmCards<'_> {req.clone(),&mut resp,&customer_id,- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),).await?;@@ -1163,7 +1149,7 @@ impl PaymentMethodsController for PmCards<'_> {req.clone(),&mut resp,&customer_id,- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),).await?;@@ -1197,7 +1183,7 @@ impl PaymentMethodsController for PmCards<'_> {if let Err(err) = add_card_resp {logger::error!(vault_err=?err);db.delete_payment_method_by_merchant_id_payment_method_id(- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),merchant_id,&resp.payment_method_id,)@@ -1247,7 +1233,7 @@ impl PaymentMethodsController for PmCards<'_> {.async_map(|updated_pmd| {create_encrypted_data(&key_manager_state,- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),updated_pmd,)})@@ -1262,10 +1248,10 @@ impl PaymentMethodsController for PmCards<'_> {};db.update_payment_method(- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),existing_pm,pm_update,- self.platform.get_processor().get_account().storage_scheme,+ self.provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1290,7 +1276,7 @@ impl PaymentMethodsController for PmCards<'_> {.insert_payment_method(&resp,req,- self.platform.get_processor().get_key_store(),+ self.provider.get_key_store(),merchant_id,&customer_id,pm_metadata.cloned(),@@ -1319,11 +1305,11 @@ impl PaymentMethodsController for PmCards<'_> {pub async fn get_client_secret_or_add_payment_method(state: &routes::SessionState,req: api::PaymentMethodCreate,- platform: &domain::Platform,+ provider: &domain::Provider,) -> errors::RouterResponse<api::PaymentMethodResponse> {- let merchant_id = platform.get_processor().get_account().get_id();+ let merchant_id = provider.get_account().get_id();let customer_id = req.customer_id.clone().get_required_value("customer_id")?;- let cards = PmCards { state, platform };+ let cards = PmCards { state, provider };#[cfg(not(feature = "payouts"))]let condition = req.card.is_some();#[cfg(feature = "payouts")]@@ -1333,11 +1319,7 @@ pub async fn get_client_secret_or_add_payment_method(.billing.clone().async_map(|billing| {- create_encrypted_data(- &key_manager_state,- platform.get_processor().get_key_store(),- billing,- )+ create_encrypted_data(&key_manager_state, provider.get_key_store(), billing)}).await.transpose()@@ -1432,13 +1414,13 @@ pub fn authenticate_pm_client_secret_and_check_expiry(pub async fn add_payment_method_data(state: routes::SessionState,req: api::PaymentMethodCreate,- platform: domain::Platform,+ provider: domain::Provider,pm_id: String,) -> errors::RouterResponse<api::PaymentMethodResponse> {let db = &*state.store;let cards = PmCards {state: &state,- platform: &platform,+ provider: &provider,};let pmd = req@@ -1452,9 +1434,9 @@ pub async fn add_payment_method_data(.get_required_value("client_secret")?;let payment_method = db.find_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),pm_id.as_str(),- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::PaymentMethodNotFound)@@ -1469,9 +1451,9 @@ pub async fn add_payment_method_data(let customer = db.find_customer_by_customer_id_merchant_id(&customer_id,- platform.get_processor().get_account().get_id(),- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ provider.get_account().get_id(),+ provider.get_key_store(),+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;@@ -1499,10 +1481,10 @@ pub async fn add_payment_method_data(};db.update_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),payment_method,pm_update,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1513,7 +1495,7 @@ pub async fn add_payment_method_data(req.clone(),&mut pm_resp,&customer_id,- platform.get_processor().get_key_store(),+ provider.get_key_store(),).await?;@@ -1550,7 +1532,7 @@ pub async fn add_payment_method_data(let pm_data_encrypted: Encryptable<Secret<serde_json::Value>> =create_encrypted_data(&key_manager_state,- platform.get_processor().get_key_store(),+ provider.get_key_store(),PaymentMethodsData::Card(updated_card),).await@@ -1571,10 +1553,10 @@ pub async fn add_payment_method_data(};db.update_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),payment_method,pm_update,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1583,7 +1565,7 @@ pub async fn add_payment_method_data(if customer.default_payment_method_id.is_none() {let _ = cards.set_default_payment_method(- platform.get_processor().get_account().get_id(),+ provider.get_account().get_id(),&customer_id,pm_id,)@@ -1606,10 +1588,10 @@ pub async fn add_payment_method_data(};db.update_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),payment_method,pm_update,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1626,10 +1608,9 @@ pub async fn add_payment_method_data(#[instrument(skip_all)]pub async fn update_customer_payment_method(state: routes::SessionState,- platform: domain::Platform,+ provider: domain::Provider,req: api::PaymentMethodUpdate,payment_method_id: &str,-pm_data: Option<domain::PaymentMethod>,) -> errors::RouterResponse<api::CustomerPaymentMethodUpdateResponse> {let db = state.store.as_ref();@@ -1638,9 +1619,9 @@ pub async fn update_customer_payment_method(pm} else {db.find_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),payment_method_id,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?@@ -1744,7 +1725,7 @@ pub async fn update_customer_payment_method(new_pm.validate()?;let cards = PmCards {state: &state,- platform: &platform,+ provider: &provider,};// Delete old payment method from lockercards@@ -1799,11 +1780,7 @@ pub async fn update_customer_payment_method(let key_manager_state = (&state).into();let pm_data_encrypted: Option<Encryptable<Secret<serde_json::Value>>> = updated_pmd.async_map(|updated_pmd| {- create_encrypted_data(- &key_manager_state,- platform.get_processor().get_key_store(),- updated_pmd,- )+ create_encrypted_data(&key_manager_state, provider.get_key_store(), updated_pmd)}).await.transpose()@@ -1820,10 +1797,10 @@ pub async fn update_customer_payment_method(.clone_from(&pm.payment_method_id);db.update_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),pm,pm_update,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -1880,14 +1857,11 @@ pub async fn update_customer_payment_method(let updated_pmd = PaymentMethodsData::WalletDetails(wallet_update);let key_manager_state = (&state).into();- let pm_data_encrypted = create_encrypted_data(- &key_manager_state,- platform.get_processor().get_key_store(),- updated_pmd,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Unable to encrypt payment method data")?;+ let pm_data_encrypted =+ create_encrypted_data(&key_manager_state, provider.get_key_store(), updated_pmd)+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Unable to encrypt payment method data")?;let pm_update = storage::PaymentMethodUpdate::PaymentMethodDataUpdate {payment_method_data: Some(pm_data_encrypted.into()),@@ -1896,10 +1870,10 @@ pub async fn update_customer_payment_method(let pm = db.update_payment_method(- platform.get_processor().get_key_store(),+ provider.get_key_store(),pm,pm_update,- platform.get_processor().get_account().storage_scheme,+ provider.get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)@@ -2721,8 +2695,8 @@ pub async fn list_payment_methods(db.find_customer_by_customer_id_merchant_id(cust,&pi.merchant_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)@@ -2739,8 +2713,8 @@ pub async fn list_payment_methods(&pi.payment_id,&pi.merchant_id,&pi.active_attempt.get_id(),- platform.get_processor().get_account().storage_scheme,- platform.get_processor().get_key_store(),+ platform.get_provider().get_account().storage_scheme,+ platform.get_provider().get_key_store(),).await.change_context(errors::ApiErrorResponse::PaymentNotFound)@@ -3130,7 +3104,7 @@ pub async fn list_payment_methods(straight_through_algorithm: Some(encoded),amount_capturable: None,updated_by: platform- .get_processor()+ .get_provider().get_account().storage_scheme.to_string(),@@ -3146,8 +3120,8 @@ pub async fn list_payment_methods(.update_payment_attempt_with_attempt_id(payment_attempt.clone(),attempt_update,- platform.get_processor().get_account().storage_scheme,- platform.get_processor().get_key_store(),+ platform.get_provider().get_account().storage_scheme,+ platform.get_provider().get_key_store(),).await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;@@ -3702,9 +3676,9 @@ async fn validate_payment_method_and_client_secret(let payment_method = db.find_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),pm_id,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::PaymentMethodNotFound)@@ -3770,13 +3744,13 @@ pub async fn call_surcharge_decision_management(storage::PaymentIntentUpdate::SurchargeApplicableUpdate {surcharge_applicable: true,updated_by: platform- .get_processor()+ .get_provider().get_account().storage_scheme.to_string(),},- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)@@ -3830,13 +3804,13 @@ pub async fn call_surcharge_decision_management_for_saved_card(storage::PaymentIntentUpdate::SurchargeApplicableUpdate {surcharge_applicable: true,updated_by: platform- .get_processor()+ .get_provider().get_account().storage_scheme.to_string(),},- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)@@ -4223,9 +4197,9 @@ pub async fn list_customer_payment_method(let customer = db.find_customer_by_customer_id_merchant_id(customer_id,- platform.get_processor().get_account().get_id(),- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().get_id(),+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;@@ -4256,12 +4230,12 @@ pub async fn list_customer_payment_method(let resp = db.find_payment_method_by_customer_id_merchant_id_status(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),customer_id,- platform.get_processor().get_account().get_id(),+ platform.get_provider().get_account().get_id(),common_enums::PaymentMethodStatus::Active,limit,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -4301,12 +4275,12 @@ pub async fn list_customer_payment_method(let pm_list_context = get_pm_list_context(state,&payment_method,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&pm,Some(parent_payment_method_token.clone()),true,false,- &platform,+ platform.get_provider(),).await?;@@ -4461,9 +4435,9 @@ pub async fn get_pm_list_context(#[cfg(not(feature = "payouts"))] _parent_payment_method_token: Option<String>,is_payment_associated: bool,force_fetch_card_from_vault: bool,- platform: &domain::Platform,+ provider: &domain::Provider,) -> Result<Option<PaymentMethodListContext>, error_stack::Report<errors::ApiErrorResponse>> {- let cards = PmCards { state, platform };+ let cards = PmCards { state, provider };let payment_method_retrieval_context = match payment_method {enums::PaymentMethod::Card => {let card_details = if force_fetch_card_from_vault {@@ -4564,10 +4538,10 @@ async fn perform_surcharge_ops(.store.find_payment_attempt_by_payment_id_merchant_id_attempt_id(payment_intent.get_id(),- platform.get_processor().get_account().get_id(),+ platform.get_provider().get_account().get_id(),&payment_intent.active_attempt.get_id(),- platform.get_processor().get_account().storage_scheme,- platform.get_processor().get_key_store(),+ platform.get_provider().get_account().storage_scheme,+ platform.get_provider().get_key_store(),).await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)@@ -5098,13 +5072,13 @@ pub async fn list_countries_currencies_for_connector_payment_method_util(pub async fn tokenize_card_flow(state: &routes::SessionState,req: domain::CardNetworkTokenizeRequest,- platform: &domain::Platform,+ provider: &domain::Provider,) -> errors::RouterResult<api::CardNetworkTokenizeResponse> {match req.data {domain::TokenizeDataRequest::Card(ref card_req) => {let executor = tokenize::CardNetworkTokenizeExecutor::new(state,- platform,+ provider,card_req,&req.customer,);@@ -5115,7 +5089,7 @@ pub async fn tokenize_card_flow(domain::TokenizeDataRequest::ExistingPaymentMethod(ref payment_method) => {let executor = tokenize::CardNetworkTokenizeExecutor::new(state,- platform,+ provider,payment_method,&req.customer,);diff --git a/crates/router/src/core/payment_methods/migration.rs b/crates/router/src/core/payment_methods/migration.rsindex 5be3d0a2c4..5a4b6f9047 100644--- a/crates/router/src/core/payment_methods/migration.rs+++ b/crates/router/src/core/payment_methods/migration.rs@@ -69,9 +69,9 @@ pub async fn update_payment_method_record(let payment_method = db.find_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),&payment_method_id,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;@@ -102,7 +102,7 @@ pub async fn update_payment_method_record(Some(create_encrypted_data(&key_manager_state,- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),pm_api::PaymentMethodsData::Card(card_data),).await@@ -359,10 +359,10 @@ pub async fn update_payment_method_record(let response = db.update_payment_method(- platform.get_processor().get_key_store(),+ platform.get_provider().get_key_store(),payment_method,pm_update,- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_account().storage_scheme,).await.change_context(errors::ApiErrorResponse::InternalServerError)diff --git a/crates/router/src/core/payment_methods/network_tokenization.rs b/crates/router/src/core/payment_methods/network_tokenization.rsindex f3bb20a657..42a4ccf767 100644--- a/crates/router/src/core/payment_methods/network_tokenization.rs+++ b/crates/router/src/core/payment_methods/network_tokenization.rs@@ -940,10 +940,10 @@ pub async fn delete_network_token_from_locker_and_token_service(payment_method_id: String,network_token_locker_id: Option<String>,network_token_requestor_reference_id: String,- platform: &domain::Platform,+ provider: &domain::Provider,) -> errors::RouterResult<DeleteCardResp> {//deleting network token from locker- let resp = payment_methods::cards::PmCards { state, platform }+ let resp = payment_methods::cards::PmCards { state, provider }.delete_card_from_locker(customer_id,merchant_id,diff --git a/crates/router/src/core/payment_methods/tokenize.rs b/crates/router/src/core/payment_methods/tokenize.rsindex ab3ef6e55f..57b996c3ca 100644--- a/crates/router/src/core/payment_methods/tokenize.rs+++ b/crates/router/src/core/payment_methods/tokenize.rs@@ -96,7 +96,7 @@ pub fn get_tokenize_card_form_records(pub async fn tokenize_cards(state: &SessionState,records: Vec<payment_methods_api::CardNetworkTokenizeRequest>,- platform: &domain::Platform,+ provider: &domain::Provider,) -> errors::RouterResponse<Vec<payment_methods_api::CardNetworkTokenizeResponse>> {use futures::stream::StreamExt;@@ -108,7 +108,7 @@ pub async fn tokenize_cards(Box::pin(tokenize_card_flow(state,domain::CardNetworkTokenizeRequest::foreign_from(record),- platform,+ provider,)).await.unwrap_or_else(|e| {@@ -193,7 +193,7 @@ pub trait TransitionTo<S: State> {}pub trait NetworkTokenizationProcess<'a, D> {fn new(state: &'a SessionState,- platform: &'a domain::Platform,+ provider: &'a domain::Provider,data: &'a D,customer: &'a domain_request_types::CustomerDetails,) -> Self;@@ -243,7 +243,7 @@ where{fn new(state: &'a SessionState,- platform: &'a domain::Platform,+ provider: &'a domain::Provider,data: &'a D,customer: &'a domain_request_types::CustomerDetails,) -> Self {@@ -251,8 +251,8 @@ wheredata,customer,state,- merchant_account: platform.get_processor().get_account(),- key_store: platform.get_processor().get_key_store(),+ merchant_account: provider.get_account(),+ key_store: provider.get_key_store(),}}async fn encrypt_card(diff --git a/crates/router/src/core/payment_methods/tokenize/card_executor.rs b/crates/router/src/core/payment_methods/tokenize/card_executor.rsindex bf6b947f87..50d505f4fe 100644--- a/crates/router/src/core/payment_methods/tokenize/card_executor.rs+++ b/crates/router/src/core/payment_methods/tokenize/card_executor.rs@@ -573,14 +573,15 @@ impl CardNetworkTokenizeExecutor<'_, domain::TokenizeCardRequest> {connector_mandate_details: None,network_transaction_id: None,};+ let platform = domain::Platform::new(+ self.merchant_account.clone(),+ self.key_store.clone(),+ self.merchant_account.clone(),+ self.key_store.clone(),+ );PmCards {state: self.state,- platform: &domain::Platform::new(- self.merchant_account.clone(),- self.key_store.clone(),- self.merchant_account.clone(),- self.key_store.clone(),- ),+ provider: platform.get_provider(),}.create_payment_method(&payment_method_create,diff --git a/crates/router/src/core/payment_methods/validator.rs b/crates/router/src/core/payment_methods/validator.rsindex 0a88194c31..88492652bc 100644--- a/crates/router/src/core/payment_methods/validator.rs+++ b/crates/router/src/core/payment_methods/validator.rs@@ -33,14 +33,14 @@ pub async fn validate_request_and_initiate_payment_method_collect_link(// Validate customer_idlet db: &dyn StorageInterface = &*state.store;let customer_id = req.customer_id.clone();- let merchant_id = platform.get_processor().get_account().get_id().clone();+ let merchant_id = platform.get_provider().get_account().get_id().clone();#[cfg(feature = "v1")]match db.find_customer_by_customer_id_merchant_id(&customer_id,&merchant_id,- platform.get_processor().get_key_store(),- platform.get_processor().get_account().storage_scheme,+ platform.get_provider().get_key_store(),+ platform.get_provider().get_account().storage_scheme,).await{diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rsindex df46e26fb7..218d6288c3 100644--- a/crates/router/src/core/payment_methods/vault.rs+++ b/crates/router/src/core/payment_methods/vault.rs@@ -1910,7 +1910,7 @@ pub async fn retrieve_payment_method_from_vault(retrieve_payment_method_from_vault_external(state,- platform.get_processor().get_account(),+ platform.get_provider().get_account(),pm,merchant_connector_account,)@@ -2092,7 +2092,7 @@ pub async fn delete_payment_method_data_from_vault(delete_payment_method_data_from_vault_external(state,- platform.get_processor().get_account(),+ platform.get_provider().get_account(),merchant_connector_account,vault_id.clone(),&pm.customer_id,diff --git a/crates/router/src/core/payments/payment_methods.rs b/crates/router/src/core/payments/payment_methods.rsindex 62d70cf5f9..60662c66fc 100644--- a/crates/router/src/core/payments/payment_methods.rs+++ b/crates/router/src/core/payments/payment_methods.rs@@ -56,8 +56,12 @@ pub async fn list_payment_methods(let customer_payment_methods = match &payment_intent.customer_id {Some(customer_id) => Some(- payment_methods::list_customer_payment_methods_core(&state, &platform, customer_id)- .await?,+ payment_methods::list_customer_payment_methods_core(+ &state,+ platform.get_provider(),+ customer_id,+ )+ .await?,),None => None,};diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rsindex c8168f88f8..5f8856ad71 100644--- a/crates/router/src/core/payments/tokenization.rs+++ b/crates/router/src/core/payments/tokenization.rs@@ -137,7 +137,10 @@ whereFData: mandate::MandateBehaviour + Clone,{let mut pm_status = None;- let cards = PmCards { state, platform };+ let cards = PmCards {+ state,+ provider: platform.get_provider(),+ };match save_payment_method_data.response {Ok(responses) => {let db = &*state.store;@@ -1110,17 +1113,16 @@ pub async fn save_in_locker_internal(.clone().get_required_value("customer_id")?;match (payment_method_request.card.clone(), card_detail) {- (_, Some(card)) | (Some(card), _) => {- Box::pin(PmCards { state, platform }.add_card_to_locker(- payment_method_request,- &card,- &customer_id,- None,- ))- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Add Card Failed")- }+ (_, Some(card)) | (Some(card), _) => Box::pin(+ PmCards {+ state,+ provider: platform.get_provider(),+ }+ .add_card_to_locker(payment_method_request, &card, &customer_id, None),+ )+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Add Card Failed"),_ => {let pm_id = common_utils::generate_id(consts::ID_LENGTH, "pm");let payment_method_response = api::PaymentMethodResponse {@@ -1288,12 +1290,18 @@ pub async fn save_network_token_in_locker(match network_token_data {Some(nt_data) => {- let (res, dc) = Box::pin(PmCards { state, platform }.add_card_to_locker(- payment_method_request,- &nt_data,- &customer_id,- None,- ))+ let (res, dc) = Box::pin(+ PmCards {+ state,+ provider: platform.get_provider(),+ }+ .add_card_to_locker(+ payment_method_request,+ &nt_data,+ &customer_id,+ None,+ ),+ ).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Add Network Token Failed")?;@@ -1331,12 +1339,18 @@ pub async fn save_network_token_in_locker(card_type: None,};- let (res, dc) = Box::pin(PmCards { state, platform }.add_card_to_locker(- payment_method_request,- &network_token_data,- &customer_id,- None,- ))+ let (res, dc) = Box::pin(+ PmCards {+ state,+ provider: platform.get_provider(),+ }+ .add_card_to_locker(+ payment_method_request,+ &network_token_data,+ &customer_id,+ None,+ ),+ ).await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Add Network Token Failed")?;diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rsindex 27adad356a..bd09c665ed 100644--- a/crates/router/src/core/payouts/helpers.rs+++ b/crates/router/src/core/payouts/helpers.rs@@ -626,27 +626,30 @@ pub async fn save_payout_data_to_locker(if should_insert_in_pm_table {let payment_method_id = common_utils::generate_id(consts::ID_LENGTH, "pm");payout_data.payment_method = Some(- cards::PmCards { state, platform }- .create_payment_method(- &new_payment_method,- customer_id,- &payment_method_id,- Some(stored_resp.card_reference.clone()),- platform.get_processor().get_account().get_id(),- None,- None,- card_details_encrypted.clone(),- connector_mandate_details,- None,- None,- payment_method_billing_address,- None,- None,- None,- None,- Default::default(),- )- .await?,+ cards::PmCards {+ state,+ provider: platform.get_provider(),+ }+ .create_payment_method(+ &new_payment_method,+ customer_id,+ &payment_method_id,+ Some(stored_resp.card_reference.clone()),+ platform.get_processor().get_account().get_id(),+ None,+ None,+ card_details_encrypted.clone(),+ connector_mandate_details,+ None,+ None,+ payment_method_billing_address,+ None,+ None,+ None,+ None,+ Default::default(),+ )+ .await?,);}diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rsindex 31c841c0ff..59501d6cc5 100644--- a/crates/router/src/core/payouts/validator.rs+++ b/crates/router/src/core/payouts/validator.rs@@ -247,7 +247,7 @@ pub async fn validate_create_request(None,false,true,- platform,+ platform.get_provider(),).await?{diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex 54c99a6fee..670ca0cbe9 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -2884,7 +2884,7 @@ async fn update_additional_payment_method_data(Box::pin(cards::update_customer_payment_method(state.clone(),- platform.clone(),+ platform.get_provider().clone(),payment_method_update,&payment_method_id,Some(pm),diff --git a/crates/router/src/core/webhooks/network_tokenization_incoming.rs b/crates/router/src/core/webhooks/network_tokenization_incoming.rsindex 649601fe78..160bebc265 100644--- a/crates/router/src/core/webhooks/network_tokenization_incoming.rs+++ b/crates/router/src/core/webhooks/network_tokenization_incoming.rs@@ -287,7 +287,10 @@ pub async fn handle_metadata_update(let payment_method_request: api::payment_methods::PaymentMethodCreate =PaymentMethodCreateWrapper::from((&card_data, payment_method)).get_inner();- let pm_cards = cards::PmCards { state, platform };+ let pm_cards = cards::PmCards {+ state,+ provider: platform.get_provider(),+ };pm_cards.delete_card_from_locker(customer_id, merchant_id, &locker_id)diff --git a/crates/router/src/routes/customers.rs b/crates/router/src/routes/customers.rsindex 292aeef763..8fda3ba685 100644--- a/crates/router/src/routes/customers.rs+++ b/crates/router/src/routes/customers.rs@@ -389,8 +389,8 @@ pub async fn customers_delete(&req,id,|state, auth: auth::AuthenticationData, id, _| {- let platform = auth.into();- delete_customer(state, platform, id)+ let platform: domain::Platform = auth.into();+ delete_customer(state, platform.get_provider().clone(), id)},auth::auth_type(&auth::V2ApiKeyAuth {@@ -423,13 +423,13 @@ pub async fn customers_delete(&req,customer_id,|state, auth: auth::AuthenticationData, customer_id, _| {- let platform = auth.into();- delete_customer(state, platform, customer_id)+ let platform: domain::Platform = auth.into();+ delete_customer(state, platform.get_provider().clone(), customer_id)},auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),&auth::JWTAuth {permission: Permission::MerchantCustomerWrite,diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rsindex ef7f774081..f64fcd7b19 100644--- a/crates/router/src/routes/payment_methods.rs+++ b/crates/router/src/routes/payment_methods.rs@@ -46,15 +46,17 @@ pub async fn create_payment_method_api(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| async move {- let platform = auth.into();+ let platform: domain::Platform = auth.into();Box::pin(cards::get_client_secret_or_add_payment_method(- &state, req, &platform,+ &state,+ req,+ platform.get_provider(),)).await},&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),api_locking::LockAction::NotApplicable,))@@ -110,9 +112,11 @@ pub async fn create_payment_method_intent_api(&req,json_payload.into_inner(),|state, auth: auth::AuthenticationData, req, _| async move {- let platform = auth.into();+ let platform: domain::Platform = auth.into();Box::pin(payment_methods_routes::payment_method_intent_create(- &state, req, &platform,+ &state,+ req,+ platform.get_provider().clone(),)).await},@@ -206,8 +210,12 @@ pub async fn payment_method_retrieve_api(&req,payload,|state, auth: auth::AuthenticationData, pm, _| {- let platform = auth.into();- payment_methods_routes::retrieve_payment_method(state, pm, platform)+ let platform: domain::Platform = auth.into();+ payment_methods_routes::retrieve_payment_method(+ state,+ pm,+ platform.get_provider().clone(),+ )},&auth::V2ApiKeyAuth {is_connected_allowed: false,@@ -277,7 +285,7 @@ pub async fn migrate_payment_method_api(&platform,&cards::PmCards {state: &state,- platform: &platform,+ provider: platform.get_provider(),},)).await@@ -381,7 +389,7 @@ pub async fn migrate_payment_methods(.change_context(errors::ApiErrorResponse::InternalServerError)?;let controller = cards::PmCards {state: &state,- platform: &platform,+ provider: platform.get_provider(),};Box::pin(migration::migrate_payment_methods(&(&state).into(),@@ -454,7 +462,10 @@ pub async fn save_payment_method_api(let flow = Flow::PaymentMethodSave;let payload = json_payload.into_inner();let pm_id = path.into_inner();- let api_auth = auth::ApiKeyAuth::default();+ let api_auth = auth::ApiKeyAuth {+ is_connected_allowed: true,+ is_platform_allowed: true,+ };let (auth, _) = match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth){@@ -468,11 +479,11 @@ pub async fn save_payment_method_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();+ let platform: domain::Platform = auth.into();Box::pin(cards::add_payment_method_data(state,req,- platform,+ platform.get_provider().clone(),pm_id.clone(),))},@@ -491,7 +502,10 @@ pub async fn list_payment_method_api() -> HttpResponse {let flow = Flow::PaymentMethodsList;let payload = json_payload.into_inner();- let api_auth = auth::ApiKeyAuth::default();+ let api_auth = auth::ApiKeyAuth {+ is_connected_allowed: true,+ is_platform_allowed: true,+ };let (auth, _) = match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth){@@ -529,7 +543,10 @@ pub async fn list_customer_payment_method_api(let flow = Flow::CustomerPaymentMethodsList;let payload = query_payload.into_inner();let customer_id = customer_id.into_inner().0;- let api_auth = auth::ApiKeyAuth::default();+ let api_auth = auth::ApiKeyAuth {+ is_connected_allowed: true,+ is_platform_allowed: true,+ };let ephemeral_auth = match auth::is_ephemeral_auth(req.headers(), api_auth) {Ok(auth) => auth,@@ -569,8 +586,10 @@ pub async fn list_customer_payment_method_api_client(let flow = Flow::CustomerPaymentMethodsList;let payload = query_payload.into_inner();let api_key = auth::get_api_key(req.headers()).ok();- let api_auth = auth::ApiKeyAuth::default();-+ let api_auth = auth::ApiKeyAuth {+ is_connected_allowed: true,+ is_platform_allowed: true,+ };let (auth, _, is_ephemeral_auth) =match auth::get_ephemeral_or_other_auth(req.headers(), false, Some(&payload), api_auth).await@@ -618,8 +637,8 @@ pub async fn initiate_pm_collect_link_flow(payment_methods_routes::initiate_pm_collect_link(state, platform, req)},&auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,},api_locking::LockAction::NotApplicable,))@@ -644,10 +663,10 @@ pub async fn list_customer_payment_method_api(&req,payload,|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();+ let platform: domain::Platform = auth.into();payment_methods_routes::list_saved_payment_methods_for_customer(state,- platform,+ platform.get_provider().clone(),customer_id.clone(),)},@@ -684,10 +703,10 @@ 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,- auth.merchant_account,- auth.key_store,+ platform.get_provider().clone(),auth.profile,req,payment_method_id.clone(),@@ -722,8 +741,11 @@ pub async fn get_total_payment_method_count(&req,(),|state, auth: auth::AuthenticationData, _, _| {- let platform = auth.into();- payment_methods_routes::get_total_saved_payment_methods_for_merchant(state, platform)+ let platform: domain::Platform = auth.into();+ payment_methods_routes::get_total_saved_payment_methods_for_merchant(+ state,+ platform.get_provider().clone(),+ )},auth::auth_type(&auth::V2ApiKeyAuth {@@ -760,8 +782,12 @@ pub async fn render_pm_collect_link(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- payment_methods_routes::render_pm_collect_link(state, platform, req)+ let platform: domain::Platform = auth.into();+ payment_methods_routes::render_pm_collect_link(+ state,+ platform.get_provider().clone(),+ req,+ )},&auth::MerchantIdAuth(merchant_id),api_locking::LockAction::NotApplicable,@@ -788,17 +814,17 @@ pub async fn payment_method_retrieve_api(&req,payload,|state, auth: auth::AuthenticationData, pm, _| async move {- let platform = auth.into();+ let platform: domain::Platform = auth.into();cards::PmCards {state: &state,- platform: &platform,+ provider: platform.get_provider(),}.retrieve_payment_method(pm).await},&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),api_locking::LockAction::NotApplicable,))@@ -816,7 +842,10 @@ pub async fn payment_method_update_api(let flow = Flow::PaymentMethodsUpdate;let payment_method_id = path.into_inner();let payload = json_payload.into_inner();- let api_auth = auth::ApiKeyAuth::default();+ let api_auth = auth::ApiKeyAuth {+ is_connected_allowed: true,+ is_platform_allowed: true,+ };let (auth, _) = match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth){@@ -830,8 +859,14 @@ pub async fn payment_method_update_api(&req,payload,|state, auth: auth::AuthenticationData, req, _| {- let platform = auth.into();- cards::update_customer_payment_method(state, platform, req, &payment_method_id, None)+ let platform: domain::Platform = auth.into();+ cards::update_customer_payment_method(+ state,+ platform.get_provider().clone(),+ req,+ &payment_method_id,+ None,+ )},&*auth,api_locking::LockAction::NotApplicable,@@ -850,7 +885,10 @@ pub async fn payment_method_delete_api(let pm = PaymentMethodId {payment_method_id: payment_method_id.into_inner().0,};- let api_auth = auth::ApiKeyAuth::default();+ let api_auth = auth::ApiKeyAuth {+ is_connected_allowed: true,+ is_platform_allowed: true,+ };let ephemeral_auth = match auth::is_ephemeral_auth(req.headers(), api_auth) {Ok(auth) => auth,@@ -863,10 +901,10 @@ pub async fn payment_method_delete_api(&req,pm,|state, auth: auth::AuthenticationData, req, _| async move {- let platform = auth.into();+ let platform: domain::Platform = auth.into();cards::PmCards {state: &state,- platform: &platform,+ provider: platform.get_provider(),}.delete_payment_method(req).await@@ -901,8 +939,8 @@ pub async fn list_countries_currencies_for_connector_payment_method(#[cfg(not(feature = "release"))]auth::auth_type(&auth::HeaderAuth(auth::ApiKeyAuth {- is_connected_allowed: false,- is_platform_allowed: false,+ is_connected_allowed: true,+ is_platform_allowed: true,}),&auth::JWTAuth {permission: Permission::ProfileConnectorWrite,@@ -970,7 +1008,10 @@ pub async fn default_payment_method_set_api(let payload = path.into_inner();let pc = payload.clone();let customer_id = &pc.customer_id;- let api_auth = auth::ApiKeyAuth::default();+ let api_auth = auth::ApiKeyAuth {+ is_connected_allowed: true,+ is_platform_allowed: true,+ };let ephemeral_auth = match auth::is_ephemeral_auth(req.headers(), api_auth) {Ok(auth) => auth,@@ -982,18 +1023,13 @@ pub async fn default_payment_method_set_api(&req,payload,|state, auth: auth::AuthenticationData, default_payment_method, _| async move {- let merchant_id = auth.merchant_account.get_id();+ let platform: domain::Platform = auth.into();cards::PmCards {state: &state,- platform: &domain::Platform::new(- auth.merchant_account.clone(),- auth.key_store.clone(),- auth.merchant_account.clone(),- auth.key_store,- ),+ provider: platform.get_provider(),}.set_default_payment_method(- merchant_id,+ platform.get_provider().get_account().get_id(),customer_id,default_payment_method.payment_method_id,)@@ -1132,7 +1168,7 @@ pub async fn tokenize_card_api(let res = Box::pin(cards::tokenize_card_flow(&state,CardNetworkTokenizeRequest::foreign_from(req),- &platform,+ platform.get_provider(),)).await?;Ok(services::ApplicationResponse::Json(res))@@ -1181,7 +1217,7 @@ pub async fn tokenize_card_using_pm_api(let res = Box::pin(cards::tokenize_card_flow(&state,CardNetworkTokenizeRequest::foreign_from(req),- &platform,+ platform.get_provider(),)).await?;Ok(services::ApplicationResponse::Json(res))@@ -1221,7 +1257,12 @@ pub async fn tokenize_card_batch_api(merchant_account,key_store,);- Box::pin(tokenize::tokenize_cards(&state, req, &platform)).await+ Box::pin(tokenize::tokenize_cards(+ &state,+ req,+ platform.get_provider(),+ ))+ .await}},&auth::AdminApiAuth,@@ -1246,8 +1287,13 @@ pub async fn payment_methods_session_create(&req,payload,|state, auth: auth::AuthenticationData, request, _| async move {- let platform = auth.into();- payment_methods_routes::payment_methods_session_create(state, platform, request).await+ let platform: domain::Platform = auth.into();+ payment_methods_routes::payment_methods_session_create(+ state,+ platform.get_provider().clone(),+ request,+ )+ .await},&auth::V2ApiKeyAuth {is_connected_allowed: false,@@ -1277,10 +1323,10 @@ pub async fn payment_methods_session_update(|state, auth: auth::AuthenticationData, req, _| {let value = payment_method_session_id.clone();async move {- let platform = auth.into();+ let platform: domain::Platform = auth.into();payment_methods_routes::payment_methods_session_update(state,- platform,+ platform.get_provider().clone(),value.clone(),req,)@@ -1312,10 +1358,10 @@ 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 = auth.into();+ let platform: domain::Platform = auth.into();payment_methods_routes::payment_methods_session_retrieve(state,- platform,+ platform.get_provider().clone(),payment_method_session_id,).await@@ -1353,7 +1399,7 @@ 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 = auth.clone().into();+ let platform: domain::Platform = auth.clone().into();payment_methods_routes::list_payment_methods_for_session(state,platform,@@ -1537,8 +1583,12 @@ pub async fn network_token_status_check_api(&req,payment_method_id,|state, auth: auth::AuthenticationData, payment_method_id, _| {- let platform = auth.into();- payment_methods_routes::check_network_token_status(state, platform, payment_method_id)+ let platform: domain::Platform = auth.into();+ payment_methods_routes::check_network_token_status(+ state,+ platform.get_provider().clone(),+ payment_method_id,+ )},&auth::V2ApiKeyAuth {is_connected_allowed: false,diff --git a/crates/router/src/types/api/mandates.rs b/crates/router/src/types/api/mandates.rsindex 582cdce53b..9032239187 100644--- a/crates/router/src/types/api/mandates.rs+++ b/crates/router/src/types/api/mandates.rs@@ -84,7 +84,7 @@ impl MandateResponseExt for MandateResponse {);payment_methods::cards::PmCards {state,- platform: &platform,+ provider: platform.get_provider(),}.get_card_details_without_locker_fallback(&payment_method).await?