Skip to content

Commit

Permalink
feat(connector): [BOA] Fix 5XX Error response
Browse files Browse the repository at this point in the history
  • Loading branch information
deepanshu-iiitu committed Dec 20, 2023
1 parent d2b3b2d commit 775f655
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
39 changes: 6 additions & 33 deletions crates/router/src/connector/bankofamerica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
&self,
res: Response,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: bankofamerica::BankOfAmerica5XXErrorResponse = res
let response: bankofamerica::BankOfAmericaServerErrorResponse = res
.response
.parse_struct("BankOfAmerica 5XX ErrorResponse")
.parse_struct("BankOfAmericaServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let attempt_status = match response.reason {
Some(reason) => match reason {
Expand Down Expand Up @@ -574,9 +574,9 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
&self,
res: Response,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: bankofamerica::BankOfAmerica5XXErrorResponse = res
let response: bankofamerica::BankOfAmericaServerErrorResponse = res
.response
.parse_struct("BankOfAmerica 5XX ErrorResponse")
.parse_struct("BankOfAmericaServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

Ok(ErrorResponse {
Expand Down Expand Up @@ -694,9 +694,9 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
&self,
res: Response,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: bankofamerica::BankOfAmerica5XXErrorResponse = res
let response: bankofamerica::BankOfAmericaServerErrorResponse = res
.response
.parse_struct("BankOfAmerica 5XX ErrorResponse")
.parse_struct("BankOfAmericaServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

Ok(ErrorResponse {
Expand Down Expand Up @@ -800,33 +800,6 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res)
}

fn get_5xx_error_response(
&self,
res: Response,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: bankofamerica::BankOfAmerica5XXErrorResponse = res
.response
.parse_struct("BankOfAmerica 5XX ErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let attempt_status = match response.reason {
Some(reason) => match reason {
transformers::Reason::SystemError => Some(enums::AttemptStatus::Failure),
transformers::Reason::ServerTimeout | transformers::Reason::ServiceTimeout => None,
},
None => None,
};
Ok(ErrorResponse {
status_code: res.status_code,
reason: response.status.clone(),
code: response.status.unwrap_or(consts::NO_ERROR_CODE.to_string()),
message: response
.message
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()),
attempt_status,
connector_transaction_id: None,
})
}
}

impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponseData>
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/bankofamerica/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ pub struct BankOfAmericaStandardErrorResponse {

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BankOfAmerica5XXErrorResponse {
pub struct BankOfAmericaServerErrorResponse {
pub status: Option<String>,
pub message: Option<String>,
pub reason: Option<Reason>,
Expand Down

0 comments on commit 775f655

Please sign in to comment.