refactor: refactor connector auth type failure to 4xx (#2616)

This commit is contained in:
Arjun Karthik
2023-10-18 16:52:06 +05:30
committed by GitHub
parent 73e93910cd
commit 1dad7455c4
7 changed files with 125 additions and 20 deletions

View File

@ -239,6 +239,8 @@ pub enum StripeErrorCode {
PaymentLinkNotFound,
#[error(error_type = StripeErrorType::HyperswitchError, code = "", message = "Resource Busy. Please try again later")]
LockTimeout,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "", message = "Merchant connector account is configured with invalid {config}")]
InvalidConnectorConfiguration { config: String },
// [#216]: https://github.com/juspay/hyperswitch/issues/216
// Implement the remaining stripe error codes
@ -590,6 +592,9 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
Self::PaymentMethodUnactivated
}
errors::ApiErrorResponse::ResourceBusy => Self::PaymentMethodUnactivated,
errors::ApiErrorResponse::InvalidConnectorConfiguration { config } => {
Self::InvalidConnectorConfiguration { config }
}
}
}
}
@ -656,7 +661,8 @@ impl actix_web::ResponseError for StripeErrorCode {
| Self::FileProviderNotSupported
| Self::CurrencyNotSupported { .. }
| Self::DuplicateCustomer
| Self::PaymentMethodUnactivated => StatusCode::BAD_REQUEST,
| Self::PaymentMethodUnactivated
| Self::InvalidConnectorConfiguration { .. } => StatusCode::BAD_REQUEST,
Self::RefundFailed
| Self::PayoutFailed
| Self::PaymentLinkNotFound