fix(connector): [HELCIM] Handle 4XX Errors (#3458)

This commit is contained in:
DEEPANSHU BANSAL
2024-01-25 16:16:03 +05:30
committed by GitHub
parent 9a54838b05
commit ec859eabbf
2 changed files with 14 additions and 4 deletions

View File

@ -128,9 +128,12 @@ impl ConnectorCommon for Helcim {
.response
.parse_struct("HelcimErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let error_string = match response.errors {
let error_string = match response {
transformers::HelcimErrorResponse::Payment(response) => match response.errors {
transformers::HelcimErrorTypes::StringType(error) => error,
transformers::HelcimErrorTypes::JsonType(error) => error.to_string(),
},
transformers::HelcimErrorResponse::General(error_string) => error_string,
};
Ok(ErrorResponse {

View File

@ -756,6 +756,13 @@ pub enum HelcimErrorTypes {
}
#[derive(Debug, Deserialize)]
pub struct HelcimErrorResponse {
pub struct HelcimPaymentsErrorResponse {
pub errors: HelcimErrorTypes,
}
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum HelcimErrorResponse {
Payment(HelcimPaymentsErrorResponse),
General(String),
}