Bug: [BUG] payment status is processing if there is a validation error



### Bug Description

The payment flow is as follows
- Merchant server creates the Payments with amount and currency and other merchant specific fields.
- The SDK confirms the payment with `PaymentMethodData`.

During confirm, the connector / gateway is called to create the actual transaction, we update the payment status before this, i.e make the payment status as `processing` since after we get the response from connector it will be updated to a terminal status ( happy case ). If for some reason, the connector request cannot be created, then the payment status will still be processing which is not the intended behaviour.

### Expected Behavior

If there is a bad request error, then the trackers should not be updated.

### Actual Behavior

The payment status is changed to processing.

### Steps To Reproduce

Provide an unambiguous set of steps to reproduce this bug. Include code or configuration to reproduce, if relevant.
1. Create a `zen` payment, without order details.
2. Confirm with payment method data - fails saying that `order_details` is a required field.
3. Retrieve the payment, the status will be `processing`


### Context For The Bug

_No response_

### Environment

Local environment


### Have you spent some time to check if this bug has been raised before?

- [X] I checked and didn't find similar issue

### Have you read the Contributing Guidelines?

- [X] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Are you willing to submit a PR?

Yes I am willing to submit a PR!
diff --git a/crates/router/src/connector/airwallex.rs b/crates/router/src/connector/airwallex.rs
index 2c4915c40c8..1a95f670426 100644
--- a/crates/router/src/connector/airwallex.rs
+++ b/crates/router/src/connector/airwallex.rs
@@ -308,6 +308,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
             integ,
             authorize_data,
             payments::CallConnectorAction::Trigger,
+            None,
         )
         .await?;
         router_data.reference_id = resp.reference_id;
diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs
index b7d2c4ec3a0..d8f5237379f 100644
--- a/crates/router/src/connector/nuvei.rs
+++ b/crates/router/src/connector/nuvei.rs
@@ -483,6 +483,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
             integ,
             authorize_data,
             payments::CallConnectorAction::Trigger,
+            None,
         )
         .await?;
         router_data.session_token = resp.session_token;
@@ -510,6 +511,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
                         integ,
                         init_data,
                         payments::CallConnectorAction::Trigger,
+                        None,
                     )
                     .await?;
                     match init_resp.response {
diff --git a/crates/router/src/connector/shift4.rs b/crates/router/src/connector/shift4.rs
index 86dc4e58492..fd62faaeb29 100644
--- a/crates/router/src/connector/shift4.rs
+++ b/crates/router/src/connector/shift4.rs
@@ -199,6 +199,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
                 integ,
                 init_data,
                 payments::CallConnectorAction::Trigger,
+                None,
             )
             .await?;
             if init_resp.request.enrolled_for_3ds {
diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rs
index e4e8404a2ca..c90f91c9270 100644
--- a/crates/router/src/core/disputes.rs
+++ b/crates/router/src/core/disputes.rs
@@ -127,6 +127,7 @@ pub async fn accept_dispute(
         connector_integration,
         &router_data,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .to_dispute_failed_response()
@@ -234,6 +235,7 @@ pub async fn submit_evidence(
         connector_integration,
         &router_data,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .to_dispute_failed_response()
@@ -270,6 +272,7 @@ pub async fn submit_evidence(
                 connector_integration_defend_dispute,
                 &defend_dispute_router_data,
                 payments::CallConnectorAction::Trigger,
+                None,
             )
             .await
             .to_dispute_failed_response()
diff --git a/crates/router/src/core/files/helpers.rs b/crates/router/src/core/files/helpers.rs
index ed748badc09..751dd5b047f 100644
--- a/crates/router/src/core/files/helpers.rs
+++ b/crates/router/src/core/files/helpers.rs
@@ -188,6 +188,7 @@ pub async fn retrieve_file_from_connector(
         connector_integration,
         &router_data,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .change_context(errors::ApiErrorResponse::InternalServerError)
@@ -339,6 +340,7 @@ pub async fn upload_and_get_provider_provider_file_id_connector_label(
                     connector_integration,
                     &router_data,
                     payments::CallConnectorAction::Trigger,
+                    None,
                 )
                 .await
                 .change_context(errors::ApiErrorResponse::InternalServerError)
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 8fe2d45f139..ebac8bb0d23 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -129,18 +129,6 @@ where
     )
     .await?;
 
-    let (operation, mut payment_data) = operation
-        .to_update_tracker()?
-        .update_trackers(
-            &*state.store,
-            &validate_result.payment_id,
-            payment_data,
-            customer.clone(),
-            validate_result.storage_scheme,
-            updated_customer,
-        )
-        .await?;
-
     if let Some(connector_details) = connector {
         if should_add_task_to_process_tracker(&payment_data) {
             operation
@@ -160,6 +148,7 @@ where
                     &customer,
                     call_connector_action,
                     tokenization_action,
+                    updated_customer,
                 )
                 .await?;
 
@@ -189,11 +178,24 @@ where
                 .await?
             }
         };
+
         if should_delete_pm_from_locker(payment_data.payment_intent.status) {
             vault::Vault::delete_locker_payment_method_by_lookup_key(state, &payment_data.token)
                 .await
         }
+    } else {
+        (_, payment_data) = operation
+            .to_update_tracker()?
+            .update_trackers(
+                &*state.store,
+                payment_data.clone(),
+                customer.clone(),
+                validate_result.storage_scheme,
+                updated_customer,
+            )
+            .await?;
     }
+
     Ok((payment_data, req, customer))
 }
 
@@ -485,30 +487,28 @@ impl PaymentRedirectFlow for PaymentRedirectSync {
 }
 
 #[allow(clippy::too_many_arguments)]
-pub async fn call_connector_service<F, Op, Req>(
+pub async fn call_connector_service<F, RouterDReq, ApiRequest>(
     state: &AppState,
     merchant_account: &domain::MerchantAccount,
     connector: api::ConnectorData,
-    _operation: &Op,
+    operation: &BoxedOperation<'_, F, ApiRequest>,
     payment_data: &mut PaymentData<F>,
     customer: &Option<domain::Customer>,
     call_connector_action: CallConnectorAction,
     tokenization_action: TokenizationAction,
-) -> RouterResult<types::RouterData<F, Req, types::PaymentsResponseData>>
+    updated_customer: Option<storage::CustomerUpdate>,
+) -> RouterResult<types::RouterData<F, RouterDReq, types::PaymentsResponseData>>
 where
-    Op: Debug + Sync,
     F: Send + Clone + Sync,
-    Req: Send + Sync,
+    RouterDReq: Send + Sync,
 
     // To create connector flow specific interface data
-    PaymentData<F>: ConstructFlowSpecificData<F, Req, types::PaymentsResponseData>,
-    types::RouterData<F, Req, types::PaymentsResponseData>: Feature<F, Req> + Send,
+    PaymentData<F>: ConstructFlowSpecificData<F, RouterDReq, types::PaymentsResponseData>,
+    types::RouterData<F, RouterDReq, types::PaymentsResponseData>: Feature<F, RouterDReq> + Send,
 
     // To construct connector flow specific api
-    dyn api::Connector: services::api::ConnectorIntegration<F, Req, types::PaymentsResponseData>,
-
-    // To perform router related operation for PaymentResponse
-    PaymentResponse: Operation<F, Req>,
+    dyn api::Connector:
+        services::api::ConnectorIntegration<F, RouterDReq, types::PaymentsResponseData>,
 {
     let stime_connector = Instant::now();
 
@@ -520,7 +520,7 @@ where
         .add_access_token(state, &connector, merchant_account)
         .await?;
 
-    let mut should_continue_payment = access_token::update_router_data_with_access_token_result(
+    let mut should_continue_further = access_token::update_router_data_with_access_token_result(
         &add_access_token_result,
         &mut router_data,
         &call_connector_action,
@@ -534,12 +534,12 @@ where
         router_data.payment_method_token = Some(payment_method_token);
     };
 
-    (router_data, should_continue_payment) = complete_preprocessing_steps_if_required(
+    (router_data, should_continue_further) = complete_preprocessing_steps_if_required(
         state,
         &connector,
         payment_data,
         router_data,
-        should_continue_payment,
+        should_continue_further,
     )
     .await?;
 
@@ -551,7 +551,26 @@ where
         payment_data.sessions_token.push(session_token);
     };
 
-    let router_data_res = if should_continue_payment {
+    let router_data_res = if should_continue_further {
+        // Check if the actual flow specific request can be built with available data
+        let request = router_data
+            .build_flow_specific_connector_request(state, &connector, call_connector_action.clone())
+            .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
+        operation
+            .to_update_tracker()?
+            .update_trackers(
+                &*state.store,
+                payment_data.clone(),
+                customer.clone(),
+                merchant_account.storage_scheme,
+                updated_customer,
+            )
+            .await?;
+
         router_data
             .decide_flows(
                 state,
@@ -559,6 +578,7 @@ where
                 customer,
                 call_connector_action,
                 merchant_account,
+                request,
             )
             .await
     } else {
@@ -609,6 +629,7 @@ where
             customer,
             CallConnectorAction::Trigger,
             merchant_account,
+            None,
         );
 
         join_handlers.push(res);
diff --git a/crates/router/src/core/payments/access_token.rs b/crates/router/src/core/payments/access_token.rs
index ad4706abde6..6bae1067b0e 100644
--- a/crates/router/src/core/payments/access_token.rs
+++ b/crates/router/src/core/payments/access_token.rs
@@ -13,6 +13,10 @@ use crate::{
     types::{self, api as api_types, domain, transformers::ForeignInto},
 };
 
+/// After we get the access token, check if there was an error and if the flow should proceed further
+/// Returns bool
+/// true - Everything is well, continue with the flow
+/// false - There was an error, cannot proceed further
 pub fn update_router_data_with_access_token_result<F, Req, Res>(
     add_access_token_result: &types::AddAccessTokenResult,
     router_data: &mut types::RouterData<F, Req, Res>,
@@ -152,6 +156,7 @@ pub async fn refresh_connector_auth(
         connector_integration,
         router_data,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .change_context(errors::ApiErrorResponse::InternalServerError)
diff --git a/crates/router/src/core/payments/customers.rs b/crates/router/src/core/payments/customers.rs
index 213a7cbc103..5bfe7fbe1cf 100644
--- a/crates/router/src/core/payments/customers.rs
+++ b/crates/router/src/core/payments/customers.rs
@@ -46,6 +46,7 @@ pub async fn create_connector_customer<F: Clone, T: Clone>(
         connector_integration,
         &customer_router_data,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .to_payment_failed_response()?;
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index 4abbe9291f6..e128bcb8954 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -39,6 +39,7 @@ pub trait Feature<F, T> {
         maybe_customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         merchant_account: &domain::MerchantAccount,
+        connector_request: Option<services::Request>,
     ) -> RouterResult<Self>
     where
         Self: Sized,
@@ -95,6 +96,15 @@ pub trait Feature<F, T> {
     {
         Ok(None)
     }
+
+    async fn build_flow_specific_connector_request(
+        &mut self,
+        _state: &AppState,
+        _connector: &api::ConnectorData,
+        _call_connector_action: payments::CallConnectorAction,
+    ) -> RouterResult<Option<services::Request>> {
+        Ok(None)
+    }
 }
 
 macro_rules! default_imp_for_complete_authorize{
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 1efc09ffbc3..49d30f6e87e 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -51,24 +51,46 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
         mut self,
         state: &AppState,
         connector: &api::ConnectorData,
-        customer: &Option<domain::Customer>,
+        maybe_customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         merchant_account: &domain::MerchantAccount,
+        connector_request: Option<services::Request>,
     ) -> RouterResult<Self> {
-        let resp = self
-            .decide_flow(
+        let connector_integration: services::BoxedConnectorIntegration<
+            '_,
+            api::Authorize,
+            types::PaymentsAuthorizeData,
+            types::PaymentsResponseData,
+        > = connector.connector.get_connector_integration();
+
+        if self.should_proceed_with_authorize() {
+            self.decide_authentication_type();
+            logger::debug!(auth_type=?self.auth_type);
+            let resp = services::execute_connector_processing_step(
                 state,
-                connector,
-                customer,
-                Some(true),
+                connector_integration,
+                &self,
                 call_connector_action,
-                merchant_account,
+                connector_request,
             )
-            .await;
+            .await
+            .to_payment_failed_response()?;
+
+            metrics::PAYMENT_COUNT.add(&metrics::CONTEXT, 1, &[]); // Metrics
 
-        metrics::PAYMENT_COUNT.add(&metrics::CONTEXT, 1, &[]); // Metrics
+            let pm_id = tokenization::save_payment_method(
+                state,
+                connector,
+                resp.to_owned(),
+                maybe_customer,
+                merchant_account,
+            )
+            .await?;
 
-        resp
+            Ok(mandate::mandate_procedure(state, resp, maybe_customer, pm_id).await?)
+        } else {
+            Ok(self.clone())
+        }
     }
 
     async fn add_access_token<'a>(
@@ -117,26 +139,22 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
         )
         .await
     }
-}
 
-impl types::PaymentsAuthorizeRouterData {
-    pub async fn decide_flow<'a, 'b>(
-        &'b mut self,
-        state: &'a AppState,
+    async fn build_flow_specific_connector_request(
+        &mut self,
+        state: &AppState,
         connector: &api::ConnectorData,
-        maybe_customer: &Option<domain::Customer>,
-        confirm: Option<bool>,
         call_connector_action: payments::CallConnectorAction,
-        merchant_account: &domain::MerchantAccount,
-    ) -> RouterResult<Self> {
-        match confirm {
-            Some(true) => {
+    ) -> RouterResult<Option<services::Request>> {
+        match call_connector_action {
+            payments::CallConnectorAction::Trigger => {
                 let connector_integration: services::BoxedConnectorIntegration<
                     '_,
                     api::Authorize,
                     types::PaymentsAuthorizeData,
                     types::PaymentsResponseData,
                 > = connector.connector.get_connector_integration();
+
                 connector_integration
                     .execute_pretasks(self, state)
                     .await
@@ -155,36 +173,24 @@ impl types::PaymentsAuthorizeRouterData {
                 );
 
                 logger::debug!(completed_pre_tasks=?true);
+
                 if self.should_proceed_with_authorize() {
                     self.decide_authentication_type();
                     logger::debug!(auth_type=?self.auth_type);
-                    let resp = services::execute_connector_processing_step(
-                        state,
-                        connector_integration,
-                        self,
-                        call_connector_action,
-                    )
-                    .await
-                    .to_payment_failed_response()?;
-
-                    let pm_id = tokenization::save_payment_method(
-                        state,
-                        connector,
-                        resp.to_owned(),
-                        maybe_customer,
-                        merchant_account,
-                    )
-                    .await?;
 
-                    Ok(mandate::mandate_procedure(state, resp, maybe_customer, pm_id).await?)
+                    connector_integration
+                        .build_request(self, &state.conf.connectors)
+                        .to_payment_failed_response()
                 } else {
-                    Ok(self.clone())
+                    Ok(None)
                 }
             }
-            _ => Ok(self.clone()),
+            _ => Ok(None),
         }
     }
+}
 
+impl types::PaymentsAuthorizeRouterData {
     fn decide_authentication_type(&mut self) {
         if self.auth_type == storage_models::enums::AuthenticationType::ThreeDs
             && !self.request.enrolled_for_3ds
@@ -204,12 +210,6 @@ impl types::PaymentsAuthorizeRouterData {
     }
 }
 
-pub enum Action {
-    Update,
-    Insert,
-    Skip,
-}
-
 impl mandate::MandateBehaviour for types::PaymentsAuthorizeData {
     fn get_amount(&self) -> i64 {
         self.amount
@@ -264,6 +264,7 @@ pub async fn authorize_preprocessing_steps<F: Clone>(
             connector_integration,
             &preprocessing_router_data,
             payments::CallConnectorAction::Trigger,
+            None,
         )
         .await
         .to_payment_failed_response()?;
diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rs
index c769d9c59ac..06c8c88f0fe 100644
--- a/crates/router/src/core/payments/flows/cancel_flow.rs
+++ b/crates/router/src/core/payments/flows/cancel_flow.rs
@@ -41,9 +41,10 @@ impl Feature<api::Void, types::PaymentsCancelData>
         self,
         state: &AppState,
         connector: &api::ConnectorData,
-        customer: &Option<domain::Customer>,
+        _customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         _merchant_account: &domain::MerchantAccount,
+        connector_request: Option<services::Request>,
     ) -> RouterResult<Self> {
         metrics::PAYMENT_CANCEL_COUNT.add(
             &metrics::CONTEXT,
@@ -53,14 +54,25 @@ impl Feature<api::Void, types::PaymentsCancelData>
                 connector.connector_name.to_string(),
             )],
         );
-        self.decide_flow(
+
+        let connector_integration: services::BoxedConnectorIntegration<
+            '_,
+            api::Void,
+            types::PaymentsCancelData,
+            types::PaymentsResponseData,
+        > = connector.connector.get_connector_integration();
+
+        let resp = services::execute_connector_processing_step(
             state,
-            connector,
-            customer,
-            Some(true),
+            connector_integration,
+            &self,
             call_connector_action,
+            connector_request,
         )
         .await
+        .to_payment_failed_response()?;
+
+        Ok(resp)
     }
 
     async fn add_access_token<'a>(
@@ -71,33 +83,27 @@ impl Feature<api::Void, types::PaymentsCancelData>
     ) -> RouterResult<types::AddAccessTokenResult> {
         access_token::add_access_token(state, connector, merchant_account, self).await
     }
-}
 
-impl types::PaymentsCancelRouterData {
-    #[allow(clippy::too_many_arguments)]
-    pub async fn decide_flow<'a, 'b>(
-        &'b self,
+    async fn build_flow_specific_connector_request(
+        &mut self,
         state: &AppState,
         connector: &api::ConnectorData,
-        _maybe_customer: &Option<domain::Customer>,
-        _confirm: Option<bool>,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Self> {
-        let connector_integration: services::BoxedConnectorIntegration<
-            '_,
-            api::Void,
-            types::PaymentsCancelData,
-            types::PaymentsResponseData,
-        > = connector.connector.get_connector_integration();
-        let resp = services::execute_connector_processing_step(
-            state,
-            connector_integration,
-            self,
-            call_connector_action,
-        )
-        .await
-        .to_payment_failed_response()?;
+    ) -> RouterResult<Option<services::Request>> {
+        match call_connector_action {
+            payments::CallConnectorAction::Trigger => {
+                let connector_integration: services::BoxedConnectorIntegration<
+                    '_,
+                    api::Void,
+                    types::PaymentsCancelData,
+                    types::PaymentsResponseData,
+                > = connector.connector.get_connector_integration();
 
-        Ok(resp)
+                connector_integration
+                    .build_request(self, &state.conf.connectors)
+                    .to_payment_failed_response()
+            }
+            _ => Ok(None),
+        }
     }
 }
diff --git a/crates/router/src/core/payments/flows/capture_flow.rs b/crates/router/src/core/payments/flows/capture_flow.rs
index c4f1cfdae4c..937c3daec6c 100644
--- a/crates/router/src/core/payments/flows/capture_flow.rs
+++ b/crates/router/src/core/payments/flows/capture_flow.rs
@@ -42,18 +42,29 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
         self,
         state: &AppState,
         connector: &api::ConnectorData,
-        customer: &Option<domain::Customer>,
+        _customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         _merchant_account: &domain::MerchantAccount,
+        connector_request: Option<services::Request>,
     ) -> RouterResult<Self> {
-        self.decide_flow(
+        let connector_integration: services::BoxedConnectorIntegration<
+            '_,
+            api::Capture,
+            types::PaymentsCaptureData,
+            types::PaymentsResponseData,
+        > = connector.connector.get_connector_integration();
+
+        let resp = services::execute_connector_processing_step(
             state,
-            connector,
-            customer,
-            Some(true),
+            connector_integration,
+            &self,
             call_connector_action,
+            connector_request,
         )
         .await
+        .to_payment_failed_response()?;
+
+        Ok(resp)
     }
 
     async fn add_access_token<'a>(
@@ -64,33 +75,27 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
     ) -> RouterResult<types::AddAccessTokenResult> {
         access_token::add_access_token(state, connector, merchant_account, self).await
     }
-}
 
-impl types::PaymentsCaptureRouterData {
-    #[allow(clippy::too_many_arguments)]
-    pub async fn decide_flow<'a, 'b>(
-        &'b self,
-        state: &'a AppState,
+    async fn build_flow_specific_connector_request(
+        &mut self,
+        state: &AppState,
         connector: &api::ConnectorData,
-        _maybe_customer: &Option<domain::Customer>,
-        _confirm: Option<bool>,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Self> {
-        let connector_integration: services::BoxedConnectorIntegration<
-            '_,
-            api::Capture,
-            types::PaymentsCaptureData,
-            types::PaymentsResponseData,
-        > = connector.connector.get_connector_integration();
-        let resp = services::execute_connector_processing_step(
-            state,
-            connector_integration,
-            self,
-            call_connector_action,
-        )
-        .await
-        .to_payment_failed_response()?;
+    ) -> RouterResult<Option<services::Request>> {
+        match call_connector_action {
+            payments::CallConnectorAction::Trigger => {
+                let connector_integration: services::BoxedConnectorIntegration<
+                    '_,
+                    api::Capture,
+                    types::PaymentsCaptureData,
+                    types::PaymentsResponseData,
+                > = connector.connector.get_connector_integration();
 
-        Ok(resp)
+                connector_integration
+                    .build_request(self, &state.conf.connectors)
+                    .to_payment_failed_response()
+            }
+            _ => Ok(None),
+        }
     }
 }
diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
index 65502087b86..6e2646f5378 100644
--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
@@ -58,18 +58,29 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
         mut self,
         state: &AppState,
         connector: &api::ConnectorData,
-        customer: &Option<domain::Customer>,
+        _customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         _merchant_account: &domain::MerchantAccount,
+        connector_request: Option<services::Request>,
     ) -> RouterResult<Self> {
-        self.decide_flow(
+        let connector_integration: services::BoxedConnectorIntegration<
+            '_,
+            api::CompleteAuthorize,
+            types::CompleteAuthorizeData,
+            types::PaymentsResponseData,
+        > = connector.connector.get_connector_integration();
+
+        let resp = services::execute_connector_processing_step(
             state,
-            connector,
-            customer,
-            Some(true),
+            connector_integration,
+            &self,
             call_connector_action,
+            connector_request,
         )
         .await
+        .to_payment_failed_response()?;
+
+        Ok(resp)
     }
 
     async fn add_access_token<'a>(
@@ -80,32 +91,27 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
     ) -> RouterResult<types::AddAccessTokenResult> {
         access_token::add_access_token(state, connector, merchant_account, self).await
     }
-}
 
-impl types::PaymentsCompleteAuthorizeRouterData {
-    pub async fn decide_flow<'a, 'b>(
-        &'b mut self,
-        state: &'a AppState,
+    async fn build_flow_specific_connector_request(
+        &mut self,
+        state: &AppState,
         connector: &api::ConnectorData,
-        _maybe_customer: &Option<domain::Customer>,
-        _confirm: Option<bool>,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Self> {
-        let connector_integration: services::BoxedConnectorIntegration<
-            '_,
-            api::CompleteAuthorize,
-            types::CompleteAuthorizeData,
-            types::PaymentsResponseData,
-        > = connector.connector.get_connector_integration();
-        let resp = services::execute_connector_processing_step(
-            state,
-            connector_integration,
-            self,
-            call_connector_action,
-        )
-        .await
-        .to_payment_failed_response()?;
+    ) -> RouterResult<Option<services::Request>> {
+        match call_connector_action {
+            payments::CallConnectorAction::Trigger => {
+                let connector_integration: services::BoxedConnectorIntegration<
+                    '_,
+                    api::CompleteAuthorize,
+                    types::CompleteAuthorizeData,
+                    types::PaymentsResponseData,
+                > = connector.connector.get_connector_integration();
 
-        Ok(resp)
+                connector_integration
+                    .build_request(self, &state.conf.connectors)
+                    .to_payment_failed_response()
+            }
+            _ => Ok(None),
+        }
     }
 }
diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs
index 8492d9fd32e..d4d593bd9b5 100644
--- a/crates/router/src/core/payments/flows/psync_flow.rs
+++ b/crates/router/src/core/payments/flows/psync_flow.rs
@@ -43,18 +43,28 @@ impl Feature<api::PSync, types::PaymentsSyncData>
         self,
         state: &AppState,
         connector: &api::ConnectorData,
-        customer: &Option<domain::Customer>,
+        _customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         _merchant_account: &domain::MerchantAccount,
+        connector_request: Option<services::Request>,
     ) -> RouterResult<Self> {
-        self.decide_flow(
+        let connector_integration: services::BoxedConnectorIntegration<
+            '_,
+            api::PSync,
+            types::PaymentsSyncData,
+            types::PaymentsResponseData,
+        > = connector.connector.get_connector_integration();
+        let resp = services::execute_connector_processing_step(
             state,
-            connector,
-            customer,
-            Some(true),
+            connector_integration,
+            &self,
             call_connector_action,
+            connector_request,
         )
         .await
+        .to_payment_failed_response()?;
+
+        Ok(resp)
     }
 
     async fn add_access_token<'a>(
@@ -65,32 +75,27 @@ impl Feature<api::PSync, types::PaymentsSyncData>
     ) -> RouterResult<types::AddAccessTokenResult> {
         access_token::add_access_token(state, connector, merchant_account, self).await
     }
-}
 
-impl types::PaymentsSyncRouterData {
-    pub async fn decide_flow<'a, 'b>(
-        &'b self,
-        state: &'a AppState,
+    async fn build_flow_specific_connector_request(
+        &mut self,
+        state: &AppState,
         connector: &api::ConnectorData,
-        _maybe_customer: &Option<domain::Customer>,
-        _confirm: Option<bool>,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Self> {
-        let connector_integration: services::BoxedConnectorIntegration<
-            '_,
-            api::PSync,
-            types::PaymentsSyncData,
-            types::PaymentsResponseData,
-        > = connector.connector.get_connector_integration();
-        let resp = services::execute_connector_processing_step(
-            state,
-            connector_integration,
-            self,
-            call_connector_action,
-        )
-        .await
-        .to_payment_failed_response()?;
+    ) -> RouterResult<Option<services::Request>> {
+        match call_connector_action {
+            payments::CallConnectorAction::Trigger => {
+                let connector_integration: services::BoxedConnectorIntegration<
+                    '_,
+                    api::PSync,
+                    types::PaymentsSyncData,
+                    types::PaymentsResponseData,
+                > = connector.connector.get_connector_integration();
 
-        Ok(resp)
+                connector_integration
+                    .build_request(self, &state.conf.connectors)
+                    .to_payment_failed_response()
+            }
+            _ => Ok(None),
+        }
     }
 }
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index f30ff80a48c..c6be6940e52 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -49,6 +49,7 @@ impl Feature<api::Session, types::PaymentsSessionData> for types::PaymentsSessio
         customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         _merchant_account: &domain::MerchantAccount,
+        _connector_request: Option<services::Request>,
     ) -> RouterResult<Self> {
         metrics::SESSION_TOKEN_CREATED.add(
             &metrics::CONTEXT,
@@ -371,6 +372,7 @@ impl types::PaymentsSessionRouterData {
                     connector_integration,
                     self,
                     call_connector_action,
+                    None,
                 )
                 .await
                 .to_payment_failed_response()?;
diff --git a/crates/router/src/core/payments/flows/verify_flow.rs b/crates/router/src/core/payments/flows/verify_flow.rs
index 0b37dce2d87..274ad4fcdc0 100644
--- a/crates/router/src/core/payments/flows/verify_flow.rs
+++ b/crates/router/src/core/payments/flows/verify_flow.rs
@@ -40,19 +40,37 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
         self,
         state: &AppState,
         connector: &api::ConnectorData,
-        customer: &Option<domain::Customer>,
+        maybe_customer: &Option<domain::Customer>,
         call_connector_action: payments::CallConnectorAction,
         merchant_account: &domain::MerchantAccount,
+        connector_request: Option<services::Request>,
     ) -> RouterResult<Self> {
-        self.decide_flow(
+        let connector_integration: services::BoxedConnectorIntegration<
+            '_,
+            api::Verify,
+            types::VerifyRequestData,
+            types::PaymentsResponseData,
+        > = connector.connector.get_connector_integration();
+        let resp = services::execute_connector_processing_step(
             state,
-            connector,
-            customer,
-            Some(true),
+            connector_integration,
+            &self,
             call_connector_action,
-            merchant_account,
+            connector_request,
         )
         .await
+        .to_verify_failed_response()?;
+
+        let pm_id = tokenization::save_payment_method(
+            state,
+            connector,
+            resp.to_owned(),
+            maybe_customer,
+            merchant_account,
+        )
+        .await?;
+
+        mandate::mandate_procedure(state, resp, maybe_customer, pm_id).await
     }
 
     async fn add_access_token<'a>(
@@ -93,6 +111,29 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
         )
         .await
     }
+
+    async fn build_flow_specific_connector_request(
+        &mut self,
+        state: &AppState,
+        connector: &api::ConnectorData,
+        call_connector_action: payments::CallConnectorAction,
+    ) -> RouterResult<Option<services::Request>> {
+        match call_connector_action {
+            payments::CallConnectorAction::Trigger => {
+                let connector_integration: services::BoxedConnectorIntegration<
+                    '_,
+                    api::Verify,
+                    types::VerifyRequestData,
+                    types::PaymentsResponseData,
+                > = connector.connector.get_connector_integration();
+
+                connector_integration
+                    .build_request(self, &state.conf.connectors)
+                    .to_payment_failed_response()
+            }
+            _ => Ok(None),
+        }
+    }
 }
 
 impl TryFrom<types::VerifyRequestData> for types::ConnectorCustomerData {
@@ -131,6 +172,7 @@ impl types::VerifyRouterData {
                     connector_integration,
                     self,
                     call_connector_action,
+                    None,
                 )
                 .await
                 .to_verify_failed_response()?;
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index c253a23315f..0a61dd8755d 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -136,7 +136,6 @@ pub trait UpdateTracker<F, D, Req>: Send {
     async fn update_trackers<'b>(
         &'b self,
         db: &dyn StorageInterface,
-        payment_id: &api::PaymentIdType,
         payment_data: D,
         customer: Option<domain::Customer>,
         storage_scheme: enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index f06bf9e252a..0b32c0629a0 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -62,7 +62,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCancelRequest>
                 enums::IntentStatus::Processing,
                 enums::IntentStatus::RequiresMerchantAction,
             ],
-            "cancelled",
+            "cancel",
         )?;
 
         let mut payment_attempt = db
@@ -166,7 +166,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsCancelRequest> for
     async fn update_trackers<'b>(
         &'b self,
         db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         mut payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         storage_scheme: enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs
index cedc9d7a6d3..621871d3269 100644
--- a/crates/router/src/core/payments/operations/payment_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_capture.rs
@@ -174,7 +174,6 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentData<F>, api::PaymentsCaptureRe
     async fn update_trackers<'b>(
         &'b self,
         _db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         payment_data: payments::PaymentData<F>,
         _customer: Option<domain::Customer>,
         _storage_scheme: enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index 6f7bb3494ec..4618076a169 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -292,7 +292,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Comple
     async fn update_trackers<'b>(
         &'b self,
         _db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         _storage_scheme: storage_enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 0c8fd679f27..f39153eec8d 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -343,7 +343,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
     async fn update_trackers<'b>(
         &'b self,
         db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         mut payment_data: PaymentData<F>,
         customer: Option<domain::Customer>,
         storage_scheme: storage_enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index ef89d7151b2..c7606e87132 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -328,7 +328,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
     async fn update_trackers<'b>(
         &'b self,
         db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         mut payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         storage_scheme: enums::MerchantStorageScheme,
@@ -344,6 +343,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
             },
             IntentStatus::RequiresConfirmation => {
                 if let Some(true) = payment_data.confirm {
+                    //TODO: do this later, request validation should happen before
                     Some(IntentStatus::Processing)
                 } else {
                     None
diff --git a/crates/router/src/core/payments/operations/payment_method_validate.rs b/crates/router/src/core/payments/operations/payment_method_validate.rs
index ffdbe36c323..15d6ba59db6 100644
--- a/crates/router/src/core/payments/operations/payment_method_validate.rs
+++ b/crates/router/src/core/payments/operations/payment_method_validate.rs
@@ -201,7 +201,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::VerifyRequest> for PaymentM
     async fn update_trackers<'b>(
         &'b self,
         db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         mut payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         storage_scheme: storage_enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index 829951671bc..9576eec59a8 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -185,7 +185,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsSessionRequest> for
     async fn update_trackers<'b>(
         &'b self,
         db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         mut payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         storage_scheme: storage_enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index 5cb6613a28b..0c2fa20584e 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -157,7 +157,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsStartRequest> for P
     async fn update_trackers<'b>(
         &'b self,
         _db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         _storage_scheme: storage_enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index ff102a87911..7220ae39082 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -112,7 +112,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
     async fn update_trackers<'b>(
         &'b self,
         _db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         _storage_scheme: enums::MerchantStorageScheme,
@@ -130,7 +129,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRetrieveRequest> fo
     async fn update_trackers<'b>(
         &'b self,
         _db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         payment_data: PaymentData<F>,
         _customer: Option<domain::Customer>,
         _storage_scheme: enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index b7f06ad76f1..de670dcea25 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -390,7 +390,6 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
     async fn update_trackers<'b>(
         &'b self,
         db: &dyn StorageInterface,
-        _payment_id: &api::PaymentIdType,
         mut payment_data: PaymentData<F>,
         customer: Option<domain::Customer>,
         storage_scheme: storage_enums::MerchantStorageScheme,
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index 34176380b8d..b60d9a68aa4 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -227,6 +227,7 @@ pub async fn add_payment_method_token<F: Clone, T: Clone>(
                 connector_integration,
                 &pm_token_router_data,
                 payments::CallConnectorAction::Trigger,
+                None,
             )
             .await
             .to_payment_failed_response()?;
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index 810e12f4624..32e41ae9942 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -189,6 +189,7 @@ pub async fn trigger_refund_to_gateway(
             connector_integration,
             &router_data,
             payments::CallConnectorAction::Trigger,
+            None,
         )
         .await
         .to_refund_failed_response()?
@@ -408,6 +409,7 @@ pub async fn sync_refund_with_gateway(
             connector_integration,
             &router_data,
             payments::CallConnectorAction::Trigger,
+            None,
         )
         .await
         .to_refund_failed_response()?
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index cc4ce8d00bf..26cec958c05 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -186,6 +186,9 @@ pub trait ConnectorIntegration<T, Req, Resp>: ConnectorIntegrationAny<T, Req, Re
     }
 }
 
+/// Handle the flow by interacting with connector module
+/// `connector_request` is applicable only in case if the `CallConnectorAction` is `Trigger`
+/// In other cases, It will be created if required, even if it is not passed
 #[instrument(skip_all)]
 pub async fn execute_connector_processing_step<
     'b,
@@ -198,6 +201,7 @@ pub async fn execute_connector_processing_step<
     connector_integration: BoxedConnectorIntegration<'a, T, Req, Resp>,
     req: &'b types::RouterData<T, Req, Resp>,
     call_connector_action: payments::CallConnectorAction,
+    connector_request: Option<Request>,
 ) -> CustomResult<types::RouterData<T, Req, Resp>, errors::ConnectorError>
 where
     T: Clone + Debug,
@@ -252,7 +256,8 @@ where
                     ),
                 ],
             );
-            match connector_integration
+
+            let connector_request = connector_request.or(connector_integration
                 .build_request(req, &state.conf.connectors)
                 .map_err(|error| {
                     if matches!(
@@ -260,7 +265,7 @@ where
                         &errors::ConnectorError::RequestEncodingFailed
                             | &errors::ConnectorError::RequestEncodingFailedWithReason(_)
                     ) {
-                        metrics::RESPONSE_DESERIALIZATION_FAILURE.add(
+                        metrics::REQUEST_BUILD_FAILURE.add(
                             &metrics::CONTEXT,
                             1,
                             &[metrics::request::add_attributes(
@@ -270,7 +275,9 @@ where
                         )
                     }
                     error
-                })? {
+                })?);
+
+            match connector_request {
                 Some(request) => {
                     logger::debug!(connector_request=?request);
                     let response = call_connector_api(state, request).await;
diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs
index 6211dc24c30..168710e370e 100644
--- a/crates/router/tests/connectors/aci.rs
+++ b/crates/router/tests/connectors/aci.rs
@@ -148,6 +148,7 @@ async fn payments_create_success() {
         connector_integration,
         &request,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .unwrap();
@@ -193,6 +194,7 @@ async fn payments_create_failure() {
             connector_integration,
             &request,
             payments::CallConnectorAction::Trigger,
+            None,
         )
         .await
         .is_err();
@@ -225,6 +227,7 @@ async fn refund_for_successful_payments() {
         connector_integration,
         &request,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .unwrap();
@@ -250,6 +253,7 @@ async fn refund_for_successful_payments() {
         connector_integration,
         &refund_request,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .unwrap();
@@ -285,6 +289,7 @@ async fn refunds_create_failure() {
         connector_integration,
         &request,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
     .is_err();
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index 9470b23f2b6..927963ec0c3 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -442,6 +442,7 @@ async fn call_connector<
         integration,
         &request,
         payments::CallConnectorAction::Trigger,
+        None,
     )
     .await
 }

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Refactoring

## Description
<!-- Describe your changes in detail -->
Update trackers has been moved before callling the connector. This is to make sure that if there is any validation error, then the payment status will not be updated. 
For other flows where connector does not need to be called ( except `session_token` flow, there is an issue to move it outside payment core #888), it will be called as normal.


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless its an obvious bug or documentation fix
that will have little conversation).
-->
Fixes #1471 

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
- Create a payment with zen, without email - Payment status is `requires_payment_method`.
- Confirm the payment - error is Missing required param: email
- Retrieve the payment - status will be `requires_payment_method`.

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed submitted code
