mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat: add error type for empty connector list (#1363)
Co-authored-by: ItsMeShashank <shashank.attarde@juspay.in>
This commit is contained in:
		| @ -198,6 +198,8 @@ pub enum StripeErrorCode { | ||||
|     FileNotAvailable, | ||||
|     #[error(error_type = StripeErrorType::HyperswitchError, code = "", message = "There was an issue with processing webhooks")] | ||||
|     WebhookProcessingError, | ||||
|     #[error(error_type = StripeErrorType::InvalidRequestError, code = "payment_method_unactivated", message = "The operation cannot be performed as the payment method used has not been activated. Activate the payment method in the Dashboard, then try again.")] | ||||
|     PaymentMethodUnactivated, | ||||
|     // [#216]: https://github.com/juspay/hyperswitch/issues/216 | ||||
|     // Implement the remaining stripe error codes | ||||
|  | ||||
| @ -298,7 +300,6 @@ pub enum StripeErrorCode { | ||||
|         PaymentMethodMicrodepositVerificationTimeout, | ||||
|         PaymentMethodProviderDecline, | ||||
|         PaymentMethodProviderTimeout, | ||||
|         PaymentMethodUnactivated, | ||||
|         PaymentMethodUnexpectedState, | ||||
|         PaymentMethodUnsupportedType, | ||||
|         PayoutsNotAllowed, | ||||
| @ -509,6 +510,9 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode { | ||||
|             | errors::ApiErrorResponse::WebhookProcessingFailure | ||||
|             | errors::ApiErrorResponse::WebhookAuthenticationFailed | ||||
|             | errors::ApiErrorResponse::WebhookUnprocessableEntity => Self::WebhookProcessingError, | ||||
|             errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration => { | ||||
|                 Self::PaymentMethodUnactivated | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -564,7 +568,8 @@ impl actix_web::ResponseError for StripeErrorCode { | ||||
|             | Self::MissingFilePurpose | ||||
|             | Self::MissingDisputeId | ||||
|             | Self::FileNotFound | ||||
|             | Self::FileNotAvailable => StatusCode::BAD_REQUEST, | ||||
|             | Self::FileNotAvailable | ||||
|             | Self::PaymentMethodUnactivated => StatusCode::BAD_REQUEST, | ||||
|             Self::RefundFailed | ||||
|             | Self::InternalServerError | ||||
|             | Self::MandateActive | ||||
|  | ||||
| @ -194,6 +194,8 @@ pub enum ApiErrorResponse { | ||||
|     WebhookBadRequest, | ||||
|     #[error(error_type = ErrorType::RouterError, code = "WE_03", message = "There was some issue processing the webhook")] | ||||
|     WebhookProcessingFailure, | ||||
|     #[error(error_type = ErrorType::InvalidRequestError, code = "HE_04", message = "required payment method is not configured or configured incorrectly for all configured connectors")] | ||||
|     IncorrectPaymentMethodConfiguration, | ||||
|     #[error(error_type = ErrorType::InvalidRequestError, code = "WE_05", message = "Unable to process the webhook body")] | ||||
|     WebhookUnprocessableEntity, | ||||
| } | ||||
| @ -249,9 +251,6 @@ impl actix_web::ResponseError for ApiErrorResponse { | ||||
|             Self::InvalidDataFormat { .. } | Self::InvalidRequestData { .. } => { | ||||
|                 StatusCode::UNPROCESSABLE_ENTITY | ||||
|             } // 422 | ||||
|             Self::RefundAmountExceedsPaymentAmount => StatusCode::BAD_REQUEST,                // 400 | ||||
|             Self::MaximumRefundCount => StatusCode::BAD_REQUEST,                              // 400 | ||||
|             Self::PreconditionFailed { .. } => StatusCode::BAD_REQUEST,                       // 400 | ||||
|  | ||||
|             Self::PaymentAuthorizationFailed { .. } | ||||
|             | Self::PaymentAuthenticationFailed { .. } | ||||
| @ -262,7 +261,11 @@ impl actix_web::ResponseError for ApiErrorResponse { | ||||
|             | Self::RefundNotPossible { .. } | ||||
|             | Self::VerificationFailed { .. } | ||||
|             | Self::PaymentUnexpectedState { .. } | ||||
|             | Self::MandateValidationFailed { .. } => StatusCode::BAD_REQUEST, // 400 | ||||
|             | Self::MandateValidationFailed { .. } | ||||
|             | Self::RefundAmountExceedsPaymentAmount | ||||
|             | Self::MaximumRefundCount | ||||
|             | Self::IncorrectPaymentMethodConfiguration | ||||
|             | Self::PreconditionFailed { .. } => StatusCode::BAD_REQUEST, // 400 | ||||
|  | ||||
|             Self::MandateUpdateFailed | ||||
|             | Self::InternalServerError | ||||
| @ -540,6 +543,9 @@ impl common_utils::errors::ErrorSwitch<api_models::errors::types::ApiErrorRespon | ||||
|             } | ||||
|             Self::WebhookProcessingFailure => { | ||||
|                 AER::InternalServerError(ApiError::new("WE", 3, "There was an issue processing the webhook", None)) | ||||
|             }, | ||||
|             Self::IncorrectPaymentMethodConfiguration => { | ||||
|                 AER::BadRequest(ApiError::new("HE", 4, "No eligible connector was found for the current payment method configuration", None)) | ||||
|             } | ||||
|             Self::WebhookUnprocessableEntity => { | ||||
|                 AER::Unprocessable(ApiError::new("WE", 5, "There was an issue processing the webhook body", None)) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Narayan Bhat
					Narayan Bhat