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(revenue_recovery): route v2 proxy payments through UCS rollout decision (#14757)
CHALLA NISHANTH BABUa495dac0060b
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex cfd091dd7d..bfdd972a0f 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -7656,6 +7656,7 @@ whererollout_scope: rollout_result.rollout_scope.clone(),execution_mode,};+let call_connector_service_response = call_connector_service(&updated_state,req_state,@@ -7893,14 +7894,17 @@ where};let (connector_request, should_continue_further) = if should_continue_further {- // Check if the actual flow specific request can be built with available data- router_data- .build_flow_specific_connector_request(- &updated_state,- &connector,- call_connector_action.clone(),- )- .await?+ if gateway_context.execution_path.is_direct_gateway() {+ router_data+ .build_flow_specific_connector_request(+ &updated_state,+ &connector,+ call_connector_action.clone(),+ )+ .await?+ } else {+ (None, should_continue_further)+ }} else {(None, false)};@@ -8004,14 +8008,6 @@ where.with_processor_merchant_id(platform.get_processor().get_processor_merchant_id()).with_provider_merchant_id(platform.get_provider().get_provider_merchant_id());- let profile_id = payment_data.get_payment_intent().profile_id.clone();- let default_gateway_context = gateway_context::RouterGatewayContext::direct(- platform.get_processor().clone(),- merchant_connector_account.clone(),- payment_data.get_payment_intent().merchant_id.clone(),- profile_id,- payment_data.get_creds_identifier().map(|id| id.to_string()),- );operation.to_domain()?.populate_payment_data(@@ -8035,13 +8031,41 @@ where).await?;+ // Every recovery attempt is routed from the rollout config alone; the gateway is not sticky+ // across attempts, so there is no previous gateway to consider.+ let (execution_path, updated_state, rollout_result) = should_call_unified_connector_service(+ state,+ platform.get_processor(),+ &router_data,+ None,+ call_connector_action.clone(),+ None,+ common_enums::TransactionType::Payment,+ )+ .await?;++ let lineage_ids = grpc_client::LineageIds::new(+ business_profile.merchant_id.clone(),+ business_profile.get_id().clone(),+ );++ let gateway_context = gateway_context::RouterGatewayContext::from_rollout(+ platform.get_processor().clone(),+ header_payload.clone(),+ lineage_ids,+ merchant_connector_account.clone(),+ payment_data.get_creds_identifier().map(|id| id.to_string()),+ execution_path,+ rollout_result,+ );+let add_access_token_result = router_data.add_access_token(- state,+ &updated_state,&connector,platform.get_processor(),payment_data.get_creds_identifier(),- &default_gateway_context,+ &gateway_context,).await?;@@ -8052,13 +8076,21 @@ where);router_data- .add_session_token(state, &connector, &default_gateway_context)+ .add_session_token(&updated_state, &connector, &gateway_context).await?;let (connector_request, should_continue_further) = if should_continue_further {- router_data- .build_flow_specific_connector_request(state, &connector, call_connector_action.clone())- .await?+ if gateway_context.execution_path.is_direct_gateway() {+ router_data+ .build_flow_specific_connector_request(+ &updated_state,+ &connector,+ call_connector_action.clone(),+ )+ .await?+ } else {+ (None, should_continue_further)+ }} else {(None, false)};@@ -8066,7 +8098,7 @@ where(_, *payment_data) = operation.to_update_tracker()?.update_trackers(- state,+ &updated_state,req_state,platform.get_processor(),payment_data.clone(),@@ -8079,14 +8111,14 @@ wherelet router_data = if should_continue_further {router_data.decide_flows(- state,+ &updated_state,&connector,call_connector_action,connector_request,business_profile,header_payload.clone(),return_raw_connector_response,- default_gateway_context,+ gateway_context,).await} else {diff --git a/crates/router/src/core/payments/gateway/context.rs b/crates/router/src/core/payments/gateway/context.rsindex d3e38f1295..a9aa0642a9 100644--- a/crates/router/src/core/payments/gateway/context.rs+++ b/crates/router/src/core/payments/gateway/context.rs@@ -98,6 +98,34 @@ impl RouterGatewayContext {}}+ /// Context for a gated path: the execution mode is derived from the path the gate chose,+ /// and the kill switch settings are carried over from the gate's result.+ pub fn from_rollout(+ processor: Processor,+ header_payload: HeaderPayload,+ lineage_ids: LineageIds,+ #[cfg(feature = "v1")] merchant_connector_account: helpers::MerchantConnectorAccountType,+ #[cfg(feature = "v2")]+ merchant_connector_account: hyperswitch_domain_models::merchant_connector_account::MerchantConnectorAccountTypeDetails,+ creds_identifier: Option<String>,+ execution_path: ExecutionPath,+ rollout_result: helpers::RolloutExecutionResult,+ ) -> Self {+ Self {+ creds_identifier,+ processor,+ header_payload,+ lineage_ids,+ merchant_connector_account,+ execution_mode: execution_path.get_execution_mode(),+ execution_path,+ kill_switch_enabled: rollout_result.kill_switch_enabled,+ kill_switch_threshold: rollout_result.kill_switch_threshold,+ connector_decline_threshold: rollout_result.connector_decline_threshold,+ rollout_scope: rollout_result.rollout_scope,+ }+ }+/// Get the gateway system (Direct, UnifiedConnectorService, etc.)/// The kill switch settings this request resolved, for the UCS logging wrappers.pub fn rollout_settings(