mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	refactor(router): add the connector_label field to DuplicateMerchantConnectorAccount error message (#1044)
				
					
				
			This commit is contained in:
		| @ -103,8 +103,8 @@ pub enum StripeErrorCode { | |||||||
|     #[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "duplicate merchant account")] |     #[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "duplicate merchant account")] | ||||||
|     DuplicateMerchantAccount, |     DuplicateMerchantAccount, | ||||||
|  |  | ||||||
|     #[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "duplicate merchant_connector_account")] |     #[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "The merchant connector account with the specified connector_label '{connector_label}' already exists in our records")] | ||||||
|     DuplicateMerchantConnectorAccount, |     DuplicateMerchantConnectorAccount { connector_label: String }, | ||||||
|  |  | ||||||
|     #[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "duplicate payment method")] |     #[error(error_type = StripeErrorType::InvalidRequestError, code = "token_already_used", message = "duplicate payment method")] | ||||||
|     DuplicatePaymentMethod, |     DuplicatePaymentMethod, | ||||||
| @ -438,8 +438,8 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode { | |||||||
|             } |             } | ||||||
|             errors::ApiErrorResponse::ReturnUrlUnavailable => Self::ReturnUrlUnavailable, |             errors::ApiErrorResponse::ReturnUrlUnavailable => Self::ReturnUrlUnavailable, | ||||||
|             errors::ApiErrorResponse::DuplicateMerchantAccount => Self::DuplicateMerchantAccount, |             errors::ApiErrorResponse::DuplicateMerchantAccount => Self::DuplicateMerchantAccount, | ||||||
|             errors::ApiErrorResponse::DuplicateMerchantConnectorAccount => { |             errors::ApiErrorResponse::DuplicateMerchantConnectorAccount { connector_label } => { | ||||||
|                 Self::DuplicateMerchantConnectorAccount |                 Self::DuplicateMerchantConnectorAccount { connector_label } | ||||||
|             } |             } | ||||||
|             errors::ApiErrorResponse::DuplicatePaymentMethod => Self::DuplicatePaymentMethod, |             errors::ApiErrorResponse::DuplicatePaymentMethod => Self::DuplicatePaymentMethod, | ||||||
|             errors::ApiErrorResponse::ClientSecretInvalid => Self::PaymentIntentInvalidParameter { |             errors::ApiErrorResponse::ClientSecretInvalid => Self::PaymentIntentInvalidParameter { | ||||||
| @ -521,7 +521,7 @@ impl actix_web::ResponseError for StripeErrorCode { | |||||||
|             | Self::MandateNotFound |             | Self::MandateNotFound | ||||||
|             | Self::ApiKeyNotFound |             | Self::ApiKeyNotFound | ||||||
|             | Self::DuplicateMerchantAccount |             | Self::DuplicateMerchantAccount | ||||||
|             | Self::DuplicateMerchantConnectorAccount |             | Self::DuplicateMerchantConnectorAccount { .. } | ||||||
|             | Self::DuplicatePaymentMethod |             | Self::DuplicatePaymentMethod | ||||||
|             | Self::PaymentFailed |             | Self::PaymentFailed | ||||||
|             | Self::VerificationFailed { .. } |             | Self::VerificationFailed { .. } | ||||||
|  | |||||||
| @ -422,7 +422,11 @@ pub async fn create_payment_connector( | |||||||
|     let mca = store |     let mca = store | ||||||
|         .insert_merchant_connector_account(merchant_connector_account) |         .insert_merchant_connector_account(merchant_connector_account) | ||||||
|         .await |         .await | ||||||
|         .to_duplicate_response(errors::ApiErrorResponse::DuplicateMerchantConnectorAccount)?; |         .to_duplicate_response( | ||||||
|  |             errors::ApiErrorResponse::DuplicateMerchantConnectorAccount { | ||||||
|  |                 connector_label: connector_label.clone(), | ||||||
|  |             }, | ||||||
|  |         )?; | ||||||
|  |  | ||||||
|     let mca_response = ForeignTryFrom::foreign_try_from(mca)?; |     let mca_response = ForeignTryFrom::foreign_try_from(mca)?; | ||||||
|  |  | ||||||
|  | |||||||
| @ -118,8 +118,8 @@ pub enum ApiErrorResponse { | |||||||
|     DuplicateMandate, |     DuplicateMandate, | ||||||
|     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant account with the specified details already exists in our records")] |     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant account with the specified details already exists in our records")] | ||||||
|     DuplicateMerchantAccount, |     DuplicateMerchantAccount, | ||||||
|     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant connector account with the specified details already exists in our records")] |     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant connector account with the specified connector_label '{connector_label}' already exists in our records")] | ||||||
|     DuplicateMerchantConnectorAccount, |     DuplicateMerchantConnectorAccount { connector_label: String }, | ||||||
|     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment method with the specified details already exists in our records")] |     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment method with the specified details already exists in our records")] | ||||||
|     DuplicatePaymentMethod, |     DuplicatePaymentMethod, | ||||||
|     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment with the specified payment_id '{payment_id}' already exists in our records")] |     #[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment with the specified payment_id '{payment_id}' already exists in our records")] | ||||||
| @ -270,7 +270,7 @@ impl actix_web::ResponseError for ApiErrorResponse { | |||||||
|             | Self::ApiKeyNotFound |             | Self::ApiKeyNotFound | ||||||
|             | Self::DisputeStatusValidationFailed { .. } => StatusCode::BAD_REQUEST, // 400 |             | Self::DisputeStatusValidationFailed { .. } => StatusCode::BAD_REQUEST, // 400 | ||||||
|             Self::DuplicateMerchantAccount |             Self::DuplicateMerchantAccount | ||||||
|             | Self::DuplicateMerchantConnectorAccount |             | Self::DuplicateMerchantConnectorAccount { .. } | ||||||
|             | Self::DuplicatePaymentMethod |             | Self::DuplicatePaymentMethod | ||||||
|             | Self::DuplicateMandate |             | Self::DuplicateMandate | ||||||
|             | Self::DisputeNotFound { .. } |             | Self::DisputeNotFound { .. } | ||||||
| @ -409,8 +409,8 @@ impl common_utils::errors::ErrorSwitch<api_models::errors::types::ApiErrorRespon | |||||||
|             Self::DuplicateRefundRequest => AER::BadRequest(ApiError::new("HE", 1, "Duplicate refund request. Refund already attempted with the refund ID", None)), |             Self::DuplicateRefundRequest => AER::BadRequest(ApiError::new("HE", 1, "Duplicate refund request. Refund already attempted with the refund ID", None)), | ||||||
|             Self::DuplicateMandate => AER::BadRequest(ApiError::new("HE", 1, "Duplicate mandate request. Mandate already attempted with the Mandate ID", None)), |             Self::DuplicateMandate => AER::BadRequest(ApiError::new("HE", 1, "Duplicate mandate request. Mandate already attempted with the Mandate ID", None)), | ||||||
|             Self::DuplicateMerchantAccount => AER::BadRequest(ApiError::new("HE", 1, "The merchant account with the specified details already exists in our records", None)), |             Self::DuplicateMerchantAccount => AER::BadRequest(ApiError::new("HE", 1, "The merchant account with the specified details already exists in our records", None)), | ||||||
|             Self::DuplicateMerchantConnectorAccount => { |             Self::DuplicateMerchantConnectorAccount { connector_label } => { | ||||||
|                 AER::BadRequest(ApiError::new("HE", 1, "The merchant connector account with the specified details already exists in our records", None)) |                 AER::BadRequest(ApiError::new("HE", 1, format!("The merchant connector account with the specified connector_label '{connector_label}' already exists in our records"), None)) | ||||||
|             } |             } | ||||||
|             Self::DuplicatePaymentMethod => AER::BadRequest(ApiError::new("HE", 1, "The payment method with the specified details already exists in our records", None)), |             Self::DuplicatePaymentMethod => AER::BadRequest(ApiError::new("HE", 1, "The payment method with the specified details already exists in our records", None)), | ||||||
|             Self::DuplicatePayment { payment_id } => { |             Self::DuplicatePayment { payment_id } => { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 EliKalter
					EliKalter