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
feat: add error type for empty connector list (#1363)
Narayan Bhatb2da92028090
diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rsindex 17b33da056..c68f56d70f 100644--- a/crates/router/src/compatibility/stripe/errors.rs+++ b/crates/router/src/compatibility/stripe/errors.rs@@ -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::MandateActivediff --git a/crates/router/src/core/errors/api_error_response.rs b/crates/router/src/core/errors/api_error_response.rsindex 6955082a07..4238a53092 100644--- a/crates/router/src/core/errors/api_error_response.rs+++ b/crates/router/src/core/errors/api_error_response.rs@@ -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, // 400Self::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, // 400Self::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))