Repository: juspay/hyperswitch
File: crates/router/src/core/payments/flows/psync_flow.rs (Rust)

Code before:
                    api::PSync,
                    types::PaymentsSyncData,
                    types::PaymentsResponseData,
                > = connector.connector.get_connector_integration();

                connector_integration
                    .build_request(self, &state.conf.connectors)
                    .to_payment_failed_response()?
            }
            _ => None,
        };

        Ok((request, true))
    }

    async fn call_unified_connector_service<'a>(
        &mut self,
        state: &SessionState,
        #[cfg(feature = "v1")] merchant_connector_account: helpers::MerchantConnectorAccountType,
        #[cfg(feature = "v2")]
        merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
        merchant_context: &domain::MerchantContext,
    ) -> RouterResult<()> {
        // Clone data to avoid lifetime issues
        let merchant_connector_account = merchant_connector_account.clone();
        let merchant_context = merchant_context.clone();

        let client = state
            .grpc_client
            .unified_connector_service_client
            .clone()
            .ok_or(ApiErrorResponse::InternalServerError)
            .attach_printable("Failed to fetch Unified Connector Service client")?;

        let payment_get_request = payments_grpc::PaymentServiceGetRequest::foreign_try_from(&*self)
            .change_context(ApiErrorResponse::InternalServerError)
            .attach_printable("Failed to construct Payment Get Request")?;

        let connector_auth_metadata = build_unified_connector_service_auth_metadata(
            merchant_connector_account,
            &merchant_context,
        )
        .change_context(ApiErrorResponse::InternalServerError)
        .attach_printable("Failed to construct request metadata")?;

        let payment_get_request_clone = payment_get_request.clone();
        let updated_router_data = Box::pin(ucs_logging_wrapper(
            self.clone(),
            state,
            &payment_get_request,
            |mut router_data| async move {

Review comment (suggestion):
I don't think cloning is required here as well
```suggestion
```

Code after:
                    api::PSync,
                    types::PaymentsSyncData,
                    types::PaymentsResponseData,
                > = connector.connector.get_connector_integration();

                connector_integration
                    .build_request(self, &state.conf.connectors)
                    .to_payment_failed_response()?
            }
            _ => None,
        };

        Ok((request, true))
    }

    async fn call_unified_connector_service<'a>(
        &mut self,
        state: &SessionState,
        #[cfg(feature = "v1")] merchant_connector_account: helpers::MerchantConnectorAccountType,
        #[cfg(feature = "v2")]
        merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
        merchant_context: &domain::MerchantContext,
    ) -> RouterResult<()> {
        let client = state
            .grpc_client
            .unified_connector_service_client
            .clone()
            .ok_or(ApiErrorResponse::InternalServerError)
            .attach_printable("Failed to fetch Unified Connector Service client")?;

        let payment_get_request = payments_grpc::PaymentServiceGetRequest::foreign_try_from(&*self)
            .change_context(ApiErrorResponse::InternalServerError)
            .attach_printable("Failed to construct Payment Get Request")?;

        let connector_auth_metadata = build_unified_connector_service_auth_metadata(
            merchant_connector_account,
            merchant_context,
        )
        .change_context(ApiErrorResponse::InternalServerError)
        .attach_printable("Failed to construct request metadata")?;

        let updated_router_data = Box::pin(ucs_logging_wrapper(
            self.clone(),
            state,
            payment_get_request,
            |mut router_data, payment_get_request| async move {
                let response = client
                    .payment_get(
                        payment_get_request,
                        connector_auth_metadata,
                        state.get_grpc_headers(),