Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(core): Rename crate data_models to hyperswitch_domain_models (#4504)

DEEPANSHU BANSAL86e93cd3a0f0
diff --git a/Cargo.lock b/Cargo.lock
index 635edcc995..00c491d710 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -337,11 +337,11 @@ dependencies = [
"aws-smithy-types 1.1.8",
"bigdecimal",
"common_utils",
- "data_models",
"diesel_models",
"error-stack",
"external_services",
"futures 0.3.30",
+ "hyperswitch_domain_models",
"hyperswitch_interfaces",
"masking",
"once_cell",
@@ -2402,23 +2402,6 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
-[[package]]
-name = "data_models"
-version = "0.1.0"
-dependencies = [
- "api_models",
- "async-trait",
- "common_enums",
- "common_utils",
- "diesel_models",
- "error-stack",
- "masking",
- "serde",
- "serde_json",
- "thiserror",
- "time",
-]
-
[[package]]
name = "deadpool"
version = "0.10.0"
@@ -3619,6 +3602,23 @@ dependencies = [
"tokio 1.37.0",
]
+[[package]]
+name = "hyperswitch_domain_models"
+version = "0.1.0"
+dependencies = [
+ "api_models",
+ "async-trait",
+ "common_enums",
+ "common_utils",
+ "diesel_models",
+ "error-stack",
+ "masking",
+ "serde",
+ "serde_json",
+ "thiserror",
+ "time",
+]
+
[[package]]
name = "hyperswitch_interfaces"
version = "0.1.0"
@@ -5593,7 +5593,6 @@ dependencies = [
"config",
"cookie 0.18.1",
"currency_conversion",
- "data_models",
"derive_deref",
"diesel",
"diesel_models",
@@ -5609,6 +5608,7 @@ dependencies = [
"hex",
"http 0.2.12",
"hyper 0.14.28",
+ "hyperswitch_domain_models",
"hyperswitch_interfaces",
"image",
"infer",
@@ -6643,13 +6643,13 @@ dependencies = [
"common_utils",
"config",
"crc32fast",
- "data_models",
"diesel",
"diesel_models",
"dyn-clone",
"error-stack",
"futures 0.3.30",
"http 0.2.12",
+ "hyperswitch_domain_models",
"masking",
"mime",
"moka",
diff --git a/crates/analytics/Cargo.toml b/crates/analytics/Cargo.toml
index b6cd29bade..52680df5c4 100644
--- a/crates/analytics/Cargo.toml
+++ b/crates/analytics/Cargo.toml
@@ -26,7 +26,7 @@ router_env = { version = "0.1.0", path = "../router_env", features = [
diesel_models = { version = "0.1.0", path = "../diesel_models", features = [
"kv_store",
] }
-data_models = { version = "0.1.0", path = "../data_models", default-features = false }
+hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
#Third Party dependencies
actix-web = "4.5.1"
diff --git a/crates/analytics/src/opensearch.rs b/crates/analytics/src/opensearch.rs
index 58569338cf..7b19ba0ed0 100644
--- a/crates/analytics/src/opensearch.rs
+++ b/crates/analytics/src/opensearch.rs
@@ -4,8 +4,8 @@ use api_models::{
};
use aws_config::{self, meta::region::RegionProviderChain, Region};
use common_utils::errors::{CustomResult, ErrorSwitch};
-use data_models::errors::{StorageError, StorageResult};
use error_stack::ResultExt;
+use hyperswitch_domain_models::errors::{StorageError, StorageResult};
use opensearch::{
auth::Credentials,
cert::CertificateValidation,
diff --git a/crates/data_models/Cargo.toml b/crates/hyperswitch_domain_models/Cargo.toml
similarity index 96%
rename from crates/data_models/Cargo.toml
rename to crates/hyperswitch_domain_models/Cargo.toml
index 54130ca002..58eff10a36 100644
--- a/crates/data_models/Cargo.toml
+++ b/crates/hyperswitch_domain_models/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "data_models"
+name = "hyperswitch_domain_models"
description = "Represents the data/domain models used by the business layer"
version = "0.1.0"
edition.workspace = true
diff --git a/crates/data_models/README.md b/crates/hyperswitch_domain_models/README.md
similarity index 67%
rename from crates/data_models/README.md
rename to crates/hyperswitch_domain_models/README.md
index 0c1c517055..d0b974d13c 100644
--- a/crates/data_models/README.md
+++ b/crates/hyperswitch_domain_models/README.md
@@ -1,3 +1,3 @@
-# Data models
+# Hyperswitch domain models
Represents the data/domain models used by the business/domain layer
\ No newline at end of file
diff --git a/crates/data_models/src/errors.rs b/crates/hyperswitch_domain_models/src/errors.rs
similarity index 100%
rename from crates/data_models/src/errors.rs
rename to crates/hyperswitch_domain_models/src/errors.rs
diff --git a/crates/data_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs
similarity index 100%
rename from crates/data_models/src/lib.rs
rename to crates/hyperswitch_domain_models/src/lib.rs
diff --git a/crates/data_models/src/mandates.rs b/crates/hyperswitch_domain_models/src/mandates.rs
similarity index 100%
rename from crates/data_models/src/mandates.rs
rename to crates/hyperswitch_domain_models/src/mandates.rs
diff --git a/crates/data_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
similarity index 100%
rename from crates/data_models/src/payments.rs
rename to crates/hyperswitch_domain_models/src/payments.rs
diff --git a/crates/data_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
similarity index 100%
rename from crates/data_models/src/payments/payment_attempt.rs
rename to crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
diff --git a/crates/data_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
similarity index 100%
rename from crates/data_models/src/payments/payment_intent.rs
rename to crates/hyperswitch_domain_models/src/payments/payment_intent.rs
diff --git a/crates/data_models/src/payouts.rs b/crates/hyperswitch_domain_models/src/payouts.rs
similarity index 100%
rename from crates/data_models/src/payouts.rs
rename to crates/hyperswitch_domain_models/src/payouts.rs
diff --git a/crates/data_models/src/payouts/payout_attempt.rs b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs
similarity index 100%
rename from crates/data_models/src/payouts/payout_attempt.rs
rename to crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs
diff --git a/crates/data_models/src/payouts/payouts.rs b/crates/hyperswitch_domain_models/src/payouts/payouts.rs
similarity index 100%
rename from crates/data_models/src/payouts/payouts.rs
rename to crates/hyperswitch_domain_models/src/payouts/payouts.rs
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 8915ab573e..f8e2cfad12 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -14,7 +14,7 @@ email = ["external_services/email", "scheduler/email", "olap"]
frm = ["api_models/frm"]
stripe = ["dep:serde_qs"]
release = ["stripe", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen", "recon", "external_services/aws_kms", "external_services/aws_s3"]
-olap = ["data_models/olap", "storage_impl/olap", "scheduler/olap", "api_models/olap", "dep:analytics"]
+olap = ["hyperswitch_domain_models/olap", "storage_impl/olap", "scheduler/olap", "api_models/olap", "dep:analytics"]
oltp = ["storage_impl/oltp"]
kv_store = ["scheduler/kv_store"]
accounts_cache = []
@@ -26,7 +26,7 @@ dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "kgra
connector_choice_mca_id = ["api_models/connector_choice_mca_id", "euclid/connector_choice_mca_id", "kgraph_utils/connector_choice_mca_id"]
external_access_dc = ["dummy_connector"]
detailed_errors = ["api_models/detailed_errors", "error-stack/serde"]
-payouts = ["api_models/payouts", "common_enums/payouts", "data_models/payouts", "storage_impl/payouts"]
+payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_domain_models/payouts", "storage_impl/payouts"]
payout_retry = ["payouts"]
recon = ["email", "api_models/recon"]
retry = []
@@ -104,7 +104,7 @@ cards = { version = "0.1.0", path = "../cards" }
common_enums = { version = "0.1.0", path = "../common_enums" }
common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext", "logs"] }
currency_conversion = { version = "0.1.0", path = "../currency_conversion" }
-data_models = { version = "0.1.0", path = "../data_models", default-features = false }
+hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_store"] }
euclid = { version = "0.1.0", path = "../euclid", features = ["valued_jit"] }
pm_auth = { version = "0.1.0", path = "../pm_auth", package = "pm_auth" }
diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rs
index a240154a0f..8fd148864f 100644
--- a/crates/router/src/connector/noon/transformers.rs
+++ b/crates/router/src/connector/noon/transformers.rs
@@ -373,11 +373,13 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NoonPaymentsRequest {
.get_setup_mandate_details()
.map(|mandate_data| {
let max_amount = match &mandate_data.mandate_type {
- Some(data_models::mandates::MandateDataType::SingleUse(mandate))
- | Some(data_models::mandates::MandateDataType::MultiUse(Some(mandate))) => {
- conn_utils::to_currency_base_unit(mandate.amount, mandate.currency)
- }
- Some(data_models::mandates::MandateDataType::MultiUse(None)) => {
+ Some(hyperswitch_domain_models::mandates::MandateDataType::SingleUse(
+ mandate,
+ ))
+ | Some(hyperswitch_domain_models::mandates::MandateDataType::MultiUse(Some(
+ mandate,
+ ))) => conn_utils::to_currency_base_unit(mandate.amount, mandate.currency),
+ Some(hyperswitch_domain_models::mandates::MandateDataType::MultiUse(None)) => {
Err(errors::ConnectorError::MissingRequiredField {
field_name:
"setup_future_usage.mandate_data.mandate_type.multi_use.amount",
diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs
index 793ec2d87d..e0d7a58566 100644
--- a/crates/router/src/connector/nuvei/transformers.rs
+++ b/crates/router/src/connector/nuvei/transformers.rs
@@ -5,8 +5,8 @@ use common_utils::{
fp_utils,
pii::{Email, IpAddress},
};
-use data_models::mandates::MandateDataType;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates::MandateDataType;
use masking::{ExposeInterface, PeekInterface, Secret};
use reqwest::Url;
use serde::{Deserialize, Serialize};
diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs
index 093a319f87..46c47a51f3 100644
--- a/crates/router/src/connector/stripe/transformers.rs
+++ b/crates/router/src/connector/stripe/transformers.rs
@@ -7,8 +7,8 @@ use common_utils::{
pii::{self, Email},
request::RequestContent,
};
-use data_models::mandates::AcceptanceType;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates::AcceptanceType;
use masking::{ExposeInterface, ExposeOptionInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use serde_json::Value;
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index efcaa5bfce..2cb3aa436e 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -12,9 +12,9 @@ use common_utils::{
errors::ReportSwitchExt,
pii::{self, Email, IpAddress},
};
-use data_models::payments::payment_attempt::PaymentAttempt;
use diesel_models::enums;
use error_stack::{report, ResultExt};
+use hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt;
use masking::{ExposeInterface, Secret};
use once_cell::sync::Lazy;
use regex::Regex;
diff --git a/crates/router/src/core/errors.rs b/crates/router/src/core/errors.rs
index a7d36ff512..d80d86460b 100644
--- a/crates/router/src/core/errors.rs
+++ b/crates/router/src/core/errors.rs
@@ -10,8 +10,8 @@ use std::fmt::Display;
use actix_web::{body::BoxBody, ResponseError};
pub use common_utils::errors::{CustomResult, ParsingError, ValidationError};
-pub use data_models::errors::StorageError as DataStorageError;
use diesel_models::errors as storage_errors;
+pub use hyperswitch_domain_models::errors::StorageError as DataStorageError;
pub use redis_interface::errors::RedisError;
use scheduler::errors as sch_errors;
use storage_impl::errors as storage_impl_errors;
diff --git a/crates/router/src/core/errors/user/sample_data.rs b/crates/router/src/core/errors/user/sample_data.rs
index 84c6c9fa43..3e72e49d31 100644
--- a/crates/router/src/core/errors/user/sample_data.rs
+++ b/crates/router/src/core/errors/user/sample_data.rs
@@ -1,6 +1,6 @@
use api_models::errors::types::{ApiError, ApiErrorResponse};
use common_utils::errors::{CustomResult, ErrorSwitch, ErrorSwitchFrom};
-use data_models::errors::StorageError;
+use hyperswitch_domain_models::errors::StorageError;
pub type SampleDataResult<T> = CustomResult<T, SampleDataError>;
diff --git a/crates/router/src/core/errors/utils.rs b/crates/router/src/core/errors/utils.rs
index f664c33681..678a351a4c 100644
--- a/crates/router/src/core/errors/utils.rs
+++ b/crates/router/src/core/errors/utils.rs
@@ -42,7 +42,7 @@ impl<T> StorageErrorExt<T, errors::CustomersErrorResponse>
}
impl<T> StorageErrorExt<T, errors::ApiErrorResponse>
- for error_stack::Result<T, data_models::errors::StorageError>
+ for error_stack::Result<T, hyperswitch_domain_models::errors::StorageError>
{
#[track_caller]
fn to_not_found_response(
@@ -51,8 +51,10 @@ impl<T> StorageErrorExt<T, errors::ApiErrorResponse>
) -> error_stack::Result<T, errors::ApiErrorResponse> {
self.map_err(|err| {
let new_err = match err.current_context() {
- data_models::errors::StorageError::ValueNotFound(_) => not_found_response,
- data_models::errors::StorageError::CustomerRedacted => {
+ hyperswitch_domain_models::errors::StorageError::ValueNotFound(_) => {
+ not_found_response
+ }
+ hyperswitch_domain_models::errors::StorageError::CustomerRedacted => {
errors::ApiErrorResponse::CustomerRedacted
}
_ => errors::ApiErrorResponse::InternalServerError,
@@ -68,7 +70,9 @@ impl<T> StorageErrorExt<T, errors::ApiErrorResponse>
) -> error_stack::Result<T, errors::ApiErrorResponse> {
self.map_err(|err| {
let new_err = match err.current_context() {
- data_models::errors::StorageError::DuplicateValue { .. } => duplicate_response,
+ hyperswitch_domain_models::errors::StorageError::DuplicateValue { .. } => {
+ duplicate_response
+ }
_ => errors::ApiErrorResponse::InternalServerError,
};
err.change_context(new_err)
diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
index d59c8c5ff4..3a80865bcd 100644
--- a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
+++ b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
@@ -2,7 +2,7 @@ use api_models::payments::HeaderPayload;
use async_trait::async_trait;
use common_enums::{CaptureMethod, FrmSuggestion};
use common_utils::ext_traits::Encode;
-use data_models::payments::{
+use hyperswitch_domain_models::payments::{
payment_attempt::PaymentAttemptUpdate, payment_intent::PaymentIntentUpdate,
};
use router_env::{instrument, logger, tracing};
diff --git a/crates/router/src/core/fraud_check/types.rs b/crates/router/src/core/fraud_check/types.rs
index 082210a2e4..5acd722077 100644
--- a/crates/router/src/core/fraud_check/types.rs
+++ b/crates/router/src/core/fraud_check/types.rs
@@ -6,7 +6,7 @@ use api_models::{
};
use common_enums::FrmSuggestion;
use common_utils::pii::Email;
-use data_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
+use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
use masking::Serialize;
use serde::Deserialize;
use utoipa::ToSchema;
diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs
index 84aa9b48e6..939367bd4d 100644
--- a/crates/router/src/core/mandate.rs
+++ b/crates/router/src/core/mandate.rs
@@ -515,6 +515,8 @@ pub trait MandateBehaviour {
fn get_mandate_id(&self) -> Option<&api_models::payments::MandateIds>;
fn set_mandate_id(&mut self, new_mandate_id: Option<api_models::payments::MandateIds>);
fn get_payment_method_data(&self) -> domain::payments::PaymentMethodData;
- fn get_setup_mandate_details(&self) -> Option<&data_models::mandates::MandateData>;
+ fn get_setup_mandate_details(
+ &self,
+ ) -> Option<&hyperswitch_domain_models::mandates::MandateData>;
fn get_customer_acceptance(&self) -> Option<api_models::payments::CustomerAcceptance>;
}
diff --git a/crates/router/src/core/mandate/helpers.rs b/crates/router/src/core/mandate/helpers.rs
index c15969fd1c..f3b7b384e2 100644
--- a/crates/router/src/core/mandate/helpers.rs
+++ b/crates/router/src/core/mandate/helpers.rs
@@ -1,9 +1,9 @@
use api_models::payments as api_payments;
use common_enums::enums;
use common_utils::errors::CustomResult;
-use data_models::mandates::MandateData;
use diesel_models::Mandate;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates::MandateData;
use crate::{
core::{errors, payments},
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 2b7577e1fb..b2a4959edf 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -7,8 +7,8 @@ pub use api_models::enums::Connector;
use api_models::payments::CardToken;
#[cfg(feature = "payouts")]
pub use api_models::{enums::PayoutConnectors, payouts as payout_types};
-use data_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
use diesel_models::enums;
+use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
use crate::{
core::{errors::RouterResult, payments::helpers, pm_auth as core_pm_auth},
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 42145550c8..27d126bce9 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -2504,7 +2504,7 @@ pub async fn list_payment_methods(
payment_methods: payment_method_responses,
mandate_payment: payment_attempt.and_then(|inner| inner.mandate_details).map(
|d| match d {
- data_models::mandates::MandateDataType::SingleUse(i) => {
+ hyperswitch_domain_models::mandates::MandateDataType::SingleUse(i) => {
api::MandateType::SingleUse(api::MandateAmountData {
amount: i.amount,
currency: i.currency,
@@ -2513,7 +2513,7 @@ pub async fn list_payment_methods(
metadata: i.metadata,
})
}
- data_models::mandates::MandateDataType::MultiUse(Some(i)) => {
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(Some(i)) => {
api::MandateType::MultiUse(Some(api::MandateAmountData {
amount: i.amount,
currency: i.currency,
@@ -2522,7 +2522,7 @@ pub async fn list_payment_methods(
metadata: i.metadata,
}))
}
- data_models::mandates::MandateDataType::MultiUse(None) => {
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(None) => {
api::MandateType::MultiUse(None)
}
},
@@ -3190,7 +3190,7 @@ pub async fn do_list_customer_pm_fetch_customer_if_not_passed(
.await
} else {
let cloned_secret = req.and_then(|r| r.client_secret.as_ref().cloned());
- let payment_intent: Option<data_models::payments::PaymentIntent> =
+ let payment_intent: Option<hyperswitch_domain_models::payments::PaymentIntent> =
helpers::verify_payment_intent_time_and_client_secret(
db,
&merchant_account,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 895e5157c0..815c604a0e 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -27,12 +27,12 @@ use common_utils::{
pii,
types::Surcharge,
};
-use data_models::mandates::{CustomerAcceptance, MandateData};
use diesel_models::{ephemeral_key, fraud_check::FraudCheck};
use error_stack::{report, ResultExt};
use events::EventInfo;
use futures::future::join_all;
use helpers::ApplePayData;
+use hyperswitch_domain_models::mandates::{CustomerAcceptance, MandateData};
use masking::{ExposeInterface, Secret};
pub use payment_address::PaymentAddress;
use redis_interface::errors::RedisError;
@@ -2713,7 +2713,7 @@ pub async fn list_payments(
merchant: domain::MerchantAccount,
constraints: api::PaymentListConstraints,
) -> RouterResponse<api::PaymentListResponse> {
- use data_models::errors::StorageError;
+ use hyperswitch_domain_models::errors::StorageError;
helpers::validate_payment_list_request(&constraints)?;
let merchant_id = &merchant.merchant_id;
let db = state.store.as_ref();
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index e44456fb1c..6b64dc0404 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -231,7 +231,9 @@ impl mandate::MandateBehaviour for types::PaymentsAuthorizeData {
fn get_setup_future_usage(&self) -> Option<diesel_models::enums::FutureUsage> {
self.setup_future_usage
}
- fn get_setup_mandate_details(&self) -> Option<&data_models::mandates::MandateData> {
+ fn get_setup_mandate_details(
+ &self,
+ ) -> Option<&hyperswitch_domain_models::mandates::MandateData> {
self.setup_mandate_details.as_ref()
}
diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
index 6a810e9b3d..59f7ee1755 100644
--- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs
+++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
@@ -177,7 +177,9 @@ impl mandate::MandateBehaviour for types::SetupMandateRequestData {
self.payment_method_data.clone()
}
- fn get_setup_mandate_details(&self) -> Option<&data_models::mandates::MandateData> {
+ fn get_setup_mandate_details(
+ &self,
+ ) -> Option<&hyperswitch_domain_models::mandates::MandateData> {
self.setup_mandate_details.as_ref()
}
fn get_customer_acceptance(&self) -> Option<api_models::payments::CustomerAcceptance> {
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 45816b875c..be04d2fb1a 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -9,13 +9,13 @@ use common_utils::{
ext_traits::{AsyncExt, ByteSliceExt, Encode, ValueExt},
fp_utils, generate_id, pii,
};
-use data_models::{
- mandates::MandateData,
- payments::{payment_attempt::PaymentAttempt, PaymentIntent},
-};
use diesel_models::enums;
// TODO : Evaluate all the helper functions ()
use error_stack::{report, ResultExt};
+use hyperswitch_domain_models::{
+ mandates::MandateData,
+ payments::{payment_attempt::PaymentAttempt, PaymentIntent},
+};
use josekit::jwe;
use masking::{ExposeInterface, PeekInterface};
use openssl::{
@@ -2672,24 +2672,28 @@ pub fn generate_mandate(
Ok(Some(
match data.mandate_type.get_required_value("mandate_type")? {
- data_models::mandates::MandateDataType::SingleUse(data) => new_mandate
- .set_mandate_amount(Some(data.amount))
- .set_mandate_currency(Some(data.currency))
- .set_mandate_type(storage_enums::MandateType::SingleUse)
- .to_owned(),
-
- data_models::mandates::MandateDataType::MultiUse(op_data) => match op_data {
- Some(data) => new_mandate
+ hyperswitch_domain_models::mandates::MandateDataType::SingleUse(data) => {
+ new_mandate
.set_mandate_amount(Some(data.amount))
.set_mandate_currency(Some(data.currency))
- .set_start_date(data.start_date)
- .set_end_date(data.end_date),
- // .set_metadata(data.metadata),
- // we are storing PaymentMethodData in metadata of mandate
- None => &mut new_mandate,
+ .set_mandate_type(storage_enums::MandateType::SingleUse)
+ .to_owned()
+ }
+
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(op_data) => {
+ match op_data {
+ Some(data) => new_mandate
+ .set_mandate_amount(Some(data.amount))
+ .set_mandate_currency(Some(data.currency))
+ .set_start_date(data.start_date)
+ .set_end_date(data.end_date),
+ // .set_metadata(data.metadata),
+ // we are storing PaymentMethodData in metadata of mandate
+ None => &mut new_mandate,
+ }
+ .set_mandate_type(storage_enums::MandateType::MultiUse)
+ .to_owned()
}
- .set_mandate_type(storage_enums::MandateType::MultiUse)
- .to_owned(),
},
))
}
@@ -2911,7 +2915,9 @@ mod tests {
fingerprint_id: None,
off_session: None,
client_secret: Some("1".to_string()),
- active_attempt: data_models::RemoteStorageObject::ForeignID("nopes".to_string()),
+ active_attempt: hyperswitch_domain_models::RemoteStorageObject::ForeignID(
+ "nopes".to_string(),
+ ),
business_country: None,
business_label: None,
order_details: None,
@@ -2967,7 +2973,9 @@ mod tests {
setup_future_usage: None,
off_session: None,
client_secret: Some("1".to_string()),
- active_attempt: data_models::RemoteStorageObject::ForeignID("nopes".to_string()),
+ active_attempt: hyperswitch_domain_models::RemoteStorageObject::ForeignID(
+ "nopes".to_string(),
+ ),
business_country: None,
business_label: None,
order_details: None,
@@ -3022,7 +3030,9 @@ mod tests {
off_session: None,
client_secret: None,
fingerprint_id: None,
- active_attempt: data_models::RemoteStorageObject::ForeignID("nopes".to_string()),
+ active_attempt: hyperswitch_domain_models::RemoteStorageObject::ForeignID(
+ "nopes".to_string(),
+ ),
business_country: None,
business_label: None,
order_details: None,
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 7560257ab2..78162fbfa6 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -5,12 +5,12 @@ use api_models::{
};
use async_trait::async_trait;
use common_utils::ext_traits::{AsyncExt, Encode, ValueExt};
-use data_models::{
+use diesel_models::{ephemeral_key, PaymentMethod};
+use error_stack::{self, ResultExt};
+use hyperswitch_domain_models::{
mandates::{MandateData, MandateDetails},
payments::payment_attempt::PaymentAttempt,
};
-use diesel_models::{ephemeral_key, PaymentMethod};
-use error_stack::{self, ResultExt};
use masking::{ExposeInterface, PeekInterface};
use router_derive::PaymentOperation;
use router_env::{instrument, logger, tracing};
@@ -999,7 +999,9 @@ impl PaymentCreate {
metadata: request.metadata.clone(),
business_country: request.business_country,
business_label: request.business_label.clone(),
- active_attempt: data_models::RemoteStorageObject::ForeignID(active_attempt_id),
+ active_attempt: hyperswitch_domain_models::RemoteStorageObject::ForeignID(
+ active_attempt_id,
+ ),
order_details,
amount_captured: None,
customer_id: None,
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 47d659b5ed..f4408749fd 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -3,9 +3,9 @@ use std::collections::HashMap;
use async_trait::async_trait;
use common_enums::AuthorizationStatus;
use common_utils::ext_traits::Encode;
-use data_models::payments::payment_attempt::PaymentAttempt;
use error_stack::{report, ResultExt};
use futures::FutureExt;
+use hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt;
use router_derive;
use router_env::{instrument, logger, tracing};
use storage_impl::DataModelExt;
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index e2502e2ecb..ff7303c900 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -171,10 +171,10 @@ where
.customer_acceptance
.clone()
.map(|cat| match cat.acceptance_type {
- data_models::mandates::AcceptanceType::Online => {
+ hyperswitch_domain_models::mandates::AcceptanceType::Online => {
euclid_enums::MandateAcceptanceType::Online
}
- data_models::mandates::AcceptanceType::Offline => {
+ hyperswitch_domain_models::mandates::AcceptanceType::Offline => {
euclid_enums::MandateAcceptanceType::Offline
}
})
@@ -184,10 +184,10 @@ where
.as_ref()
.and_then(|mandate_data| {
mandate_data.mandate_type.clone().map(|mt| match mt {
- data_models::mandates::MandateDataType::SingleUse(_) => {
+ hyperswitch_domain_models::mandates::MandateDataType::SingleUse(_) => {
euclid_enums::MandateType::SingleUse
}
- data_models::mandates::MandateDataType::MultiUse(_) => {
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(_) => {
euclid_enums::MandateType::MultiUse
}
})
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index b891998dae..d459f632d8 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -661,10 +661,10 @@ where
customer_acceptance: d.customer_acceptance.map(|d| {
api::CustomerAcceptance {
acceptance_type: match d.acceptance_type {
- data_models::mandates::AcceptanceType::Online => {
+ hyperswitch_domain_models::mandates::AcceptanceType::Online => {
api::AcceptanceType::Online
}
- data_models::mandates::AcceptanceType::Offline => {
+ hyperswitch_domain_models::mandates::AcceptanceType::Offline => {
api::AcceptanceType::Offline
}
},
@@ -676,7 +676,7 @@ where
}
}),
mandate_type: d.mandate_type.map(|d| match d {
- data_models::mandates::MandateDataType::MultiUse(Some(i)) => {
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(Some(i)) => {
api::MandateType::MultiUse(Some(api::MandateAmountData {
amount: i.amount,
currency: i.currency,
@@ -685,7 +685,7 @@ where
metadata: i.metadata,
}))
}
- data_models::mandates::MandateDataType::SingleUse(i) => {
+ hyperswitch_domain_models::mandates::MandateDataType::SingleUse(i) => {
api::MandateType::SingleUse(api::payments::MandateAmountData {
amount: i.amount,
currency: i.currency,
@@ -694,7 +694,7 @@ where
metadata: i.metadata,
})
}
- data_models::mandates::MandateDataType::MultiUse(None) => {
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(None) => {
api::MandateType::MultiUse(None)
}
}),
diff --git a/crates/router/src/core/payments/types.rs b/crates/router/src/core/payments/types.rs
index 7382555806..b297470bce 100644
--- a/crates/router/src/core/payments/types.rs
+++ b/crates/router/src/core/payments/types.rs
@@ -7,9 +7,9 @@ use common_utils::{
ext_traits::{Encode, OptionExt},
types as common_types,
};
-use data_models::payments::payment_attempt::PaymentAttempt;
use diesel_models::business_profile::BusinessProfile;
use error_stack::ResultExt;
+use hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt;
use redis_interface::errors::RedisError;
use router_env::{instrument, tracing};
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs
index bdaa0c01a1..25f6191920 100644
--- a/crates/router/src/core/payouts.rs
+++ b/crates/router/src/core/payouts.rs
@@ -7,12 +7,12 @@ use std::vec::IntoIter;
use api_models::enums as api_enums;
use common_utils::{consts, crypto::Encryptable, ext_traits::ValueExt, pii};
-#[cfg(feature = "olap")]
-use data_models::errors::StorageError;
use diesel_models::enums as storage_enums;
use error_stack::{report, ResultExt};
#[cfg(feature = "olap")]
use futures::future::join_all;
+#[cfg(feature = "olap")]
+use hyperswitch_domain_models::errors::StorageError;
#[cfg(feature = "payout_retry")]
use retry::GsmValidation;
#[cfg(feature = "olap")]
diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rs
index 02ba306654..496aab13b1 100644
--- a/crates/router/src/core/payouts/validator.rs
+++ b/crates/router/src/core/payouts/validator.rs
@@ -1,7 +1,7 @@
#[cfg(feature = "olap")]
use common_utils::errors::CustomResult;
-pub use data_models::errors::StorageError;
use error_stack::{report, ResultExt};
+pub use hyperswitch_domain_models::errors::StorageError;
use router_env::{instrument, tracing};
use super::helpers;
diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rs
index 6d5ae7a08c..09ea935ea7 100644
--- a/crates/router/src/core/pm_auth.rs
+++ b/crates/router/src/core/pm_auth.rs
@@ -16,9 +16,9 @@ use common_utils::{
ext_traits::AsyncExt,
generate_id,
};
-use data_models::payments::PaymentIntent;
use error_stack::ResultExt;
use helpers::PaymentAuthConnectorDataExt;
+use hyperswitch_domain_models::payments::PaymentIntent;
use masking::{ExposeInterface, PeekInterface, Secret};
use pm_auth::{
connector::plaid::transformers::PlaidAuthType,
diff --git a/crates/router/src/core/refunds/validator.rs b/crates/router/src/core/refunds/validator.rs
index 43d44ebe41..49248ae4fe 100644
--- a/crates/router/src/core/refunds/validator.rs
+++ b/crates/router/src/core/refunds/validator.rs
@@ -107,7 +107,7 @@ pub fn validate_refund_list(limit: Option<i64>) -> CustomResult<i64, errors::Api
}
pub fn validate_for_valid_refunds(
- payment_attempt: &data_models::payments::payment_attempt::PaymentAttempt,
+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
connector: api_models::enums::Connector,
) -> RouterResult<()> {
let payment_method = payment_attempt
diff --git a/crates/router/src/core/user/sample_data.rs b/crates/router/src/core/user/sample_data.rs
index f95f48f19e..e1bde65230 100644
--- a/crates/router/src/core/user/sample_data.rs
+++ b/crates/router/src/core/user/sample_data.rs
@@ -1,7 +1,7 @@
use api_models::user::sample_data::SampleDataRequest;
use common_utils::errors::ReportSwitchExt;
-use data_models::payments::payment_intent::PaymentIntentNew;
use diesel_models::{user::sample_data::PaymentAttemptBatchNew, RefundNew};
+use hyperswitch_domain_models::payments::payment_intent::PaymentIntentNew;
pub type SampleDataApiResponse<T> = SampleDataResult<ApplicationResponse<T>>;
diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs
index c7a22e5689..3923663f5d 100644
--- a/crates/router/src/core/utils.rs
+++ b/crates/router/src/core/utils.rs
@@ -976,7 +976,7 @@ pub fn is_merchant_enabled_for_payment_id_as_connector_request_id(
pub fn get_connector_request_reference_id(
conf: &Settings,
merchant_id: &str,
- payment_attempt: &data_models::payments::payment_attempt::PaymentAttempt,
+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> String {
let is_config_enabled_for_merchant =
is_merchant_enabled_for_payment_id_as_connector_request_id(conf, merchant_id);
diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs
index eb6faea5c3..6647549e39 100644
--- a/crates/router/src/core/webhooks.rs
+++ b/crates/router/src/core/webhooks.rs
@@ -307,8 +307,10 @@ pub async fn get_payment_attempt_from_object_reference_id(
state: &AppState,
object_reference_id: api_models::webhooks::ObjectReferenceId,
merchant_account: &domain::MerchantAccount,
-) -> CustomResult<data_models::payments::payment_attempt::PaymentAttempt, errors::ApiErrorResponse>
-{
+) -> CustomResult<
+ hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
+ errors::ApiErrorResponse,
+> {
let db = &*state.store;
match object_reference_id {
api::ObjectReferenceId::PaymentId(api::PaymentIdType::ConnectorTransactionId(ref id)) => db
@@ -346,7 +348,7 @@ pub async fn get_or_update_dispute_object(
option_dispute: Option<diesel_models::dispute::Dispute>,
dispute_details: api::disputes::DisputePayload,
merchant_id: &str,
- payment_attempt: &data_models::payments::payment_attempt::PaymentAttempt,
+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
event_type: api_models::webhooks::IncomingWebhookEvent,
business_profile: &diesel_models::business_profile::BusinessProfile,
connector_name: &str,
diff --git a/crates/router/src/db.rs b/crates/router/src/db.rs
index 9f9e61a5ff..9b222486d1 100644
--- a/crates/router/src/db.rs
+++ b/crates/router/src/db.rs
@@ -35,18 +35,20 @@ pub mod routing_algorithm;
pub mod user;
pub mod user_role;
-use data_models::payments::{
- payment_attempt::PaymentAttemptInterface, payment_intent::PaymentIntentInterface,
-};
-#[cfg(feature = "payouts")]
-use data_models::payouts::{payout_attempt::PayoutAttemptInterface, payouts::PayoutsInterface};
-#[cfg(not(feature = "payouts"))]
-use data_models::{PayoutAttemptInterface, PayoutsInterface};
use diesel_models::{
fraud_check::{FraudCheck, FraudCheckNew, FraudCheckUpdate},
organization::{Organization, OrganizationNew, OrganizationUpdate},
};
use error_stack::ResultExt;
+use hyperswitch_domain_models::payments::{
+ payment_attempt::PaymentAttemptInterface, payment_intent::PaymentIntentInterface,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::payouts::{
+ payout_attempt::PayoutAttemptInterface, payouts::PayoutsInterface,
+};
+#[cfg(not(feature = "payouts"))]
+use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
use masking::PeekInterface;
use redis_interface::errors::RedisError;
use storage_impl::{errors::StorageError, redis::kv_store::RedisConnInterface, MockDb};
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index 34bf7552a4..0aaa47365f 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -2,13 +2,6 @@ use std::sync::Arc;
use common_enums::enums::MerchantStorageScheme;
use common_utils::{errors::CustomResult, pii};
-use data_models::payments::{
- payment_attempt::PaymentAttemptInterface, payment_intent::PaymentIntentInterface,
-};
-#[cfg(feature = "payouts")]
-use data_models::payouts::{payout_attempt::PayoutAttemptInterface, payouts::PayoutsInterface};
-#[cfg(not(feature = "payouts"))]
-use data_models::{PayoutAttemptInterface, PayoutsInterface};
use diesel_models::{
enums,
enums::ProcessTrackerStatus,
@@ -16,6 +9,15 @@ use diesel_models::{
reverse_lookup::{ReverseLookup, ReverseLookupNew},
user_role as user_storage,
};
+use hyperswitch_domain_models::payments::{
+ payment_attempt::PaymentAttemptInterface, payment_intent::PaymentIntentInterface,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::payouts::{
+ payout_attempt::PayoutAttemptInterface, payouts::PayoutsInterface,
+};
+#[cfg(not(feature = "payouts"))]
+use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
use masking::Secret;
use redis_interface::{errors::RedisError, RedisConnectionPool, RedisEntryId};
use router_env::logger;
@@ -1238,11 +1240,11 @@ impl PaymentAttemptInterface for KafkaStore {
async fn get_filters_for_payments(
&self,
- pi: &[data_models::payments::PaymentIntent],
+ pi: &[hyperswitch_domain_models::payments::PaymentIntent],
merchant_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<
- data_models::payments::payment_attempt::PaymentListFilters,
+ hyperswitch_domain_models::payments::payment_attempt::PaymentListFilters,
errors::DataStorageError,
> {
self.diesel_store
@@ -1344,7 +1346,7 @@ impl PaymentIntentInterface for KafkaStore {
async fn filter_payment_intent_by_constraints(
&self,
merchant_id: &str,
- filters: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
+ filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::PaymentIntent>, errors::DataStorageError> {
self.diesel_store
@@ -1372,12 +1374,12 @@ impl PaymentIntentInterface for KafkaStore {
async fn get_filtered_payment_intents_attempt(
&self,
merchant_id: &str,
- constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
+ constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<
Vec<(
- data_models::payments::PaymentIntent,
- data_models::payments::payment_attempt::PaymentAttempt,
+ hyperswitch_domain_models::payments::PaymentIntent,
+ hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
)>,
errors::DataStorageError,
> {
@@ -1390,7 +1392,7 @@ impl PaymentIntentInterface for KafkaStore {
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
merchant_id: &str,
- constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
+ constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<String>, errors::DataStorageError> {
self.diesel_store
@@ -1584,11 +1586,11 @@ impl PayoutAttemptInterface for KafkaStore {
async fn get_filters_for_payouts(
&self,
- payouts: &[data_models::payouts::payouts::Payouts],
+ payouts: &[hyperswitch_domain_models::payouts::payouts::Payouts],
merchant_id: &str,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<
- data_models::payouts::payout_attempt::PayoutListFilters,
+ hyperswitch_domain_models::payouts::payout_attempt::PayoutListFilters,
errors::DataStorageError,
> {
self.diesel_store
@@ -1663,7 +1665,7 @@ impl PayoutsInterface for KafkaStore {
async fn filter_payouts_by_constraints(
&self,
merchant_id: &str,
- filters: &data_models::payouts::PayoutFetchConstraints,
+ filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<Vec<storage::Payouts>, errors::DataStorageError> {
self.diesel_store
@@ -1675,7 +1677,7 @@ impl PayoutsInterface for KafkaStore {
async fn filter_payouts_and_attempts(
&self,
merchant_id: &str,
- filters: &data_models::payouts::PayoutFetchConstraints,
+ filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<
Vec<(
@@ -2482,9 +2484,11 @@ impl DashboardMetadataInterface for KafkaStore {
impl BatchSampleDataInterface for KafkaStore {
async fn insert_payment_intents_batch_for_sample_data(
&self,
- batch: Vec<data_models::payments::payment_intent::PaymentIntentNew>,
- ) -> CustomResult<Vec<data_models::payments::PaymentIntent>, data_models::errors::StorageError>
- {
+ batch: Vec<hyperswitch_domain_models::payments::payment_intent::PaymentIntentNew>,
+ ) -> CustomResult<
+ Vec<hyperswitch_domain_models::payments::PaymentIntent>,
+ hyperswitch_domain_models::errors::StorageError,
+ > {
let payment_intents_list = self
.diesel_store
.insert_payment_intents_batch_for_sample_data(batch)
@@ -2503,8 +2507,8 @@ impl BatchSampleDataInterface for KafkaStore {
&self,
batch: Vec<diesel_models::user::sample_data::PaymentAttemptBatchNew>,
) -> CustomResult<
- Vec<data_models::payments::payment_attempt::PaymentAttempt>,
- data_models::errors::StorageError,
+ Vec<hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt>,
+ hyperswitch_domain_models::errors::StorageError,
> {
let payment_attempts_list = self
.diesel_store
@@ -2523,7 +2527,8 @@ impl BatchSampleDataInterface for KafkaStore {
async fn insert_refunds_batch_for_sample_data(
&self,
batch: Vec<diesel_models::RefundNew>,
- ) -> CustomResult<Vec<diesel_models::Refund>, data_models::errors::StorageError> {
+ ) -> CustomResult<Vec<diesel_models::Refund>, hyperswitch_domain_models::errors::StorageError>
+ {
let refunds_list = self
.diesel_store
.insert_refunds_batch_for_sample_data(batch)
@@ -2538,8 +2543,10 @@ impl BatchSampleDataInterface for KafkaStore {
async fn delete_payment_intents_for_sample_data(
&self,
merchant_id: &str,
- ) -> CustomResult<Vec<data_models::payments::PaymentIntent>, data_models::errors::StorageError>
- {
+ ) -> CustomResult<
+ Vec<hyperswitch_domain_models::payments::PaymentIntent>,
+ hyperswitch_domain_models::errors::StorageError,
+ > {
let payment_intents_list = self
.diesel_store
.delete_payment_intents_for_sample_data(merchant_id)
@@ -2558,8 +2565,8 @@ impl BatchSampleDataInterface for KafkaStore {
&self,
merchant_id: &str,
) -> CustomResult<
- Vec<data_models::payments::payment_attempt::PaymentAttempt>,
- data_models::errors::StorageError,
+ Vec<hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt>,
+ hyperswitch_domain_models::errors::StorageError,
> {
let payment_attempts_list = self
.diesel_store
@@ -2579,7 +2586,8 @@ impl BatchSampleDataInterface for KafkaStore {
async fn delete_refunds_for_sample_data(
&self,
merchant_id: &str,
- ) -> CustomResult<Vec<diesel_models::Refund>, data_models::errors::StorageError> {
+ ) -> CustomResult<Vec<diesel_models::Refund>, hyperswitch_domain_models::errors::StorageError>
+ {
let refunds_list = self
.diesel_store
.delete_refunds_for_sample_data(merchant_id)
diff --git a/crates/router/src/db/user/sample_data.rs b/crates/router/src/db/user/sample_data.rs
index ae98332cfc..f7926021af 100644
--- a/crates/router/src/db/user/sample_data.rs
+++ b/crates/router/src/db/user/sample_data.rs
@@ -1,7 +1,3 @@
-use data_models::{
- errors::StorageError,
- payments::{payment_attempt::PaymentAttempt, payment_intent::PaymentIntentNew, PaymentIntent},
-};
use diesel_models::{
errors::DatabaseError,
query::user::sample_data as sample_data_queries,
@@ -9,6 +5,10 @@ use diesel_models::{
user::sample_data::PaymentAttemptBatchNew,
};
use error_stack::{Report, ResultExt};
+use hyperswitch_domain_models::{
+ errors::StorageError,
+ payments::{payment_attempt::PaymentAttempt, payment_intent::PaymentIntentNew, PaymentIntent},
+};
use storage_impl::DataModelExt;
use crate::{connection::pg_connection_write, core::errors::CustomResult, services::Store};
diff --git a/crates/router/src/events.rs b/crates/router/src/events.rs
index d226c2bdbe..4bca582483 100644
--- a/crates/router/src/events.rs
+++ b/crates/router/src/events.rs
@@ -1,6 +1,6 @@
-use data_models::errors::{StorageError, StorageResult};
use error_stack::ResultExt;
use events::{EventsError, Message, MessagingInterface};
+use hyperswitch_domain_models::errors::{StorageError, StorageResult};
use masking::ErasedMaskSerialize;
use router_env::logger;
use serde::{Deserialize, Serialize};
diff --git a/crates/router/src/services.rs b/crates/router/src/services.rs
index 6b604498c7..5af325a46f 100644
--- a/crates/router/src/services.rs
+++ b/crates/router/src/services.rs
@@ -13,8 +13,8 @@ pub mod recon;
#[cfg(feature = "email")]
pub mod email;
-use data_models::errors::StorageResult;
use error_stack::ResultExt;
+use hyperswitch_domain_models::errors::StorageResult;
use masking::{ExposeInterface, StrongSecret};
#[cfg(feature = "kv_store")]
use storage_impl::KVRouterStore;
diff --git a/crates/router/src/services/kafka.rs b/crates/router/src/services/kafka.rs
index 3ae923e246..ba9806b29d 100644
--- a/crates/router/src/services/kafka.rs
+++ b/crates/router/src/services/kafka.rs
@@ -15,8 +15,8 @@ mod dispute;
mod payment_attempt;
mod payment_intent;
mod refund;
-use data_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
use diesel_models::refund::Refund;
+use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
use serde::Serialize;
use time::{OffsetDateTime, PrimitiveDateTime};
diff --git a/crates/router/src/services/kafka/payment_attempt.rs b/crates/router/src/services/kafka/payment_attempt.rs
index 787a633b0c..9f442876fa 100644
--- a/crates/router/src/services/kafka/payment_attempt.rs
+++ b/crates/router/src/services/kafka/payment_attempt.rs
@@ -1,6 +1,8 @@
// use diesel_models::enums::MandateDetails;
-use data_models::{mandates::MandateDetails, payments::payment_attempt::PaymentAttempt};
use diesel_models::enums as storage_enums;
+use hyperswitch_domain_models::{
+ mandates::MandateDetails, payments::payment_attempt::PaymentAttempt,
+};
use time::OffsetDateTime;
#[derive(serde::Serialize, Debug)]
diff --git a/crates/router/src/services/kafka/payment_intent.rs b/crates/router/src/services/kafka/payment_intent.rs
index 6a756c664d..2edd0d49cc 100644
--- a/crates/router/src/services/kafka/payment_intent.rs
+++ b/crates/router/src/services/kafka/payment_intent.rs
@@ -1,5 +1,5 @@
-use data_models::payments::PaymentIntent;
use diesel_models::enums as storage_enums;
+use hyperswitch_domain_models::payments::PaymentIntent;
use time::OffsetDateTime;
#[derive(serde::Serialize, Debug)]
diff --git a/crates/router/src/services/kafka/payout.rs b/crates/router/src/services/kafka/payout.rs
index e2bd8ef83f..6b25c724eb 100644
--- a/crates/router/src/services/kafka/payout.rs
+++ b/crates/router/src/services/kafka/payout.rs
@@ -1,6 +1,6 @@
use common_utils::pii;
-use data_models::payouts::{payout_attempt::PayoutAttempt, payouts::Payouts};
use diesel_models::enums as storage_enums;
+use hyperswitch_domain_models::payouts::{payout_attempt::PayoutAttempt, payouts::Payouts};
use time::OffsetDateTime;
#[derive(serde::Serialize, Debug)]
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 77d53584da..bffa3eaf8f 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -24,8 +24,8 @@ pub use api_models::{enums::PayoutConnectors, payouts as payout_types};
use common_enums::MandateStatus;
pub use common_utils::request::RequestContent;
use common_utils::{pii, pii::Email};
-use data_models::mandates::{CustomerAcceptance, MandateData};
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates::{CustomerAcceptance, MandateData};
use masking::Secret;
use serde::Serialize;
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 38fd773b9b..57f51c7b8b 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -93,7 +93,7 @@ pub trait ConnectorMandateRevoke:
pub trait ConnectorTransactionId: ConnectorCommon + Sync {
fn connector_transaction_id(
&self,
- payment_attempt: data_models::payments::payment_attempt::PaymentAttempt,
+ payment_attempt: hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
) -> Result<Option<String>, errors::ApiErrorResponse> {
Ok(payment_attempt.connector_transaction_id)
}
diff --git a/crates/router/src/types/storage.rs b/crates/router/src/types/storage.rs
index ec164000b3..77550bedab 100644
--- a/crates/router/src/types/storage.rs
+++ b/crates/router/src/types/storage.rs
@@ -39,19 +39,19 @@ pub mod user_role;
use std::collections::HashMap;
-pub use data_models::payments::{
+pub use diesel_models::{
+ ProcessTracker, ProcessTrackerNew, ProcessTrackerRunner, ProcessTrackerUpdate,
+};
+pub use hyperswitch_domain_models::payments::{
payment_attempt::{PaymentAttempt, PaymentAttemptNew, PaymentAttemptUpdate},
payment_intent::{PaymentIntentNew, PaymentIntentUpdate},
PaymentIntent,
};
#[cfg(feature = "payouts")]
-pub use data_models::payouts::{
+pub use hyperswitch_domain_models::payouts::{
payout_attempt::{PayoutAttempt, PayoutAttemptNew, PayoutAttemptUpdate},
payouts::{Payouts, PayoutsNew, PayoutsUpdate},
};
-pub use diesel_models::{
- ProcessTracker, ProcessTrackerNew, ProcessTrackerRunner, ProcessTrackerUpdate,
-};
pub use scheduler::db::process_tracker;
pub use self::{
diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rs
index 0d840326f9..41e1aae635 100644
--- a/crates/router/src/types/storage/payment_attempt.rs
+++ b/crates/router/src/types/storage/payment_attempt.rs
@@ -1,8 +1,8 @@
-pub use data_models::payments::payment_attempt::{
- PaymentAttempt, PaymentAttemptNew, PaymentAttemptUpdate,
-};
use diesel_models::{capture::CaptureNew, enums};
use error_stack::ResultExt;
+pub use hyperswitch_domain_models::payments::payment_attempt::{
+ PaymentAttempt, PaymentAttemptNew, PaymentAttemptUpdate,
+};
use crate::{
core::errors, errors::RouterResult, types::transformers::ForeignFrom, utils::OptionExt,
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index ba60da5748..ef12e32d57 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -315,30 +315,34 @@ impl ForeignFrom<storage_enums::MandateAmountData> for api_models::payments::Man
}
// TODO: remove foreign from since this conversion won't be needed in the router crate once data models is treated as a single & primary source of truth for structure information
-impl ForeignFrom<api_models::payments::MandateData> for data_models::mandates::MandateData {
+impl ForeignFrom<api_models::payments::MandateData>
+ for hyperswitch_domain_models::mandates::MandateData
+{
fn foreign_from(d: api_models::payments::MandateData) -> Self {
Self {
customer_acceptance: d.customer_acceptance.map(|d| {
- data_models::mandates::CustomerAcceptance {
+ hyperswitch_domain_models::mandates::CustomerAcceptance {
acceptance_type: match d.acceptance_type {
api_models::payments::AcceptanceType::Online => {
- data_models::mandates::AcceptanceType::Online
+ hyperswitch_domain_models::mandates::AcceptanceType::Online
}
api_models::payments::AcceptanceType::Offline => {
- data_models::mandates::AcceptanceType::Offline
+ hyperswitch_domain_models::mandates::AcceptanceType::Offline
}
},
accepted_at: d.accepted_at,
- online: d.online.map(|d| data_models::mandates::OnlineMandate {
- ip_address: d.ip_address,
- user_agent: d.user_agent,
- }),
+ online: d
+ .online
+ .map(|d| hyperswitch_domain_models::mandates::OnlineMandate {
+ ip_address: d.ip_address,
+ user_agent: d.user_agent,
+ }),
}
}),
mandate_type: d.mandate_type.map(|d| match d {
api_models::payments::MandateType::MultiUse(Some(i)) => {
- data_models::mandates::MandateDataType::MultiUse(Some(
- data_models::mandates::MandateAmountData {
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(Some(
+ hyperswitch_domain_models::mandates::MandateAmountData {
amount: i.amount,
currency: i.currency,
start_date: i.start_date,
@@ -348,8 +352,8 @@ impl ForeignFrom<api_models::payments::MandateData> for data_models::mandates::M
))
}
api_models::payments::MandateType::SingleUse(i) => {
- data_models::mandates::MandateDataType::SingleUse(
- data_models::mandates::MandateAmountData {
+ hyperswitch_domain_models::mandates::MandateDataType::SingleUse(
+ hyperswitch_domain_models::mandates::MandateAmountData {
amount: i.amount,
currency: i.currency,
start_date: i.start_date,
@@ -359,7 +363,7 @@ impl ForeignFrom<api_models::payments::MandateData> for data_models::mandates::M
)
}
api_models::payments::MandateType::MultiUse(None) => {
- data_models::mandates::MandateDataType::MultiUse(None)
+ hyperswitch_domain_models::mandates::MandateDataType::MultiUse(None)
}
}),
update_mandate_id: d.update_mandate_id,
diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rs
index 2d4b34b30d..341c560e4d 100644
--- a/crates/router/src/utils.rs
+++ b/crates/router/src/utils.rs
@@ -23,8 +23,8 @@ pub use common_utils::{
fp_utils::when,
validation::validate_email,
};
-use data_models::payments::PaymentIntent;
use error_stack::ResultExt;
+use hyperswitch_domain_models::payments::PaymentIntent;
use image::Luma;
use masking::ExposeInterface;
use nanoid::nanoid;
diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs
index 8469bf770d..2216cb1055 100644
--- a/crates/router/src/utils/user/sample_data.rs
+++ b/crates/router/src/utils/user/sample_data.rs
@@ -2,9 +2,9 @@ use api_models::{
enums::Connector::{DummyConnector4, DummyConnector7},
user::sample_data::SampleDataRequest,
};
-use data_models::payments::payment_intent::PaymentIntentNew;
use diesel_models::{user::sample_data::PaymentAttemptBatchNew, RefundNew};
use error_stack::ResultExt;
+use hyperswitch_domain_models::payments::payment_intent::PaymentIntentNew;
use rand::{prelude::SliceRandom, thread_rng, Rng};
use time::OffsetDateTime;
@@ -187,7 +187,9 @@ pub async fn generate_sample_data(
client_secret: Some(client_secret),
business_country: business_country_default,
business_label: business_label_default.clone(),
- active_attempt: data_models::RemoteStorageObject::ForeignID(attempt_id.clone()),
+ active_attempt: hyperswitch_domain_models::RemoteStorageObject::ForeignID(
+ attempt_id.clone(),
+ ),
attempt_count: 1,
customer_id: Some("hs-dashboard-user".to_string()),
amount_captured: Some(amount * 100),
diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rs
index 932a06bae6..5dbfff8342 100644
--- a/crates/router/src/workflows/payment_sync.rs
+++ b/crates/router/src/workflows/payment_sync.rs
@@ -123,9 +123,9 @@ impl ProcessTrackerWorkflow<AppState> for PaymentsSyncWorkflow {
.as_ref()
.is_none()
{
- let payment_intent_update = data_models::payments::payment_intent::PaymentIntentUpdate::PGStatusUpdate { status: api_models::enums::IntentStatus::Failed,updated_by: merchant_account.storage_scheme.to_string(), incremental_authorization_allowed: Some(false) };
+ let payment_intent_update = hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdate::PGStatusUpdate { status: api_models::enums::IntentStatus::Failed,updated_by: merchant_account.storage_scheme.to_string(), incremental_authorization_allowed: Some(false) };
let payment_attempt_update =
- data_models::payments::payment_attempt::PaymentAttemptUpdate::ErrorUpdate {
+ hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::ErrorUpdate {
connector: None,
status: api_models::enums::AttemptStatus::AuthenticationFailed,
error_code: None,
diff --git a/crates/storage_impl/Cargo.toml b/crates/storage_impl/Cargo.toml
index 5421e301f6..ab656c3f65 100644
--- a/crates/storage_impl/Cargo.toml
+++ b/crates/storage_impl/Cargo.toml
@@ -11,14 +11,14 @@ license.workspace = true
[features]
default = ["olap", "oltp"]
oltp = []
-olap = ["data_models/olap"]
-payouts = ["data_models/payouts"]
+olap = ["hyperswitch_domain_models/olap"]
+payouts = ["hyperswitch_domain_models/payouts"]
[dependencies]
# First Party dependencies
api_models = { version = "0.1.0", path = "../api_models" }
common_utils = { version = "0.1.0", path = "../common_utils" }
-data_models = { version = "0.1.0", path = "../data_models", default-features = false }
+hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
diesel_models = { version = "0.1.0", path = "../diesel_models" }
masking = { version = "0.1.0", path = "../masking" }
redis_interface = { version = "0.1.0", path = "../redis_interface" }
diff --git a/crates/storage_impl/src/database/store.rs b/crates/storage_impl/src/database/store.rs
index 92ba8910bf..17ae76b5bb 100644
--- a/crates/storage_impl/src/database/store.rs
+++ b/crates/storage_impl/src/database/store.rs
@@ -1,8 +1,8 @@
use async_bb8_diesel::{AsyncConnection, ConnectionError};
use bb8::CustomizeConnection;
-use data_models::errors::{StorageError, StorageResult};
use diesel::PgConnection;
use error_stack::ResultExt;
+use hyperswitch_domain_models::errors::{StorageError, StorageResult};
use masking::PeekInterface;
use crate::config::Database;
diff --git a/crates/storage_impl/src/errors.rs b/crates/storage_impl/src/errors.rs
index 8210b29a7c..41099bea75 100644
--- a/crates/storage_impl/src/errors.rs
+++ b/crates/storage_impl/src/errors.rs
@@ -3,8 +3,8 @@ use std::fmt::Display;
use actix_web::ResponseError;
use common_utils::errors::ErrorSwitch;
use config::ConfigError;
-use data_models::errors::StorageError as DataStorageError;
use http::StatusCode;
+use hyperswitch_domain_models::errors::StorageError as DataStorageError;
pub use redis_interface::errors::RedisError;
use router_env::opentelemetry::metrics::MetricsError;
diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rs
index f139641a56..e35d1f4151 100644
--- a/crates/storage_impl/src/lib.rs
+++ b/crates/storage_impl/src/lib.rs
@@ -1,8 +1,8 @@
use std::sync::Arc;
-use data_models::errors::{StorageError, StorageResult};
use diesel_models as store;
use error_stack::ResultExt;
+use hyperswitch_domain_models::errors::{StorageError, StorageResult};
use masking::StrongSecret;
use redis::{kv_store::RedisConnInterface, RedisStore};
mod address;
@@ -25,9 +25,9 @@ mod reverse_lookup;
mod utils;
use common_utils::errors::CustomResult;
-#[cfg(not(feature = "payouts"))]
-use data_models::{PayoutAttemptInterface, PayoutsInterface};
use database::store::PgPool;
+#[cfg(not(feature = "payouts"))]
+use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
pub use mock_db::MockDb;
use redis_interface::{errors::RedisError, SaddReply};
diff --git a/crates/storage_impl/src/lookup.rs b/crates/storage_impl/src/lookup.rs
index fb8c866443..f8daabf2e9 100644
--- a/crates/storage_impl/src/lookup.rs
+++ b/crates/storage_impl/src/lookup.rs
@@ -1,5 +1,4 @@
use common_utils::errors::CustomResult;
-use data_models::errors;
use diesel_models::{
enums as storage_enums, kv,
reverse_lookup::{
@@ -7,6 +6,7 @@ use diesel_models::{
},
};
use error_stack::ResultExt;
+use hyperswitch_domain_models::errors;
use redis_interface::SetnxReply;
use crate::{
diff --git a/crates/storage_impl/src/mock_db.rs b/crates/storage_impl/src/mock_db.rs
index 77cda9817a..5cf0123eb7 100644
--- a/crates/storage_impl/src/mock_db.rs
+++ b/crates/storage_impl/src/mock_db.rs
@@ -1,12 +1,12 @@
use std::sync::Arc;
-use data_models::{
- errors::StorageError,
- payments::{payment_attempt::PaymentAttempt, PaymentIntent},
-};
use diesel_models::{self as store};
use error_stack::ResultExt;
use futures::lock::Mutex;
+use hyperswitch_domain_models::{
+ errors::StorageError,
+ payments::{payment_attempt::PaymentAttempt, PaymentIntent},
+};
use redis_interface::RedisSettings;
use crate::redis::RedisStore;
@@ -19,7 +19,7 @@ pub mod payout_attempt;
pub mod payouts;
pub mod redis_conn;
#[cfg(not(feature = "payouts"))]
-use data_models::{PayoutAttemptInterface, PayoutsInterface};
+use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
#[derive(Clone)]
pub struct MockDb {
diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rs
index 996c8e102b..33ef6d416f 100644
--- a/crates/storage_impl/src/mock_db/payment_attempt.rs
+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs
@@ -1,12 +1,12 @@
use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};
use common_utils::errors::CustomResult;
-use data_models::{
+use diesel_models::enums as storage_enums;
+use hyperswitch_domain_models::{
errors::StorageError,
payments::payment_attempt::{
PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
},
};
-use diesel_models::enums as storage_enums;
use super::MockDb;
use crate::DataModelExt;
@@ -26,11 +26,13 @@ impl PaymentAttemptInterface for MockDb {
async fn get_filters_for_payments(
&self,
- _pi: &[data_models::payments::PaymentIntent],
+ _pi: &[hyperswitch_domain_models::payments::PaymentIntent],
_merchant_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
- ) -> CustomResult<data_models::payments::payment_attempt::PaymentListFilters, StorageError>
- {
+ ) -> CustomResult<
+ hyperswitch_domain_models::payments::payment_attempt::PaymentListFilters,
+ StorageError,
+ > {
Err(StorageError::MockDbError)?
}
diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rs
index a693eb5e26..1dfb7ac9d9 100644
--- a/crates/storage_impl/src/mock_db/payment_intent.rs
+++ b/crates/storage_impl/src/mock_db/payment_intent.rs
@@ -1,5 +1,7 @@
use common_utils::errors::CustomResult;
-use data_models::{
+use diesel_models::enums as storage_enums;
+use error_stack::ResultExt;
+use hyperswitch_domain_models::{
errors::StorageError,
payments::{
payment_attempt::PaymentAttempt,
@@ -7,8 +9,6 @@ use data_models::{
PaymentIntent,
},
};
-use diesel_models::enums as storage_enums;
-use error_stack::ResultExt;
use super::MockDb;
use crate::DataModelExt;
@@ -19,7 +19,7 @@ impl PaymentIntentInterface for MockDb {
async fn filter_payment_intent_by_constraints(
&self,
_merchant_id: &str,
- _filters: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
+ _filters: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Vec<PaymentIntent>, StorageError> {
// [#172]: Implement function for `MockDb`
@@ -39,7 +39,7 @@ impl PaymentIntentInterface for MockDb {
async fn get_filtered_active_attempt_ids_for_total_count(
&self,
_merchant_id: &str,
- _constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
+ _constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<String>, StorageError> {
// [#172]: Implement function for `MockDb`
@@ -49,7 +49,7 @@ impl PaymentIntentInterface for MockDb {
async fn get_filtered_payment_intents_attempt(
&self,
_merchant_id: &str,
- _constraints: &data_models::payments::payment_intent::PaymentIntentFetchConstraints,
+ _constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {
// [#172]: Implement function for `MockDb`
@@ -159,7 +159,7 @@ impl PaymentIntentInterface for MockDb {
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, StorageError> {
match payment.active_attempt.clone() {
- data_models::RemoteStorageObject::ForeignID(id) => {
+ hyperswitch_domain_models::RemoteStorageObject::ForeignID(id) => {
let attempts = self.payment_attempts.lock().await;
let attempt = attempts
.iter()
@@ -169,7 +169,7 @@ impl PaymentIntentInterface for MockDb {
payment.active_attempt = attempt.clone().into();
Ok(attempt.clone())
}
- data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
+ hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
}
}
}
diff --git a/crates/storage_impl/src/mock_db/payout_attempt.rs b/crates/storage_impl/src/mock_db/payout_attempt.rs
index 6b792e033d..8f26b8c581 100644
--- a/crates/storage_impl/src/mock_db/payout_attempt.rs
+++ b/crates/storage_impl/src/mock_db/payout_attempt.rs
@@ -1,5 +1,6 @@
use common_utils::errors::CustomResult;
-use data_models::{
+use diesel_models::enums as storage_enums;
+use hyperswitch_domain_models::{
errors::StorageError,
payouts::{
payout_attempt::{
@@ -8,7 +9,6 @@ use data_models::{
payouts::Payouts,
},
};
-use diesel_models::enums as storage_enums;
use super::MockDb;
@@ -50,7 +50,10 @@ impl PayoutAttemptInterface for MockDb {
_payouts: &[Payouts],
_merchant_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
- ) -> CustomResult<data_models::payouts::payout_attempt::PayoutListFilters, StorageError> {
+ ) -> CustomResult<
+ hyperswitch_domain_models::payouts::payout_attempt::PayoutListFilters,
+ StorageError,
+ > {
Err(StorageError::MockDbError)?
}
}
diff --git a/crates/storage_impl/src/mock_db/payouts.rs b/crates/storage_impl/src/mock_db/payouts.rs
index 1aee200eed..04e1321f1e 100644
--- a/crates/storage_impl/src/mock_db/payouts.rs
+++ b/crates/storage_impl/src/mock_db/payouts.rs
@@ -1,12 +1,12 @@
use common_utils::errors::CustomResult;
-use data_models::{
+use diesel_models::enums as storage_enums;
+use hyperswitch_domain_models::{
errors::StorageError,
payouts::{
payout_attempt::PayoutAttempt,
payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
},
};
-use diesel_models::enums as storage_enums;
use super::MockDb;
@@ -56,7 +56,7 @@ impl PayoutsInterface for MockDb {
async fn filter_payouts_by_constraints(
&self,
_merchant_id: &str,
- _filters: &data_models::payouts::PayoutFetchConstraints,
+ _filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Vec<Payouts>, StorageError> {
// TODO: Implement function for `MockDb`
@@ -67,7 +67,7 @@ impl PayoutsInterface for MockDb {
async fn filter_payouts_and_attempts(
&self,
_merchant_id: &str,
- _filters: &data_models::payouts::PayoutFetchConstraints,
+ _filters: &hyperswitch_domain_models::payouts::PayoutFetchConstraints,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Vec<(Payouts, PayoutAttempt, diesel_models::Customer)>, StorageError> {
// TODO: Implement function for `MockDb`
diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs
index 683b0469a2..4308e463b0 100644
--- a/crates/storage_impl/src/payments/payment_attempt.rs
+++ b/crates/storage_impl/src/payments/payment_attempt.rs
@@ -1,16 +1,5 @@
use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};
use common_utils::{errors::CustomResult, fallback_reverse_lookup_not_found};
-use data_models::{
- errors,
- mandates::{MandateAmountData, MandateDataType, MandateDetails},
- payments::{
- payment_attempt::{
- PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
- PaymentListFilters,
- },
- PaymentIntent,
- },
-};
use diesel_models::{
enums::{
MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,
@@ -24,6 +13,17 @@ use diesel_models::{
reverse_lookup::{ReverseLookup, ReverseLookupNew},
};
use error_stack::ResultExt;
+use hyperswitch_domain_models::{
+ errors,
+ mandates::{MandateAmountData, MandateDataType, MandateDetails},
+ payments::{
+ payment_attempt::{
+ PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
+ PaymentListFilters,
+ },
+ PaymentIntent,
+ },
+};
use redis_interface::HsetnxReply;
use router_env::{instrument, tracing};
diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs
index 4d984a02cc..fcc4ec63ff 100644
--- a/crates/storage_impl/src/payments/payment_intent.rs
+++ b/crates/storage_impl/src/payments/payment_intent.rs
@@ -6,17 +6,6 @@ use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::errors::ReportSwitchExt;
use common_utils::{date_time, ext_traits::Encode};
#[cfg(feature = "olap")]
-use data_models::payments::payment_intent::PaymentIntentFetchConstraints;
-use data_models::{
- errors::StorageError,
- payments::{
- payment_attempt::PaymentAttempt,
- payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},
- PaymentIntent,
- },
- RemoteStorageObject,
-};
-#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
use diesel_models::{
enums::MerchantStorageScheme,
@@ -33,6 +22,17 @@ use diesel_models::{
schema::{payment_attempt::dsl as pa_dsl, payment_intent::dsl as pi_dsl},
};
use error_stack::ResultExt;
+#[cfg(feature = "olap")]
+use hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints;
+use hyperswitch_domain_models::{
+ errors::StorageError,
+ payments::{
+ payment_attempt::PaymentAttempt,
+ payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},
+ PaymentIntent,
+ },
+ RemoteStorageObject,
+};
use redis_interface::HsetnxReply;
#[cfg(feature = "olap")]
use router_env::logger;
@@ -257,7 +257,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, StorageError> {
match payment.active_attempt.clone() {
- data_models::RemoteStorageObject::ForeignID(attempt_id) => {
+ hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
let conn = pg_connection_read(self).await?;
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
@@ -271,10 +271,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)?;
- payment.active_attempt = data_models::RemoteStorageObject::Object(pa.clone());
+ payment.active_attempt =
+ hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
Ok(pa)
}
- data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
+ hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
}
}
@@ -396,7 +397,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, StorageError> {
match &payment.active_attempt {
- data_models::RemoteStorageObject::ForeignID(attempt_id) => {
+ hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
let conn = pg_connection_read(self).await?;
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
@@ -410,10 +411,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)?;
- payment.active_attempt = data_models::RemoteStorageObject::Object(pa.clone());
+ payment.active_attempt =
+ hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
Ok(pa)
}
- data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
+ hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
}
}
diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rs
index 50334442e6..6a62832e1b 100644
--- a/crates/storage_impl/src/payouts/payout_attempt.rs
+++ b/crates/storage_impl/src/payouts/payout_attempt.rs
@@ -2,16 +2,6 @@ use std::str::FromStr;
use api_models::enums::PayoutConnectors;
use common_utils::{errors::CustomResult, ext_traits::Encode, fallback_reverse_lookup_not_found};
-use data_models::{
- errors,
- payouts::{
- payout_attempt::{
- PayoutAttempt, PayoutAttemptInterface, PayoutAttemptNew, PayoutAttemptUpdate,
- PayoutListFilters,
- },
- payouts::Payouts,
- },
-};
use diesel_models::{
enums::MerchantStorageScheme,
kv,
@@ -22,6 +12,16 @@ use diesel_models::{
ReverseLookupNew,
};
use error_stack::ResultExt;
+use hyperswitch_domain_models::{
+ errors,
+ payouts::{
+ payout_attempt::{
+ PayoutAttempt, PayoutAttemptInterface, PayoutAttemptNew, PayoutAttemptUpdate,
+ PayoutListFilters,
+ },
+ payouts::Payouts,
+ },
+};
use redis_interface::HsetnxReply;
use router_env::{instrument, logger, tracing};
diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rs
index 0b16694675..19921121a9 100644
--- a/crates/storage_impl/src/payouts/payouts.rs
+++ b/crates/storage_impl/src/payouts/payouts.rs
@@ -2,15 +2,6 @@
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::ext_traits::Encode;
#[cfg(feature = "olap")]
-use data_models::payouts::PayoutFetchConstraints;
-use data_models::{
- errors::StorageError,
- payouts::{
- payout_attempt::PayoutAttempt,
- payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
- },
-};
-#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
#[cfg(feature = "olap")]
use diesel_models::{
@@ -28,6 +19,15 @@ use diesel_models::{
},
};
use error_stack::ResultExt;
+#[cfg(feature = "olap")]
+use hyperswitch_domain_models::payouts::PayoutFetchConstraints;
+use hyperswitch_domain_models::{
+ errors::StorageError,
+ payouts::{
+ payout_attempt::PayoutAttempt,
+ payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
+ },
+};
use redis_interface::HsetnxReply;
#[cfg(feature = "olap")]
use router_env::logger;
diff --git a/crates/storage_impl/src/redis/cache.rs b/crates/storage_impl/src/redis/cache.rs
index a960261f86..dc2a2225dc 100644
--- a/crates/storage_impl/src/redis/cache.rs
+++ b/crates/storage_impl/src/redis/cache.rs
@@ -4,9 +4,9 @@ use common_utils::{
errors::{self, CustomResult},
ext_traits::AsyncExt,
};
-use data_models::errors::StorageError;
use dyn_clone::DynClone;
use error_stack::{Report, ResultExt};
+use hyperswitch_domain_models::errors::StorageError;
use moka::future::Cache as MokaCache;
use once_cell::sync::Lazy;
use redis_interface::{errors::RedisError, RedisValue};
diff --git a/crates/storage_impl/src/utils.rs b/crates/storage_impl/src/utils.rs
index 78198e9275..b634f41a98 100644
--- a/crates/storage_impl/src/utils.rs
+++ b/crates/storage_impl/src/utils.rs
@@ -1,7 +1,7 @@
use bb8::PooledConnection;
-use data_models::errors::StorageError;
use diesel::PgConnection;
use error_stack::ResultExt;
+use hyperswitch_domain_models::errors::StorageError;
use crate::{errors::RedisErrorExt, metrics, DatabaseStore};