Skip to content

Commit

Permalink
Merge branch 'main' into surcharge-related-status-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-eugine authored Nov 24, 2023
2 parents 027c1a7 + d56d805 commit 5e854f9
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 5e854f9

Please sign in to comment.