Issue:
Bug: Add audit events for PaymentCapture update





Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Added an event each time a payment capture happens with the relevant contextual info

- Pass along request_state to payment_core
- Modify the UpdateTracker trait to accept request state
- Modify the PaymentCapture implementation of UpdateTracker to generate an event
- Showing the `capture_amount` and `multiple_capture_count` fields in the event
- Added `tenant_id` field for the event

### 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).
-->
To generate audit events whenever the payment state changes so we can get a brief overview without needing to comb through the logs.

## 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)?
-->
- Implemented an event trigger that activates whenever the payment capture API is utilized. This event triggers an audit event, the details of which are subsequently reflected in the Kafka UI.
- Create a payment & then capture it.
- Fields that need to be tested are: `capture_amount`, `multiple_capture_count` and `tenant_id`.
```
{"topic": "hyperswitch-audit-events"}
```
<img width="894" alt="Screenshot 2024-06-10 at 4 09 13 PM" src="https://github.com/juspay/hyperswitch/assets/83278309/6bc8137f-6fa8-4fbe-8daa-e31360b9321d">
<img width="879" alt="Screenshot 2024-06-10 at 4 09 51 PM" src="https://github.com/juspay/hyperswitch/assets/83278309/ee713dd5-f4ff-4c64-9442-ad07c5860dc9">



## Checklist
<!-- Put an `x` in the boxes that apply -->

- [ ] I formatted the code `cargo +nightly fmt --all`
- [ ] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible


Testing:

- Implemented an event trigger that activates whenever the payment capture API is utilized. This event triggers an audit event, the details of which are subsequently reflected in the Kafka UI.
- Create a payment & then capture it.
- Fields that need to be tested are: `capture_amount`, `multiple_capture_count` and `tenant_id`.
```
{"topic": "hyperswitch-audit-events"}
```
<img width="894" alt="Screenshot 2024-06-10 at 4 09 13 PM" src="https://github.com/juspay/hyperswitch/assets/83278309/6bc8137f-6fa8-4fbe-8daa-e31360b9321d">
<img width="879" alt="Screenshot 2024-06-10 at 4 09 51 PM" src="https://github.com/juspay/hyperswitch/assets/83278309/ee713dd5-f4ff-4c64-9442-ad07c5860dc9">

Patch:
diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs
index 447f7b92906..02c69681a88 100644
--- a/crates/router/src/core/payments/operations/payment_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_capture.rs
@@ -12,6 +12,7 @@ use crate::{
         errors::{self, RouterResult, StorageErrorExt},
         payments::{self, helpers, operations, types::MultipleCaptureData},
     },
+    events::audit_events::{AuditEvent, AuditEventType},
     routes::{app::ReqState, SessionState},
     services,
     types::{
@@ -255,7 +256,7 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentData<F>, api::PaymentsCaptureRe
     async fn update_trackers<'b>(
         &'b self,
         db: &'b SessionState,
-        _req_state: ReqState,
+        req_state: ReqState,
         mut payment_data: payments::PaymentData<F>,
         _customer: Option<domain::Customer>,
         storage_scheme: enums::MerchantStorageScheme,
@@ -294,6 +295,16 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentData<F>, api::PaymentsCaptureRe
         } else {
             payment_data.payment_attempt
         };
+        let capture_amount = payment_data.payment_attempt.amount_to_capture;
+        let multiple_capture_count = payment_data.payment_attempt.multiple_capture_count;
+        req_state
+            .event_context
+            .event(AuditEvent::new(AuditEventType::PaymentCapture {
+                capture_amount,
+                multiple_capture_count,
+            }))
+            .with(payment_data.to_event())
+            .emit();
         Ok((Box::new(self), payment_data))
     }
 }
diff --git a/crates/router/src/events/audit_events.rs b/crates/router/src/events/audit_events.rs
index 6fc19018655..367a573a93b 100644
--- a/crates/router/src/events/audit_events.rs
+++ b/crates/router/src/events/audit_events.rs
@@ -1,3 +1,4 @@
+use common_utils::types::MinorUnit;
 use diesel_models::fraud_check::FraudCheck;
 use events::{Event, EventInfo};
 use serde::Serialize;
@@ -22,6 +23,10 @@ pub enum AuditEventType {
     PaymentCancelled {
         cancellation_reason: Option<String>,
     },
+    PaymentCapture {
+        capture_amount: Option<MinorUnit>,
+        multiple_capture_count: Option<i16>,
+    },
 }
 
 #[derive(Debug, Clone, Serialize)]
@@ -55,6 +60,7 @@ impl Event for AuditEvent {
             AuditEventType::PaymentConfirm { .. } => "payment_confirm",
             AuditEventType::ConnectorDecided => "connector_decided",
             AuditEventType::ConnectorCalled => "connector_called",
+            AuditEventType::PaymentCapture { .. } => "payment_capture",
             AuditEventType::RefundCreated => "refund_created",
             AuditEventType::RefundSuccess => "refund_success",
             AuditEventType::RefundFail => "refund_fail",
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index 12da9e6765f..baa824ced3f 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -958,6 +958,9 @@ where
                 }
             })??
     };
+    request_state
+        .event_context
+        .record_info(("tenant_id".to_string(), tenant_id.to_string()));
     // let tenant_id = "public".to_string();
     let mut session_state =
         Arc::new(app_state.clone()).get_session_state(tenant_id.as_str(), || {