Issue:
Bug: [BUG] : Bank Transfer status mapping is wrong for stripe



### Bug Description

While making the payment for bank transfer its going to "processing" state instead of "requires_customer_action".
Even after payment sync also its in processing state.

### Expected Behavior

It should be in "requires_customer_action" state


### Actual Behavior


Its going to "processing" state


### Steps To Reproduce

1.Create a payment intent
2.confirm the payment with bank transfer payment method details
3.The status is going to processing instead of requires_customer_action.


### Context For The Bug

_No response_

### Environment

Integ

### 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?

None

Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix

## Description
<!-- Describe your changes in detail -->
The status of `router_data` was being updated after update trackers to `processing`. But in case of Bank transfers, the status of payment is updated in pre processing steps, so we need to persist the routerdata instead of overriding it.


## 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 #1495.

## 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)?
-->
- Test stripe card payment
- Test ach bank transfers.
- Test shift4 3ds
- Test applepay trustpay

## 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


Testing:

- Test stripe card payment
- Test ach bank transfers.
- Test shift4 3ds
- Test applepay trustpay

Patch:
diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rs
index e93c0358b80..ffb84059f11 100644
--- a/crates/router/src/connector/trustpay/transformers.rs
+++ b/crates/router/src/connector/trustpay/transformers.rs
@@ -950,6 +950,7 @@ impl<F, T>
                     },
                 ))),
             }),
+            status: storage_models::enums::AttemptStatus::Pending,
             ..item.data
         })
     }
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index cfad9583b53..cf05ae9897a 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -551,13 +551,15 @@ where
         payment_data.sessions_token.push(session_token);
     };
 
-    let connector_request = if should_continue_further {
+    // In case of authorize flow, pre-task and post-tasks are being called in build request
+    // if we do not want to proceed further, then the function will return Ok(None, false)
+    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(state, &connector, call_connector_action.clone())
             .await?
     } else {
-        None
+        (None, false)
     };
 
     // Update the payment trackers just before calling the connector
@@ -574,11 +576,12 @@ where
         )
         .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 {
+        // The status of payment_attempt and intent will be updated in the previous step
+        // update this in router_data.
+        // This is added because few connector integrations do not update the status,
+        // and rely on previous status set in router_data
+        router_data.status = payment_data.payment_attempt.status;
         router_data
             .decide_flows(
                 state,
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index e128bcb8954..39110a08051 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -97,13 +97,14 @@ pub trait Feature<F, T> {
         Ok(None)
     }
 
+    /// Returns the connector request and a bool which specifies whether to proceed with further
     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)
+    ) -> RouterResult<(Option<services::Request>, bool)> {
+        Ok((None, true))
     }
 }
 
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 36d40d7480e..9d530a0a03e 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -146,7 +146,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
         state: &AppState,
         connector: &api::ConnectorData,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Option<services::Request>> {
+    ) -> RouterResult<(Option<services::Request>, bool)> {
         match call_connector_action {
             payments::CallConnectorAction::Trigger => {
                 let connector_integration: services::BoxedConnectorIntegration<
@@ -179,14 +179,17 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
                     self.decide_authentication_type();
                     logger::debug!(auth_type=?self.auth_type);
 
-                    connector_integration
-                        .build_request(self, &state.conf.connectors)
-                        .to_payment_failed_response()
+                    Ok((
+                        connector_integration
+                            .build_request(self, &state.conf.connectors)
+                            .to_payment_failed_response()?,
+                        true,
+                    ))
                 } else {
-                    Ok(None)
+                    Ok((None, false))
                 }
             }
-            _ => Ok(None),
+            _ => Ok((None, true)),
         }
     }
 }
diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rs
index 06c8c88f0fe..6c590a9cf93 100644
--- a/crates/router/src/core/payments/flows/cancel_flow.rs
+++ b/crates/router/src/core/payments/flows/cancel_flow.rs
@@ -89,8 +89,8 @@ impl Feature<api::Void, types::PaymentsCancelData>
         state: &AppState,
         connector: &api::ConnectorData,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Option<services::Request>> {
-        match call_connector_action {
+    ) -> RouterResult<(Option<services::Request>, bool)> {
+        let request = match call_connector_action {
             payments::CallConnectorAction::Trigger => {
                 let connector_integration: services::BoxedConnectorIntegration<
                     '_,
@@ -101,9 +101,11 @@ impl Feature<api::Void, types::PaymentsCancelData>
 
                 connector_integration
                     .build_request(self, &state.conf.connectors)
-                    .to_payment_failed_response()
+                    .to_payment_failed_response()?
             }
-            _ => Ok(None),
-        }
+            _ => None,
+        };
+
+        Ok((request, true))
     }
 }
diff --git a/crates/router/src/core/payments/flows/capture_flow.rs b/crates/router/src/core/payments/flows/capture_flow.rs
index 937c3daec6c..3c509d7df6b 100644
--- a/crates/router/src/core/payments/flows/capture_flow.rs
+++ b/crates/router/src/core/payments/flows/capture_flow.rs
@@ -81,8 +81,8 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
         state: &AppState,
         connector: &api::ConnectorData,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Option<services::Request>> {
-        match call_connector_action {
+    ) -> RouterResult<(Option<services::Request>, bool)> {
+        let request = match call_connector_action {
             payments::CallConnectorAction::Trigger => {
                 let connector_integration: services::BoxedConnectorIntegration<
                     '_,
@@ -93,9 +93,11 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
 
                 connector_integration
                     .build_request(self, &state.conf.connectors)
-                    .to_payment_failed_response()
+                    .to_payment_failed_response()?
             }
-            _ => Ok(None),
-        }
+            _ => None,
+        };
+
+        Ok((request, true))
     }
 }
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 6e2646f5378..f78305de023 100644
--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
@@ -97,8 +97,8 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
         state: &AppState,
         connector: &api::ConnectorData,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Option<services::Request>> {
-        match call_connector_action {
+    ) -> RouterResult<(Option<services::Request>, bool)> {
+        let request = match call_connector_action {
             payments::CallConnectorAction::Trigger => {
                 let connector_integration: services::BoxedConnectorIntegration<
                     '_,
@@ -109,9 +109,11 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
 
                 connector_integration
                     .build_request(self, &state.conf.connectors)
-                    .to_payment_failed_response()
+                    .to_payment_failed_response()?
             }
-            _ => Ok(None),
-        }
+            _ => None,
+        };
+
+        Ok((request, true))
     }
 }
diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs
index d4d593bd9b5..4f1d877fea9 100644
--- a/crates/router/src/core/payments/flows/psync_flow.rs
+++ b/crates/router/src/core/payments/flows/psync_flow.rs
@@ -81,8 +81,8 @@ impl Feature<api::PSync, types::PaymentsSyncData>
         state: &AppState,
         connector: &api::ConnectorData,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Option<services::Request>> {
-        match call_connector_action {
+    ) -> RouterResult<(Option<services::Request>, bool)> {
+        let request = match call_connector_action {
             payments::CallConnectorAction::Trigger => {
                 let connector_integration: services::BoxedConnectorIntegration<
                     '_,
@@ -93,9 +93,11 @@ impl Feature<api::PSync, types::PaymentsSyncData>
 
                 connector_integration
                     .build_request(self, &state.conf.connectors)
-                    .to_payment_failed_response()
+                    .to_payment_failed_response()?
             }
-            _ => Ok(None),
-        }
+            _ => None,
+        };
+
+        Ok((request, true))
     }
 }
diff --git a/crates/router/src/core/payments/flows/verify_flow.rs b/crates/router/src/core/payments/flows/verify_flow.rs
index a70e4419b33..bd30f1e7865 100644
--- a/crates/router/src/core/payments/flows/verify_flow.rs
+++ b/crates/router/src/core/payments/flows/verify_flow.rs
@@ -118,7 +118,7 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
         state: &AppState,
         connector: &api::ConnectorData,
         call_connector_action: payments::CallConnectorAction,
-    ) -> RouterResult<Option<services::Request>> {
+    ) -> RouterResult<(Option<services::Request>, bool)> {
         match call_connector_action {
             payments::CallConnectorAction::Trigger => {
                 let connector_integration: services::BoxedConnectorIntegration<
@@ -128,11 +128,14 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
                     types::PaymentsResponseData,
                 > = connector.connector.get_connector_integration();
 
-                connector_integration
-                    .build_request(self, &state.conf.connectors)
-                    .to_payment_failed_response()
+                Ok((
+                    connector_integration
+                        .build_request(self, &state.conf.connectors)
+                        .to_payment_failed_response()?,
+                    true,
+                ))
             }
-            _ => Ok(None),
+            _ => Ok((None, true)),
         }
     }
 }