Skip to content

Commit

Permalink
fix: [CYBERSOURCE] Fix Status Mapping (#3144)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
deepanshu-iiitu and hyperswitch-bot[bot] authored Dec 17, 2023
1 parent a78fed7 commit 62c0c47
Show file tree
Hide file tree
Showing 2 changed files with 359 additions and 168 deletions.
75 changes: 26 additions & 49 deletions crates/router/src/connector/cybersource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,11 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
.response
.parse_struct("Cybersource PaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
types::RouterData::try_from((
types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
},
true,
))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
Expand Down Expand Up @@ -496,17 +492,11 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
.response
.parse_struct("Cybersource PaymentSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let is_auto_capture =
data.request.capture_method == Some(diesel_models::enums::CaptureMethod::Automatic);
types::RouterData::try_from((
types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
},
is_auto_capture,
))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
Expand Down Expand Up @@ -587,17 +577,11 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
.response
.parse_struct("Cybersource PaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let is_auto_capture =
data.request.capture_method == Some(diesel_models::enums::CaptureMethod::Automatic);
types::RouterData::try_from((
types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
},
is_auto_capture,
))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}

fn get_error_response(
Expand Down Expand Up @@ -669,15 +653,11 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
.response
.parse_struct("Cybersource PaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
types::RouterData::try_from((
types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
},
false,
))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}

fn get_error_response(
Expand Down Expand Up @@ -759,16 +739,15 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
data: &types::RefundExecuteRouterData,
res: types::Response,
) -> CustomResult<types::RefundExecuteRouterData, errors::ConnectorError> {
let response: cybersource::CybersourcePaymentsResponse = res
let response: cybersource::CybersourceRefundResponse = res
.response
.parse_struct("Cybersource PaymentResponse")
.parse_struct("Cybersource RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
.change_context(errors::ConnectorError::ResponseHandlingFailed)
}
fn get_error_response(
&self,
Expand Down Expand Up @@ -826,17 +805,15 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
data: &types::RefundSyncRouterData,
res: types::Response,
) -> CustomResult<types::RefundSyncRouterData, errors::ConnectorError> {
let response: cybersource::CybersourceTransactionResponse = res
let response: cybersource::CybersourceRsyncResponse = res
.response
.parse_struct("Cybersource RefundsSyncResponse")
.parse_struct("Cybersource RefundSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
types::ResponseRouterData {
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
}
.try_into()
.change_context(errors::ConnectorError::ResponseHandlingFailed)
})
}
fn get_error_response(
&self,
Expand Down
Loading

0 comments on commit 62c0c47

Please sign in to comment.