Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(router): mark refund status as failure for not_implemented error from connector flows (#2978)
Sai Harsha Vardhand56d80557050
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rsindex b2f73c0b7c..aba6e9794e 100644--- a/crates/router/src/core/refunds.rs+++ b/crates/router/src/core/refunds.rs@@ -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};