diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rs index 57a466b66c..78c5c55171 100644 --- a/crates/router/src/compatibility/stripe/errors.rs +++ b/crates/router/src/compatibility/stripe/errors.rs @@ -88,8 +88,8 @@ pub enum StripeErrorCode { #[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such resource ID")] ResourceIdNotFound, - #[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such merchant connector account")] - MerchantConnectorAccountNotFound, + #[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "Merchant connector account with id '{id}' does not exist in our records")] + MerchantConnectorAccountNotFound { id: String }, #[error(error_type = StripeErrorType::InvalidRequestError, code = "resource_missing", message = "No such mandate")] MandateNotFound, @@ -429,8 +429,8 @@ impl From for StripeErrorCode { | errors::ApiErrorResponse::ClientSecretExpired => Self::ClientSecretNotFound, errors::ApiErrorResponse::MerchantAccountNotFound => Self::MerchantAccountNotFound, errors::ApiErrorResponse::ResourceIdNotFound => Self::ResourceIdNotFound, - errors::ApiErrorResponse::MerchantConnectorAccountNotFound => { - Self::MerchantConnectorAccountNotFound + errors::ApiErrorResponse::MerchantConnectorAccountNotFound { id } => { + Self::MerchantConnectorAccountNotFound { id } } errors::ApiErrorResponse::MandateNotFound => Self::MandateNotFound, errors::ApiErrorResponse::ApiKeyNotFound => Self::ApiKeyNotFound, @@ -518,7 +518,7 @@ impl actix_web::ResponseError for StripeErrorCode { | Self::PaymentNotFound | Self::PaymentMethodNotFound | Self::MerchantAccountNotFound - | Self::MerchantConnectorAccountNotFound + | Self::MerchantConnectorAccountNotFound { .. } | Self::MandateNotFound | Self::ApiKeyNotFound | Self::DuplicateMerchantAccount diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index 10f60d64c9..a23e9d36d6 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -449,7 +449,9 @@ pub async fn retrieve_payment_connector( &merchant_connector_id, ) .await - .to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound)?; + .to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound { + id: merchant_connector_id.clone(), + })?; Ok(service_api::ApplicationResponse::Json( ForeignTryFrom::foreign_try_from(mca)?, @@ -469,7 +471,7 @@ pub async fn list_payment_connectors( let merchant_connector_accounts = store .find_merchant_connector_account_by_merchant_id_and_disabled_list(&merchant_id, true) .await - .to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound)?; + .to_not_found_response(errors::ApiErrorResponse::InternalServerError)?; let mut response = vec![]; // The can be eliminated once [#79711](https://github.com/rust-lang/rust/issues/79711) is stabilized @@ -497,7 +499,9 @@ pub async fn update_payment_connector( merchant_connector_id, ) .await - .to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound)?; + .to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound { + id: merchant_connector_id.to_string(), + })?; let payment_methods_enabled = req.payment_methods_enabled.map(|pm_enabled| { pm_enabled @@ -557,7 +561,9 @@ pub async fn delete_payment_connector( &merchant_connector_id, ) .await - .to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound)?; + .to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound { + id: merchant_connector_id.clone(), + })?; let response = api::MerchantConnectorDeleteResponse { merchant_id, merchant_connector_id, diff --git a/crates/router/src/core/errors/api_error_response.rs b/crates/router/src/core/errors/api_error_response.rs index 0da5cebc30..523e55f228 100644 --- a/crates/router/src/core/errors/api_error_response.rs +++ b/crates/router/src/core/errors/api_error_response.rs @@ -136,8 +136,8 @@ pub enum ApiErrorResponse { PaymentMethodNotFound, #[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant account does not exist in our records")] MerchantAccountNotFound, - #[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant connector account does not exist in our records")] - MerchantConnectorAccountNotFound, + #[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant connector account with id '{id}' does not exist in our records")] + MerchantConnectorAccountNotFound { id: String }, #[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Resource ID does not exist in our records")] ResourceIdNotFound, #[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Mandate does not exist in our records")] @@ -259,7 +259,7 @@ impl actix_web::ResponseError for ApiErrorResponse { | Self::PaymentNotFound | Self::PaymentMethodNotFound | Self::MerchantAccountNotFound - | Self::MerchantConnectorAccountNotFound + | Self::MerchantConnectorAccountNotFound { .. } | Self::MandateNotFound | Self::ClientSecretNotGiven | Self::ClientSecretExpired @@ -438,8 +438,8 @@ impl common_utils::errors::ErrorSwitch { AER::NotFound(ApiError::new("HE", 2, "Merchant account does not exist in our records", None)) } - Self::MerchantConnectorAccountNotFound => { - AER::NotFound(ApiError::new("HE", 2, "Merchant connector account does not exist in our records", None)) + Self::MerchantConnectorAccountNotFound { id } => { + AER::NotFound(ApiError::new("HE", 2, format!("Merchant connector account with id '{id}' does not exist in our records"), None)) } Self::ResourceIdNotFound => { AER::NotFound(ApiError::new("HE", 2, "Resource ID does not exist in our records", None)) diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 97cbea16af..7c3bfdb85f 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1565,7 +1565,9 @@ pub async fn get_merchant_connector_account( .find_config_by_key(format!("mcd_{merchant_id}_{creds_identifier}").as_str()) .await .to_not_found_response( - errors::ApiErrorResponse::MerchantConnectorAccountNotFound, + errors::ApiErrorResponse::MerchantConnectorAccountNotFound { + id: connector_label.to_string(), + }, )?; #[cfg(feature = "kms")] @@ -1605,7 +1607,9 @@ pub async fn get_merchant_connector_account( ) .await .map(MerchantConnectorAccountType::DbVal) - .change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound), + .change_context(errors::ApiErrorResponse::MerchantConnectorAccountNotFound { + id: connector_label.to_string(), + }), } }