Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Data models
# Hyperswitch domain models

Represents the data/domain models used by the business/domain layer
6 changes: 3 additions & 3 deletions crates/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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 = []
Expand Down Expand Up @@ -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" }
Expand Down
12 changes: 7 additions & 5 deletions crates/router/src/connector/noon/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/nuvei/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/errors/user/sample_data.rs
Original file line number Diff line number Diff line change
@@ -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>;

Expand Down
12 changes: 8 additions & 4 deletions crates/router/src/core/errors/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/fraud_check/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion crates/router/src/core/mandate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
2 changes: 1 addition & 1 deletion crates/router/src/core/mandate/helpers.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
8 changes: 4 additions & 4 deletions crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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)
}
},
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2703,7 +2703,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();
Expand Down
4 changes: 3 additions & 1 deletion crates/router/src/core/payments/flows/authorize_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
Loading