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
fix(revenue_recovery): scope recovery MCA lookups to the authenticated profile (#13809)
CHALLA NISHANTH BABU52b1c2ad9530
diff --git a/crates/router/src/core/revenue_recovery/api.rs b/crates/router/src/core/revenue_recovery/api.rsindex af0ee16360..aa44e47735 100644--- a/crates/router/src/core/revenue_recovery/api.rs+++ b/crates/router/src/core/revenue_recovery/api.rs@@ -23,6 +23,7 @@ use crate::{storage::{self, revenue_recovery as revenue_recovery_types},transformers::ForeignFrom,},+ utils,};pub async fn call_psync_api(@@ -264,6 +265,7 @@ pub async fn custom_revenue_recovery_core() -> RouterResponse<payments_api::RecoveryPaymentsResponse> {let store = state.store.as_ref();let payment_merchant_connector_account_id = request.payment_merchant_connector_id.to_owned();+ let profile_id = profile.get_id();// Find the payment & billing merchant connector id at the top level to avoid multiple DB calls.let payment_merchant_connector_account = store.find_merchant_connector_account_by_id(@@ -277,6 +279,18 @@ pub async fn custom_revenue_recovery_core(.get_string_repr().to_string(),})?;++ utils::when(+ &payment_merchant_connector_account.profile_id != profile_id,+ || {+ Err(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {+ id: payment_merchant_connector_account_id+ .clone()+ .get_string_repr()+ .to_string(),+ })+ },+ )?;let billing_connector_account = store.find_merchant_connector_account_by_id(&request.billing_merchant_connector_id.clone(),@@ -290,6 +304,15 @@ pub async fn custom_revenue_recovery_core(.get_string_repr().to_string(),})?;+ utils::when(&billing_connector_account.profile_id != profile_id, || {+ Err(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {+ id: request+ .billing_merchant_connector_id+ .clone()+ .get_string_repr()+ .to_string(),+ })+ })?;let recovery_intent =recovery_incoming::RevenueRecoveryInvoice::get_or_create_custom_recovery_intent(