mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	refactor(router): add id field in MerchantConnectorAccountNotFound (#1098)
				
					
				
			This commit is contained in:
		| @ -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<errors::ApiErrorResponse> 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 | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
| @ -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<api_models::errors::types::ApiErrorRespon | ||||
|             Self::MerchantAccountNotFound => { | ||||
|                 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)) | ||||
|  | ||||
| @ -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(), | ||||
|             }), | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 EliKalter
					EliKalter