Issue:
Bug: [BUG] Add feature flags and db methods for refunds v2 to non kv config



Add feature flags and db methods for refunds v2 to non kv config. 
Currently the compilation fails if we disable the `kv_store` feature flag

Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
This PR contains support for db calls that are used in refunds v2 core flows for non kv config.
There are 2 ways that HS use to interact with DB, using KV and without KV.
In code we represent it by `kv_store` feature flag.

### 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).
-->
Since KV is default in HyperSwitch, if some opensource merchant wants to use our product without this kv feature, the refunds v2 flow will still be supported through postgres DB calls.

## 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)?
-->
- Go to router crate's `Cargo.toml`, in default_common under features, remove `kv_store`
- Use `just run_v2` to run the app.

- Create Refund API Call
```
curl --location 'http://localhost:8080/v2/refunds' \
--header 'X-Profile-Id: pro_qxkJLjzL3XeuzDKGsp1S' \
--header 'Content-Type: application/json' \
--header 'Authorization: api-key=dev_R1HetQC825xDVj4cT8Pjj5EARrN86R1hBluyhMbXqMVQcJC1JvUHQKrIzaKzPCZt' \
--data '{
    "payment_id":"12345_pay_019734bc76567f31ae472001903e2185",
    "merchant_reference_id":"1748936520",
    "reason":"Paid by mistake",
    "metadata":{
        "foo":"bar"
    }
}'
```
- Response from the above call
```
{
    "id": "12345_ref_019734bcee6c76a3bd9f37fb0a57a062",
    "payment_id": "12345_pay_019734bc76567f31ae472001903e2185",
    "merchant_reference_id": "1748936487",
    "amount": 70,
    "currency": "EUR",
    "status": "succeeded",
    "reason": "Paid by mistake",
    "metadata": {
        "foo": "bar"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-06-03T07:41:26.559Z",
    "updated_at": "2025-06-03T07:41:27.758Z",
    "connector": "stripe",
    "profile_id": "pro_qxkJLjzL3XeuzDKGsp1S",
    "merchant_connector_id": "mca_tgPFo4p9Yhg6COBKqVLF",
    "connector_refund_reference_id": null
}
```
- Refunds Retrieve API Call
```
curl --location 'http://localhost:8080/v2/refunds/12345_ref_019734bcee6c76a3bd9f37fb0a57a062' \
--header 'x-profile-id: pro_qxkJLjzL3XeuzDKGsp1S' \
--header 'Authorization: api-key=dev_R1HetQC825xDVj4cT8Pjj5EARrN86R1hBluyhMbXqMVQcJC1JvUHQKrIzaKzPCZt'
```
- Response from the above call
```
{
    "id": "12345_ref_019734bcee6c76a3bd9f37fb0a57a062",
    "payment_id": "12345_pay_019734bc76567f31ae472001903e2185",
    "merchant_reference_id": "1748936487",
    "amount": 70,
    "currency": "EUR",
    "status": "succeeded",
    "reason": "Paid by mistake",
    "metadata": {
        "foo": "bar"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-06-03T07:41:26.559Z",
    "updated_at": "2025-06-03T07:41:27.758Z",
    "connector": "stripe",
    "profile_id": "pro_qxkJLjzL3XeuzDKGsp1S",
    "merchant_connector_id": "mca_tgPFo4p9Yhg6COBKqVLF",
    "connector_refund_reference_id": null
}
```

- Screenshot of DB record of this refund

<img width="586" alt="Screenshot 2025-06-03 at 1 14 30 PM" src="https://github.com/user-attachments/assets/e875aa2c-fb32-4cf7-8530-f70532d21046" />


## 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 the submitted code
- [ ] I added unit tests for my changes where possible


Testing:

- Go to router crate's `Cargo.toml`, in default_common under features, remove `kv_store`
- Use `just run_v2` to run the app.

- Create Refund API Call
```
curl --location 'http://localhost:8080/v2/refunds' \
--header 'X-Profile-Id: pro_qxkJLjzL3XeuzDKGsp1S' \
--header 'Content-Type: application/json' \
--header 'Authorization: api-key=dev_R1HetQC825xDVj4cT8Pjj5EARrN86R1hBluyhMbXqMVQcJC1JvUHQKrIzaKzPCZt' \
--data '{
    "payment_id":"12345_pay_019734bc76567f31ae472001903e2185",
    "merchant_reference_id":"1748936520",
    "reason":"Paid by mistake",
    "metadata":{
        "foo":"bar"
    }
}'
```
- Response from the above call
```
{
    "id": "12345_ref_019734bcee6c76a3bd9f37fb0a57a062",
    "payment_id": "12345_pay_019734bc76567f31ae472001903e2185",
    "merchant_reference_id": "1748936487",
    "amount": 70,
    "currency": "EUR",
    "status": "succeeded",
    "reason": "Paid by mistake",
    "metadata": {
        "foo": "bar"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-06-03T07:41:26.559Z",
    "updated_at": "2025-06-03T07:41:27.758Z",
    "connector": "stripe",
    "profile_id": "pro_qxkJLjzL3XeuzDKGsp1S",
    "merchant_connector_id": "mca_tgPFo4p9Yhg6COBKqVLF",
    "connector_refund_reference_id": null
}
```
- Refunds Retrieve API Call
```
curl --location 'http://localhost:8080/v2/refunds/12345_ref_019734bcee6c76a3bd9f37fb0a57a062' \
--header 'x-profile-id: pro_qxkJLjzL3XeuzDKGsp1S' \
--header 'Authorization: api-key=dev_R1HetQC825xDVj4cT8Pjj5EARrN86R1hBluyhMbXqMVQcJC1JvUHQKrIzaKzPCZt'
```
- Response from the above call
```
{
    "id": "12345_ref_019734bcee6c76a3bd9f37fb0a57a062",
    "payment_id": "12345_pay_019734bc76567f31ae472001903e2185",
    "merchant_reference_id": "1748936487",
    "amount": 70,
    "currency": "EUR",
    "status": "succeeded",
    "reason": "Paid by mistake",
    "metadata": {
        "foo": "bar"
    },
    "error_details": {
        "code": "",
        "message": ""
    },
    "created_at": "2025-06-03T07:41:26.559Z",
    "updated_at": "2025-06-03T07:41:27.758Z",
    "connector": "stripe",
    "profile_id": "pro_qxkJLjzL3XeuzDKGsp1S",
    "merchant_connector_id": "mca_tgPFo4p9Yhg6COBKqVLF",
    "connector_refund_reference_id": null
}
```

- Screenshot of DB record of this refund

<img width="586" alt="Screenshot 2025-06-03 at 1 14 30 PM" src="https://github.com/user-attachments/assets/e875aa2c-fb32-4cf7-8530-f70532d21046" />

Patch:
diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rs
index 7d9a8703169..eead49c12da 100644
--- a/crates/router/src/db/refund.rs
+++ b/crates/router/src/db/refund.rs
@@ -91,7 +91,7 @@ pub trait RefundInterface {
         offset: i64,
     ) -> CustomResult<Vec<diesel_models::refund::Refund>, errors::StorageError>;
 
-    #[cfg(all(feature = "v2", feature = "refunds_v2"))]
+    #[cfg(all(feature = "v2", feature = "refunds_v2", feature = "olap"))]
     async fn filter_refund_by_constraints(
         &self,
         merchant_id: &common_utils::id_type::MerchantId,
@@ -138,7 +138,7 @@ pub trait RefundInterface {
         storage_scheme: enums::MerchantStorageScheme,
     ) -> CustomResult<i64, errors::StorageError>;
 
-    #[cfg(all(feature = "v2", feature = "refunds_v2"))]
+    #[cfg(all(feature = "v2", feature = "refunds_v2", feature = "olap"))]
     async fn get_total_count_of_refunds(
         &self,
         merchant_id: &common_utils::id_type::MerchantId,
@@ -150,6 +150,7 @@ pub trait RefundInterface {
 #[cfg(not(feature = "kv_store"))]
 mod storage {
     use error_stack::report;
+    use hyperswitch_domain_models::refunds;
     use router_env::{instrument, tracing};
 
     use super::RefundInterface;
@@ -162,6 +163,7 @@ mod storage {
 
     #[async_trait::async_trait]
     impl RefundInterface for Store {
+        #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
         #[instrument(skip_all)]
         async fn find_refund_by_internal_reference_id_merchant_id(
             &self,
@@ -208,6 +210,19 @@ mod storage {
             .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
+        #[cfg(all(feature = "v2", feature = "refunds_v2"))]
+        async fn find_refund_by_id(
+            &self,
+            id: &common_utils::id_type::GlobalRefundId,
+            storage_scheme: enums::MerchantStorageScheme,
+        ) -> CustomResult<storage_types::Refund, errors::StorageError> {
+            let conn = connection::pg_connection_read(self).await?;
+            storage_types::Refund::find_by_global_id(&conn, id)
+                .await
+                .map_err(|error| report!(errors::StorageError::from(error)))
+        }
+
+        #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
         #[instrument(skip_all)]
         async fn update_refund(
             &self,
@@ -221,6 +236,21 @@ mod storage {
                 .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
+        #[cfg(all(feature = "v2", feature = "refunds_v2"))]
+        #[instrument(skip_all)]
+        async fn update_refund(
+            &self,
+            this: storage_types::Refund,
+            refund: storage_types::RefundUpdate,
+            _storage_scheme: enums::MerchantStorageScheme,
+        ) -> CustomResult<storage_types::Refund, errors::StorageError> {
+            let conn = connection::pg_connection_write(self).await?;
+            this.update_with_id(&conn, refund)
+                .await
+                .map_err(|error| report!(errors::StorageError::from(error)))
+        }
+
+        #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
         #[instrument(skip_all)]
         async fn find_refund_by_merchant_id_refund_id(
             &self,
@@ -234,6 +264,7 @@ mod storage {
                 .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
+        #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
         #[instrument(skip_all)]
         async fn find_refund_by_merchant_id_connector_refund_id_connector(
             &self,
@@ -253,6 +284,7 @@ mod storage {
             .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
+        #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
         #[instrument(skip_all)]
         async fn find_refund_by_payment_id_merchant_id(
             &self,
@@ -266,7 +298,11 @@ mod storage {
                 .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
-        #[cfg(feature = "olap")]
+        #[cfg(all(
+            any(feature = "v1", feature = "v2"),
+            not(feature = "refunds_v2"),
+            feature = "olap"
+        ))]
         #[instrument(skip_all)]
         async fn filter_refund_by_constraints(
             &self,
@@ -288,7 +324,33 @@ mod storage {
             .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
-        #[cfg(feature = "olap")]
+        #[cfg(all(feature = "v2", feature = "refunds_v2", feature = "olap"))]
+        #[instrument(skip_all)]
+        async fn filter_refund_by_constraints(
+            &self,
+            merchant_id: &common_utils::id_type::MerchantId,
+            refund_details: refunds::RefundListConstraints,
+            _storage_scheme: enums::MerchantStorageScheme,
+            limit: i64,
+            offset: i64,
+        ) -> CustomResult<Vec<diesel_models::refund::Refund>, errors::StorageError> {
+            let conn = connection::pg_connection_read(self).await?;
+            <diesel_models::refund::Refund as storage_types::RefundDbExt>::filter_by_constraints(
+                &conn,
+                merchant_id,
+                refund_details,
+                limit,
+                offset,
+            )
+            .await
+            .map_err(|error| report!(errors::StorageError::from(error)))
+        }
+
+        #[cfg(all(
+            any(feature = "v1", feature = "v2"),
+            not(feature = "refunds_v2"),
+            feature = "olap"
+        ))]
         #[instrument(skip_all)]
         async fn filter_refund_by_meta_constraints(
             &self,
@@ -306,7 +368,11 @@ mod storage {
             .map_err(|error|report!(errors::StorageError::from(error)))
         }
 
-        #[cfg(feature = "olap")]
+        #[cfg(all(
+            any(feature = "v1", feature = "v2"),
+            not(feature = "refunds_v2"),
+            feature = "olap"
+        ))]
         #[instrument(skip_all)]
         async fn get_refund_status_with_count(
             &self,
@@ -321,7 +387,11 @@ mod storage {
             .map_err(|error|report!(errors::StorageError::from(error)))
         }
 
-        #[cfg(feature = "olap")]
+        #[cfg(all(
+            any(feature = "v1", feature = "v2"),
+            not(feature = "refunds_v2"),
+            feature = "olap"
+        ))]
         #[instrument(skip_all)]
         async fn get_total_count_of_refunds(
             &self,
@@ -338,6 +408,24 @@ mod storage {
             .await
             .map_err(|error| report!(errors::StorageError::from(error)))
         }
+
+        #[cfg(all(feature = "v2", feature = "refunds_v2", feature = "olap"))]
+        #[instrument(skip_all)]
+        async fn get_total_count_of_refunds(
+            &self,
+            merchant_id: &common_utils::id_type::MerchantId,
+            refund_details: refunds::RefundListConstraints,
+            _storage_scheme: enums::MerchantStorageScheme,
+        ) -> CustomResult<i64, errors::StorageError> {
+            let conn = connection::pg_connection_read(self).await?;
+            <diesel_models::refund::Refund as storage_types::RefundDbExt>::get_refunds_count(
+                &conn,
+                merchant_id,
+                refund_details,
+            )
+            .await
+            .map_err(|error| report!(errors::StorageError::from(error)))
+        }
     }
 }
 
@@ -943,7 +1031,7 @@ mod storage {
             .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
-        #[cfg(all(feature = "v2", feature = "refunds_v2"))]
+        #[cfg(all(feature = "v2", feature = "refunds_v2", feature = "olap"))]
         #[instrument(skip_all)]
         async fn filter_refund_by_constraints(
             &self,
@@ -1024,7 +1112,7 @@ mod storage {
             .map_err(|error| report!(errors::StorageError::from(error)))
         }
 
-        #[cfg(all(feature = "v2", feature = "refunds_v2"))]
+        #[cfg(all(feature = "v2", feature = "refunds_v2", feature = "olap"))]
         #[instrument(skip_all)]
         async fn get_total_count_of_refunds(
             &self,