fix(connector): [Paypal]fix error deserelization for source verification call (#2611)

This commit is contained in:
chikke srujan
2023-10-18 14:04:13 +05:30
committed by GitHub
parent a1472c6b78
commit da77d1393b
2 changed files with 13 additions and 8 deletions

View File

@ -174,26 +174,31 @@ impl ConnectorCommon for Paypal {
.map(|error_details| {
error_details
.iter()
.try_fold::<_, _, CustomResult<_, errors::ConnectorError>>(
String::new(),
|mut acc, error| {
write!(acc, "description - {} ;", error.description)
.try_fold(String::new(), |mut acc, error| {
if let Some(description) = &error.description {
write!(acc, "description - {} ;", description)
.into_report()
.change_context(
errors::ConnectorError::ResponseDeserializationFailed,
)
.attach_printable("Failed to concatenate error details")
.map(|_| acc)
},
)
} else {
Ok(acc)
}
})
})
.transpose()?;
let reason = error_reason
.unwrap_or(response.message.to_owned())
.is_empty()
.then_some(response.message.to_owned());
Ok(ErrorResponse {
status_code: res.status_code,
code: response.name,
message: response.message.clone(),
reason: error_reason.or(Some(response.message)),
reason,
})
}
}

View File

@ -1380,7 +1380,7 @@ pub struct PaypalOrderErrorResponse {
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ErrorDetails {
pub issue: String,
pub description: String,
pub description: Option<String>,
}
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]