Skip to content

Commit

Permalink
fix(router): mark refund status as failure for not_implemented error …
Browse files Browse the repository at this point in the history
…from connector flows (#2978)

Co-authored-by: Bernard Eugine <[email protected]>
  • Loading branch information
sai-harsha-vardhan and bernard-eugine authored Nov 24, 2023
1 parent 97a38a7 commit d56d805
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions crates/router/src/core/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,48 @@ pub async fn trigger_refund_to_gateway(
types::RefundsData,
types::RefundsResponseData,
> = connector.connector.get_connector_integration();
services::execute_connector_processing_step(
let router_data_res = services::execute_connector_processing_step(
state,
connector_integration,
&router_data,
payments::CallConnectorAction::Trigger,
None,
)
.await
.to_refund_failed_response()?
.await;
let option_refund_error_update =
router_data_res
.as_ref()
.err()
.and_then(|error| match error.current_context() {
errors::ConnectorError::NotImplemented(message) => {
Some(storage::RefundUpdate::ErrorUpdate {
refund_status: Some(enums::RefundStatus::Failure),
refund_error_message: Some(message.to_string()),
refund_error_code: Some("NOT_IMPLEMENTED".to_string()),
updated_by: storage_scheme.to_string(),
})
}
_ => None,
});
// Update the refund status as failure if connector_error is NotImplemented
if let Some(refund_error_update) = option_refund_error_update {
state
.store
.update_refund(
refund.to_owned(),
refund_error_update,
merchant_account.storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::InternalServerError)
.attach_printable_lazy(|| {
format!(
"Failed while updating refund: refund_id: {}",
refund.refund_id
)
})?;
}
router_data_res.to_refund_failed_response()?
} else {
router_data
};
Expand Down

0 comments on commit d56d805

Please sign in to comment.