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): allow platform API key for profile and connector CRUD routes for connected merchant (#11134)
Sandeep Kumar1d00de1e8761
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex d3a846129f..c46af9da4c 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -8242,15 +8242,11 @@ pub async fn list_payments(.collect::<Result<Vec<(storage::PaymentIntent, storage::PaymentAttempt)>, _>>();//Will collect responses in same order async, leading to sorted responses- let api_initiator = platform- .get_initiator()- .and_then(domain::Initiator::to_api_initiator);-//Converting Intent-Attempt array to Response if no errorlet data: Vec<api::PaymentsResponse> = pi_pa_tuple_vec.change_context(errors::ApiErrorResponse::InternalServerError)?.into_iter()- .map(|(pi, pa)| ForeignFrom::foreign_from((pi, pa, api_initiator)))+ .map(ForeignFrom::foreign_from).collect();Ok(services::ApplicationResponse::Json(@@ -8501,15 +8497,8 @@ pub async fn apply_filters_on_payments().await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;- let api_initiator = platform- .get_initiator()- .and_then(domain::Initiator::to_api_initiator);- let data: Vec<api::PaymentsResponse> = list- .into_iter()- .map(|(payment_intent, payment_attempt)| {- ForeignFrom::foreign_from((payment_intent, payment_attempt, api_initiator))- })- .collect();+ let data: Vec<api::PaymentsResponse> =+ list.into_iter().map(ForeignFrom::foreign_from).collect();let active_attempt_ids = db.get_filtered_active_attempt_ids_for_total_count(diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 6b213b0356..36b52046a2 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -547,9 +547,9 @@ pub async fn get_token_pm_type_mandate_details(let payment_method_info = state.store.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(@@ -628,9 +628,9 @@ pub async fn get_token_pm_type_mandate_details(let customer_saved_pm_option = match state.store.find_payment_method_by_customer_id_merchant_id_list(- 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(),None,).await@@ -683,9 +683,9 @@ pub async fn get_token_pm_type_mandate_details(state.store.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(@@ -713,9 +713,9 @@ pub async fn get_token_pm_type_mandate_details(state.store.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)diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex c2294554b1..c1ed5f8f96 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -4239,20 +4239,8 @@ pub fn construct_connector_invoke_hidden_frame(}#[cfg(feature = "v1")]-impl- ForeignFrom<(- storage::PaymentIntent,- storage::PaymentAttempt,- Option<api_models::platform::Initiator>,- )> for api::PaymentsResponse-{- fn foreign_from(- (pi, pa, api_initiator): (- storage::PaymentIntent,- storage::PaymentAttempt,- Option<api_models::platform::Initiator>,- ),- ) -> Self {+impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::PaymentsResponse {+ fn foreign_from((pi, pa): (storage::PaymentIntent, storage::PaymentAttempt)) -> Self {let connector_transaction_id = pa.get_connector_payment_id().map(ToString::to_string);Self {payment_id: pi.payment_id,@@ -4329,7 +4317,7 @@ implnet_amount: pa.net_amount.get_total_amount(),amount_received: None,processor_merchant_id: pi.processor_merchant_id,- initiator: api_initiator,+ initiator: None,sdk_authorization: None,refunds: None,disputes: None,diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rsindex 1d671b6371..7165d46c7d 100644--- a/crates/router/src/services/authentication.rs+++ b/crates/router/src/services/authentication.rs@@ -827,15 +827,11 @@ where.await?;let merchant_id_from_route = self.0.clone();- let merchant_id_from_api_key = auth_type- .get_merchant_id()- .ok_or(report!(errors::ApiErrorResponse::Unauthorized))- .attach_printable("Merchant ID not found in API key authentication type")?;+ let processor_merchant_id = auth_data.platform.get_processor().get_account().get_id();- if merchant_id_from_route != *merchant_id_from_api_key {- return Err(report!(errors::ApiErrorResponse::Unauthorized)).attach_printable(- "Merchant ID from route and Merchant ID from api-key in header do not match",- );+ if merchant_id_from_route != *processor_merchant_id {+ return Err(report!(errors::ApiErrorResponse::Unauthorized))+ .attach_printable("Merchant ID from route and Processor Merchant Id do not match");}Ok((auth_data, auth_type))