Bug: [BUG] Payments list doesn't work with pagination parameters



### Context
- Currently the API accepts payment_id as pagination parameters for e.g starting_after = `pay_Ajabdhakjhah`
- However the underlying code relies on the auto-increment characteristic of databases
- While we do some sort of conversion here our pagination filters are based on `id` whereas the sort is `modified_at`
- This causes the response list to be not actually be paginated but return inconsistent & wrong results

#### Possible Solutions

- Either we can update the pagination filters to use `modified_at` (which can cause inconsistencies with data lists since `modified_at` can be changed)
- We can also try to sort out the list by incremental id

diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 384a2230389..c9bc3d0a649 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -1204,8 +1204,6 @@ pub async fn list_payments(
     merchant: domain::MerchantAccount,
     constraints: api::PaymentListConstraints,
 ) -> RouterResponse<api::PaymentListResponse> {
-    use futures::stream::StreamExt;
-
     use crate::types::transformers::ForeignFrom;
 
     helpers::validate_payment_list_request(&constraints)?;
@@ -1215,9 +1213,9 @@ pub async fn list_payments(
             .await
             .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
 
-    let pi = futures::stream::iter(payment_intents)
-        .filter_map(|pi| async {
-            let pa = db
+    let collected_futures = payment_intents.into_iter().map(|pi| {
+        async {
+            match db
                 .find_payment_attempt_by_payment_id_merchant_id_attempt_id(
                     &pi.payment_id,
                     merchant_id,
@@ -1226,13 +1224,38 @@ pub async fn list_payments(
                     storage_enums::MerchantStorageScheme::PostgresOnly,
                 )
                 .await
-                .ok()?;
-            Some((pi, pa))
-        })
-        .collect::<Vec<(storage::PaymentIntent, storage::PaymentAttempt)>>()
-        .await;
+            {
+                Ok(pa) => Some(Ok((pi, pa))),
+                Err(e) => {
+                    if e.current_context().is_db_not_found() {
+                        logger::warn!(
+                            "payment_attempts missing for payment_id : {} | error : {}",
+                            pi.payment_id,
+                            e
+                        );
+                        return None;
+                    }
+                    Some(Err(e))
+                }
+            }
+        }
+    });
 
-    let data: Vec<api::PaymentsResponse> = pi.into_iter().map(ForeignFrom::foreign_from).collect();
+    //If any of the response are Err, we will get Result<Err(_)>
+    let pi_pa_tuple_vec: Result<Vec<(storage::PaymentIntent, storage::PaymentAttempt)>, _> =
+        join_all(collected_futures)
+            .await
+            .into_iter()
+            .flatten() //Will ignore `None`, will only flatten 1 level
+            .collect::<Result<Vec<(storage::PaymentIntent, storage::PaymentAttempt)>, _>>();
+    //Will collect responses in same order async, leading to sorted responses
+
+    //Converting Intent-Attempt array to Response if no error
+    let data: Vec<api::PaymentsResponse> = pi_pa_tuple_vec
+        .change_context(errors::ApiErrorResponse::InternalServerError)?
+        .into_iter()
+        .map(ForeignFrom::foreign_from)
+        .collect();
 
     Ok(services::ApplicationResponse::Json(
         api::PaymentListResponse {
diff --git a/crates/router/src/types/storage/payment_intent.rs b/crates/router/src/types/storage/payment_intent.rs
index 89bcafa08e0..b4ec4fe2b5a 100644
--- a/crates/router/src/types/storage/payment_intent.rs
+++ b/crates/router/src/types/storage/payment_intent.rs
@@ -40,7 +40,7 @@ impl PaymentIntentDbExt for PaymentIntent {
         // when https://github.com/rust-lang/rust/issues/52662 becomes stable
         let mut filter = <Self as HasTable>::table()
             .filter(dsl::merchant_id.eq(merchant_id.to_owned()))
-            .order(dsl::modified_at.desc())
+            .order(dsl::created_at.desc())
             .into_boxed();
 
         if let Some(customer_id) = customer_id {

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

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
Sorted the payment list order in API response for descending based on `created_at` parameter. It allows the database fetches to be asycn and is collected in an hashmap and collected later in a descending order.


### Additional Changes

- [x] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
Fixes #1439.

<!--

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).
-->


## 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)?
-->
There were no new tests written (Although if needed we can write 1 test to check descending order in postman). But the endpoints behaviour was tested using postman.


## 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
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable (Im not sure if this is needed)
