Issue:
Bug:  Implement `EphemeralKeyInterface` for `MockDb`



Spin out from https://github.com/juspay/hyperswitch/issues/172. Please refer to that issue for more information.

Pull request description:
## Type of Change


- [ ] Bugfix
- [X] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
Implemented Mock db for ephemeral key


### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables



## Motivation and Context

Fixes #1191 

## How did you test it?


## Checklist

- [ ] I formatted the code `cargo +nightly fmt --all`
- [ ] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable


Testing:

Patch:
diff --git a/crates/router/src/db.rs b/crates/router/src/db.rs
index 0bec1c7c081..c33d3f00225 100644
--- a/crates/router/src/db.rs
+++ b/crates/router/src/db.rs
@@ -108,6 +108,7 @@ pub struct MockDb {
     connector_response: Arc<Mutex<Vec<storage::ConnectorResponse>>>,
     redis: Arc<redis_interface::RedisConnectionPool>,
     api_keys: Arc<Mutex<Vec<storage::ApiKey>>>,
+    ephemeral_keys: Arc<Mutex<Vec<storage::EphemeralKey>>>,
     cards_info: Arc<Mutex<Vec<storage::CardInfo>>>,
     events: Arc<Mutex<Vec<storage::Event>>>,
     disputes: Arc<Mutex<Vec<storage::Dispute>>>,
@@ -128,6 +129,7 @@ impl MockDb {
             connector_response: Default::default(),
             redis: Arc::new(crate::connection::redis_connection(redis).await),
             api_keys: Default::default(),
+            ephemeral_keys: Default::default(),
             cards_info: Default::default(),
             events: Default::default(),
             disputes: Default::default(),
diff --git a/crates/router/src/db/ephemeral_key.rs b/crates/router/src/db/ephemeral_key.rs
index dc3e181340a..a95ba436e16 100644
--- a/crates/router/src/db/ephemeral_key.rs
+++ b/crates/router/src/db/ephemeral_key.rs
@@ -1,3 +1,5 @@
+use time::ext::NumericalDuration;
+
 use crate::{
     core::errors::{self, CustomResult},
     db::MockDb,
@@ -125,21 +127,53 @@ mod storage {
 impl EphemeralKeyInterface for MockDb {
     async fn create_ephemeral_key(
         &self,
-        _ek: EphemeralKeyNew,
-        _validity: i64,
+        ek: EphemeralKeyNew,
+        validity: i64,
     ) -> CustomResult<EphemeralKey, errors::StorageError> {
-        Err(errors::StorageError::KVError.into())
+        let mut ephemeral_keys = self.ephemeral_keys.lock().await;
+        let created_at = common_utils::date_time::now();
+        let expires = created_at.saturating_add(validity.hours());
+
+        let ephemeral_key = EphemeralKey {
+            id: ek.id,
+            merchant_id: ek.merchant_id,
+            customer_id: ek.customer_id,
+            created_at: created_at.assume_utc().unix_timestamp(),
+            expires: expires.assume_utc().unix_timestamp(),
+            secret: ek.secret,
+        };
+        ephemeral_keys.push(ephemeral_key.clone());
+        Ok(ephemeral_key)
     }
     async fn get_ephemeral_key(
         &self,
-        _key: &str,
+        key: &str,
     ) -> CustomResult<EphemeralKey, errors::StorageError> {
-        Err(errors::StorageError::KVError.into())
+        match self
+            .ephemeral_keys
+            .lock()
+            .await
+            .iter()
+            .find(|ephemeral_key| ephemeral_key.secret.eq(key))
+        {
+            Some(ephemeral_key) => Ok(ephemeral_key.clone()),
+            None => Err(
+                errors::StorageError::ValueNotFound("ephemeral key not found".to_string()).into(),
+            ),
+        }
     }
     async fn delete_ephemeral_key(
         &self,
-        _id: &str,
+        id: &str,
     ) -> CustomResult<EphemeralKey, errors::StorageError> {
-        Err(errors::StorageError::KVError.into())
+        let mut ephemeral_keys = self.ephemeral_keys.lock().await;
+        if let Some(pos) = ephemeral_keys.iter().position(|x| (*x.id).eq(id)) {
+            let ek = ephemeral_keys.remove(pos);
+            Ok(ek)
+        } else {
+            return Err(
+                errors::StorageError::ValueNotFound("ephemeral key not found".to_string()).into(),
+            );
+        }
     }
 }
diff --git a/crates/router/src/types/storage.rs b/crates/router/src/types/storage.rs
index e56d93b08a0..781bd495cbc 100644
--- a/crates/router/src/types/storage.rs
+++ b/crates/router/src/types/storage.rs
@@ -27,7 +27,7 @@ pub mod kv;
 
 pub use self::{
     address::*, api_keys::*, cards_info::*, configs::*, connector_response::*, customers::*,
-    dispute::*, events::*, file::*, locker_mock_up::*, mandate::*, merchant_account::*,
-    merchant_connector_account::*, payment_attempt::*, payment_intent::*, payment_method::*,
-    process_tracker::*, refund::*, reverse_lookup::*,
+    dispute::*, ephemeral_key::*, events::*, file::*, locker_mock_up::*, mandate::*,
+    merchant_account::*, merchant_connector_account::*, payment_attempt::*, payment_intent::*,
+    payment_method::*, process_tracker::*, refund::*, reverse_lookup::*,
 };