Skip to content

Commit

Permalink
fix(connector): [Paypal]fix error deserelization for source verificat…
Browse files Browse the repository at this point in the history
…ion call (#2611)
  • Loading branch information
srujanchikke authored Oct 18, 2023
1 parent a1472c6 commit da77d13
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions crates/router/src/connector/paypal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/paypal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit da77d13

Please sign in to comment.