From 8fffc161ea909fb29a81090f97ee9f811431d539 Mon Sep 17 00:00:00 2001 From: Narayan Bhat <48803246+Narayanbhat166@users.noreply.github.com> Date: Tue, 20 Jun 2023 11:45:48 +0530 Subject: [PATCH] refactor(core): update trackers for preprocessing steps (#1481) --- crates/router/src/core/payments.rs | 42 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index ebac8bb0d2..cfad9583b5 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -551,26 +551,34 @@ where payment_data.sessions_token.push(session_token); }; - let router_data_res = if should_continue_further { + let connector_request = if should_continue_further { // Check if the actual flow specific request can be built with available data - let request = router_data + router_data .build_flow_specific_connector_request(state, &connector, call_connector_action.clone()) - .await?; + .await? + } else { + None + }; - // Update the payment trackers just before calling the connector - // Since the request is already built in the previous step, - // there should be no error in request construction from hyperswitch end - operation - .to_update_tracker()? - .update_trackers( - &*state.store, - payment_data.clone(), - customer.clone(), - merchant_account.storage_scheme, - updated_customer, - ) - .await?; + // Update the payment trackers just before calling the connector + // Since the request is already built in the previous step, + // there should be no error in request construction from hyperswitch end + (_, *payment_data) = operation + .to_update_tracker()? + .update_trackers( + &*state.store, + payment_data.clone(), + customer.clone(), + merchant_account.storage_scheme, + updated_customer, + ) + .await?; + // The status of payment_attempt and intent will be updated in the previous step + // This field will be used by the connector + router_data.status = payment_data.payment_attempt.status; + + let router_data_res = if should_continue_further { router_data .decide_flows( state, @@ -578,7 +586,7 @@ where customer, call_connector_action, merchant_account, - request, + connector_request, ) .await } else {