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(payouts): add should_continue flag for propagating error for each call (#9531)
Sakil Mostakf95c976c42d4
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex 90ba7f161b..59f83799a5 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -1657,29 +1657,35 @@ pub async fn create_payout().await?;- // 3. Fetch connector integration details- let connector_integration: services::BoxedPayoutConnectorIntegrationInterface<- api::PoCreate,- types::PayoutsData,- types::PayoutsResponseData,- > = connector_data.connector.get_connector_integration();-- // 4. Execute pretasks- complete_payout_quote_steps_if_required(state, connector_data, &mut router_data).await?;+ // 3. Execute pretasks+ if helpers::should_continue_payout(&router_data) {+ complete_payout_quote_steps_if_required(state, connector_data, &mut router_data).await?;+ };- // 5. Call connector service- let router_data_resp = services::execute_connector_processing_step(- state,- connector_integration,- &router_data,- payments::CallConnectorAction::Trigger,- None,- None,- )- .await- .to_payout_failed_response()?;+ // 4. Call connector service+ let router_data_resp = match helpers::should_continue_payout(&router_data) {+ true => {+ let connector_integration: services::BoxedPayoutConnectorIntegrationInterface<+ api::PoCreate,+ types::PayoutsData,+ types::PayoutsResponseData,+ > = connector_data.connector.get_connector_integration();++ services::execute_connector_processing_step(+ state,+ connector_integration,+ &router_data,+ payments::CallConnectorAction::Trigger,+ None,+ None,+ )+ .await+ .to_payout_failed_response()?+ }+ false => router_data,+ };- // 6. Process data returned by the connector+ // 5. Process data returned by the connectorlet db = &*state.store;match router_data_resp.response {Ok(payout_response_data) => {@@ -1881,26 +1887,30 @@ pub async fn create_payout_retrieve().await?;- // 3. Fetch connector integration details- let connector_integration: services::BoxedPayoutConnectorIntegrationInterface<- api::PoSync,- types::PayoutsData,- types::PayoutsResponseData,- > = connector_data.connector.get_connector_integration();-- // 4. Call connector service- let router_data_resp = services::execute_connector_processing_step(- state,- connector_integration,- &router_data,- payments::CallConnectorAction::Trigger,- None,- None,- )- .await- .to_payout_failed_response()?;+ // 3. Call connector service+ let router_data_resp = match helpers::should_continue_payout(&router_data) {+ true => {+ let connector_integration: services::BoxedPayoutConnectorIntegrationInterface<+ api::PoSync,+ types::PayoutsData,+ types::PayoutsResponseData,+ > = connector_data.connector.get_connector_integration();++ services::execute_connector_processing_step(+ state,+ connector_integration,+ &router_data,+ payments::CallConnectorAction::Trigger,+ None,+ None,+ )+ .await+ .to_payout_failed_response()?+ }+ false => router_data,+ };- // 5. Process data returned by the connector+ // 4. Process data returned by the connectorupdate_retrieve_payout_tracker(state, merchant_context, payout_data, &router_data_resp).await?;Ok(())@@ -2384,26 +2394,30 @@ pub async fn fulfill_payout().await?;- // 3. Fetch connector integration details- let connector_integration: services::BoxedPayoutConnectorIntegrationInterface<- api::PoFulfill,- types::PayoutsData,- types::PayoutsResponseData,- > = connector_data.connector.get_connector_integration();-- // 4. Call connector service- let router_data_resp = services::execute_connector_processing_step(- state,- connector_integration,- &router_data,- payments::CallConnectorAction::Trigger,- None,- None,- )- .await- .to_payout_failed_response()?;+ // 3. Call connector service+ let router_data_resp = match helpers::should_continue_payout(&router_data) {+ true => {+ let connector_integration: services::BoxedPayoutConnectorIntegrationInterface<+ api::PoFulfill,+ types::PayoutsData,+ types::PayoutsResponseData,+ > = connector_data.connector.get_connector_integration();++ services::execute_connector_processing_step(+ state,+ connector_integration,+ &router_data,+ payments::CallConnectorAction::Trigger,+ None,+ None,+ )+ .await+ .to_payout_failed_response()?+ }+ false => router_data,+ };- // 5. Process data returned by the connector+ // 4. Process data returned by the connectorlet db = &*state.store;match router_data_resp.response {Ok(payout_response_data) => {diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rsindex e2d6cf65e8..a9164a2336 100644--- a/crates/router/src/core/payouts/helpers.rs+++ b/crates/router/src/core/payouts/helpers.rs@@ -38,6 +38,7 @@ use crate::{routes::{metrics, SessionState},services,types::{+ self as router_types,api::{self, enums as api_enums},domain::{self, types::AsyncLift},storage,@@ -1643,3 +1644,9 @@ pub async fn resolve_billing_address_for_payout((None, None, None) => Ok((None, None)),}}++pub fn should_continue_payout<F: Clone + 'static>(+ router_data: &router_types::PayoutsRouterData<F>,+) -> bool {+ router_data.response.is_ok()+}