Bug: [FEATURE] Include created_at and modified_at keys in PaymentAttemptResponse



### Feature Description

Include created_at and modified_at keys in PaymentAttemptResponse, to display in payments dashboard

### Possible Implementation

Include created_at and modified_at keys in PaymentAttemptResponse, to display in payments dashboard

### Have you spent some time checking if this feature request has been raised before?

- [X] I checked and didn't find a 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/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 5ac8d0edcc3..dd4ae572fd0 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -758,9 +758,7 @@ impl HeaderPayload {
     }
 }
 
-#[derive(
-    Default, Debug, serde::Serialize, Clone, PartialEq, ToSchema, router_derive::PolymorphicSchema,
-)]
+#[derive(Debug, serde::Serialize, Clone, PartialEq, ToSchema, router_derive::PolymorphicSchema)]
 pub struct PaymentAttemptResponse {
     /// Unique identifier for the attempt
     pub attempt_id: String,
@@ -788,6 +786,14 @@ pub struct PaymentAttemptResponse {
     /// The transaction authentication can be set to undergo payer authentication. By default, the authentication will be marked as NO_THREE_DS
     #[schema(value_type = Option<AuthenticationType>, example = "no_three_ds", default = "three_ds")]
     pub authentication_type: Option<enums::AuthenticationType>,
+    /// Time at which the payment attempt was created
+    #[schema(value_type = PrimitiveDateTime, example = "2022-09-10T10:11:12Z")]
+    #[serde(with = "common_utils::custom_serde::iso8601")]
+    pub created_at: PrimitiveDateTime,
+    /// Time at which the payment attempt was last modified
+    #[schema(value_type = PrimitiveDateTime, example = "2022-09-10T10:11:12Z")]
+    #[serde(with = "common_utils::custom_serde::iso8601")]
+    pub modified_at: PrimitiveDateTime,
     /// If the payment was cancelled the reason will be provided here
     pub cancellation_reason: Option<String>,
     /// A unique identifier to link the payment to a mandate, can be use instead of payment_method_data
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 3cad4f16e81..b32ce2c9e51 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -1006,6 +1006,8 @@ impl ForeignFrom<storage::PaymentAttempt> for payments::PaymentAttemptResponse {
             connector_transaction_id: payment_attempt.connector_transaction_id,
             capture_method: payment_attempt.capture_method,
             authentication_type: payment_attempt.authentication_type,
+            created_at: payment_attempt.created_at,
+            modified_at: payment_attempt.modified_at,
             cancellation_reason: payment_attempt.cancellation_reason,
             mandate_id: payment_attempt.mandate_id,
             error_code: payment_attempt.error_code,

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

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

## Description
<!-- Describe your changes in detail -->
## Summary
This PR introduces the created_at and modified_at keys to the PaymentAttemptResponse object. These keys will store the timestamps for when a payment attempt is created and last modified, respectively.

**Changes**
Added **created_at** key: This key records the timestamp of when a payment attempt is initially created.
Added **modified_at** key: This key captures the timestamp of the most recent modification to a payment attempt.

**Impact**
Enhanced Data Tracking: With the inclusion of created_at and modified_at, users will have better visibility into the lifecycle of a payment attempt.
Improved Auditing: These timestamps will facilitate more precise auditing and troubleshooting.
Backward Compatibility: Existing integrations will remain unaffected as these additions are non-breaking.

### Additional Changes

- [ ] 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
<!--
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 it is 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)?
-->
```
curl 'http://localhost:8080/payments/pay_sQBhXpPgst6s57BvS9Fk?expand_attempts=true' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,fr;q=0.7' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Origin: http://localhost:9000' \
  -H 'Pragma: no-cache' \
  -H 'Referer: http://localhost:9000/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-site' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \
  -H 'api-key: hyperswitch' \
  -H 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiZjA0MmUxZjQtMTczYS00MjI1LWE1YWMtYWIwY2VhYzkyODM2IiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzE2Mzc5MTEyIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcyMTg5OTY3MCwib3JnX2lkIjoib3JnXzc5RnRJcVRLQnpibW9Wd2dPc3dCIn0.fMpzPPQM1tNOnUBEkT-rk0HmAJgRc4wl4IU9eEFoe_E' \
  -H 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"'
```
Response - attempts
```
{
   ...,
    "attempts": [
        {
            "attempt_id": "pay_sQBhXpPgst6s57BvS9Fk_1",
            "status": "charged",
            "amount": 10000,
            "currency": "USD",
            "connector": "pretendpay",
            "error_message": null,
            "payment_method": "card",
            "connector_transaction_id": "dummy_pay_lHI6sx97Y8oswLZizvcf",
            "capture_method": "automatic",
            "authentication_type": "no_three_ds",
            "created_at": "2024-07-23 09:31:57.179205",
            "modified_at": "2024-07-23 09:35:27.53897",
            "cancellation_reason": null,
            "mandate_id": null,
            "error_code": null,
            "payment_token": null,
            "connector_metadata": null,
            "payment_experience": null,
            "payment_method_type": null,
            "reference_id": null,
            "unified_code": null,
            "unified_message": null,
            "client_source": "Payment",
            "client_version": "0.54.0"
        }
    ]
}
```



## 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`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
