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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
chore: change serde value to strict type in payment intent domain and diesel model (#6393)
Hrithikesha5ac69d1a77e
diff --git a/Cargo.lock b/Cargo.lockindex d232fcbf02..0a08788ecf 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2050,6 +2050,7 @@ name = "common_enums"version = "0.1.0"dependencies = ["diesel",+ "masking","router_derive","serde","serde_json",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 8fd3b5d25d..2ace2b956e 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -5,6 +5,9 @@ use std::{};pub mod additional_info;use cards::CardNumber;+use common_enums::ProductType;+#[cfg(feature = "v2")]+use common_utils::id_type::GlobalPaymentId;use common_utils::{consts::default_payments_list_limit,crypto,@@ -374,7 +377,7 @@ pub struct PaymentsIntentResponse {/// Use this parameter to restrict the Payment Method Types to show for a given PaymentIntent#[schema(value_type = Option<Vec<PaymentMethodType>>)]- pub allowed_payment_method_types: Option<pii::SecretSerdeValue>,+ pub allowed_payment_method_types: Option<Vec<api_enums::PaymentMethodType>>,/// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>, example = r#"{ "udf1": "some-value", "udf2": "some-value" }"#)]@@ -386,7 +389,7 @@ pub struct PaymentsIntentResponse {/// Additional data that might be required by hyperswitch based on the requested features by the merchants.#[schema(value_type = Option<FeatureMetadata>)]- pub feature_metadata: Option<pii::SecretSerdeValue>,+ pub feature_metadata: Option<FeatureMetadata>,/// Whether to generate the payment link for this payment or not (if applicable)#[schema(value_type = EnablePaymentLinkRequest)]@@ -5107,18 +5110,6 @@ pub struct OrderDetailsWithAmount {impl masking::SerializableSecret for OrderDetailsWithAmount {}-#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]-#[serde(rename_all = "snake_case")]-pub enum ProductType {- #[default]- Physical,- Digital,- Travel,- Ride,- Event,- Accommodation,-}-#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]pub struct OrderDetails {/// Name of the product that is being purchaseddiff --git a/crates/common_enums/Cargo.toml b/crates/common_enums/Cargo.tomlindex da03b530eb..92fc2f0206 100644--- a/crates/common_enums/Cargo.toml+++ b/crates/common_enums/Cargo.toml@@ -22,6 +22,7 @@ utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order# First party cratesrouter_derive = { version = "0.1.0", path = "../router_derive" }+masking = { version = "0.1.0", path = "../masking" }[dev-dependencies]serde_json = "1.0.115"diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 917030c1e8..4d2e117a88 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -1,5 +1,7 @@+mod payments;use std::num::{ParseFloatError, TryFromIntError};+pub use payments::ProductType;use serde::{Deserialize, Serialize};use utoipa::ToSchema;@@ -1575,6 +1577,8 @@ pub enum PaymentMethodType {OpenBankingPIS,}+impl masking::SerializableSecret for PaymentMethodType {}+/// Indicates the type of payment method. Eg: 'card', 'wallet', etc.#[derive(Clone,diff --git a/crates/common_enums/src/enums/payments.rs b/crates/common_enums/src/enums/payments.rsnew file mode 100644index 0000000000..895303bab4--- /dev/null+++ b/crates/common_enums/src/enums/payments.rs@@ -0,0 +1,14 @@+use serde;+use utoipa::ToSchema;++#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]+#[serde(rename_all = "snake_case")]+pub enum ProductType {+ #[default]+ Physical,+ Digital,+ Travel,+ Ride,+ Event,+ Accommodation,+}diff --git a/crates/common_utils/src/hashing.rs b/crates/common_utils/src/hashing.rsindex d08cd9f086..0982ca5378 100644--- a/crates/common_utils/src/hashing.rs+++ b/crates/common_utils/src/hashing.rs@@ -1,7 +1,7 @@use masking::{PeekInterface, Secret, Strategy};use serde::{Deserialize, Serialize, Serializer};-#[derive(Clone, Debug, Deserialize)]+#[derive(Clone, PartialEq, Debug, Deserialize)]/// Represents a hashed string using blake3's hashing strategy.pub struct HashedString<T: Strategy<String>>(Secret<String, T>);diff --git a/crates/diesel_models/src/lib.rs b/crates/diesel_models/src/lib.rsindex 598035524a..c7a3818d5f 100644--- a/crates/diesel_models/src/lib.rs+++ b/crates/diesel_models/src/lib.rs@@ -41,6 +41,7 @@ pub mod refund;pub mod reverse_lookup;pub mod role;pub mod routing_algorithm;+pub mod types;pub mod unified_translations;#[allow(unused_qualifications)]diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rsindex 210b12b7aa..883e239309 100644--- a/crates/diesel_models/src/payment_intent.rs+++ b/crates/diesel_models/src/payment_intent.rs@@ -9,6 +9,8 @@ use crate::enums as storage_enums;use crate::schema::payment_intent;#[cfg(feature = "v2")]use crate::schema_v2::payment_intent;+#[cfg(feature = "v2")]+use crate::types::{FeatureMetadata, OrderDetailsWithAmount};#[cfg(feature = "v2")]#[derive(Clone, Debug, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Selectable)]@@ -32,11 +34,11 @@ pub struct PaymentIntent {pub setup_future_usage: Option<storage_enums::FutureUsage>,pub client_secret: common_utils::types::ClientSecret,pub active_attempt_id: Option<String>,- #[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]- pub order_details: Option<Vec<pii::SecretSerdeValue>>,+ #[diesel(deserialize_as = super::OptionalDieselArray<masking::Secret<OrderDetailsWithAmount>>)]+ pub order_details: Option<Vec<masking::Secret<OrderDetailsWithAmount>>>,pub allowed_payment_method_types: Option<pii::SecretSerdeValue>,pub connector_metadata: Option<pii::SecretSerdeValue>,- pub feature_metadata: Option<pii::SecretSerdeValue>,+ pub feature_metadata: Option<FeatureMetadata>,pub attempt_count: i16,pub profile_id: common_utils::id_type::ProfileId,pub payment_link_id: Option<String>,@@ -249,11 +251,11 @@ pub struct PaymentIntentNew {pub setup_future_usage: Option<storage_enums::FutureUsage>,pub client_secret: common_utils::types::ClientSecret,pub active_attempt_id: Option<String>,- #[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]- pub order_details: Option<Vec<pii::SecretSerdeValue>>,+ #[diesel(deserialize_as = super::OptionalDieselArray<masking::Secret<OrderDetailsWithAmount>>)]+ pub order_details: Option<Vec<masking::Secret<OrderDetailsWithAmount>>>,pub allowed_payment_method_types: Option<pii::SecretSerdeValue>,pub connector_metadata: Option<pii::SecretSerdeValue>,- pub feature_metadata: Option<pii::SecretSerdeValue>,+ pub feature_metadata: Option<FeatureMetadata>,pub attempt_count: i16,pub profile_id: common_utils::id_type::ProfileId,pub payment_link_id: Option<String>,diff --git a/crates/diesel_models/src/types.rs b/crates/diesel_models/src/types.rsnew file mode 100644index 0000000000..94f1fa8d26--- /dev/null+++ b/crates/diesel_models/src/types.rs@@ -0,0 +1,57 @@+use common_utils::{hashing::HashedString, pii, types::MinorUnit};+use diesel::{+ sql_types::{Json, Jsonb},+ AsExpression, FromSqlRow,+};+use masking::{Secret, WithType};+use serde::{Deserialize, Serialize};+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, FromSqlRow, AsExpression)]+#[diesel(sql_type = Jsonb)]+pub struct OrderDetailsWithAmount {+ /// Name of the product that is being purchased+ pub product_name: String,+ /// The quantity of the product to be purchased+ pub quantity: u16,+ /// the amount per quantity of product+ pub amount: MinorUnit,+ // Does the order includes shipping+ pub requires_shipping: Option<bool>,+ /// The image URL of the product+ pub product_img_link: Option<String>,+ /// ID of the product that is being purchased+ pub product_id: Option<String>,+ /// Category of the product that is being purchased+ pub category: Option<String>,+ /// Sub category of the product that is being purchased+ pub sub_category: Option<String>,+ /// Brand of the product that is being purchased+ pub brand: Option<String>,+ /// Type of the product that is being purchased+ pub product_type: Option<common_enums::ProductType>,+ /// The tax code for the product+ pub product_tax_code: Option<String>,+}++impl masking::SerializableSecret for OrderDetailsWithAmount {}++common_utils::impl_to_sql_from_sql_json!(OrderDetailsWithAmount);++#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, FromSqlRow, AsExpression)]+#[diesel(sql_type = Json)]+pub struct FeatureMetadata {+ /// Redirection response coming in request as metadata field only for redirection scenarios+ pub redirect_response: Option<RedirectResponse>,+ // TODO: Convert this to hashedstrings to avoid PII sensitive data+ /// Additional tags to be used for global search+ pub search_tags: Option<Vec<HashedString<WithType>>>,+}+impl masking::SerializableSecret for FeatureMetadata {}+common_utils::impl_to_sql_from_sql_json!(FeatureMetadata);++#[derive(Default, Debug, Eq, PartialEq, Deserialize, Serialize, Clone)]+pub struct RedirectResponse {+ pub param: Option<Secret<String>>,+ pub json_payload: Option<pii::SecretSerdeValue>,+}+impl masking::SerializableSecret for RedirectResponse {}+common_utils::impl_to_sql_from_sql_json!(RedirectResponse);diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rsindex a0daab47a2..110917226f 100644--- a/crates/hyperswitch_connectors/src/utils.rs+++ b/crates/hyperswitch_connectors/src/utils.rs@@ -1,6 +1,6 @@use std::collections::{HashMap, HashSet};-use api_models::payments::{self, Address, AddressDetails, OrderDetailsWithAmount, PhoneDetails};+use api_models::payments::{self, Address, AddressDetails, PhoneDetails};use base64::Engine;use common_enums::{enums,@@ -26,6 +26,7 @@ use hyperswitch_domain_models::{PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId,SetupMandateRequestData,},+ types::OrderDetailsWithAmount,};use hyperswitch_interfaces::{api, consts, errors, types::Response};use image::Luma;diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rsindex af6c8e65c8..02795481ad 100644--- a/crates/hyperswitch_domain_models/src/lib.rs+++ b/crates/hyperswitch_domain_models/src/lib.rs@@ -30,6 +30,12 @@ pub trait PayoutAttemptInterface {}#[cfg(not(feature = "payouts"))]pub trait PayoutsInterface {}+use api_models::payments::{+ FeatureMetadata as ApiFeatureMetadata, OrderDetailsWithAmount as ApiOrderDetailsWithAmount,+ RedirectResponse as ApiRedirectResponse,+};+use diesel_models::types::{FeatureMetadata, OrderDetailsWithAmount, RedirectResponse};+#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize)]pub enum RemoteStorageObject<T: ForeignIDRef> {ForeignID(String),@@ -60,6 +66,116 @@ use std::fmt::Debug;pub trait ApiModelToDieselModelConvertor<F> {/// Convert from a foreign type to the current typefn convert_from(from: F) -> Self;+ fn convert_back(self) -> F;+}++impl ApiModelToDieselModelConvertor<ApiFeatureMetadata> for FeatureMetadata {+ fn convert_from(from: ApiFeatureMetadata) -> Self {+ let ApiFeatureMetadata {+ redirect_response,+ search_tags,+ } = from;+ Self {+ redirect_response: redirect_response.map(RedirectResponse::convert_from),+ search_tags,+ }+ }++ fn convert_back(self) -> ApiFeatureMetadata {+ let Self {+ redirect_response,+ search_tags,+ } = self;+ ApiFeatureMetadata {+ redirect_response: redirect_response+ .map(|redirect_response| redirect_response.convert_back()),+ search_tags,+ }+ }+}++impl ApiModelToDieselModelConvertor<ApiRedirectResponse> for RedirectResponse {+ fn convert_from(from: ApiRedirectResponse) -> Self {+ let ApiRedirectResponse {+ param,+ json_payload,+ } = from;+ Self {+ param,+ json_payload,+ }+ }++ fn convert_back(self) -> ApiRedirectResponse {+ let Self {+ param,+ json_payload,+ } = self;+ ApiRedirectResponse {+ param,+ json_payload,+ }+ }+}++impl ApiModelToDieselModelConvertor<ApiOrderDetailsWithAmount> for OrderDetailsWithAmount {+ fn convert_from(from: ApiOrderDetailsWithAmount) -> Self {+ let ApiOrderDetailsWithAmount {+ product_name,+ quantity,+ amount,+ requires_shipping,+ product_img_link,+ product_id,+ category,+ sub_category,+ brand,+ product_type,+ product_tax_code,+ } = from;+ Self {+ product_name,+ quantity,+ amount,+ requires_shipping,+ product_img_link,+ product_id,+ category,+ sub_category,+ brand,+ product_type,+ product_tax_code,+ }+ }++ fn convert_back(self) -> ApiOrderDetailsWithAmount {+ let Self {+ product_name,+ quantity,+ amount,+ requires_shipping,+ product_img_link,+ product_id,+ category,+ sub_category,+ brand,+ product_type,+ product_tax_code,+ } = self;+ ApiOrderDetailsWithAmount {+ product_name,+ quantity,+ amount,+ requires_shipping,+ product_img_link,+ product_id,+ category,+ sub_category,+ brand,+ product_type,+ product_tax_code,+ }+ }}#[cfg(feature = "v2")]@@ -86,6 +202,31 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkConfigRequest>}),}}+ fn convert_back(self) -> api_models::admin::PaymentLinkConfigRequest {+ let Self {+ theme,+ logo,+ seller_name,+ sdk_layout,+ display_sdk_only,+ enabled_saved_payment_method,+ transaction_details,+ } = self;+ api_models::admin::PaymentLinkConfigRequest {+ theme,+ logo,+ seller_name,+ sdk_layout,+ display_sdk_only,+ enabled_saved_payment_method,+ transaction_details: transaction_details.map(|transaction_details| {+ transaction_details+ .into_iter()+ .map(|transaction_detail| transaction_detail.convert_back())+ .collect()+ }),+ }+ }}#[cfg(feature = "v2")]@@ -101,6 +242,19 @@ impl ApiModelToDieselModelConvertor<api_models::admin::PaymentLinkTransactionDet.map(diesel_models::TransactionDetailsUiConfiguration::convert_from),}}+ fn convert_back(self) -> api_models::admin::PaymentLinkTransactionDetails {+ let Self {+ key,+ value,+ ui_configuration,+ } = self;+ api_models::admin::PaymentLinkTransactionDetails {+ key,+ value,+ ui_configuration: ui_configuration+ .map(|ui_configuration| ui_configuration.convert_back()),+ }+ }}#[cfg(feature = "v2")]@@ -114,6 +268,18 @@ impl ApiModelToDieselModelConvertor<api_models::admin::TransactionDetailsUiConfiis_value_bold: from.is_value_bold,}}+ fn convert_back(self) -> api_models::admin::TransactionDetailsUiConfiguration {+ let Self {+ position,+ is_key_bold,+ is_value_bold,+ } = self;+ api_models::admin::TransactionDetailsUiConfiguration {+ position,+ is_key_bold,+ is_value_bold,+ }+ }}#[cfg(feature = "v2")]diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex cd41458dfb..a21788e1bb 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -3,8 +3,6 @@ use std::marker::PhantomData;#[cfg(feature = "v2")]use api_models::payments::Address;-#[cfg(feature = "v2")]-use api_models::payments::OrderDetailsWithAmount;use common_utils::{self,crypto::Encryptable,@@ -26,6 +24,8 @@ pub mod payment_attempt;pub mod payment_intent;use common_enums as storage_enums;+#[cfg(feature = "v2")]+use diesel_models::types::{FeatureMetadata, OrderDetailsWithAmount};use self::payment_attempt::PaymentAttempt;use crate::RemoteStorageObject;@@ -278,10 +278,10 @@ pub struct PaymentIntent {pub order_details: Option<Vec<Secret<OrderDetailsWithAmount>>>,/// This is the list of payment method types that are allowed for the payment intent./// This field allows the merchant to restrict the payment methods that can be used for the payment intent.- pub allowed_payment_method_types: Option<pii::SecretSerdeValue>,+ pub allowed_payment_method_types: Option<Vec<common_enums::PaymentMethodType>>,/// This metadata contains details aboutpub connector_metadata: Option<pii::SecretSerdeValue>,- pub feature_metadata: Option<pii::SecretSerdeValue>,+ pub feature_metadata: Option<FeatureMetadata>,/// Number of attempts that have been made for the orderpub attempt_count: i16,/// The profile id for the payment.@@ -381,20 +381,14 @@ impl PaymentIntent {billing_address: Option<Encryptable<Secret<Address>>>,shipping_address: Option<Encryptable<Secret<Address>>>,) -> CustomResult<Self, errors::api_error_response::ApiErrorResponse> {- let allowed_payment_method_types = request- .get_allowed_payment_method_types_as_value()- .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)- .attach_printable("Error getting allowed payment method types as value")?;let connector_metadata = request.get_connector_metadata_as_value().change_context(errors::api_error_response::ApiErrorResponse::InternalServerError).attach_printable("Error getting connector metadata as value")?;- let feature_metadata = request- .get_feature_metadata_as_value()- .change_context(errors::api_error_response::ApiErrorResponse::InternalServerError)- .attach_printable("Error getting feature metadata as value")?;let request_incremental_authorization =Self::get_request_incremental_authorization_value(&request)?;+ let allowed_payment_method_types = request.allowed_payment_method_types;+let session_expiry =common_utils::date_time::now().saturating_add(time::Duration::seconds(request.session_expiry.map(i64::from).unwrap_or(@@ -404,9 +398,12 @@ impl PaymentIntent {),));let client_secret = payment_id.generate_client_secret();- let order_details = request- .order_details- .map(|order_details| order_details.into_iter().map(Secret::new).collect());+ let order_details = request.order_details.map(|order_details| {+ order_details+ .into_iter()+ .map(|order_detail| Secret::new(OrderDetailsWithAmount::convert_from(order_detail)))+ .collect()+ });Ok(Self {id: payment_id.clone(),merchant_id: merchant_account.get_id().clone(),@@ -428,7 +425,7 @@ impl PaymentIntent {order_details,allowed_payment_method_types,connector_metadata,- feature_metadata,+ feature_metadata: request.feature_metadata.map(FeatureMetadata::convert_from),// Attempt count is 0 in create intent as no attempt is made yetattempt_count: 0,profile_id: profile.get_id().clone(),diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex c9f7a5e2ae..3b26ff94e5 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -14,6 +14,8 @@ use common_utils::{MinorUnit,},};+#[cfg(feature = "v2")]+use diesel_models::types::OrderDetailsWithAmount;use diesel_models::{PaymentIntent as DieselPaymentIntent, PaymentIntentNew as DieselPaymentIntentNew,};@@ -33,6 +35,7 @@ use crate::{type_encryption::{crypto_operation, CryptoOperation},RemoteStorageObject,};+#[async_trait::async_trait]pub trait PaymentIntentInterface {async fn update_payment_intent(@@ -1180,18 +1183,22 @@ impl behaviour::Conversion for PaymentIntent {setup_future_usage: Some(setup_future_usage),client_secret,active_attempt_id: active_attempt.map(|attempt| attempt.get_id()),- order_details: order_details- .map(|order_details| {- order_details- .into_iter()- .map(|order_detail| order_detail.encode_to_value().map(Secret::new))- .collect::<Result<Vec<_>, _>>()+ order_details: order_details.map(|order_details| {+ order_details+ .into_iter()+ .map(|order_detail| Secret::new(order_detail.expose()))+ .collect::<Vec<_>>()+ }),+ allowed_payment_method_types: allowed_payment_method_types+ .map(|allowed_payment_method_types| {+ allowed_payment_method_types+ .encode_to_value()+ .change_context(ValidationError::InvalidValue {+ message: "Failed to serialize allowed_payment_method_types".to_string(),+ })})- .transpose()- .change_context(ValidationError::InvalidValue {- message: "invalid value found for order_details".to_string(),- })?,- allowed_payment_method_types,+ .transpose()?+ .map(Secret::new),connector_metadata,feature_metadata,attempt_count,@@ -1290,7 +1297,13 @@ impl behaviour::Conversion for PaymentIntent {.transpose().change_context(common_utils::errors::CryptoError::DecodingFailed).attach_printable("Error while deserializing Address")?;-+ let allowed_payment_method_types = storage_model+ .allowed_payment_method_types+ .map(|allowed_payment_method_types| {+ allowed_payment_method_types.parse_value("Vec<PaymentMethodType>")+ })+ .transpose()+ .change_context(common_utils::errors::CryptoError::DecodingFailed)?;Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {merchant_id: storage_model.merchant_id,status: storage_model.status,@@ -1309,19 +1322,13 @@ impl behaviour::Conversion for PaymentIntent {active_attempt: storage_model.active_attempt_id.map(RemoteStorageObject::ForeignID),- order_details: storage_model- .order_details- .map(|order_details| {- order_details- .into_iter()- .map(|order_detail| {- order_detail.expose().parse_value("OrderDetailsWithAmount")- })- .collect::<Result<Vec<_>, _>>()- })- .transpose()- .change_context(common_utils::errors::CryptoError::DecodingFailed)?,- allowed_payment_method_types: storage_model.allowed_payment_method_types,+ order_details: storage_model.order_details.map(|order_details| {+ order_details+ .into_iter()+ .map(|order_detail| Secret::new(order_detail.expose()))+ .collect::<Vec<_>>()+ }),+ allowed_payment_method_types,connector_metadata: storage_model.connector_metadata,feature_metadata: storage_model.feature_metadata,attempt_count: storage_model.attempt_count,@@ -1389,19 +1396,18 @@ impl behaviour::Conversion for PaymentIntent {setup_future_usage: Some(self.setup_future_usage),client_secret: self.client_secret,active_attempt_id: self.active_attempt.map(|attempt| attempt.get_id()),- order_details: self- .order_details- .map(|order_details| {- order_details- .into_iter()- .map(|order_detail| order_detail.encode_to_value().map(Secret::new))- .collect::<Result<Vec<_>, _>>()+ order_details: self.order_details,+ allowed_payment_method_types: self+ .allowed_payment_method_types+ .map(|allowed_payment_method_types| {+ allowed_payment_method_types+ .encode_to_value()+ .change_context(ValidationError::InvalidValue {+ message: "Failed to serialize allowed_payment_method_types".to_string(),+ })})- .transpose()- .change_context(ValidationError::InvalidValue {- message: "Invalid value found for ".to_string(),- })?,- allowed_payment_method_types: self.allowed_payment_method_types,+ .transpose()?+ .map(Secret::new),connector_metadata: self.connector_metadata,feature_metadata: self.feature_metadata,attempt_count: self.attempt_count,diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex 344eb632f4..c645d0b4b5 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -7,7 +7,7 @@ use common_utils::{id_type, pii,types::{self as common_types, MinorUnit},};-use diesel_models::enums as storage_enums;+use diesel_models::{enums as storage_enums, types::OrderDetailsWithAmount};use error_stack::ResultExt;use masking::Secret;use serde::Serialize;@@ -49,7 +49,7 @@ pub struct PaymentsAuthorizeData {pub customer_acceptance: Option<mandates::CustomerAcceptance>,pub setup_mandate_details: Option<mandates::MandateData>,pub browser_info: Option<BrowserInformation>,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub order_category: Option<String>,pub session_token: Option<String>,pub enrolled_for_3ds: bool,@@ -288,7 +288,7 @@ pub struct PaymentsPreProcessingData {pub payment_method_type: Option<storage_enums::PaymentMethodType>,pub setup_mandate_details: Option<mandates::MandateData>,pub capture_method: Option<storage_enums::CaptureMethod>,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub router_return_url: Option<String>,pub webhook_url: Option<String>,pub complete_authorize_url: Option<String>,@@ -823,7 +823,7 @@ pub struct PaymentsSessionData {pub currency: common_enums::Currency,pub country: Option<common_enums::CountryAlpha2>,pub surcharge_details: Option<SurchargeDetails>,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub email: Option<pii::Email>,// Minor Unit amount for amount frame workpub minor_amount: MinorUnit,@@ -834,7 +834,7 @@ pub struct PaymentsTaxCalculationData {pub amount: MinorUnit,pub currency: storage_enums::Currency,pub shipping_cost: Option<MinorUnit>,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub shipping_address: Address,}diff --git a/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs b/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rsindex 30a87c5c13..4d7f4bfdf4 100644--- a/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs@@ -4,6 +4,7 @@ use common_utils::{events::{ApiEventMetric, ApiEventsType},pii::Email,};+use diesel_models::types::OrderDetailsWithAmount;use masking::Secret;use serde::{Deserialize, Serialize};use utoipa::ToSchema;@@ -12,7 +13,7 @@ use crate::router_request_types;#[derive(Debug, Clone)]pub struct FraudCheckSaleData {pub amount: i64,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub currency: Option<common_enums::Currency>,pub email: Option<Email>,}@@ -20,7 +21,7 @@ pub struct FraudCheckSaleData {#[derive(Debug, Clone)]pub struct FraudCheckCheckoutData {pub amount: i64,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub currency: Option<common_enums::Currency>,pub browser_info: Option<router_request_types::BrowserInformation>,pub payment_method_data: Option<api_models::payments::AdditionalPaymentData>,@@ -31,7 +32,7 @@ pub struct FraudCheckCheckoutData {#[derive(Debug, Clone)]pub struct FraudCheckTransactionData {pub amount: i64,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub currency: Option<common_enums::Currency>,pub payment_method: Option<common_enums::PaymentMethod>,pub error_code: Option<String>,diff --git a/crates/hyperswitch_domain_models/src/types.rs b/crates/hyperswitch_domain_models/src/types.rsindex a629f8e639..201a073dd3 100644--- a/crates/hyperswitch_domain_models/src/types.rs+++ b/crates/hyperswitch_domain_models/src/types.rs@@ -1,3 +1,5 @@+pub use diesel_models::types::OrderDetailsWithAmount;+use crate::{router_data::{AccessToken, RouterData},router_flow_types::{diff --git a/crates/masking/src/strategy.rs b/crates/masking/src/strategy.rsindex eb705ca490..b497cc3ed4 100644--- a/crates/masking/src/strategy.rs+++ b/crates/masking/src/strategy.rs@@ -8,7 +8,7 @@ pub trait Strategy<T> {/// Debug with type#[cfg_attr(feature = "serde", derive(serde::Deserialize))]-#[derive(Debug, Copy, Clone)]+#[derive(Debug, Copy, Clone, PartialEq)]pub enum WithType {}impl<T> Strategy<T> for WithType {diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 75d1bb9f27..c4a57830ae 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -400,7 +400,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::ApplePayShippingContactFields,api_models::payments::ApplePayAddressParameters,api_models::payments::AmountInfo,- api_models::payments::ProductType,+ api_models::enums::ProductType,api_models::payments::GooglePayWalletData,api_models::payments::PayPalWalletData,api_models::payments::PaypalRedirection,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex 40f694b80a..2201e3c492 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -187,6 +187,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::customers::CustomerResponse,api_models::admin::AcceptedCountries,api_models::admin::AcceptedCurrencies,+ api_models::enums::ProductType,api_models::enums::PaymentType,api_models::enums::PaymentMethod,api_models::enums::PaymentMethodType,@@ -339,7 +340,6 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::ApplePayShippingContactFields,api_models::payments::ApplePayAddressParameters,api_models::payments::AmountInfo,- api_models::payments::ProductType,api_models::payments::GooglePayWalletData,api_models::payments::PayPalWalletData,api_models::payments::PaypalRedirection,diff --git a/crates/router/src/analytics.rs b/crates/router/src/analytics.rsindex aba1c2e2ef..ed25725358 100644--- a/crates/router/src/analytics.rs+++ b/crates/router/src/analytics.rs@@ -50,6 +50,11 @@ pub mod routes {pub struct Analytics;impl Analytics {+ #[cfg(feature = "v2")]+ pub fn server(_state: AppState) -> Scope {+ todo!()+ }+ #[cfg(feature = "v1")]pub fn server(state: AppState) -> Scope {web::scope("/analytics").app_data(web::Data::new(state))@@ -452,6 +457,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]/// # Panics////// Panics if `json_payload` array does not contain one `GetPaymentMetricRequest` element.@@ -578,6 +584,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]/// # Panics////// Panics if `json_payload` array does not contain one `GetPaymentIntentMetricRequest` element.@@ -702,6 +709,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]/// # Panics////// Panics if `json_payload` array does not contain one `GetRefundMetricRequest` element.@@ -955,6 +963,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn get_profile_payment_filters(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1076,6 +1085,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn get_profile_refund_filters(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1259,6 +1269,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn generate_merchant_refund_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1309,6 +1320,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn generate_org_refund_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1357,6 +1369,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn generate_profile_refund_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1411,7 +1424,7 @@ pub mod routes {)).await}-+ #[cfg(feature = "v1")]pub async fn generate_merchant_dispute_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1461,7 +1474,7 @@ pub mod routes {)).await}-+ #[cfg(feature = "v1")]pub async fn generate_org_dispute_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1510,6 +1523,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn generate_profile_dispute_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1565,6 +1579,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn generate_merchant_payment_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1614,7 +1629,7 @@ pub mod routes {)).await}-+ #[cfg(feature = "v1")]pub async fn generate_org_payment_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -1663,6 +1678,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn generate_profile_payment_report(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -2073,6 +2089,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn get_profile_dispute_filters(state: web::Data<AppState>,req: actix_web::HttpRequest,@@ -2176,6 +2193,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]/// # Panics////// Panics if `json_payload` array does not contain one `GetDisputeMetricRequest` element.@@ -2319,6 +2337,7 @@ pub mod routes {.await}+ #[cfg(feature = "v1")]pub async fn get_profile_sankey(state: web::Data<AppState>,req: actix_web::HttpRequest,diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rsindex 95ac2a67a5..bba9fc2f85 100644--- a/crates/router/src/connector/adyen/transformers.rs+++ b/crates/router/src/connector/adyen/transformers.rs@@ -1763,8 +1763,7 @@ pub fn get_address_info(}fn get_line_items(item: &AdyenRouterData<&types::PaymentsAuthorizeRouterData>) -> Vec<LineItem> {- let order_details: Option<Vec<payments::OrderDetailsWithAmount>> =- item.router_data.request.order_details.clone();+ let order_details = item.router_data.request.order_details.clone();match order_details {Some(od) => od.iter()diff --git a/crates/router/src/connector/riskified/transformers/api.rs b/crates/router/src/connector/riskified/transformers/api.rsindex d2d38855da..cfa183e9e8 100644--- a/crates/router/src/connector/riskified/transformers/api.rs+++ b/crates/router/src/connector/riskified/transformers/api.rs@@ -113,7 +113,7 @@ pub struct LineItem {price: i64,quantity: i32,title: String,- product_type: Option<api_models::payments::ProductType>,+ product_type: Option<common_enums::ProductType>,requires_shipping: Option<bool>,product_id: Option<String>,category: Option<String>,diff --git a/crates/router/src/connector/signifyd/transformers/api.rs b/crates/router/src/connector/signifyd/transformers/api.rsindex eed0e9937b..348ca3d099 100644--- a/crates/router/src/connector/signifyd/transformers/api.rs+++ b/crates/router/src/connector/signifyd/transformers/api.rs@@ -153,7 +153,7 @@ impl TryFrom<&frm_types::FrmSaleRouterData> for SignifydPaymentsSaleRequest {item_is_digital: order_detail.product_type.as_ref()- .map(|product| (product == &api_models::payments::ProductType::Digital)),+ .map(|product| (product == &common_enums::ProductType::Digital)),}).collect::<Vec<_>>();let metadata: SignifydFrmMetadata = item@@ -390,7 +390,7 @@ impl TryFrom<&frm_types::FrmCheckoutRouterData> for SignifydPaymentsCheckoutRequitem_is_digital: order_detail.product_type.as_ref()- .map(|product| (product == &api_models::payments::ProductType::Digital)),+ .map(|product| (product == &common_enums::ProductType::Digital)),}).collect::<Vec<_>>();let metadata: SignifydFrmMetadata = itemdiff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex 76def480cf..a9a5a01eef 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -7,7 +7,7 @@ use std::{use api_models::payouts::{self, PayoutVendorAccountDetails};use api_models::{enums::{CanadaStatesAbbreviation, UsStatesAbbreviation},- payments::{self, OrderDetailsWithAmount},+ payments,};use base64::Engine;use common_utils::{@@ -18,7 +18,7 @@ use common_utils::{pii::{self, Email, IpAddress},types::{AmountConvertor, MinorUnit},};-use diesel_models::enums;+use diesel_models::{enums, types::OrderDetailsWithAmount};use error_stack::{report, ResultExt};use hyperswitch_domain_models::{mandates,diff --git a/crates/router/src/core/fraud_check/types.rs b/crates/router/src/core/fraud_check/types.rsindex 3f5988777f..2aa486fdb3 100644--- a/crates/router/src/core/fraud_check/types.rs+++ b/crates/router/src/core/fraud_check/types.rs@@ -7,8 +7,11 @@ use api_models::{use common_enums::FrmSuggestion;use common_utils::pii::SecretSerdeValue;use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};-pub use hyperswitch_domain_models::router_request_types::fraud_check::{- Address, Destination, FrmFulfillmentRequest, FulfillmentStatus, Fulfillments, Product,+pub use hyperswitch_domain_models::{+ router_request_types::fraud_check::{+ Address, Destination, FrmFulfillmentRequest, FulfillmentStatus, Fulfillments, Product,+ },+ types::OrderDetailsWithAmount,};use masking::Serialize;use serde::Deserialize;@@ -54,7 +57,7 @@ pub struct FrmData {pub fraud_check: FraudCheck,pub address: PaymentAddress,pub connector_details: ConnectorDetailsCore,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub refund: Option<RefundResponse>,pub frm_metadata: Option<SecretSerdeValue>,}@@ -79,7 +82,7 @@ pub struct PaymentToFrmData {pub merchant_account: MerchantAccount,pub address: PaymentAddress,pub connector_details: ConnectorDetailsCore,- pub order_details: Option<Vec<api_models::payments::OrderDetailsWithAmount>>,+ pub order_details: Option<Vec<OrderDetailsWithAmount>>,pub frm_metadata: Option<SecretSerdeValue>,}diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 38b475590f..45d0f75cce 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -18,6 +18,8 @@ use diesel_models::{use error_stack::{report, ResultExt};#[cfg(feature = "v2")]use hyperswitch_domain_models::payments::PaymentConfirmData;+#[cfg(feature = "v2")]+use hyperswitch_domain_models::ApiModelToDieselModelConvertor;use hyperswitch_domain_models::{payments::payment_intent::CustomerData, router_request_types};use masking::{ExposeInterface, Maskable, PeekInterface, Secret};use router_env::{instrument, metrics::add_attributes, tracing};@@ -822,13 +824,16 @@ whereorder_details: payment_intent.order_details.clone().map(|order_details| {order_details.into_iter()- .map(|order_detail| order_detail.expose())+ .map(|order_detail| order_detail.expose().convert_back()).collect()}),allowed_payment_method_types: payment_intent.allowed_payment_method_types.clone(),metadata: payment_intent.metadata.clone(),connector_metadata: payment_intent.connector_metadata.clone(),- feature_metadata: payment_intent.feature_metadata.clone(),+ feature_metadata: payment_intent+ .feature_metadata+ .clone()+ .map(|feature_metadata| feature_metadata.convert_back()),payment_link_enabled: payment_intent.enable_payment_link.clone(),payment_link_config: payment_intent.payment_link_configdiff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex abd602760f..fea112bc3b 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -1,11 +1,8 @@use std::{collections::HashSet, marker::PhantomData, str::FromStr};+use api_models::enums::{DisputeStage, DisputeStatus};#[cfg(feature = "payouts")]use api_models::payouts::PayoutVendorAccountDetails;-use api_models::{- enums::{DisputeStage, DisputeStatus},- payments::OrderDetailsWithAmount,-};use common_enums::{IntentStatus, RequestIncrementalAuthorization};#[cfg(feature = "payouts")]use common_utils::{crypto::Encryptable, pii::Email};@@ -17,7 +14,7 @@ use common_utils::{use error_stack::{report, ResultExt};use hyperswitch_domain_models::{merchant_connector_account::MerchantConnectorAccount, payment_address::PaymentAddress,- router_data::ErrorResponse,+ router_data::ErrorResponse, types::OrderDetailsWithAmount,};#[cfg(feature = "payouts")]use masking::{ExposeInterface, PeekInterface};diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rsindex 8ca0b29376..cf73bd5b11 100644--- a/crates/router/src/db/kafka_store.rs+++ b/crates/router/src/db/kafka_store.rs@@ -73,7 +73,7 @@ use crate::{unified_translations::UnifiedTranslationsInterface,CommonStorageInterface, GlobalStorageInterface, MasterKeyInterface, StorageInterface,},- services::{authentication, kafka::KafkaProducer, Store},+ services::{kafka::KafkaProducer, Store},types::{domain, storage, AccessToken},};@@ -1007,7 +1007,8 @@ impl MerchantAccountInterface for KafkaStore {&self,state: &KeyManagerState,publishable_key: &str,- ) -> CustomResult<authentication::AuthenticationData, errors::StorageError> {+ ) -> CustomResult<(domain::MerchantAccount, domain::MerchantKeyStore), errors::StorageError>+ {self.diesel_store.find_merchant_account_by_publishable_key(state, publishable_key).awaitdiff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rsindex 3984450389..6eb355e443 100644--- a/crates/router/src/db/merchant_account.rs+++ b/crates/router/src/db/merchant_account.rs@@ -13,7 +13,6 @@ use crate::{connection,core::errors::{self, CustomResult},db::merchant_key_store::MerchantKeyStoreInterface,- services::authentication,types::{domain::{self,@@ -68,7 +67,7 @@ where&self,state: &KeyManagerState,publishable_key: &str,- ) -> CustomResult<authentication::AuthenticationData, errors::StorageError>;+ ) -> CustomResult<(domain::MerchantAccount, domain::MerchantKeyStore), errors::StorageError>;#[cfg(feature = "olap")]async fn list_merchant_accounts_by_organization_id(@@ -229,7 +228,8 @@ impl MerchantAccountInterface for Store {&self,state: &KeyManagerState,publishable_key: &str,- ) -> CustomResult<authentication::AuthenticationData, errors::StorageError> {+ ) -> CustomResult<(domain::MerchantAccount, domain::MerchantKeyStore), errors::StorageError>+ {let fetch_by_pub_key_func = || async {let conn = connection::pg_connection_read(self).await?;@@ -261,20 +261,15 @@ impl MerchantAccountInterface for Store {&self.get_master_key().to_vec().into(),).await?;-- Ok(authentication::AuthenticationData {- merchant_account: merchant_account- .convert(- state,- key_store.key.get_inner(),- key_store.merchant_id.clone().into(),- )- .await- .change_context(errors::StorageError::DecryptionError)?,-- key_store,- profile_id: None,- })+ let domain_merchant_account = merchant_account+ .convert(+ state,+ key_store.key.get_inner(),+ key_store.merchant_id.clone().into(),+ )+ .await+ .change_context(errors::StorageError::DecryptionError)?;+ Ok((domain_merchant_account, key_store))}#[cfg(feature = "olap")]@@ -578,7 +573,8 @@ impl MerchantAccountInterface for MockDb {&self,state: &KeyManagerState,publishable_key: &str,- ) -> CustomResult<authentication::AuthenticationData, errors::StorageError> {+ ) -> CustomResult<(domain::MerchantAccount, domain::MerchantKeyStore), errors::StorageError>+ {let accounts = self.merchant_accounts.lock().await;let account = accounts.iter()@@ -599,20 +595,16 @@ impl MerchantAccountInterface for MockDb {&self.get_master_key().to_vec().into(),).await?;- Ok(authentication::AuthenticationData {- merchant_account: account- .clone()- .convert(- state,- key_store.key.get_inner(),- key_store.merchant_id.clone().into(),- )- .await- .change_context(errors::StorageError::DecryptionError)?,-- key_store,- profile_id: None,- })+ let merchant_account = account+ .clone()+ .convert(+ state,+ key_store.key.get_inner(),+ key_store.merchant_id.clone().into(),+ )+ .await+ .change_context(errors::StorageError::DecryptionError)?;+ Ok((merchant_account, key_store))}async fn update_all_merchant_account(diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rsindex 0996838b4c..64a0630c40 100644--- a/crates/router/src/routes/admin.rs+++ b/crates/router/src/routes/admin.rs@@ -357,7 +357,7 @@ pub async fn connector_create(state,&req,payload,- |state, auth_data, req, _| {+ |state, auth_data: auth::AuthenticationData, req, _| {create_connector(state,req,@@ -554,6 +554,8 @@ pub async fn connector_list().await}++#[cfg(all(feature = "v1", feature = "olap"))]/// Merchant Connector - List////// List Merchant Connector Details for the merchantdiff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex ae099a36e4..5ad8f38644 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -46,7 +46,7 @@ use super::pm_auth;use super::poll;#[cfg(feature = "olap")]use super::routing;-#[cfg(feature = "olap")]+#[cfg(all(feature = "olap", feature = "v1"))]use super::verification::{apple_pay_merchant_registration, retrieve_apple_pay_verified_domains};#[cfg(all(feature = "oltp", feature = "v1"))]use super::webhooks::*;@@ -66,6 +66,8 @@ pub use crate::analytics::opensearch::OpenSearchClient;use crate::analytics::AnalyticsProvider;#[cfg(feature = "partial-auth")]use crate::errors::RouterResult;+#[cfg(feature = "v1")]+use crate::routes::cards_info::card_iin_info;#[cfg(all(feature = "frm", feature = "oltp"))]use crate::routes::fraud_check as frm_routes;#[cfg(all(feature = "recon", feature = "olap"))]@@ -74,7 +76,6 @@ pub use crate::{configs::settings,db::{CommonStorageInterface, GlobalStorageInterface, StorageImpl, StorageInterface},events::EventsHandler,- routes::cards_info::card_iin_info,services::{get_cache_store, get_store},};use crate::{@@ -670,6 +671,7 @@ pub struct Forex;#[cfg(any(feature = "olap", feature = "oltp"))]impl Forex {+ #[cfg(feature = "v1")]pub fn server(state: AppState) -> Scope {web::scope("/forex").app_data(web::Data::new(state.clone()))@@ -679,6 +681,10 @@ impl Forex {web::resource("/convert_from_minor").route(web::get().to(currency::convert_forex)),)}+ #[cfg(feature = "v2")]+ pub fn server(state: AppState) -> Scope {+ todo!()+ }}#[cfg(feature = "olap")]@@ -1055,6 +1061,11 @@ pub struct Payouts;#[cfg(feature = "payouts")]impl Payouts {+ #[cfg(feature = "v2")]+ pub fn server(state: AppState) -> Scope {+ todo!()+ }+ #[cfg(feature = "v1")]pub fn server(state: AppState) -> Scope {let mut route = web::scope("/payouts").app_data(web::Data::new(state));route = route.service(web::resource("/create").route(web::post().to(payouts_create)));@@ -1563,11 +1574,16 @@ impl Disputes {pub struct Cards;impl Cards {+ #[cfg(feature = "v1")]pub fn server(state: AppState) -> Scope {web::scope("/cards").app_data(web::Data::new(state)).service(web::resource("/{bin}").route(web::get().to(card_iin_info)))}+ #[cfg(feature = "v2")]+ pub fn server(state: AppState) -> Scope {+ todo!()+ }}pub struct Files;@@ -1628,6 +1644,7 @@ pub struct PayoutLink;#[cfg(feature = "payouts")]impl PayoutLink {+ #[cfg(feature = "v1")]pub fn server(state: AppState) -> Scope {let mut route = web::scope("/payout_link").app_data(web::Data::new(state));route = route.service(@@ -1635,6 +1652,10 @@ impl PayoutLink {);route}+ #[cfg(feature = "v2")]+ pub fn server(state: AppState) -> Scope {+ todo!()+ }}pub struct Profile;@@ -1750,6 +1771,7 @@ pub struct ProfileNew;#[cfg(feature = "olap")]impl ProfileNew {+ #[cfg(feature = "v1")]pub fn server(state: AppState) -> Scope {web::scope("/account/{account_id}/profile").app_data(web::Data::new(state))@@ -1760,6 +1782,10 @@ impl ProfileNew {web::resource("/connectors").route(web::get().to(admin::connector_list_profile)),)}+ #[cfg(feature = "v2")]+ pub fn server(state: AppState) -> Scope {+ todo!()+ }}pub struct Gsm;diff --git a/crates/router/src/routes/cards_info.rs b/crates/router/src/routes/cards_info.rsindex 889b6e0ec4..1fe2d6db34 100644--- a/crates/router/src/routes/cards_info.rs+++ b/crates/router/src/routes/cards_info.rs@@ -7,6 +7,7 @@ use crate::{services::{api, authentication as auth},};+#[cfg(feature = "v1")]/// Cards Info - Retrieve////// Retrieve the card information given the card bindiff --git a/crates/router/src/routes/currency.rs b/crates/router/src/routes/currency.rsindex 4d800ddf1a..b3969509bf 100644--- a/crates/router/src/routes/currency.rs+++ b/crates/router/src/routes/currency.rs@@ -7,6 +7,7 @@ use crate::{services::{api, authentication as auth},};+#[cfg(feature = "v1")]pub async fn retrieve_forex(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {let flow = Flow::RetrieveForexFlow;Box::pin(api::server_wrap(@@ -25,6 +26,7 @@ pub async fn retrieve_forex(state: web::Data<AppState>, req: HttpRequest) -> Htt.await}+#[cfg(feature = "v1")]pub async fn convert_forex(state: web::Data<AppState>,req: HttpRequest,diff --git a/crates/router/src/routes/disputes.rs b/crates/router/src/routes/disputes.rsindex 5577bb96ef..1935b8cd00 100644--- a/crates/router/src/routes/disputes.rs+++ b/crates/router/src/routes/disputes.rs@@ -13,6 +13,7 @@ use crate::{types::api::disputes as dispute_types,};+#[cfg(feature = "v1")]/// Disputes - Retrieve Dispute#[utoipa::path(get,@@ -109,6 +110,7 @@ pub async fn retrieve_disputes_list(.await}+#[cfg(feature = "v1")]/// Disputes - List Disputes for The Given Business Profiles#[utoipa::path(get,@@ -200,6 +202,7 @@ pub async fn get_disputes_filters(state: web::Data<AppState>, req: HttpRequest).await}+#[cfg(feature = "v1")]/// Disputes - Disputes Filters Profile#[utoipa::path(get,@@ -241,6 +244,7 @@ pub async fn get_disputes_filters_profile(.await}+#[cfg(feature = "v1")]/// Disputes - Accept Dispute#[utoipa::path(get,@@ -291,6 +295,8 @@ pub async fn accept_dispute()).await}++#[cfg(feature = "v1")]/// Disputes - Submit Dispute Evidence#[utoipa::path(post,@@ -336,6 +342,7 @@ pub async fn submit_dispute_evidence()).await}+#[cfg(feature = "v1")]/// Disputes - Attach Evidence to Dispute////// To attach an evidence file to dispute@@ -390,6 +397,7 @@ pub async fn attach_dispute_evidence(.await}+#[cfg(feature = "v1")]/// Disputes - Retrieve Dispute#[utoipa::path(get,@@ -506,6 +514,7 @@ pub async fn get_disputes_aggregate(.await}+#[cfg(feature = "v1")]#[instrument(skip_all, fields(flow = ?Flow::DisputesAggregate))]pub async fn get_disputes_aggregate_profile(state: web::Data<AppState>,diff --git a/crates/router/src/routes/files.rs b/crates/router/src/routes/files.rsindex 2ebb1176ae..e68a7a63b3 100644--- a/crates/router/src/routes/files.rs+++ b/crates/router/src/routes/files.rs@@ -12,6 +12,7 @@ use crate::{types::api::files,};+#[cfg(feature = "v1")]/// Files - Create////// To create a file@@ -56,6 +57,8 @@ pub async fn files_create()).await}++#[cfg(feature = "v1")]/// Files - Delete////// To delete a file@@ -100,6 +103,8 @@ pub async fn files_delete()).await}++#[cfg(feature = "v1")]/// Files - Retrieve////// To retrieve a filediff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rsindex 3b47a06cf7..b92e2f260f 100644--- a/crates/router/src/routes/payment_methods.rs+++ b/crates/router/src/routes/payment_methods.rs@@ -86,7 +86,7 @@ pub async fn create_payment_method_api(state,&req,json_payload.into_inner(),- |state, auth: auth::AuthenticationDataV2, req, _| async move {+ |state, auth: auth::AuthenticationData, req, _| async move {Box::pin(create_payment_method(&state,req,@@ -115,7 +115,7 @@ pub async fn create_payment_method_intent_api(state,&req,json_payload.into_inner(),- |state, auth: auth::AuthenticationDataV2, req, _| async move {+ |state, auth: auth::AuthenticationData, req, _| async move {Box::pin(payment_method_intent_create(&state,req,@@ -197,7 +197,7 @@ pub async fn payment_method_update_api(state,&req,payload,- |state, auth: auth::AuthenticationDataV2, req, _| {+ |state, auth: auth::AuthenticationData, req, _| {update_payment_method(state,auth.merchant_account,@@ -230,7 +230,7 @@ pub async fn payment_method_retrieve_api(state,&req,payload,- |state, auth: auth::AuthenticationDataV2, pm, _| {+ |state, auth: auth::AuthenticationData, pm, _| {retrieve_payment_method(state, pm, auth.key_store, auth.merchant_account)},&auth::HeaderAuth(auth::ApiKeyAuth),@@ -257,7 +257,7 @@ pub async fn payment_method_delete_api(state,&req,payload,- |state, auth: auth::AuthenticationDataV2, pm, _| {+ |state, auth: auth::AuthenticationData, pm, _| {delete_payment_method(state, pm, auth.key_store, auth.merchant_account)},&auth::HeaderAuth(auth::ApiKeyAuth),@@ -726,6 +726,7 @@ pub async fn initiate_pm_collect_link_flow(.await}+#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]/// Generate a form link for collecting payment methods for a customer#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodCollectLink))]pub async fn render_pm_collect_link(@@ -861,6 +862,7 @@ pub async fn payment_method_delete_api(.await}+#[cfg(feature = "v1")]#[instrument(skip_all, fields(flow = ?Flow::ListCountriesCurrencies))]pub async fn list_countries_currencies_for_connector_payment_method(state: web::Data<AppState>,diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rsindex 62cb4a0b79..ba785fbee8 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -123,7 +123,7 @@ pub async fn payments_create_intent(state,&req,json_payload.into_inner(),- |state, auth: auth::AuthenticationDataV2, req, req_state| {+ |state, auth: auth::AuthenticationData, req, req_state| {payments::payments_intent_core::<api_types::PaymentCreateIntent,payment_types::PaymentsIntentResponse,@@ -183,7 +183,7 @@ pub async fn payments_get_intent(state,&req,payload,- |state, auth: auth::AuthenticationDataV2, req, req_state| {+ |state, auth: auth::AuthenticationData, req, req_state| {payments::payments_intent_core::<api_types::PaymentGetIntent,payment_types::PaymentsIntentResponse,@@ -2103,7 +2103,7 @@ pub async fn payment_confirm_intent(state,&req,internal_payload,- |state, auth: auth::AuthenticationDataV2, req, req_state| async {+ |state, auth: auth::AuthenticationData, req, req_state| async {let payment_id = req.global_payment_id;let request = req.payload;diff --git a/crates/router/src/routes/payout_link.rs b/crates/router/src/routes/payout_link.rsindex 8715743572..25528b21ed 100644--- a/crates/router/src/routes/payout_link.rs+++ b/crates/router/src/routes/payout_link.rs@@ -12,6 +12,7 @@ use crate::{},AppState,};+#[cfg(feature = "v1")]pub async fn render_payout_link(state: web::Data<AppState>,req: actix_web::HttpRequest,diff --git a/crates/router/src/routes/payouts.rs b/crates/router/src/routes/payouts.rsindex 62d16c4c4d..2329a48ef2 100644--- a/crates/router/src/routes/payouts.rs+++ b/crates/router/src/routes/payouts.rs@@ -49,6 +49,8 @@ pub async fn payouts_create()).await}++#[cfg(all(feature = "v1", feature = "payouts"))]/// Payouts - Retrieve#[instrument(skip_all, fields(flow = ?Flow::PayoutsRetrieve))]pub async fn payouts_retrieve(@@ -245,7 +247,7 @@ pub async fn payouts_list(}/// Payouts - List Profile-#[cfg(feature = "olap")]+#[cfg(all(feature = "olap", feature = "payouts", feature = "v1"))]#[instrument(skip_all, fields(flow = ?Flow::PayoutsList))]pub async fn payouts_list_profile(state: web::Data<AppState>,@@ -323,7 +325,7 @@ pub async fn payouts_list_by_filter(}/// Payouts - Filtered list-#[cfg(feature = "olap")]+#[cfg(all(feature = "olap", feature = "payouts", feature = "v1"))]#[instrument(skip_all, fields(flow = ?Flow::PayoutsList))]pub async fn payouts_list_by_filter_profile(state: web::Data<AppState>,@@ -394,7 +396,7 @@ pub async fn payouts_list_available_filters_for_merchant(}/// Payouts - Available filters for Profile-#[cfg(feature = "olap")]+#[cfg(all(feature = "olap", feature = "payouts", feature = "v1"))]#[instrument(skip_all, fields(flow = ?Flow::PayoutsFilter))]pub async fn payouts_list_available_filters_for_profile(state: web::Data<AppState>,diff --git a/crates/router/src/routes/profiles.rs b/crates/router/src/routes/profiles.rsindex cbb7957987..6c2e5407cf 100644--- a/crates/router/src/routes/profiles.rs+++ b/crates/router/src/routes/profiles.rs@@ -245,6 +245,7 @@ pub async fn profiles_list(.await}+#[cfg(all(feature = "olap", feature = "v1"))]#[instrument(skip_all, fields(flow = ?Flow::ProfileList))]pub async fn profiles_list_at_profile_level(state: web::Data<AppState>,@@ -337,6 +338,7 @@ pub async fn toggle_extended_card_info(.await}+#[cfg(feature = "v1")]#[instrument(skip_all, fields(flow = ?Flow::MerchantConnectorsList))]pub async fn payment_connector_list_profile(state: web::Data<AppState>,diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rsindex f3a589524a..29c7594255 100644--- a/crates/router/src/routes/routing.rs+++ b/crates/router/src/routes/routing.rs@@ -15,7 +15,7 @@ use crate::{routes::AppState,services::{api as oss_api, authentication as auth, authorization::permissions::Permission},};-#[cfg(feature = "olap")]+#[cfg(all(feature = "olap", feature = "v1"))]#[instrument(skip_all)]pub async fn routing_create_config(state: web::Data<AppState>,@@ -56,6 +56,48 @@ pub async fn routing_create_config(.await}+#[cfg(all(feature = "olap", feature = "v2"))]+#[instrument(skip_all)]+pub async fn routing_create_config(+ state: web::Data<AppState>,+ req: HttpRequest,+ json_payload: web::Json<routing_types::RoutingConfigRequest>,+ transaction_type: &enums::TransactionType,+) -> impl Responder {+ let flow = Flow::RoutingCreateConfig;+ Box::pin(oss_api::server_wrap(+ flow,+ state,+ &req,+ json_payload.into_inner(),+ |state, auth: auth::AuthenticationData, payload, _| {+ routing::create_routing_algorithm_under_profile(+ state,+ auth.merchant_account,+ auth.key_store,+ Some(auth.profile.get_id().clone()),+ payload,+ transaction_type,+ )+ },+ #[cfg(not(feature = "release"))]+ auth::auth_type(+ &auth::HeaderAuth(auth::ApiKeyAuth),+ &auth::JWTAuth {+ permission: Permission::RoutingWrite,+ minimum_entity_level: EntityType::Profile,+ },+ req.headers(),+ ),+ #[cfg(feature = "release")]+ &auth::JWTAuth {+ permission: Permission::ProfileRoutingWrite,+ },+ api_locking::LockAction::NotApplicable,+ ))+ .await+}+#[cfg(all(feature = "olap", feature = "v1"))]#[instrument(skip_all)]pub async fn routing_link_config(@@ -146,7 +188,7 @@ pub async fn routing_link_config(.await}-#[cfg(feature = "olap")]+#[cfg(all(feature = "olap", feature = "v1"))]#[instrument(skip_all)]pub async fn routing_retrieve_config(state: web::Data<AppState>,@@ -186,6 +228,47 @@ pub async fn routing_retrieve_config(.await}+#[cfg(all(feature = "olap", feature = "v2"))]+#[instrument(skip_all)]+pub async fn routing_retrieve_config(+ state: web::Data<AppState>,+ req: HttpRequest,+ path: web::Path<common_utils::id_type::RoutingId>,+) -> impl Responder {+ let algorithm_id = path.into_inner();+ let flow = Flow::RoutingRetrieveConfig;+ Box::pin(oss_api::server_wrap(+ flow,+ state,+ &req,+ algorithm_id,+ |state, auth: auth::AuthenticationData, algorithm_id, _| {+ routing::retrieve_routing_algorithm_from_algorithm_id(+ state,+ auth.merchant_account,+ auth.key_store,+ Some(auth.profile.get_id().clone()),+ algorithm_id,+ )+ },+ #[cfg(not(feature = "release"))]+ auth::auth_type(+ &auth::HeaderAuth(auth::ApiKeyAuth),+ &auth::JWTAuth {+ permission: Permission::RoutingRead,+ minimum_entity_level: EntityType::Profile,+ },+ req.headers(),+ ),+ #[cfg(feature = "release")]+ &auth::JWTAuth {+ permission: Permission::ProfileRoutingRead,+ },+ api_locking::LockAction::NotApplicable,+ ))+ .await+}+#[cfg(feature = "olap")]#[instrument(skip_all)]pub async fn list_routing_configs(@@ -226,7 +309,7 @@ pub async fn list_routing_configs(.await}-#[cfg(feature = "olap")]+#[cfg(all(feature = "olap", feature = "v1"))]#[instrument(skip_all)]pub async fn list_routing_configs_for_profile(state: web::Data<AppState>,diff --git a/crates/router/src/routes/verification.rs b/crates/router/src/routes/verification.rsindex 56ad42947c..d89f3c65cb 100644--- a/crates/router/src/routes/verification.rs+++ b/crates/router/src/routes/verification.rs@@ -8,6 +8,7 @@ use crate::{services::{api, authentication as auth, authorization::permissions::Permission},};+#[cfg(all(feature = "olap", feature = "v1"))]#[instrument(skip_all, fields(flow = ?Flow::Verification))]pub async fn apple_pay_merchant_registration(state: web::Data<AppState>,diff --git a/crates/router/src/routes/verify_connector.rs b/crates/router/src/routes/verify_connector.rsindex b8e089f066..76e10652a3 100644--- a/crates/router/src/routes/verify_connector.rs+++ b/crates/router/src/routes/verify_connector.rs@@ -8,6 +8,7 @@ use crate::{services::{self, authentication as auth, authorization::permissions::Permission},};+#[cfg(feature = "v1")]#[instrument(skip_all, fields(flow = ?Flow::VerifyPaymentConnector))]pub async fn payment_connector_verify(state: web::Data<AppState>,diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rsindex a3cc54de34..cbd694f3ac 100644--- a/crates/router/src/services/authentication.rs+++ b/crates/router/src/services/authentication.rs@@ -19,8 +19,10 @@ use router_env::logger;use serde::Serialize;use self::blacklist::BlackList;+#[cfg(all(feature = "partial-auth", feature = "v1"))]+use self::detached::ExtractedPayload;#[cfg(feature = "partial-auth")]-use self::detached::{ExtractedPayload, GetAuthType};+use self::detached::GetAuthType;use super::authorization::{self, permissions::Permission};#[cfg(feature = "olap")]use super::jwt;@@ -30,7 +32,7 @@ use crate::configs::Settings;use crate::consts;#[cfg(feature = "olap")]use crate::core::errors::UserResult;-#[cfg(feature = "partial-auth")]+#[cfg(all(feature = "partial-auth", feature = "v1"))]use crate::core::metrics;use crate::{core::{@@ -51,6 +53,7 @@ pub mod decision;#[cfg(feature = "partial-auth")]mod detached;+#[cfg(feature = "v1")]#[derive(Clone, Debug)]pub struct AuthenticationData {pub merchant_account: domain::MerchantAccount,@@ -60,7 +63,7 @@ pub struct AuthenticationData {#[cfg(feature = "v2")]#[derive(Clone, Debug)]-pub struct AuthenticationDataV2 {+pub struct AuthenticationData {pub merchant_account: domain::MerchantAccount,pub key_store: domain::MerchantKeyStore,pub profile: domain::Profile,@@ -277,6 +280,7 @@ impl AuthInfo for () {}}+#[cfg(feature = "v1")]impl AuthInfo for AuthenticationData {fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {Some(self.merchant_account.get_id())@@ -284,7 +288,7 @@ impl AuthInfo for AuthenticationData {}#[cfg(feature = "v2")]-impl AuthInfo for AuthenticationDataV2 {+impl AuthInfo for AuthenticationData {fn get_merchant_id(&self) -> Option<&id_type::MerchantId> {Some(self.merchant_account.get_id())}@@ -369,7 +373,7 @@ where#[cfg(feature = "v2")]#[async_trait]-impl<A> AuthenticateAndFetch<AuthenticationDataV2, A> for ApiKeyAuth+impl<A> AuthenticateAndFetch<AuthenticationData, A> for ApiKeyAuthwhereA: SessionStateInfo + Sync,{@@ -377,7 +381,7 @@ where&self,request_headers: &HeaderMap,state: &A,- ) -> RouterResult<(AuthenticationDataV2, AuthenticationType)> {+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {let api_key = get_api_key(request_headers).change_context(errors::ApiErrorResponse::Unauthorized)?.trim();@@ -429,7 +433,12 @@ wherelet profile = state.store()- .find_business_profile_by_profile_id(key_manager_state, &key_store, &profile_id)+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &stored_api_key.merchant_id,+ &profile_id,+ ).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;@@ -443,7 +452,7 @@ where.await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth = AuthenticationDataV2 {+ let auth = AuthenticationData {merchant_account: merchant,key_store,profile,@@ -458,6 +467,7 @@ where}}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for ApiKeyAuthwhere@@ -555,7 +565,7 @@ where}}-#[cfg(feature = "partial-auth")]+#[cfg(all(feature = "partial-auth", feature = "v1"))]#[async_trait]impl<A, I> AuthenticateAndFetch<AuthenticationData, A> for HeaderAuth<I>where@@ -642,10 +652,10 @@ where#[cfg(all(feature = "partial-auth", feature = "v2"))]#[async_trait]-impl<A, I> AuthenticateAndFetch<AuthenticationDataV2, A> for HeaderAuth<I>+impl<A, I> AuthenticateAndFetch<AuthenticationData, A> for HeaderAuth<I>whereA: SessionStateInfo + Sync,- I: AuthenticateAndFetch<AuthenticationDataV2, A>+ I: AuthenticateAndFetch<AuthenticationData, A>+ AuthenticateAndFetch<AuthenticationData, A>+ GetAuthType+ Sync@@ -655,7 +665,7 @@ where&self,request_headers: &HeaderMap,state: &A,- ) -> RouterResult<(AuthenticationDataV2, AuthenticationType)> {+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {let (auth_data, auth_type): (AuthenticationData, AuthenticationType) = self.0.authenticate_and_fetch(request_headers, state)@@ -667,14 +677,15 @@ wherelet key_manager_state = &(&state.session_state()).into();let profile = state.store()- .find_business_profile_by_profile_id(+ .find_business_profile_by_merchant_id_profile_id(key_manager_state,&auth_data.key_store,+ auth_data.merchant_account.get_id(),&profile_id,).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;- let auth_data_v2 = AuthenticationDataV2 {+ let auth_data_v2 = AuthenticationData {merchant_account: auth_data.merchant_account,key_store: auth_data.key_store,profile,@@ -683,7 +694,7 @@ where}}-#[cfg(feature = "partial-auth")]+#[cfg(all(feature = "partial-auth", feature = "v1"))]async fn construct_authentication_data<A>(state: &A,merchant_id: &id_type::MerchantId,@@ -870,6 +881,7 @@ where#[derive(Debug)]pub struct AdminApiAuthWithMerchantIdFromRoute(pub id_type::MerchantId);+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for AdminApiAuthWithMerchantIdFromRoutewhere@@ -895,27 +907,13 @@ where&state.store().get_master_key().to_vec().into(),).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::Unauthorized)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to fetch merchant key store for the merchant id")- }- })?;+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;let merchant = state.store().find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::Unauthorized)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to fetch merchant account for the merchant id")- }- })?;+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;let auth = AuthenticationData {merchant_account: merchant,@@ -930,6 +928,64 @@ where}}+#[cfg(feature = "v2")]+#[async_trait]+impl<A> AuthenticateAndFetch<AuthenticationData, A> for AdminApiAuthWithMerchantIdFromRoute+where+ A: SessionStateInfo + Sync,+{+ async fn authenticate_and_fetch(+ &self,+ request_headers: &HeaderMap,+ state: &A,+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {+ AdminApiAuth+ .authenticate_and_fetch(request_headers, state)+ .await?;++ let merchant_id = self.0.clone();+ let profile_id =+ get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?+ .get_required_value(headers::X_PROFILE_ID)?;+ let key_manager_state = &(&state.session_state()).into();+ let key_store = state+ .store()+ .get_merchant_key_store_by_merchant_id(+ key_manager_state,+ &merchant_id,+ &state.store().get_master_key().to_vec().into(),+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &merchant_id,+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let merchant = state+ .store()+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let auth = AuthenticationData {+ merchant_account: merchant,+ key_store,+ profile,+ };++ Ok((+ auth,+ AuthenticationType::AdminApiAuthWithMerchantId { merchant_id },+ ))+ }+}+/// A helper struct to extract headers from the requestpub(crate) struct HeaderMapStruct<'a> {headers: &'a HeaderMap,@@ -999,6 +1055,7 @@ impl<'a> HeaderMapStruct<'a> {#[derive(Debug)]pub struct AdminApiAuthWithMerchantIdFromHeader;+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for AdminApiAuthWithMerchantIdFromHeaderwhere@@ -1025,27 +1082,13 @@ where&state.store().get_master_key().to_vec().into(),).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::MerchantAccountNotFound)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to fetch merchant key store for the merchant id")- }- })?;+ .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;let merchant = state.store().find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::Unauthorized)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to fetch merchant account for the merchant id")- }- })?;+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;let auth = AuthenticationData {merchant_account: merchant,@@ -1059,9 +1102,69 @@ where}}+#[cfg(feature = "v2")]+#[async_trait]+impl<A> AuthenticateAndFetch<AuthenticationData, A> for AdminApiAuthWithMerchantIdFromHeader+where+ A: SessionStateInfo + Sync,+{+ async fn authenticate_and_fetch(+ &self,+ request_headers: &HeaderMap,+ state: &A,+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {+ AdminApiAuth+ .authenticate_and_fetch(request_headers, state)+ .await?;++ let merchant_id = HeaderMapStruct::new(request_headers)+ .get_id_type_from_header::<id_type::MerchantId>(headers::X_MERCHANT_ID)?;+ let profile_id =+ get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?+ .get_required_value(headers::X_PROFILE_ID)?;++ let key_manager_state = &(&state.session_state()).into();+ let key_store = state+ .store()+ .get_merchant_key_store_by_merchant_id(+ key_manager_state,+ &merchant_id,+ &state.store().get_master_key().to_vec().into(),+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &merchant_id,+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let merchant = state+ .store()+ .find_merchant_account_by_merchant_id(key_manager_state, &merchant_id, &key_store)+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let auth = AuthenticationData {+ merchant_account: merchant,+ key_store,+ profile,+ };+ Ok((+ auth,+ AuthenticationType::AdminApiAuthWithMerchantId { merchant_id },+ ))+ }+}+#[derive(Debug)]pub struct EphemeralKeyAuth;+// #[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for EphemeralKeyAuthwhere@@ -1088,6 +1191,7 @@ where#[derive(Debug)]pub struct MerchantIdAuth(pub id_type::MerchantId);+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for MerchantIdAuthwhere@@ -1107,26 +1211,13 @@ where&state.store().get_master_key().to_vec().into(),).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::Unauthorized)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to fetch merchant key store for the merchant id")- }- })?;+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;let merchant = state.store().find_merchant_account_by_merchant_id(key_manager_state, &self.0, &key_store).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::Unauthorized)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- }- })?;+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;let auth = AuthenticationData {merchant_account: merchant,@@ -1142,6 +1233,61 @@ where}}+#[cfg(feature = "v2")]+#[async_trait]+impl<A> AuthenticateAndFetch<AuthenticationData, A> for MerchantIdAuth+where+ A: SessionStateInfo + Sync,+{+ async fn authenticate_and_fetch(+ &self,+ request_headers: &HeaderMap,+ state: &A,+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {+ let key_manager_state = &(&state.session_state()).into();+ let profile_id =+ get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?+ .get_required_value(headers::X_PROFILE_ID)?;+ let key_store = state+ .store()+ .get_merchant_key_store_by_merchant_id(+ key_manager_state,+ &self.0,+ &state.store().get_master_key().to_vec().into(),+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &self.0,+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let merchant = state+ .store()+ .find_merchant_account_by_merchant_id(key_manager_state, &self.0, &key_store)+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;++ let auth = AuthenticationData {+ merchant_account: merchant,+ key_store,+ profile,+ };+ Ok((+ auth.clone(),+ AuthenticationType::MerchantId {+ merchant_id: auth.merchant_account.get_id().clone(),+ },+ ))+ }+}+#[derive(Debug)]pub struct PublishableKeyAuth;@@ -1152,6 +1298,7 @@ impl GetAuthType for PublishableKeyAuth {}}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for PublishableKeyAuthwhere@@ -1169,19 +1316,16 @@ where.store().find_merchant_account_by_publishable_key(key_manager_state, publishable_key).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::Unauthorized)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- }- })- .map(|auth| {+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)+ .map(|(merchant_account, key_store)| {+ let merchant_id = merchant_account.get_id().clone();(- auth.clone(),- AuthenticationType::PublishableKey {- merchant_id: auth.merchant_account.get_id().clone(),+ AuthenticationData {+ merchant_account,+ key_store,+ profile_id: None,},+ AuthenticationType::PublishableKey { merchant_id },)})}@@ -1189,7 +1333,7 @@ where#[cfg(feature = "v2")]#[async_trait]-impl<A> AuthenticateAndFetch<AuthenticationDataV2, A> for PublishableKeyAuth+impl<A> AuthenticateAndFetch<AuthenticationData, A> for PublishableKeyAuthwhereA: SessionStateInfo + Sync,{@@ -1197,43 +1341,34 @@ where&self,request_headers: &HeaderMap,state: &A,- ) -> RouterResult<(AuthenticationDataV2, AuthenticationType)> {+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {let publishable_key =get_api_key(request_headers).change_context(errors::ApiErrorResponse::Unauthorized)?;let key_manager_state = &(&state.session_state()).into();- let authentication_data = state+ let profile_id =+ get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?+ .get_required_value(headers::X_PROFILE_ID)?;++ let (merchant_account, key_store) = state.store().find_merchant_account_by_publishable_key(key_manager_state, publishable_key).await- .map_err(|e| {- if e.current_context().is_db_not_found() {- e.change_context(errors::ApiErrorResponse::Unauthorized)- } else {- e.change_context(errors::ApiErrorResponse::InternalServerError)- }- })?;-- let profile_id = HeaderMapStruct::new(request_headers)- .get_id_type_from_header::<id_type::ProfileId>(headers::X_PROFILE_ID)?;-+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let merchant_id = merchant_account.get_id().clone();let profile = state.store()- .find_business_profile_by_profile_id(+ .find_business_profile_by_merchant_id_profile_id(key_manager_state,- &authentication_data.key_store,+ &key_store,+ &merchant_id,&profile_id,).await- .to_not_found_response(errors::ApiErrorResponse::ProfileNotFound {- id: profile_id.get_string_repr().to_owned(),- })?;-- let merchant_id = authentication_data.merchant_account.get_id().clone();-+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;Ok((- AuthenticationDataV2 {- merchant_account: authentication_data.merchant_account,- key_store: authentication_data.key_store,+ AuthenticationData {+ merchant_account,+ key_store,profile,},AuthenticationType::PublishableKey { merchant_id },@@ -1445,6 +1580,7 @@ where}}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthMerchantFromHeaderwhere@@ -1459,7 +1595,6 @@ whereif payload.check_in_blacklist(state).await? {return Err(errors::ApiErrorResponse::InvalidJwtToken.into());}-let role_info = authorization::get_role_info(state, &payload).await?;authorization::check_permission(&self.required_permission, &role_info)?;@@ -1511,6 +1646,86 @@ where}}+#[cfg(feature = "v2")]+#[async_trait]+impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthMerchantFromHeader+where+ A: SessionStateInfo + Sync,+{+ async fn authenticate_and_fetch(+ &self,+ request_headers: &HeaderMap,+ state: &A,+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {+ let payload = parse_jwt_payload::<A, AuthToken>(request_headers, state).await?;+ if payload.check_in_blacklist(state).await? {+ return Err(errors::ApiErrorResponse::InvalidJwtToken.into());+ }+ let profile_id =+ get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?+ .get_required_value(headers::X_PROFILE_ID)?;++ let role_info = authorization::get_role_info(state, &payload).await?;+ authorization::check_permission(&self.required_permission, &role_info)?;++ let merchant_id_from_header = HeaderMapStruct::new(request_headers)+ .get_id_type_from_header::<id_type::MerchantId>(headers::X_MERCHANT_ID)?;++ // Check if token has access to MerchantId that has been requested through headers+ if payload.merchant_id != merchant_id_from_header {+ return Err(report!(errors::ApiErrorResponse::InvalidJwtToken));+ }++ let key_manager_state = &(&state.session_state()).into();++ let key_store = state+ .store()+ .get_merchant_key_store_by_merchant_id(+ key_manager_state,+ &payload.merchant_id,+ &state.store().get_master_key().to_vec().into(),+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)+ .attach_printable("Failed to fetch merchant key store for the merchant id")?;++ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &payload.merchant_id,+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let merchant = state+ .store()+ .find_merchant_account_by_merchant_id(+ key_manager_state,+ &payload.merchant_id,+ &key_store,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)+ .attach_printable("Failed to fetch merchant account for the merchant id")?;++ let auth = AuthenticationData {+ merchant_account: merchant,+ key_store,+ profile,+ };++ Ok((+ auth,+ AuthenticationType::MerchantJwt {+ merchant_id: payload.merchant_id,+ user_id: Some(payload.user_id),+ },+ ))+ }+}+#[async_trait]impl<A> AuthenticateAndFetch<(), A> for JWTAuthMerchantFromRoutewhere@@ -1543,6 +1758,7 @@ where}}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthMerchantFromRoutewhere@@ -1602,12 +1818,86 @@ where))}}++#[cfg(feature = "v2")]+#[async_trait]+impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthMerchantFromRoute+where+ A: SessionStateInfo + Sync,+{+ async fn authenticate_and_fetch(+ &self,+ request_headers: &HeaderMap,+ state: &A,+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {+ let payload = parse_jwt_payload::<A, AuthToken>(request_headers, state).await?;+ let profile_id =+ get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?+ .get_required_value(headers::X_PROFILE_ID)?;+ if payload.check_in_blacklist(state).await? {+ return Err(errors::ApiErrorResponse::InvalidJwtToken.into());+ }++ if payload.merchant_id != self.merchant_id {+ return Err(report!(errors::ApiErrorResponse::InvalidJwtToken));+ }++ let role_info = authorization::get_role_info(state, &payload).await?;+ authorization::check_permission(&self.required_permission, &role_info)?;++ let key_manager_state = &(&state.session_state()).into();+ let key_store = state+ .store()+ .get_merchant_key_store_by_merchant_id(+ key_manager_state,+ &payload.merchant_id,+ &state.store().get_master_key().to_vec().into(),+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)+ .attach_printable("Failed to fetch merchant key store for the merchant id")?;+ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &payload.merchant_id,+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let merchant = state+ .store()+ .find_merchant_account_by_merchant_id(+ key_manager_state,+ &payload.merchant_id,+ &key_store,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)+ .attach_printable("Failed to fetch merchant account for the merchant id")?;++ let auth = AuthenticationData {+ merchant_account: merchant,+ key_store,+ profile,+ };+ Ok((+ auth.clone(),+ AuthenticationType::MerchantJwt {+ merchant_id: auth.merchant_account.get_id().clone(),+ user_id: Some(payload.user_id),+ },+ ))+ }+}pub struct JWTAuthMerchantAndProfileFromRoute {pub merchant_id: id_type::MerchantId,pub profile_id: id_type::ProfileId,pub required_permission: Permission,}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthMerchantAndProfileFromRoutewhere@@ -1682,6 +1972,7 @@ pub struct JWTAuthProfileFromRoute {pub required_permission: Permission,}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthProfileFromRoutewhere@@ -1759,6 +2050,76 @@ where}}+#[cfg(feature = "v2")]+#[async_trait]+impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthProfileFromRoute+where+ A: SessionStateInfo + Sync,+{+ async fn authenticate_and_fetch(+ &self,+ request_headers: &HeaderMap,+ state: &A,+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {+ let payload = parse_jwt_payload::<A, AuthToken>(request_headers, state).await?;+ if payload.check_in_blacklist(state).await? {+ return Err(errors::ApiErrorResponse::InvalidJwtToken.into());+ }+ let profile_id =+ get_id_type_by_key_from_headers(headers::X_PROFILE_ID.to_string(), request_headers)?+ .get_required_value(headers::X_PROFILE_ID)?;++ let role_info = authorization::get_role_info(state, &payload).await?;+ authorization::check_permission(&self.required_permission, &role_info)?;++ let key_manager_state = &(&state.session_state()).into();+ let key_store = state+ .store()+ .get_merchant_key_store_by_merchant_id(+ key_manager_state,+ &payload.merchant_id,+ &state.store().get_master_key().to_vec().into(),+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)+ .attach_printable("Failed to fetch merchant key store for the merchant id")?;++ let profile = state+ .store()+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &payload.merchant_id,+ &profile_id,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;+ let merchant = state+ .store()+ .find_merchant_account_by_merchant_id(+ key_manager_state,+ &payload.merchant_id,+ &key_store,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken)+ .attach_printable("Failed to fetch merchant account for the merchant id")?;++ let auth = AuthenticationData {+ merchant_account: merchant,+ key_store,+ profile,+ };+ Ok((+ auth.clone(),+ AuthenticationType::MerchantJwt {+ merchant_id: auth.merchant_account.get_id().clone(),+ user_id: Some(payload.user_id),+ },+ ))+ }+}+pub async fn parse_jwt_payload<A, T>(headers: &HeaderMap, state: &A) -> RouterResult<T>whereT: serde::de::DeserializeOwned,@@ -1777,6 +2138,7 @@ wheredecode_jwt(&token, state).await}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthwhere@@ -1835,7 +2197,7 @@ where#[cfg(feature = "v2")]#[async_trait]-impl<A> AuthenticateAndFetch<AuthenticationDataV2, A> for JWTAuth+impl<A> AuthenticateAndFetch<AuthenticationData, A> for JWTAuthwhereA: SessionStateInfo + Sync,{@@ -1843,7 +2205,7 @@ where&self,request_headers: &HeaderMap,state: &A,- ) -> RouterResult<(AuthenticationDataV2, AuthenticationType)> {+ ) -> RouterResult<(AuthenticationData, AuthenticationType)> {let payload = parse_jwt_payload::<A, AuthToken>(request_headers, state).await?;if payload.check_in_blacklist(state).await? {return Err(errors::ApiErrorResponse::InvalidJwtToken.into());@@ -1869,7 +2231,12 @@ wherelet profile = state.store()- .find_business_profile_by_profile_id(key_manager_state, &key_store, &profile_id)+ .find_business_profile_by_merchant_id_profile_id(+ key_manager_state,+ &key_store,+ &payload.merchant_id,+ &profile_id,+ ).await.to_not_found_response(errors::ApiErrorResponse::Unauthorized)?;let merchant = state@@ -1883,7 +2250,7 @@ where.to_not_found_response(errors::ApiErrorResponse::InvalidJwtToken).attach_printable("Failed to fetch merchant account for the merchant id")?;let merchant_id = merchant.get_id().clone();- let auth = AuthenticationDataV2 {+ let auth = AuthenticationData {merchant_account: merchant,key_store,profile,@@ -1900,6 +2267,7 @@ wherepub type AuthenticationDataWithUserId = (AuthenticationData, String);+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationDataWithUserId, A> for JWTAuthwhere@@ -2009,6 +2377,7 @@ where}}+#[cfg(feature = "v1")]#[async_trait]impl<A> AuthenticateAndFetch<AuthenticationData, A> for DashboardNoPermissionAuthwherediff --git a/crates/router/tests/connectors/payme.rs b/crates/router/tests/connectors/payme.rsindex 3b4cf5195f..dbc3795e7f 100644--- a/crates/router/tests/connectors/payme.rs+++ b/crates/router/tests/connectors/payme.rs@@ -1,7 +1,8 @@use std::str::FromStr;-use api_models::payments::{Address, AddressDetails, OrderDetailsWithAmount};+use api_models::payments::{Address, AddressDetails};use common_utils::{pii::Email, types::MinorUnit};+use diesel_models::types::OrderDetailsWithAmount;use masking::Secret;use router::types::{self, domain, storage::enums, PaymentAddress};diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rsindex da83bdc7d4..de60c5e8d8 100644--- a/crates/router/tests/connectors/zen.rs+++ b/crates/router/tests/connectors/zen.rs@@ -1,8 +1,8 @@use std::str::FromStr;-use api_models::payments::OrderDetailsWithAmount;use cards::CardNumber;use common_utils::{pii::Email, types::MinorUnit};+use hyperswitch_domain_models::types::OrderDetailsWithAmount;use masking::Secret;use router::types::{self, domain, storage::enums};