Skip to content

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

refactor(mandate): move mandate types from api_models to hyperswitch_domain_models (#12337)

Ayush Anand860b9782f71b
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 94dc81a463..733f435943 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -2362,197 +2362,6 @@ pub struct VerifyRequest {
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
}
-#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Eq, PartialEq, Copy)]
-#[serde(rename_all = "snake_case")]
-pub enum MandateTransactionType {
- NewMandateTransaction,
- RecurringMandateTransaction,
-}
-
-#[derive(Default, Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
-pub struct MandateIds {
- pub mandate_id: Option<String>,
- pub mandate_reference_id: Option<MandateReferenceId>,
-}
-
-impl MandateIds {
- pub fn is_network_transaction_id_flow(&self) -> bool {
- matches!(
- self.mandate_reference_id,
- Some(MandateReferenceId::NetworkMandateId(_))
- )
- }
-
- pub fn get_connector_mandate_id(&self) -> Option<String> {
- match &self.mandate_reference_id {
- Some(MandateReferenceId::ConnectorMandateId(data)) => data.connector_mandate_id.clone(),
- _ => None,
- }
- }
-
- pub fn get_connector_mandate_metadata(&self) -> Option<pii::SecretSerdeValue> {
- match &self.mandate_reference_id {
- Some(MandateReferenceId::ConnectorMandateId(data)) => data.mandate_metadata.clone(),
- _ => None,
- }
- }
-
- pub fn get_updated_mandate_details_of_connector_mandate_id(
- &self,
- ) -> Option<UpdatedMandateDetails> {
- match &self.mandate_reference_id {
- Some(MandateReferenceId::ConnectorMandateId(data)) => {
- data.updated_mandate_details.clone()
- }
- _ => None,
- }
- }
-}
-
-#[derive(Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
-pub enum MandateReferenceId {
- ConnectorMandateId(ConnectorMandateReferenceId), // mandate_id send by connector
- NetworkMandateId(NetworkMandateIdRef), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with card data
- NetworkTokenWithNTI(NetworkTokenWithNTIRef), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with network token data
- CardWithLimitedData, // indicates the recurring transaction is done by card data only
-}
-
-/// Scheme-level identifiers for PSP-agnostic MIT flows (raw card path).
-#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
-pub struct NetworkMandateIdRef {
- pub network_transaction_id: String,
- /// The Mastercard Transaction Link Identifier (TLID) provided by the card network during a CIT (Customer Initiated Transaction),
- /// when `setup_future_usage` is set to `off_session`.
- pub transaction_link_id: Option<String>,
-}
-
-#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
-pub struct NetworkTokenWithNTIRef {
- pub network_transaction_id: String,
- /// The Mastercard Transaction Link Identifier (TLID) provided by the card network during a CIT (Customer Initiated Transaction),
- /// when `setup_future_usage` is set to `off_session`.
- pub transaction_link_id: Option<String>,
- pub token_exp_month: Option<Secret<String>>,
- pub token_exp_year: Option<Secret<String>>,
-}
-
-#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
-pub struct ConnectorMandateReferenceId {
- connector_mandate_id: Option<String>,
- payment_method_id: Option<String>,
- update_history: Option<Vec<UpdateHistory>>,
- mandate_metadata: Option<pii::SecretSerdeValue>,
- connector_mandate_request_reference_id: Option<String>,
- updated_mandate_details: Option<UpdatedMandateDetails>,
-}
-
-#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Eq, PartialEq)]
-pub struct UpdatedMandateDetails {
- pub card_network: Option<common_enums::CardNetwork>,
- pub card_exp_month: Option<Secret<String>>,
- pub card_exp_year: Option<Secret<String>>,
- pub card_isin: Option<String>,
-}
-
-impl From<AdditionalCardInfo> for UpdatedMandateDetails {
- fn from(card_info: AdditionalCardInfo) -> Self {
- Self {
- card_network: card_info.card_network,
- card_exp_month: card_info.card_exp_month,
- card_exp_year: card_info.card_exp_year,
- card_isin: card_info.card_isin,
- }
- }
-}
-
-impl From<&UpdatedMandateDetails> for AdditionalCardInfo {
- fn from(card_info: &UpdatedMandateDetails) -> Self {
- Self {
- card_network: card_info.card_network.clone(),
- card_exp_month: card_info.card_exp_month.clone(),
- card_exp_year: card_info.card_exp_year.clone(),
- card_isin: card_info.card_isin.clone(),
- card_issuer: None,
- card_type: None,
- card_issuing_country: None,
- card_issuing_country_code: None,
- bank_code: None,
- last4: None,
- card_extended_bin: None,
- card_holder_name: None,
- payment_checks: None,
- authentication_data: None,
- is_regulated: None,
- signature_network: None,
- auth_code: None,
- }
- }
-}
-
-impl ConnectorMandateReferenceId {
- pub fn new(
- connector_mandate_id: Option<String>,
- payment_method_id: Option<String>,
- update_history: Option<Vec<UpdateHistory>>,
- mandate_metadata: Option<pii::SecretSerdeValue>,
- connector_mandate_request_reference_id: Option<String>,
- updated_mandate_details: Option<UpdatedMandateDetails>,
- ) -> Self {
- Self {
- connector_mandate_id,
- payment_method_id,
- update_history,
- mandate_metadata,
- connector_mandate_request_reference_id,
- updated_mandate_details,
- }
- }
-
- pub fn get_connector_mandate_id(&self) -> Option<String> {
- self.connector_mandate_id.clone()
- }
- pub fn get_payment_method_id(&self) -> Option<String> {
- self.payment_method_id.clone()
- }
- pub fn get_mandate_metadata(&self) -> Option<pii::SecretSerdeValue> {
- self.mandate_metadata.clone()
- }
- pub fn get_connector_mandate_request_reference_id(&self) -> Option<String> {
- self.connector_mandate_request_reference_id.clone()
- }
-
- pub fn update(
- &mut self,
- connector_mandate_id: Option<String>,
- payment_method_id: Option<String>,
- update_history: Option<Vec<UpdateHistory>>,
- mandate_metadata: Option<pii::SecretSerdeValue>,
- connector_mandate_request_reference_id: Option<String>,
- ) {
- self.connector_mandate_id = connector_mandate_id.or(self.connector_mandate_id.clone());
- self.payment_method_id = payment_method_id.or(self.payment_method_id.clone());
- self.update_history = update_history.or(self.update_history.clone());
- self.mandate_metadata = mandate_metadata.or(self.mandate_metadata.clone());
- self.connector_mandate_request_reference_id = connector_mandate_request_reference_id
- .or(self.connector_mandate_request_reference_id.clone());
- }
-}
-#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Eq, PartialEq)]
-pub struct UpdateHistory {
- pub connector_mandate_id: Option<String>,
- pub payment_method_id: String,
- pub original_payment_id: Option<id_type::PaymentId>,
-}
-
-impl MandateIds {
- pub fn new(mandate_id: String) -> Self {
- Self {
- mandate_id: Some(mandate_id),
- mandate_reference_id: None,
- }
- }
-}
-
/// Passing this object during payments creates a mandate. The mandate_type sub object is passed by the server.
// The fields on this struct are optional, as we want to allow the merchant to provide partial
// information about creating mandates
diff --git a/crates/hyperswitch_connectors/src/connectors/aci/transformers.rs b/crates/hyperswitch_connectors/src/connectors/aci/transformers.rs
index 08e6a4d584..23d08fe8a3 100644
--- a/crates/hyperswitch_connectors/src/connectors/aci/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/aci/transformers.rs
@@ -6,6 +6,7 @@ use common_types::payments::{ApplePayPredecryptData, GPayPredecryptData};
use common_utils::{id_type, pii::Email, request::Method, types::StringMajorUnit};
use error_stack::report;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
ApplePayWalletData, BankRedirectData, Card, GooglePayWalletData, NetworkTokenData,
PayLaterData, PaymentMethodData, SamsungPayWalletData, WalletData,
@@ -1116,14 +1117,14 @@ impl
impl
TryFrom<(
&AciRouterData<&PaymentsAuthorizeRouterData>,
- api_models::payments::MandateIds,
+ mandates::MandateIds,
)> for AciPaymentsRequest
{
type Error = Error;
fn try_from(
value: (
&AciRouterData<&PaymentsAuthorizeRouterData>,
- api_models::payments::MandateIds,
+ mandates::MandateIds,
),
) -> Result<Self, Self::Error> {
let (item, _mandate_data) = value;
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
index b0c879ddd0..e34f13249b 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
@@ -19,6 +19,7 @@ use common_utils::{
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
BankDebitData, BankRedirectData, BankTransferData, Card, CardRedirectData, GiftCardData,
NetworkTokenData, PayLaterData, PaymentMethodData, VoucherData, WalletData,
@@ -2178,14 +2179,14 @@ fn get_additional_data(
.mandate_reference_id
.as_ref()
.and_then(|mandate_ref_id| match mandate_ref_id {
- payments::MandateReferenceId::NetworkMandateId(ref_data) => {
+ mandates::MandateReferenceId::NetworkMandateId(ref_data) => {
ref_data.transaction_link_id.clone()
}
- payments::MandateReferenceId::NetworkTokenWithNTI(ref_data) => {
+ mandates::MandateReferenceId::NetworkTokenWithNTI(ref_data) => {
ref_data.transaction_link_id.clone()
}
- payments::MandateReferenceId::ConnectorMandateId(_)
- | payments::MandateReferenceId::CardWithLimitedData => None,
+ mandates::MandateReferenceId::ConnectorMandateId(_)
+ | mandates::MandateReferenceId::CardWithLimitedData => None,
})
});
@@ -3132,14 +3133,14 @@ fn get_adyen_metadata(metadata: Option<serde_json::Value>) -> AdyenMetadata {
impl
TryFrom<(
&AdyenRouterData<&PaymentsAuthorizeRouterData>,
- payments::MandateReferenceId,
+ mandates::MandateReferenceId,
)> for AdyenPaymentRequest<'_>
{
type Error = Error;
fn try_from(
value: (
&AdyenRouterData<&PaymentsAuthorizeRouterData>,
- payments::MandateReferenceId,
+ mandates::MandateReferenceId,
),
) -> Result<Self, Self::Error> {
let (item, mandate_ref_id) = value;
@@ -3161,7 +3162,7 @@ impl
.transpose()?;
let test_holder_name = testing_data.and_then(|test_data| test_data.holder_name);
let payment_method = match mandate_ref_id {
- payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids) => {
+ mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids) => {
let adyen_mandate = AdyenMandate {
payment_type: match payment_method_type {
Some(pm_type) => PaymentType::try_from(&pm_type)?,
@@ -3178,7 +3179,7 @@ impl
Box::new(adyen_mandate),
))
}
- payments::MandateReferenceId::NetworkMandateId(network_mandate_id) => {
+ mandates::MandateReferenceId::NetworkMandateId(network_mandate_id) => {
match item.router_data.request.payment_method_data {
PaymentMethodData::CardDetailsForNetworkTransactionId(
ref card_details_for_network_transaction_id,
@@ -3244,7 +3245,7 @@ impl
}
}
}
- payments::MandateReferenceId::NetworkTokenWithNTI(network_mandate_id) => {
+ mandates::MandateReferenceId::NetworkTokenWithNTI(network_mandate_id) => {
match item.router_data.request.payment_method_data {
PaymentMethodData::NetworkToken(ref token_data) => {
let card_issuer = token_data.get_card_issuer()?;
@@ -3295,7 +3296,7 @@ impl
}
}
}
- payments::MandateReferenceId::CardWithLimitedData => {
+ mandates::MandateReferenceId::CardWithLimitedData => {
Err(errors::ConnectorError::NotSupported {
message: "Card Only MIT for payment method".to_string(),
connector: "Adyen",
diff --git a/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
index 574f016756..b2d91eb947 100644
--- a/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
@@ -12,6 +12,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{Card, PaymentMethodData, WalletData},
router_data::{
AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,
@@ -814,17 +815,17 @@ impl TryFrom<&AuthorizedotnetRouterData<&PaymentsAuthorizeRouterData>>
.clone()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id)
{
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(network_trans_id)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_trans_id)) => {
TransactionRequest::try_from((
item,
network_trans_id.network_transaction_id.clone(),
))?
}
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_id,
- )) => TransactionRequest::try_from((item, connector_mandate_id))?,
- Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(api_models::payments::MandateReferenceId::CardWithLimitedData) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_id)) => {
+ TransactionRequest::try_from((item, connector_mandate_id))?
+ }
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
))?
@@ -1007,14 +1008,14 @@ fn get_address_line(
impl
TryFrom<(
&AuthorizedotnetRouterData<&PaymentsAuthorizeRouterData>,
- api_models::payments::ConnectorMandateReferenceId,
+ mandates::ConnectorMandateReferenceId,
)> for TransactionRequest
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
(item, connector_mandate_id): (
&AuthorizedotnetRouterData<&PaymentsAuthorizeRouterData>,
- api_models::payments::ConnectorMandateReferenceId,
+ mandates::ConnectorMandateReferenceId,
),
) -> Result<Self, Self::Error> {
let mandate_id = connector_mandate_id
diff --git a/crates/hyperswitch_connectors/src/connectors/celero/transformers.rs b/crates/hyperswitch_connectors/src/connectors/celero/transformers.rs
index c67cd7d448..bb96ef5c01 100644
--- a/crates/hyperswitch_connectors/src/connectors/celero/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/celero/transformers.rs
@@ -2,6 +2,7 @@ use common_enums::{enums, Currency};
use common_utils::{id_type::CustomerId, pii::Email, types::MinorUnit};
use hyperswitch_domain_models::{
address::Address as DomainAddress,
+ mandates,
payment_method_data::PaymentMethodData,
router_data::{
AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,
@@ -308,9 +309,7 @@ fn determine_cit_mit_fields(
.and_then(|mandate_ids| mandate_ids.mandate_reference_id)
{
// If there's a connector mandate ID, this is a MIT (Merchant Initiated Transaction)
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_id,
- )) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_id)) => {
mandate_fields.card_on_file_indicator = Some(CardOnFileIndicator::RecurringPayment);
mandate_fields.initiated_by = Some(InitiatedBy::Merchant); // This is a MIT
mandate_fields.stored_credential_indicator = Some(StoredCredentialIndicator::Used);
@@ -326,9 +325,9 @@ fn determine_cit_mit_fields(
))
}
// For other mandate types that might not be supported
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
- | Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(api_models::payments::MandateReferenceId::CardWithLimitedData) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData) => {
// These might need different handling or return an error
Err(errors::ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("Celero"),
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
index 778d5ab079..baa0d012d0 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
@@ -1,4 +1,3 @@
-use api_models::payments;
#[cfg(feature = "payouts")]
use api_models::payouts::PayoutMethodData;
use base64::Engine;
@@ -20,6 +19,7 @@ use hyperswitch_domain_models::{
types::PayoutsRouterData,
};
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
ApplePayWalletData, GooglePayWalletData, NetworkTokenData, PaymentMethodData,
SamsungPayWalletData, WalletData,
@@ -962,7 +962,7 @@ impl
.clone()
.and_then(|mandate_id| mandate_id.mandate_reference_id)
{
- Some(payments::MandateReferenceId::ConnectorMandateId(_)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(_)) => {
let original_amount = item
.router_data
.recurring_mandate_payment_data
@@ -1009,7 +1009,7 @@ impl
}),
)
}
- Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
let (original_amount, original_currency) = match network
.clone()
.map(|network| network.to_lowercase())
@@ -1079,7 +1079,7 @@ impl
}),
)
}
- Some(payments::MandateReferenceId::NetworkTokenWithNTI(mandate_data)) => {
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(mandate_data)) => {
let (original_amount, original_currency) = match network
.clone()
.map(|network| network.to_lowercase())
@@ -1149,7 +1149,7 @@ impl
}),
)
}
- Some(payments::MandateReferenceId::CardWithLimitedData) | None => {
+ Some(mandates::MandateReferenceId::CardWithLimitedData) | None => {
(None, None, None)
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
index d7e6d1ca41..b66d015d0e 100644
--- a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
@@ -5,6 +5,7 @@ use common_enums::{enums, PaymentMethod};
use common_utils::{ext_traits::ValueExt, pii::Email, types::MinorUnit};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{BankDebitData, PaymentMethodData},
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
@@ -285,7 +286,7 @@ impl TryFrom<&DeutschebankRouterData<&PaymentsAuthorizeRouterData>>
.into()),
}
}
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
let mandate_metadata: DeutschebankMandateMetadata = mandate_data
.get_mandate_metadata()
.ok_or(errors::ConnectorError::MissingConnectorMandateMetadata)?
@@ -309,9 +310,9 @@ impl TryFrom<&DeutschebankRouterData<&PaymentsAuthorizeRouterData>>
},
}))
}
- Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
- | Some(api_models::payments::MandateReferenceId::CardWithLimitedData) => {
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("deutschebank"),
)
diff --git a/crates/hyperswitch_connectors/src/connectors/finix/transformers.rs b/crates/hyperswitch_connectors/src/connectors/finix/transformers.rs
index 571aabdeb7..6b20044b04 100644
--- a/crates/hyperswitch_connectors/src/connectors/finix/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/finix/transformers.rs
@@ -1,7 +1,8 @@
+use hyperswitch_domain_models::mandates::MandateReferenceId;
pub mod request;
pub mod response;
use api_models::{
- payments::{MandateReferenceId, PaymentIdType},
+ payments::PaymentIdType,
webhooks::{IncomingWebhookEvent, RefundIdType},
};
use base64::Engine;
diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
index 360ea572fc..6617a4455f 100644
--- a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
@@ -14,6 +14,7 @@ use common_utils::{
};
use error_stack::{Report, ResultExt};
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
BankRedirectData, Card, CardDetailsForNetworkTransactionId, GooglePayWalletData,
PaymentMethodData, RealTimePaymentData, WalletData,
@@ -622,7 +623,7 @@ impl TryFrom<&FiuuRouterData<&PaymentsAuthorizeRouterData>> for FiuuPaymentReque
}
},
// Card payments using network transaction ID
- Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
match item.router_data.request.payment_method_data {
PaymentMethodData::CardDetailsForNetworkTransactionId(ref raw_card_details) => {
FiuuPaymentMethodData::try_from((
diff --git a/crates/hyperswitch_connectors/src/connectors/globalpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/globalpay/transformers.rs
index 3e4431da22..497d7c3179 100644
--- a/crates/hyperswitch_connectors/src/connectors/globalpay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/globalpay/transformers.rs
@@ -7,7 +7,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
- payment_method_data,
+ mandates, payment_method_data,
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, PaymentMethodToken, RouterData},
router_flow_types::{Execute, RSync},
router_request_types::ResponseId,
@@ -102,7 +102,7 @@ impl TryFrom<&GlobalPayRouterData<&PaymentsAuthorizeRouterData>> for GlobalpayPa
.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
+ Some(mandates::MandateReferenceId::ConnectorMandateId(
connector_mandate_ids,
)) => connector_mandate_ids.get_connector_mandate_id(),
_ => None,
diff --git a/crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
index 78f29ead55..bb0d4d155b 100644
--- a/crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
@@ -7,6 +7,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{BankRedirectData, PayLaterData, PaymentMethodData, WalletData},
router_data::{ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::refunds::{Execute, RSync},
@@ -924,7 +925,7 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>>
.mandate_id
.clone()
.and_then(|mandate_ids| match mandate_ids.mandate_reference_id {
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
+ Some(mandates::MandateReferenceId::ConnectorMandateId(
connector_mandate_ids,
)) => connector_mandate_ids
.get_connector_mandate_id()
diff --git a/crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
index f25d981a4a..aa993be571 100644
--- a/crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
@@ -12,6 +12,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::PaymentMethodData,
router_data::{ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
@@ -977,7 +978,7 @@ impl TryFrom<&NexixpayRouterData<&PaymentsAuthorizeRouterData>> for NexixpayPaym
}
}
}
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
let contract_id = Secret::new(
mandate_data
.get_connector_mandate_request_reference_id()
@@ -992,9 +993,9 @@ impl TryFrom<&NexixpayRouterData<&PaymentsAuthorizeRouterData>> for NexixpayPaym
},
)))
}
- Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
- | Some(api_models::payments::MandateReferenceId::CardWithLimitedData) => {
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData) => {
Err(errors::ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("nexixpay"),
)
diff --git a/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs
index 520336ca50..e412498555 100644
--- a/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs
@@ -5,6 +5,7 @@ use common_enums::{AttemptStatus, AuthenticationType, CountryAlpha2, Currency, R
use common_utils::{errors::CustomResult, ext_traits::XmlExt, pii::Email, types::FloatMajorUnit};
use error_stack::{report, Report, ResultExt};
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
ApplePayWalletData, Card, GooglePayWalletData, PaymentMethodData, WalletData,
},
@@ -708,34 +709,34 @@ impl TryFrom<&NmiRouterData<&PaymentsAuthorizeRouterData>> for NmiPaymentsReques
.clone()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id)
{
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_id,
- )) => Ok(Self {
- transaction_type,
- security_key: auth_type.api_key,
- amount,
- currency: item.router_data.request.currency,
- payment_method: PaymentMethod::MandatePayment(Box::new(MandatePayment {
- customer_vault_id: Secret::new(
- connector_mandate_id
- .get_connector_mandate_id()
- .ok_or(ConnectorError::MissingConnectorMandateID)?,
- ),
- })),
- merchant_defined_field: item
- .router_data
- .request
- .metadata
- .as_ref()
- .map(NmiMerchantDefinedField::new),
- orderid: item.router_data.connector_request_reference_id.clone(),
- customer_vault: None,
- billing_details: item.get_billing_details(),
- shipping_details: item.get_shipping_details(),
- }),
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
- | Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(api_models::payments::MandateReferenceId::CardWithLimitedData) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_id)) => {
+ Ok(Self {
+ transaction_type,
+ security_key: auth_type.api_key,
+ amount,
+ currency: item.router_data.request.currency,
+ payment_method: PaymentMethod::MandatePayment(Box::new(MandatePayment {
+ customer_vault_id: Secret::new(
+ connector_mandate_id
+ .get_connector_mandate_id()
+ .ok_or(ConnectorError::MissingConnectorMandateID)?,
+ ),
+ })),
+ merchant_defined_field: item
+ .router_data
+ .request
+ .metadata
+ .as_ref()
+ .map(NmiMerchantDefinedField::new),
+ orderid: item.router_data.connector_request_reference_id.clone(),
+ customer_vault: None,
+ billing_details: item.get_billing_details(),
+ shipping_details: item.get_shipping_details(),
+ })
+ }
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData) => {
Err(ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("nmi"),
))?
diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
index 549913bf6d..49410bac2f 100644
--- a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
@@ -12,6 +12,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
BankDebitData, PaymentMethodData, WalletData as WalletDataPaymentMethod,
},
@@ -510,7 +511,7 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym
)
.into()),
},
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
let connector_mandate_id = mandate_data.get_connector_mandate_id().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "connector_mandate_id",
@@ -547,47 +548,47 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym
custom,
})
}
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(
- network_transaction_id,
- )) => match item.router_data.request.payment_method_data {
- PaymentMethodData::CardDetailsForNetworkTransactionId(ref raw_card_details) => {
- let novalnet_card =
- NovalNetPaymentData::RawCardForNTI(NovalnetRawCardDetails {
- card_number: raw_card_details.card_number.clone(),
- card_expiry_month: raw_card_details.card_exp_month.clone(),
- card_expiry_year: raw_card_details.card_exp_year.clone(),
- scheme_tid: network_transaction_id
- .network_transaction_id
- .clone()
- .into(),
- });
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ match item.router_data.request.payment_method_data {
+ PaymentMethodData::CardDetailsForNetworkTransactionId(ref raw_card_details) => {
+ let novalnet_card =
+ NovalNetPaymentData::RawCardForNTI(NovalnetRawCardDetails {
+ card_number: raw_card_details.card_number.clone(),
+ card_expiry_month: raw_card_details.card_exp_month.clone(),
+ card_expiry_year: raw_card_details.card_exp_year.clone(),
+ scheme_tid: network_transaction_id
+ .network_transaction_id
+ .clone()
+ .into(),
+ });
- let transaction = NovalnetPaymentsRequestTransaction {
- test_mode,
- payment_type: NovalNetPaymentTypes::CREDITCARD,
- amount: NovalNetAmount::StringMinor(item.amount.clone()),
- currency: item.router_data.request.currency,
- order_no: item.router_data.connector_request_reference_id.clone(),
- hook_url: Some(hook_url),
- return_url: Some(return_url.clone()),
- error_return_url: Some(return_url.clone()),
- payment_data: Some(novalnet_card),
- enforce_3d,
- create_token,
- };
+ let transaction = NovalnetPaymentsRequestTransaction {
+ test_mode,
+ payment_type: NovalNetPaymentTypes::CREDITCARD,
+ amount: NovalNetAmount::StringMinor(item.amount.clone()),
+ currency: item.router_data.request.currency,
+ order_no: item.router_data.connector_request_reference_id.clone(),
+ hook_url: Some(hook_url),
+ return_url: Some(return_url.clone()),
+ error_return_url: Some(return_url.clone()),
+ payment_data: Some(novalnet_card),
+ enforce_3d,
+ create_token,
+ };
- Ok(Self {
- merchant,
- transaction,
- customer,
- custom,
- })
+ Ok(Self {
+ merchant,
+ transaction,
+ customer,
+ custom,
+ })
+ }
+ _ => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("novalnet"),
+ )
+ .into()),
}
- _ => Err(errors::ConnectorError::NotImplemented(
- utils::get_unimplemented_payment_method_error_message("novalnet"),
- )
- .into()),
- },
+ }
_ => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("novalnet"),
)
diff --git a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
index ba0a82701d..d2e7674e08 100644
--- a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
@@ -19,6 +19,7 @@ use common_utils::{
use error_stack::ResultExt;
use hyperswitch_domain_models::{
address::Address,
+ mandates,
payment_method_data::{
self, ApplePayWalletData, BankRedirectData, CardDetailsForNetworkTransactionId,
GooglePayWalletData, PayLaterData, PaymentMethodData, WalletData,
@@ -3895,7 +3896,7 @@ impl NuveiAuthorizePreprocessingCommon for SetupMandateRequestData {
self.mandate_id.as_ref().and_then(|mandate_ids| {
mandate_ids.mandate_reference_id.as_ref().and_then(
|mandate_ref_id| match mandate_ref_id {
- api_models::payments::MandateReferenceId::ConnectorMandateId(id) => {
+ mandates::MandateReferenceId::ConnectorMandateId(id) => {
id.get_connector_mandate_id()
}
_ => None,
diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs
index 46b1d0c816..f8307d8191 100644
--- a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs
@@ -3,6 +3,7 @@ use common_enums::{enums, AttemptStatus, CaptureMethod, Currency, PaymentMethod}
use common_utils::{errors::ParsingError, ext_traits::Encode};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::PaymentMethodData,
router_data::{ConnectorAuthType, RouterData},
router_flow_types::Execute,
@@ -187,9 +188,9 @@ fn get_transaction_type_and_stored_creds(
{
let connector_mandate_id = item.request.mandate_id.as_ref().and_then(|mandate_ids| {
match mandate_ids.mandate_reference_id.clone() {
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_ids,
- )) => connector_mandate_ids.get_connector_mandate_id(),
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ connector_mandate_ids.get_connector_mandate_id()
+ }
_ => None,
}
});
diff --git a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
index ee0cb23d1e..6994c69786 100644
--- a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
@@ -16,6 +16,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
self, BankRedirectData, Card, CardRedirectData, GiftCardData, GooglePayWalletData,
PayLaterData, PaymentMethodData, VoucherData, WalletData,
@@ -1990,7 +1991,7 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequest
.as_ref()
.and_then(|mandate_id| mandate_id.mandate_reference_id.as_ref())
.and_then(|reference_id| match reference_id {
- payments::MandateReferenceId::ConnectorMandateId(mandate_data) => {
+ mandates::MandateReferenceId::ConnectorMandateId(mandate_data) => {
Some(mandate_data.get_mandate_metadata())
}
_ => None,
@@ -2090,14 +2091,14 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequest
.clone()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id)
{
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => (
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => (
None,
connector_mandate_ids.get_connector_mandate_id(),
StripeBillingAddress::default(),
get_payment_method_type_for_saved_payment_method_payment(item)?,
None,
),
- Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
payment_method_options = Some(StripePaymentMethodOptions::Card {
mandate_options: None,
network_transaction_id: None,
@@ -2174,7 +2175,7 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequest
None,
)
}
- Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) | None => {
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) | None => {
let (payment_method_data, payment_method_type, billing_address) =
create_stripe_payment_method(
&item.request.payment_method_data,
@@ -2218,7 +2219,7 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequest
setup_future_usage,
)
}
- Some(payments::MandateReferenceId::CardWithLimitedData) => {
+ Some(mandates::MandateReferenceId::CardWithLimitedData) => {
Err(ConnectorError::NotSupported {
message: "Card Only MIT for payment method".to_string(),
connector: "Stripe",
@@ -2657,7 +2658,7 @@ pub fn get_stripe_compatible_connect_account_header(
.as_ref()
.and_then(|mandate_id| mandate_id.mandate_reference_id.as_ref())
.and_then(|reference_id| match reference_id {
- payments::MandateReferenceId::ConnectorMandateId(mandate_data) => {
+ mandates::MandateReferenceId::ConnectorMandateId(mandate_data) => {
mandate_data.get_mandate_metadata()
}
_ => None,
diff --git a/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs b/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
index fb76b1e142..fb922f26ff 100644
--- a/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
@@ -1,4 +1,3 @@
-use api_models::payments;
use base64::Engine;
use common_enums::{enums, FutureUsage};
use common_types::payments::ApplePayPredecryptData;
@@ -8,6 +7,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::{
ApplePayWalletData, BankDebitData, GooglePayWalletData, PaymentMethodData, WalletData,
},
@@ -650,7 +650,7 @@ impl
.clone()
.and_then(|mandate_id| mandate_id.mandate_reference_id)
{
- Some(payments::MandateReferenceId::ConnectorMandateId(_)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(_)) => {
let original_amount = item
.router_data
.get_recurring_mandate_payment_data()?
@@ -676,7 +676,7 @@ impl
}),
)
}
- Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
let (original_amount, original_currency) = match network
.clone()
.map(|network| network.to_lowercase())
@@ -744,8 +744,8 @@ impl
}),
)
}
- Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None => (None, None, None),
}
} else {
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs
index 80433914a2..88f248e001 100644
--- a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs
@@ -1,6 +1,5 @@
use std::collections::HashMap;
-use api_models::payments::{MandateIds, MandateReferenceId};
use base64::Engine;
use common_enums::enums;
use common_utils::{
@@ -9,6 +8,7 @@ use common_utils::{
use error_stack::ResultExt;
use hyperswitch_domain_models::{
address,
+ mandates::{MandateIds, MandateReferenceId},
payment_method_data::{PaymentMethodData, WalletData},
router_data::{ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{Authorize, SetupMandate},
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpaymodular/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpaymodular/transformers.rs
index 45d9364525..5760d5f765 100644
--- a/crates/hyperswitch_connectors/src/connectors/worldpaymodular/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/worldpaymodular/transformers.rs
@@ -1,6 +1,6 @@
+use hyperswitch_domain_models::mandates::{MandateIds, MandateReferenceId};
pub mod request;
pub mod response;
-use api_models::payments::{MandateIds, MandateReferenceId};
use base64::Engine;
use common_enums::{enums, Currency, PaymentChannel};
use common_utils::{
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
index 95b7b9207a..18723bc669 100644
--- a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
@@ -5,6 +5,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
+ mandates,
payment_method_data::PaymentMethodData,
router_data::{
AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,
@@ -1112,14 +1113,16 @@ fn get_processing_info(
.as_ref()
.and_then(|mandate| mandate.mandate_reference_id.clone())
{
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(
- network_transaction_id,
- )) => Ok(VantivMandateDetail {
- processing_type: Some(VantivProcessingType::MerchantInitiatedCOF),
- network_transaction_id: Some(network_transaction_id.network_transaction_id.into()),
- token: None,
- }),
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ Ok(VantivMandateDetail {
+ processing_type: Some(VantivProcessingType::MerchantInitiatedCOF),
+ network_transaction_id: Some(
+ network_transaction_id.network_transaction_id.into(),
+ ),
+ token: None,
+ })
+ }
+ Some(mandates::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
let network_transaction_id =
mandate_data
.get_mandate_metadata()
@@ -2370,7 +2373,7 @@ impl From<TokenResponse> for MandateReference {
}
}
-impl From<&AccountUpdaterCardTokenInfo> for api_models::payments::UpdatedMandateDetails {
+impl From<&AccountUpdaterCardTokenInfo> for mandates::UpdatedMandateDetails {
fn from(token_data: &AccountUpdaterCardTokenInfo) -> Self {
let card_exp_month = token_data
.exp_date
@@ -2412,7 +2415,7 @@ impl From<WorldpayvativCardType> for common_enums::CardNetwork {
impl From<AccountUpdaterCardTokenInfo> for MandateReference {
fn from(token_data: AccountUpdaterCardTokenInfo) -> Self {
- let mandate_metadata = api_models::payments::UpdatedMandateDetails::from(&token_data);
+ let mandate_metadata = mandates::UpdatedMandateDetails::from(&token_data);
let mandate_metadata_json = serde_json::to_value(&mandate_metadata)
.inspect_err(|_| {
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index 5c79c926bc..904da20466 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -2307,7 +2307,7 @@ pub trait PaymentsAuthorizeRequestData {
fn is_mit_payment(&self) -> bool;
fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error>;
fn get_connector_mandate_id(&self) -> Result<String, Error>;
- fn get_connector_mandate_data(&self) -> Option<payments::ConnectorMandateReferenceId>;
+ fn get_connector_mandate_data(&self) -> Option<mandates::ConnectorMandateReferenceId>;
fn get_complete_authorize_url(&self) -> Result<String, Error>;
fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>>;
fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error>;
@@ -2382,12 +2382,12 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None => None,
})
}
@@ -2434,16 +2434,16 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
.ok_or_else(missing_field_err("connector_mandate_id"))
}
- fn get_connector_mandate_data(&self) -> Option<payments::ConnectorMandateReferenceId> {
+ fn get_connector_mandate_data(&self) -> Option<mandates::ConnectorMandateReferenceId> {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
Some(connector_mandate_ids.clone())
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
| None => None,
})
}
@@ -2545,13 +2545,13 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_request_reference_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
.ok_or_else(missing_field_err("connector_mandate_request_reference_id"))
}
@@ -2563,12 +2563,12 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
Some(network_transaction_id.network_transaction_id.clone())
}
- Some(payments::MandateReferenceId::ConnectorMandateId(_))
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::ConnectorMandateId(_))
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None => None,
})
}
@@ -2695,12 +2695,12 @@ impl PaymentsSyncRequestData for PaymentsSyncData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None => None,
})
}
@@ -2958,13 +2958,13 @@ impl PaymentsCompleteAuthorizeRequestData for CompleteAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_request_reference_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
.ok_or_else(missing_field_err("connector_mandate_request_reference_id"))
}
@@ -2986,13 +2986,13 @@ impl PaymentsCompleteAuthorizeRequestData for CompleteAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
}
}
@@ -3204,13 +3204,13 @@ impl PaymentsPreProcessingRequestData for PaymentsPreProcessingData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
}
fn is_customer_initiated_mandate_payment(&self) -> bool {
diff --git a/crates/hyperswitch_domain_models/src/mandates.rs b/crates/hyperswitch_domain_models/src/mandates.rs
index 9cd301267a..c484b87d85 100644
--- a/crates/hyperswitch_domain_models/src/mandates.rs
+++ b/crates/hyperswitch_domain_models/src/mandates.rs
@@ -8,10 +8,11 @@ use common_types::payments as common_payments_types;
use common_utils::{
date_time,
errors::{CustomResult, ParsingError},
- pii,
+ id_type, pii,
types::MinorUnit,
};
use error_stack::ResultExt;
+use hyperswitch_masking::Secret;
use time::PrimitiveDateTime;
use crate::router_data::RecurringMandatePaymentData;
@@ -271,12 +272,11 @@ pub struct PayoutsMandateReferenceRecord {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PayoutsMandateReference(
- pub HashMap<common_utils::id_type::MerchantConnectorAccountId, PayoutsMandateReferenceRecord>,
+ pub HashMap<id_type::MerchantConnectorAccountId, PayoutsMandateReferenceRecord>,
);
impl std::ops::Deref for PayoutsMandateReference {
- type Target =
- HashMap<common_utils::id_type::MerchantConnectorAccountId, PayoutsMandateReferenceRecord>;
+ type Target = HashMap<id_type::MerchantConnectorAccountId, PayoutsMandateReferenceRecord>;
fn deref(&self) -> &Self::Target {
&self.0
@@ -291,13 +291,13 @@ impl std::ops::DerefMut for PayoutsMandateReference {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaymentsTokenReference(
- pub HashMap<common_utils::id_type::MerchantConnectorAccountId, ConnectorTokenReferenceRecord>,
+ pub HashMap<id_type::MerchantConnectorAccountId, ConnectorTokenReferenceRecord>,
);
#[cfg(feature = "v1")]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaymentsMandateReference(
- pub HashMap<common_utils::id_type::MerchantConnectorAccountId, PaymentsMandateReferenceRecord>,
+ pub HashMap<id_type::MerchantConnectorAccountId, PaymentsMandateReferenceRecord>,
);
#[cfg(feature = "v1")]
@@ -315,8 +315,7 @@ impl PaymentsMandateReference {
#[cfg(feature = "v1")]
impl std::ops::Deref for PaymentsMandateReference {
- type Target =
- HashMap<common_utils::id_type::MerchantConnectorAccountId, PaymentsMandateReferenceRecord>;
+ type Target = HashMap<id_type::MerchantConnectorAccountId, PaymentsMandateReferenceRecord>;
fn deref(&self) -> &Self::Target {
&self.0
@@ -331,8 +330,7 @@ impl std::ops::DerefMut for PaymentsMandateReference {
}
impl std::ops::Deref for PaymentsTokenReference {
- type Target =
- HashMap<common_utils::id_type::MerchantConnectorAccountId, ConnectorTokenReferenceRecord>;
+ type Target = HashMap<id_type::MerchantConnectorAccountId, ConnectorTokenReferenceRecord>;
fn deref(&self) -> &Self::Target {
&self.0
@@ -386,7 +384,7 @@ impl CommonMandateReference {
/// Insert a new payment token reference for the given connector_id
pub fn insert_payment_token_reference_record(
&mut self,
- connector_id: &common_utils::id_type::MerchantConnectorAccountId,
+ connector_id: &id_type::MerchantConnectorAccountId,
record: ConnectorTokenReferenceRecord,
) {
match self.payments {
@@ -597,3 +595,195 @@ impl From<PaymentsMandateReferenceRecord> for diesel_models::PaymentsMandateRefe
}
}
}
+
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Eq, PartialEq, Copy)]
+#[serde(rename_all = "snake_case")]
+pub enum MandateTransactionType {
+ NewMandateTransaction,
+ RecurringMandateTransaction,
+}
+
+#[derive(Default, Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
+pub struct MandateIds {
+ pub mandate_id: Option<String>,
+ pub mandate_reference_id: Option<MandateReferenceId>,
+}
+
+impl MandateIds {
+ pub fn is_network_transaction_id_flow(&self) -> bool {
+ matches!(
+ self.mandate_reference_id,
+ Some(MandateReferenceId::NetworkMandateId(_))
+ )
+ }
+
+ pub fn get_connector_mandate_id(&self) -> Option<String> {
+ match &self.mandate_reference_id {
+ Some(MandateReferenceId::ConnectorMandateId(data)) => data.connector_mandate_id.clone(),
+ _ => None,
+ }
+ }
+
+ pub fn get_connector_mandate_metadata(&self) -> Option<pii::SecretSerdeValue> {
+ match &self.mandate_reference_id {
+ Some(MandateReferenceId::ConnectorMandateId(data)) => data.mandate_metadata.clone(),
+ _ => None,
+ }
+ }
+
+ pub fn get_updated_mandate_details_of_connector_mandate_id(
+ &self,
+ ) -> Option<UpdatedMandateDetails> {
+ match &self.mandate_reference_id {
+ Some(MandateReferenceId::ConnectorMandateId(data)) => {
+ data.updated_mandate_details.clone()
+ }
+ _ => None,
+ }
+ }
+}
+
+impl MandateIds {
+ pub fn new(mandate_id: String) -> Self {
+ Self {
+ mandate_id: Some(mandate_id),
+ mandate_reference_id: None,
+ }
+ }
+}
+
+#[derive(Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
+pub enum MandateReferenceId {
+ ConnectorMandateId(ConnectorMandateReferenceId), // mandate_id send by connector
+ NetworkMandateId(NetworkMandateIdRef), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with card data
+ NetworkTokenWithNTI(NetworkTokenWithNTIRef), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with network token data
+ CardWithLimitedData, // indicates the recurring transaction is done by card data only
+}
+
+/// Scheme-level identifiers for PSP-agnostic MIT flows (raw card path).
+#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
+pub struct NetworkMandateIdRef {
+ pub network_transaction_id: String,
+ /// The Mastercard Transaction Link Identifier (TLID) provided by the card network during a CIT (Customer Initiated Transaction),
+ /// when `setup_future_usage` is set to `off_session`.
+ pub transaction_link_id: Option<String>,
+}
+
+#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
+pub struct NetworkTokenWithNTIRef {
+ pub network_transaction_id: String,
+ /// The Mastercard Transaction Link Identifier (TLID) provided by the card network during a CIT (Customer Initiated Transaction),
+ /// when `setup_future_usage` is set to `off_session`.
+ pub transaction_link_id: Option<String>,
+ pub token_exp_month: Option<Secret<String>>,
+ pub token_exp_year: Option<Secret<String>>,
+}
+
+#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
+pub struct ConnectorMandateReferenceId {
+ connector_mandate_id: Option<String>,
+ payment_method_id: Option<String>,
+ update_history: Option<Vec<UpdateHistory>>,
+ mandate_metadata: Option<pii::SecretSerdeValue>,
+ connector_mandate_request_reference_id: Option<String>,
+ updated_mandate_details: Option<UpdatedMandateDetails>,
+}
+
+impl ConnectorMandateReferenceId {
+ pub fn new(
+ connector_mandate_id: Option<String>,
+ payment_method_id: Option<String>,
+ update_history: Option<Vec<UpdateHistory>>,
+ mandate_metadata: Option<pii::SecretSerdeValue>,
+ connector_mandate_request_reference_id: Option<String>,
+ updated_mandate_details: Option<UpdatedMandateDetails>,
+ ) -> Self {
+ Self {
+ connector_mandate_id,
+ payment_method_id,
+ update_history,
+ mandate_metadata,
+ connector_mandate_request_reference_id,
+ updated_mandate_details,
+ }
+ }
+
+ pub fn get_connector_mandate_id(&self) -> Option<String> {
+ self.connector_mandate_id.clone()
+ }
+ pub fn get_payment_method_id(&self) -> Option<String> {
+ self.payment_method_id.clone()
+ }
+ pub fn get_mandate_metadata(&self) -> Option<pii::SecretSerdeValue> {
+ self.mandate_metadata.clone()
+ }
+ pub fn get_connector_mandate_request_reference_id(&self) -> Option<String> {
+ self.connector_mandate_request_reference_id.clone()
+ }
+
+ pub fn update(
+ &mut self,
+ connector_mandate_id: Option<String>,
+ payment_method_id: Option<String>,
+ update_history: Option<Vec<UpdateHistory>>,
+ mandate_metadata: Option<pii::SecretSerdeValue>,
+ connector_mandate_request_reference_id: Option<String>,
+ ) {
+ self.connector_mandate_id = connector_mandate_id.or(self.connector_mandate_id.clone());
+ self.payment_method_id = payment_method_id.or(self.payment_method_id.clone());
+ self.update_history = update_history.or(self.update_history.clone());
+ self.mandate_metadata = mandate_metadata.or(self.mandate_metadata.clone());
+ self.connector_mandate_request_reference_id = connector_mandate_request_reference_id
+ .or(self.connector_mandate_request_reference_id.clone());
+ }
+}
+
+#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Eq, PartialEq)]
+pub struct UpdatedMandateDetails {
+ pub card_network: Option<common_enums::CardNetwork>,
+ pub card_exp_month: Option<Secret<String>>,
+ pub card_exp_year: Option<Secret<String>>,
+ pub card_isin: Option<String>,
+}
+
+impl From<api_models::payments::AdditionalCardInfo> for UpdatedMandateDetails {
+ fn from(card_info: api_models::payments::AdditionalCardInfo) -> Self {
+ Self {
+ card_network: card_info.card_network,
+ card_exp_month: card_info.card_exp_month,
+ card_exp_year: card_info.card_exp_year,
+ card_isin: card_info.card_isin,
+ }
+ }
+}
+
+impl From<&UpdatedMandateDetails> for api_models::payments::AdditionalCardInfo {
+ fn from(card_info: &UpdatedMandateDetails) -> Self {
+ Self {
+ card_network: card_info.card_network.clone(),
+ card_exp_month: card_info.card_exp_month.clone(),
+ card_exp_year: card_info.card_exp_year.clone(),
+ card_isin: card_info.card_isin.clone(),
+ card_issuer: None,
+ card_type: None,
+ card_issuing_country: None,
+ card_issuing_country_code: None,
+ bank_code: None,
+ last4: None,
+ card_extended_bin: None,
+ card_holder_name: None,
+ payment_checks: None,
+ authentication_data: None,
+ is_regulated: None,
+ signature_network: None,
+ auth_code: None,
+ }
+ }
+}
+
+#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Eq, PartialEq)]
+pub struct UpdateHistory {
+ pub connector_mandate_id: Option<String>,
+ pub payment_method_id: String,
+ pub original_payment_id: Option<id_type::PaymentId>,
+}
diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs
index 42caf8bfee..fe00b14703 100644
--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs
+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs
@@ -2,7 +2,7 @@
use std::str::FromStr;
use api_models::{
- mandates,
+ mandates as api_mandates,
payment_methods::{self},
payments::{
additional_info as payment_additional_types, AdditionalNetworkTokenInfo, ExtendedCardInfo,
@@ -23,7 +23,7 @@ use hyperswitch_masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use time::Date;
-use crate::router_data::PaymentMethodToken;
+use crate::{mandates, router_data::PaymentMethodToken};
// We need to derive Serialize and Deserialize because some parts of payment method data are being
// stored in the database as serde_json::Value
@@ -652,9 +652,9 @@ impl CardWithLimitedDetails {
pub fn get_card_details_for_mit_flow(
card_with_limited_data: CardWithLimitedData,
- ) -> (api_models::payments::MandateReferenceId, PaymentMethodData) {
+ ) -> (mandates::MandateReferenceId, PaymentMethodData) {
(
- api_models::payments::MandateReferenceId::CardWithLimitedData,
+ mandates::MandateReferenceId::CardWithLimitedData,
PaymentMethodData::CardWithLimitedDetails(card_with_limited_data.into()),
)
}
@@ -663,9 +663,9 @@ impl CardWithLimitedDetails {
impl CardDetailsForNetworkTransactionId {
pub fn get_nti_and_card_details_for_mit_flow(
network_transaction_id_and_card_details: NetworkTransactionIdAndCardDetails,
- ) -> (api_models::payments::MandateReferenceId, PaymentMethodData) {
- let mandate_reference_id = api_models::payments::MandateReferenceId::NetworkMandateId(
- api_models::payments::NetworkMandateIdRef {
+ ) -> (mandates::MandateReferenceId, PaymentMethodData) {
+ let mandate_reference_id =
+ mandates::MandateReferenceId::NetworkMandateId(mandates::NetworkMandateIdRef {
network_transaction_id: network_transaction_id_and_card_details
.network_transaction_id
.peek()
@@ -673,8 +673,7 @@ impl CardDetailsForNetworkTransactionId {
transaction_link_id: network_transaction_id_and_card_details
.transaction_link_id
.clone(),
- },
- );
+ });
(
mandate_reference_id,
@@ -688,9 +687,9 @@ impl CardDetailsForNetworkTransactionId {
impl NetworkTokenDetailsForNetworkTransactionId {
pub fn get_nti_and_network_token_details_for_mit_flow(
network_transaction_id_and_network_token_details: NetworkTransactionIdAndNetworkTokenDetails,
- ) -> (api_models::payments::MandateReferenceId, PaymentMethodData) {
- let mandate_reference_id = api_models::payments::MandateReferenceId::NetworkMandateId(
- api_models::payments::NetworkMandateIdRef {
+ ) -> (mandates::MandateReferenceId, PaymentMethodData) {
+ let mandate_reference_id =
+ mandates::MandateReferenceId::NetworkMandateId(mandates::NetworkMandateIdRef {
network_transaction_id: network_transaction_id_and_network_token_details
.network_transaction_id
.peek()
@@ -698,8 +697,7 @@ impl NetworkTokenDetailsForNetworkTransactionId {
transaction_link_id: network_transaction_id_and_network_token_details
.transaction_link_id
.clone(),
- },
- );
+ });
(
mandate_reference_id,
@@ -713,9 +711,9 @@ impl NetworkTokenDetailsForNetworkTransactionId {
impl DecryptedWalletTokenDetailsForNetworkTransactionId {
pub fn get_nti_and_decrypted_wallet_token_details_for_mit_flow(
network_transaction_id_and_decrypted_wallet_token_details: common_types::payments::NetworkTransactionIdAndDecryptedWalletTokenDetails,
- ) -> (api_models::payments::MandateReferenceId, PaymentMethodData) {
- let mandate_reference_id = api_models::payments::MandateReferenceId::NetworkMandateId(
- api_models::payments::NetworkMandateIdRef {
+ ) -> (mandates::MandateReferenceId, PaymentMethodData) {
+ let mandate_reference_id =
+ mandates::MandateReferenceId::NetworkMandateId(mandates::NetworkMandateIdRef {
network_transaction_id: network_transaction_id_and_decrypted_wallet_token_details
.network_transaction_id
.peek()
@@ -723,8 +721,7 @@ impl DecryptedWalletTokenDetailsForNetworkTransactionId {
transaction_link_id: network_transaction_id_and_decrypted_wallet_token_details
.transaction_link_id
.clone(),
- },
- );
+ });
(
mandate_reference_id,
@@ -4270,43 +4267,43 @@ impl
}
}
-impl From<mandates::RecurringDetails> for RecurringDetails {
- fn from(value: mandates::RecurringDetails) -> Self {
+impl From<api_mandates::RecurringDetails> for RecurringDetails {
+ fn from(value: api_mandates::RecurringDetails) -> Self {
match value {
- mandates::RecurringDetails::MandateId(mandate_id) => Self::MandateId(mandate_id),
- mandates::RecurringDetails::PaymentMethodId(payment_method_id) => {
+ api_mandates::RecurringDetails::MandateId(mandate_id) => Self::MandateId(mandate_id),
+ api_mandates::RecurringDetails::PaymentMethodId(payment_method_id) => {
Self::PaymentMethodId(payment_method_id)
}
- mandates::RecurringDetails::ProcessorPaymentToken(token) => {
+ api_mandates::RecurringDetails::ProcessorPaymentToken(token) => {
Self::ProcessorPaymentToken(ProcessorPaymentToken {
processor_payment_token: token.processor_payment_token,
merchant_connector_id: token.merchant_connector_id,
})
}
- mandates::RecurringDetails::NetworkTransactionIdAndCardDetails(
+ api_mandates::RecurringDetails::NetworkTransactionIdAndCardDetails(
network_transaction_id_and_card_details,
) => Self::NetworkTransactionIdAndCardDetails(Box::new(
(*network_transaction_id_and_card_details).into(),
)),
- mandates::RecurringDetails::NetworkTransactionIdAndNetworkTokenDetails(
+ api_mandates::RecurringDetails::NetworkTransactionIdAndNetworkTokenDetails(
network_transaction_id_and_network_token_details,
) => Self::NetworkTransactionIdAndNetworkTokenDetails(Box::new(
(*network_transaction_id_and_network_token_details).into(),
)),
- mandates::RecurringDetails::NetworkTransactionIdAndDecryptedWalletTokenDetails(
+ api_mandates::RecurringDetails::NetworkTransactionIdAndDecryptedWalletTokenDetails(
network_transaction_id_and_decrypted_wallet_token_details,
) => Self::NetworkTransactionIdAndDecryptedWalletTokenDetails(Box::new(
*network_transaction_id_and_decrypted_wallet_token_details,
)),
- mandates::RecurringDetails::CardWithLimitedData(card_with_limited_data) => {
+ api_mandates::RecurringDetails::CardWithLimitedData(card_with_limited_data) => {
Self::CardWithLimitedData(Box::new((*card_with_limited_data).into()))
}
}
}
}
-impl From<mandates::NetworkTransactionIdAndCardDetails> for NetworkTransactionIdAndCardDetails {
- fn from(value: mandates::NetworkTransactionIdAndCardDetails) -> Self {
+impl From<api_mandates::NetworkTransactionIdAndCardDetails> for NetworkTransactionIdAndCardDetails {
+ fn from(value: api_mandates::NetworkTransactionIdAndCardDetails) -> Self {
Self {
card_number: value.card_number,
card_exp_month: value.card_exp_month,
@@ -4325,10 +4322,10 @@ impl From<mandates::NetworkTransactionIdAndCardDetails> for NetworkTransactionId
}
}
-impl From<mandates::NetworkTransactionIdAndNetworkTokenDetails>
+impl From<api_mandates::NetworkTransactionIdAndNetworkTokenDetails>
for NetworkTransactionIdAndNetworkTokenDetails
{
- fn from(value: mandates::NetworkTransactionIdAndNetworkTokenDetails) -> Self {
+ fn from(value: api_mandates::NetworkTransactionIdAndNetworkTokenDetails) -> Self {
Self {
network_token: value.network_token,
token_exp_month: value.token_exp_month,
@@ -4347,8 +4344,8 @@ impl From<mandates::NetworkTransactionIdAndNetworkTokenDetails>
}
}
-impl From<mandates::CardWithLimitedData> for CardWithLimitedData {
- fn from(card_with_limited_data: mandates::CardWithLimitedData) -> Self {
+impl From<api_mandates::CardWithLimitedData> for CardWithLimitedData {
+ fn from(card_with_limited_data: api_mandates::CardWithLimitedData) -> Self {
Self {
card_number: card_with_limited_data.card_number,
card_exp_month: card_with_limited_data.card_exp_month,
@@ -4362,7 +4359,7 @@ impl From<mandates::CardWithLimitedData> for CardWithLimitedData {
impl RecurringDetails {
pub fn get_mandate_reference_id_and_payment_method_data_for_proxy_flow(
&self,
- ) -> Option<(api_models::payments::MandateReferenceId, PaymentMethodData)> {
+ ) -> Option<(mandates::MandateReferenceId, PaymentMethodData)> {
match self.clone() {
Self::NetworkTransactionIdAndCardDetails(network_transaction_id_and_card_details) => {
Some(CardDetailsForNetworkTransactionId::get_nti_and_card_details_for_mit_flow(*network_transaction_id_and_card_details))
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 9a26f17c43..a71e9d06c0 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -57,7 +57,7 @@ use self::{payment_attempt::PaymentAttempt, payment_intent::CustomerData};
use crate::ext_traits::OptionExt;
#[cfg(feature = "v2")]
use crate::{
- address::Address, business_profile, customer, errors, merchant_connector_account,
+ address::Address, business_profile, customer, errors, mandates, merchant_connector_account,
merchant_connector_account::MerchantConnectorAccountTypeDetails, payment_address,
payment_method_data, payment_methods, platform, revenue_recovery, routing,
ApiModelToDieselModelConvertor,
@@ -1330,7 +1330,7 @@ where
pub payment_attempt: PaymentAttempt,
pub payment_method_data: Option<payment_method_data::PaymentMethodData>,
pub payment_address: payment_address::PaymentAddress,
- pub mandate_data: Option<api_models::payments::MandateIds>,
+ pub mandate_data: Option<mandates::MandateIds>,
pub payment_method: Option<payment_methods::PaymentMethod>,
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
pub external_vault_pmd: Option<payment_method_data::ExternalVaultPaymentMethodData>,
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index 7a63a044a2..ef4884fc52 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -2,6 +2,8 @@ use std::str::FromStr;
#[cfg(all(feature = "v1", feature = "olap"))]
use api_models::enums::Connector;
+#[cfg(feature = "v1")]
+use api_models::payments::Amount;
#[cfg(feature = "v2")]
use api_models::payments::{additional_info::UpiAdditionalData, AdditionalPaymentData};
use common_enums as storage_enums;
@@ -66,7 +68,7 @@ use crate::{
};
#[cfg(feature = "v1")]
use crate::{
- mandates::{MandateDataType, MandateDetails},
+ mandates::{MandateDataType, MandateDetails, MandateTransactionType},
router_request_types,
};
@@ -1724,7 +1726,6 @@ impl PaymentAttempt {
/// Infer the payment type (Normal / NewMandate / SetupMandate / RecurringMandate)
/// from the attempt's mandate state and whether this is a CIT transaction.
pub fn infer_payment_type(&self, is_cit_transaction: bool) -> api_models::enums::PaymentType {
- use api_models::payments::{Amount, MandateTransactionType};
let amount = Amount::from(self.net_amount.get_order_amount());
let mandate_type = if self.mandate_id.is_some() {
Some(MandateTransactionType::RecurringMandateTransaction)
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index 8dde08662e..f1364a8477 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -100,7 +100,7 @@ pub struct PaymentsAuthorizeData {
pub complete_authorize_url: Option<String>,
// Mandates
pub setup_future_usage: Option<storage_enums::FutureUsage>,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub off_session: Option<bool>,
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
pub setup_mandate_details: Option<mandates::MandateData>,
@@ -182,7 +182,7 @@ pub struct ExternalVaultProxyPaymentsData {
pub complete_authorize_url: Option<String>,
// Mandates
pub setup_future_usage: Option<storage_enums::FutureUsage>,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub off_session: Option<bool>,
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
pub setup_mandate_details: Option<mandates::MandateData>,
@@ -551,7 +551,7 @@ pub struct PaymentMethodTokenizationData {
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
pub setup_future_usage: Option<storage_enums::FutureUsage>,
pub setup_mandate_details: Option<mandates::MandateData>,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub router_return_url: Option<String>,
pub capture_method: Option<storage_enums::CaptureMethod>,
}
@@ -740,7 +740,7 @@ pub struct PaymentsPreProcessingData {
pub browser_info: Option<BrowserInformation>,
pub connector_transaction_id: Option<String>,
pub enrolled_for_3ds: bool,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub related_transaction_id: Option<String>,
pub redirect_response: Option<CompleteAuthorizeRedirectResponse>,
pub metadata: Option<Secret<serde_json::Value>>,
@@ -1072,7 +1072,7 @@ pub struct CompleteAuthorizeData {
pub capture_method: Option<storage_enums::CaptureMethod>,
// Mandates
pub setup_future_usage: Option<storage_enums::FutureUsage>,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub off_session: Option<bool>,
pub setup_mandate_details: Option<mandates::MandateData>,
pub redirect_response: Option<CompleteAuthorizeRedirectResponse>,
@@ -1110,7 +1110,7 @@ pub struct PaymentsSyncData {
pub capture_method: Option<storage_enums::CaptureMethod>,
pub connector_meta: Option<serde_json::Value>,
pub sync_type: SyncRequestType,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub payment_method_type: Option<storage_enums::PaymentMethodType>,
pub currency: storage_enums::Currency,
pub payment_experience: Option<common_enums::PaymentExperience>,
@@ -1833,7 +1833,7 @@ pub struct SetupMandateRequestData {
pub amount: i64,
pub confirm: bool,
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub setup_future_usage: Option<storage_enums::FutureUsage>,
pub off_session: Option<bool>,
pub setup_mandate_details: Option<mandates::MandateData>,
@@ -1889,19 +1889,19 @@ pub struct DisputeSyncData {
/// Implemented by request types used in flows triggered after SetupMandate,
/// where the mandate_id from the SetupMandate response needs to be propagated.
pub trait MandateIdSettable {
- fn set_mandate_id(&mut self, mandate_id: api_models::payments::MandateIds);
+ fn set_mandate_id(&mut self, mandate_id: mandates::MandateIds);
}
#[derive(Debug, Clone, Serialize)]
pub struct PushNotificationRequestData {
pub payment_method_data: Option<PaymentMethodData>,
pub feature_metadata: Option<api_models::payments::FeatureMetadata>,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub amount: Option<i64>,
}
impl MandateIdSettable for PushNotificationRequestData {
- fn set_mandate_id(&mut self, mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, mandate_id: mandates::MandateIds) {
self.mandate_id = Some(mandate_id);
}
}
@@ -1911,12 +1911,12 @@ impl PushNotificationRequestData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_ids,
- )) => connector_mandate_ids.get_connector_mandate_id(),
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
- | Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(api_models::payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ connector_mandate_ids.get_connector_mandate_id()
+ }
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None => None,
})
}
@@ -1925,11 +1925,11 @@ impl PushNotificationRequestData {
#[derive(Debug, Clone, Serialize)]
pub struct GenerateQrRequestData {
pub amount: Option<i64>,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
}
impl MandateIdSettable for GenerateQrRequestData {
- fn set_mandate_id(&mut self, mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, mandate_id: mandates::MandateIds) {
self.mandate_id = Some(mandate_id);
}
}
@@ -1939,12 +1939,12 @@ impl GenerateQrRequestData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_ids,
- )) => connector_mandate_ids.get_connector_mandate_id(),
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
- | Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_))
- | Some(api_models::payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ connector_mandate_ids.get_connector_mandate_id()
+ }
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None => None,
})
}
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 14ecb25a57..0545550267 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -23,7 +23,7 @@ use common_utils::{
};
use diesel_models::{enums, types::OrderDetailsWithAmount};
use error_stack::{report, ResultExt};
-use hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt;
+use hyperswitch_domain_models::{mandates, payments::payment_attempt::PaymentAttempt};
use hyperswitch_masking::{Deserialize, ExposeInterface, Secret};
use regex::Regex;
@@ -870,13 +870,13 @@ impl PaymentsPreProcessingData for types::PaymentsPreProcessingData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
}
}
@@ -1050,13 +1050,13 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
}
@@ -1064,12 +1064,12 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
Some(network_transaction_id.network_transaction_id.clone())
}
- Some(payments::MandateReferenceId::ConnectorMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_))
+ Some(mandates::MandateReferenceId::ConnectorMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_))
| None => None,
})
}
@@ -1177,13 +1177,13 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_request_reference_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
.ok_or_else(missing_field_err("connector_mandate_request_reference_id"))
}
@@ -1317,13 +1317,13 @@ impl PaymentsCompleteAuthorizeRequestData for types::CompleteAuthorizeData {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
- Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_request_reference_id()
}
- Some(payments::MandateReferenceId::NetworkMandateId(_))
- | Some(payments::MandateReferenceId::CardWithLimitedData)
+ Some(mandates::MandateReferenceId::NetworkMandateId(_))
+ | Some(mandates::MandateReferenceId::CardWithLimitedData)
| None
- | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
+ | Some(mandates::MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
.ok_or_else(missing_field_err("connector_mandate_request_reference_id"))
}
@@ -2026,7 +2026,7 @@ pub trait MandateReferenceData {
fn get_connector_mandate_id(&self) -> Result<String, Error>;
}
-impl MandateReferenceData for payments::ConnectorMandateReferenceId {
+impl MandateReferenceData for mandates::ConnectorMandateReferenceId {
fn get_connector_mandate_id(&self) -> Result<String, Error> {
self.get_connector_mandate_id()
.ok_or_else(missing_field_err("mandate_id"))
diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs
index 4ed0f81809..93155a8106 100644
--- a/crates/router/src/core/mandate.rs
+++ b/crates/router/src/core/mandate.rs
@@ -1,11 +1,11 @@
pub mod helpers;
pub mod utils;
-use api_models::payments;
use common_types::payments as common_payments_types;
use common_utils::{ext_traits::Encode, id_type};
use diesel_models::enums as storage_enums;
use error_stack::{report, ResultExt};
use futures::future;
+use hyperswitch_domain_models::mandates::{MandateData, MandateIds};
use router_env::{instrument, logger, tracing};
use super::payments::helpers as payment_helper;
@@ -441,11 +441,9 @@ impl ForeignFrom<Result<types::PaymentsResponseData, types::ErrorResponse>>
pub trait MandateBehaviour {
fn get_amount(&self) -> i64;
fn get_setup_future_usage(&self) -> Option<diesel_models::enums::FutureUsage>;
- fn get_mandate_id(&self) -> Option<&payments::MandateIds>;
- fn set_mandate_id(&mut self, new_mandate_id: Option<payments::MandateIds>);
+ fn get_mandate_id(&self) -> Option<&MandateIds>;
+ fn set_mandate_id(&mut self, new_mandate_id: Option<MandateIds>);
fn get_payment_method_data(&self) -> domain::payments::PaymentMethodData;
- fn get_setup_mandate_details(
- &self,
- ) -> Option<&hyperswitch_domain_models::mandates::MandateData>;
+ fn get_setup_mandate_details(&self) -> Option<&MandateData>;
fn get_customer_acceptance(&self) -> Option<common_payments_types::CustomerAcceptance>;
}
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 505539b02f..e6fb4734aa 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -1,3 +1,4 @@
+use hyperswitch_domain_models::mandates;
pub mod access_token;
#[cfg(feature = "v2")]
mod backward_compat;
@@ -657,7 +658,7 @@ pub async fn retrieve_payment_method_with_token(
_card_token_data: Option<&domain::CardToken>,
_customer: &Option<domain::Customer>,
_storage_scheme: common_enums::enums::MerchantStorageScheme,
- _mandate_id: Option<api_models::payments::MandateIds>,
+ _mandate_id: Option<mandates::MandateIds>,
_payment_method_info: Option<domain::PaymentMethod>,
_business_profile: &domain::Profile,
) -> RouterResult<storage::PaymentMethodDataWithId> {
@@ -675,7 +676,7 @@ pub async fn retrieve_payment_method_with_token(
payment_attempt: &PaymentAttempt,
card_token_data: Option<&domain::CardToken>,
storage_scheme: common_enums::enums::MerchantStorageScheme,
- mandate_id: Option<api_models::payments::MandateIds>,
+ mandate_id: Option<mandates::MandateIds>,
payment_method_info: Option<domain::PaymentMethod>,
business_profile: &domain::Profile,
should_retry_with_pan: bool,
@@ -4206,13 +4207,10 @@ fn convert_from_saved_payment_method_data(
fn create_connector_token_details_update(
token_details: payment_methods::ConnectorTokenDetails,
payment_method: &domain::PaymentMethod,
-) -> hyperswitch_domain_models::mandates::CommonMandateReference {
+) -> mandates::CommonMandateReference {
let connector_id = token_details.connector_id.clone();
- let reference_record =
- hyperswitch_domain_models::mandates::ConnectorTokenReferenceRecord::foreign_from(
- token_details,
- );
+ let reference_record = mandates::ConnectorTokenReferenceRecord::foreign_from(token_details);
let connector_token_details = payment_method.connector_mandate_details.clone();
@@ -4227,10 +4225,8 @@ fn create_connector_token_details_update(
let reference_record_hash_map =
std::collections::HashMap::from([(connector_id, reference_record)]);
let payments_mandate_reference =
- hyperswitch_domain_models::mandates::PaymentsTokenReference(
- reference_record_hash_map,
- );
- hyperswitch_domain_models::mandates::CommonMandateReference {
+ mandates::PaymentsTokenReference(reference_record_hash_map);
+ mandates::CommonMandateReference {
payments: Some(payments_mandate_reference),
payouts: None,
}
diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rs
index f435eb9acb..cf3bcd54a0 100644
--- a/crates/router/src/core/payment_methods/transformers.rs
+++ b/crates/router/src/core/payment_methods/transformers.rs
@@ -15,6 +15,7 @@ use common_utils::{
request::RequestContent,
};
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
#[cfg(feature = "v1")]
use hyperswitch_domain_models::payment_methods::PaymentMethodWithRawData;
#[cfg(feature = "v2")]
@@ -1253,7 +1254,7 @@ pub fn generate_payment_method_session_response(
#[cfg(feature = "v2")]
impl transformers::ForeignFrom<api_models::payment_methods::ConnectorTokenDetails>
- for hyperswitch_domain_models::mandates::ConnectorTokenReferenceRecord
+ for mandates::ConnectorTokenReferenceRecord
{
fn foreign_from(item: api_models::payment_methods::ConnectorTokenDetails) -> Self {
let api_models::payment_methods::ConnectorTokenDetails {
@@ -1285,16 +1286,16 @@ impl transformers::ForeignFrom<api_models::payment_methods::ConnectorTokenDetail
impl
transformers::ForeignFrom<(
id_type::MerchantConnectorAccountId,
- hyperswitch_domain_models::mandates::ConnectorTokenReferenceRecord,
+ mandates::ConnectorTokenReferenceRecord,
)> for api_models::payment_methods::ConnectorTokenDetails
{
fn foreign_from(
(connector_id, mandate_reference_record): (
id_type::MerchantConnectorAccountId,
- hyperswitch_domain_models::mandates::ConnectorTokenReferenceRecord,
+ mandates::ConnectorTokenReferenceRecord,
),
) -> Self {
- let hyperswitch_domain_models::mandates::ConnectorTokenReferenceRecord {
+ let mandates::ConnectorTokenReferenceRecord {
connector_token_request_reference_id,
original_payment_authorized_amount,
original_payment_authorized_currency,
@@ -1427,13 +1428,13 @@ impl DomainPaymentMethodWrapper {
.map(|connector_tokens| {
let payments_map: std::collections::HashMap<
id_type::MerchantConnectorAccountId,
- hyperswitch_domain_models::mandates::PaymentsMandateReferenceRecord,
+ mandates::PaymentsMandateReferenceRecord,
> = connector_tokens
.iter()
.map(|token_detail| {
(
token_detail.connector_id.clone(),
- hyperswitch_domain_models::mandates::PaymentsMandateReferenceRecord {
+ mandates::PaymentsMandateReferenceRecord {
connector_mandate_id: token_detail.token.clone().expose(),
payment_method_type: response.payment_method_type,
original_payment_authorized_amount: token_detail
@@ -1459,9 +1460,7 @@ impl DomainPaymentMethodWrapper {
})
.collect();
- serde_json::to_value(
- hyperswitch_domain_models::mandates::PaymentsMandateReference(payments_map),
- )
+ serde_json::to_value(mandates::PaymentsMandateReference(payments_map))
})
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
@@ -1551,13 +1550,13 @@ impl DomainPaymentMethodWrapper {
.map(|connector_tokens| {
let payments_map: std::collections::HashMap<
id_type::MerchantConnectorAccountId,
- hyperswitch_domain_models::mandates::PaymentsMandateReferenceRecord,
+ mandates::PaymentsMandateReferenceRecord,
> = connector_tokens
.iter()
.map(|token_detail| {
(
token_detail.connector_id.clone(),
- hyperswitch_domain_models::mandates::PaymentsMandateReferenceRecord {
+ mandates::PaymentsMandateReferenceRecord {
connector_mandate_id: token_detail.token.clone().expose(),
payment_method_type: None,
original_payment_authorized_amount: token_detail
@@ -1583,9 +1582,7 @@ impl DomainPaymentMethodWrapper {
})
.collect();
- serde_json::to_value(
- hyperswitch_domain_models::mandates::PaymentsMandateReference(payments_map),
- )
+ serde_json::to_value(mandates::PaymentsMandateReference(payments_map))
})
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 329b36c436..a1e628cf76 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -1,3 +1,4 @@
+use hyperswitch_domain_models::mandates;
pub mod access_token;
pub mod conditional_configs;
pub mod customers;
@@ -8380,10 +8381,10 @@ where
.as_ref()
.and_then(|inner| inner.mandate_reference_id.as_ref())
.map(|mandate_reference| match mandate_reference {
- api_models::payments::MandateReferenceId::ConnectorMandateId(_) => true,
- api_models::payments::MandateReferenceId::NetworkMandateId(_)
- | api_models::payments::MandateReferenceId::CardWithLimitedData
- | api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_) => false,
+ mandates::MandateReferenceId::ConnectorMandateId(_) => true,
+ mandates::MandateReferenceId::NetworkMandateId(_)
+ | mandates::MandateReferenceId::CardWithLimitedData
+ | mandates::MandateReferenceId::NetworkTokenWithNTI(_) => false,
})
.unwrap_or(false);
@@ -8681,7 +8682,7 @@ where
pub payment_attempt: storage::PaymentAttempt,
pub multiple_capture_data: Option<types::MultipleCaptureData>,
pub amount: api::Amount,
- pub mandate_id: Option<api_models::payments::MandateIds>,
+ pub mandate_id: Option<mandates::MandateIds>,
pub mandate_connector: Option<MandateConnectorDetails>,
pub currency: storage_enums::Currency,
pub setup_mandate: Option<MandateData>,
@@ -10694,7 +10695,7 @@ where
.merchant_connector_id,
);
- payment_data.set_mandate_id(payments_api::MandateIds {
+ payment_data.set_mandate_id(mandates::MandateIds {
mandate_id: None,
mandate_reference_id,
});
@@ -10755,7 +10756,7 @@ pub fn get_mandate_reference_id<F: Clone, D>(
connector_routing_data: api::ConnectorRoutingData,
payment_data: &mut D,
payment_method_info: &domain::PaymentMethod,
-) -> RouterResult<Option<api_models::payments::MandateReferenceId>>
+) -> RouterResult<Option<mandates::MandateReferenceId>>
where
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
{
@@ -10763,14 +10764,14 @@ where
Some(ActionType::NetworkTokenWithNetworkTransactionId(network_token_data)) => {
logger::info!("using network token with network_transaction_id for MIT flow");
- Some(payments_api::MandateReferenceId::NetworkTokenWithNTI(
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(
network_token_data.into(),
))
}
Some(ActionType::CardWithNetworkTransactionId(card_with_nti_ref)) => {
logger::info!("using card with network_transaction_id for MIT flow");
- Some(payments_api::MandateReferenceId::NetworkMandateId(
+ Some(mandates::MandateReferenceId::NetworkMandateId(
card_with_nti_ref.into(),
))
}
@@ -10804,8 +10805,8 @@ where
payment_data.set_recurring_mandate_payment_data(mandate_reference_record.into());
- Some(payments_api::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
+ Some(mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
Some(mandate_reference_record.connector_mandate_id.clone()),
Some(payment_method_info.get_id().clone()),
None,
@@ -10877,8 +10878,8 @@ where
}))
},
)?;
- let mandate_reference_id = Some(payments_api::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
+ let mandate_reference_id = Some(mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
Some(mandate_reference_record.connector_mandate_id.clone()),
Some(payment_method_info.get_id().clone()),
// update_history
@@ -10909,7 +10910,7 @@ where
.attach_printable("Failed to fetch the network transaction id")?;
let transaction_link_id = payment_method_info.network_transaction_link_id.clone();
- let mandate_reference_id = Some(payments_api::MandateReferenceId::NetworkMandateId(
+ let mandate_reference_id = Some(mandates::MandateReferenceId::NetworkMandateId(
CardWithNTIRef {
network_transaction_id: network_transaction_id.to_string(),
transaction_link_id,
@@ -10935,7 +10936,7 @@ where
.merchant_connector_id
.clone_from(&chosen_connector_data.merchant_connector_id);
- payment_data.set_mandate_id(payments_api::MandateIds {
+ payment_data.set_mandate_id(mandates::MandateIds {
mandate_id: None,
mandate_reference_id,
});
@@ -10969,7 +10970,7 @@ pub struct NTWithNTIRef {
pub token_exp_year: Option<Secret<String>>,
}
-impl From<NTWithNTIRef> for payments_api::NetworkTokenWithNTIRef {
+impl From<NTWithNTIRef> for mandates::NetworkTokenWithNTIRef {
fn from(network_token_data: NTWithNTIRef) -> Self {
Self {
network_transaction_id: network_token_data.network_transaction_id,
@@ -10986,7 +10987,7 @@ pub struct CardWithNTIRef {
pub transaction_link_id: Option<String>,
}
-impl From<CardWithNTIRef> for payments_api::NetworkMandateIdRef {
+impl From<CardWithNTIRef> for mandates::NetworkMandateIdRef {
fn from(card_data: CardWithNTIRef) -> Self {
Self {
network_transaction_id: card_data.network_transaction_id,
@@ -11001,7 +11002,7 @@ pub enum ActionType {
NetworkTokenWithNetworkTransactionId(NTWithNTIRef),
CardWithNetworkTransactionId(CardWithNTIRef),
#[cfg(feature = "v1")]
- ConnectorMandate(hyperswitch_domain_models::mandates::PaymentsMandateReference),
+ ConnectorMandate(mandates::PaymentsMandateReference),
}
pub fn filter_network_tokenization_supported_connectors(
@@ -11033,9 +11034,7 @@ impl ActionTypesBuilder {
pub fn with_mandate_flow(
mut self,
is_mandate_flow: bool,
- connector_mandate_details: Option<
- hyperswitch_domain_models::mandates::PaymentsMandateReference,
- >,
+ connector_mandate_details: Option<mandates::PaymentsMandateReference>,
) -> Self {
if is_mandate_flow {
self.action_types.extend(
@@ -12582,7 +12581,7 @@ pub trait OperationSessionGetters<F> {
fn get_client_secret(&self) -> &Option<Secret<String>>;
fn get_payment_method_info(&self) -> Option<&domain::PaymentMethod>;
fn get_payment_method_token(&self) -> Option<&PaymentMethodToken>;
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds>;
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds>;
fn get_address(&self) -> &PaymentAddress;
fn get_creds_identifier(&self) -> Option<&str>;
fn get_token(&self) -> Option<&str>;
@@ -12690,7 +12689,7 @@ pub trait OperationSessionSetters<F> {
recurring_mandate_payment_data:
hyperswitch_domain_models::router_data::RecurringMandatePaymentData,
);
- fn set_mandate_id(&mut self, mandate_id: api_models::payments::MandateIds);
+ fn set_mandate_id(&mut self, mandate_id: mandates::MandateIds);
fn set_setup_future_usage_in_payment_intent(
&mut self,
setup_future_usage: storage_enums::FutureUsage,
@@ -12750,7 +12749,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {
self.payment_method_token.as_ref()
}
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
self.mandate_id.as_ref()
}
@@ -13045,7 +13044,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentData<F> {
self.recurring_mandate_payment_data = Some(recurring_mandate_payment_data);
}
- fn set_mandate_id(&mut self, mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, mandate_id: mandates::MandateIds) {
self.mandate_id = Some(mandate_id);
}
@@ -13133,7 +13132,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {
todo!()
}
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
todo!()
}
@@ -13373,7 +13372,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentIntentData<F> {
todo!()
}
- fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, _mandate_id: mandates::MandateIds) {
todo!()
}
@@ -13453,7 +13452,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {
todo!()
}
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
todo!()
}
@@ -13691,7 +13690,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentConfirmData<F> {
todo!()
}
- fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, _mandate_id: mandates::MandateIds) {
todo!()
}
@@ -13771,7 +13770,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {
todo!()
}
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
todo!()
}
@@ -14005,7 +14004,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentStatusData<F> {
todo!()
}
- fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, _mandate_id: mandates::MandateIds) {
todo!()
}
@@ -14084,7 +14083,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentCaptureData<F> {
todo!()
}
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
todo!()
}
@@ -14320,7 +14319,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentCaptureData<F> {
todo!()
}
- fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, _mandate_id: mandates::MandateIds) {
todo!()
}
@@ -14394,7 +14393,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentAttemptListData<F> {
todo!()
}
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
todo!()
}
@@ -14561,7 +14560,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentCancelData<F> {
todo!()
}
- fn get_mandate_id(&self) -> Option<&payments_api::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
todo!()
}
@@ -14790,7 +14789,7 @@ impl<F: Clone> OperationSessionSetters<F> for PaymentCancelData<F> {
todo!()
}
- fn set_mandate_id(&mut self, _mandate_id: api_models::payments::MandateIds) {
+ fn set_mandate_id(&mut self, _mandate_id: mandates::MandateIds) {
todo!()
}
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index ddcb87aaf7..3f2c4b9f87 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -13,7 +13,7 @@ use hyperswitch_connectors::constants as connector_consts;
use hyperswitch_domain_models::payments::PaymentConfirmData;
use hyperswitch_domain_models::{
errors::api_error_response::ApiErrorResponse,
- payments as domain_payments, router_data,
+ mandates, payments as domain_payments, router_data,
router_data_v2::{flow_common_types, PaymentFlowData},
router_flow_types, router_request_types, router_response_types,
};
@@ -1218,7 +1218,7 @@ impl mandate::MandateBehaviour for types::PaymentsAuthorizeData {
fn get_amount(&self) -> i64 {
self.amount
}
- fn get_mandate_id(&self) -> Option<&api_models::payments::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
self.mandate_id.as_ref()
}
fn get_payment_method_data(&self) -> domain::payments::PaymentMethodData {
@@ -1227,13 +1227,11 @@ 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<&hyperswitch_domain_models::mandates::MandateData> {
+ fn get_setup_mandate_details(&self) -> Option<&mandates::MandateData> {
self.setup_mandate_details.as_ref()
}
- fn set_mandate_id(&mut self, new_mandate_id: Option<api_models::payments::MandateIds>) {
+ fn set_mandate_id(&mut self, new_mandate_id: Option<mandates::MandateIds>) {
self.mandate_id = new_mandate_id;
}
fn get_customer_acceptance(&self) -> Option<common_payments_types::CustomerAcceptance> {
diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
index 6f554d0e18..01b2d92213 100644
--- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs
+++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
@@ -3,7 +3,7 @@ use common_enums;
use common_types::payments as common_payments_types;
use hyperswitch_connectors::constants as connector_consts;
use hyperswitch_domain_models::{
- payments as domain_payments, router_data,
+ mandates, payments as domain_payments, router_data,
router_data_v2::{flow_common_types, PaymentFlowData},
router_flow_types, router_request_types, router_response_types,
};
@@ -610,11 +610,11 @@ impl mandate::MandateBehaviour for types::SetupMandateRequestData {
self.setup_future_usage
}
- fn get_mandate_id(&self) -> Option<&api_models::payments::MandateIds> {
+ fn get_mandate_id(&self) -> Option<&mandates::MandateIds> {
self.mandate_id.as_ref()
}
- fn set_mandate_id(&mut self, new_mandate_id: Option<api_models::payments::MandateIds>) {
+ fn set_mandate_id(&mut self, new_mandate_id: Option<mandates::MandateIds>) {
self.mandate_id = new_mandate_id;
}
@@ -622,9 +622,7 @@ impl mandate::MandateBehaviour for types::SetupMandateRequestData {
self.payment_method_data.clone()
}
- fn get_setup_mandate_details(
- &self,
- ) -> Option<&hyperswitch_domain_models::mandates::MandateData> {
+ fn get_setup_mandate_details(&self) -> Option<&mandates::MandateData> {
self.setup_mandate_details.as_ref()
}
fn get_customer_acceptance(&self) -> Option<common_payments_types::CustomerAcceptance> {
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 5c072c24bb..011a007750 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -41,6 +41,7 @@ use futures::future::Either;
use hyperswitch_domain_models::payments::payment_intent::CustomerData;
pub use hyperswitch_domain_models::{customer, type_encryption::AsyncLift};
use hyperswitch_domain_models::{
+ mandates,
mandates::MandateData,
payment_method_data::{GetPaymentMethodType, PazeWalletData},
payments::{
@@ -2386,13 +2387,13 @@ pub enum VaultFetchAction {
FetchCardDetailsFromLocker,
FetchCardDetailsForNetworkTransactionIdFlowFromLocker,
FetchNetworkTokenDataFromTokenizationService(String),
- FetchNetworkTokenDetailsFromLocker(api_models::payments::NetworkTokenWithNTIRef),
+ FetchNetworkTokenDetailsFromLocker(mandates::NetworkTokenWithNTIRef),
NoFetchAction,
}
pub fn decide_payment_method_retrieval_action(
is_network_tokenization_enabled: bool,
- mandate_id: Option<api_models::payments::MandateIds>,
+ mandate_id: Option<mandates::MandateIds>,
connector: Option<api_enums::Connector>,
network_tokenization_supported_connectors: &HashSet<api_enums::Connector>,
should_retry_with_pan: bool,
@@ -2599,7 +2600,7 @@ pub async fn should_execute_based_on_rollout(
pub fn determine_standard_vault_action(
is_network_tokenization_enabled: bool,
- mandate_id: Option<api_models::payments::MandateIds>,
+ mandate_id: Option<mandates::MandateIds>,
connector: Option<api_enums::Connector>,
network_tokenization_supported_connectors: &HashSet<api_enums::Connector>,
network_token_requestor_ref_id: Option<String>,
@@ -2618,16 +2619,16 @@ pub fn determine_standard_vault_action(
} else {
match mandate_id {
Some(mandate_ids) => match mandate_ids.mandate_reference_id {
- Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(nt_data)) => {
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(nt_data)) => {
VaultFetchAction::FetchNetworkTokenDetailsFromLocker(nt_data)
}
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(_)) => {
+ Some(mandates::MandateReferenceId::NetworkMandateId(_)) => {
VaultFetchAction::FetchCardDetailsForNetworkTransactionIdFlowFromLocker
}
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(_)) | None => {
+ Some(mandates::MandateReferenceId::ConnectorMandateId(_)) | None => {
VaultFetchAction::NoFetchAction
}
- Some(api_models::payments::MandateReferenceId::CardWithLimitedData) => {
+ Some(mandates::MandateReferenceId::CardWithLimitedData) => {
VaultFetchAction::NoFetchAction
}
},
@@ -2663,7 +2664,7 @@ pub async fn retrieve_payment_method_data_with_permanent_token(
card_token_data: Option<&domain::CardToken>,
platform: &domain::Platform,
_storage_scheme: enums::MerchantStorageScheme,
- mandate_id: Option<api_models::payments::MandateIds>,
+ mandate_id: Option<mandates::MandateIds>,
payment_method_info: domain::PaymentMethod,
business_profile: &domain::Profile,
connector: Option<String>,
@@ -3017,7 +3018,7 @@ pub async fn fetch_network_token_details_from_locker(
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
network_token_locker_id: &str,
- network_transaction_data: api_models::payments::NetworkTokenWithNTIRef,
+ network_transaction_data: mandates::NetworkTokenWithNTIRef,
) -> RouterResult<domain::NetworkTokenData> {
let mut token_data =
cards::get_card_from_locker(state, customer_id, merchant_id, network_token_locker_id)
@@ -3263,7 +3264,7 @@ struct PmModTransformedData(Option<domain::PaymentMethodData>);
impl<'a>
TryFrom<(
Option<&'a domain::PaymentMethodData>,
- Option<&'a api_models::payments::MandateReferenceId>,
+ Option<&'a mandates::MandateReferenceId>,
)> for PmModTransformedData
{
type Error = error_stack::Report<errors::ApiErrorResponse>;
@@ -3271,7 +3272,7 @@ impl<'a>
fn try_from(
value: (
Option<&'a domain::PaymentMethodData>,
- Option<&'a api_models::payments::MandateReferenceId>,
+ Option<&'a mandates::MandateReferenceId>,
),
) -> Result<Self, Self::Error> {
let (payment_method_data, selected_mandate_reference) = value;
@@ -3283,14 +3284,14 @@ impl<'a>
| domain::PaymentMethodData::CardWithOptionalCVC(_)
| domain::PaymentMethodData::Card(_),
),
- Some(&api_models::payments::MandateReferenceId::ConnectorMandateId(_)),
+ Some(&mandates::MandateReferenceId::ConnectorMandateId(_)),
) => Some(domain::PaymentMethodData::MandatePayment),
// NT + NTI flow when NetworkTokenWithNTI mandate reference is selected.
(
Some(domain::PaymentMethodData::CardWithNetworkTokenDetails(
card_with_network_token_details,
)),
- Some(&api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_)),
+ Some(&mandates::MandateReferenceId::NetworkTokenWithNTI(_)),
) => Some(domain::PaymentMethodData::NetworkToken(
domain::NetworkTokenData::from(
card_with_network_token_details
@@ -3303,7 +3304,7 @@ impl<'a>
Some(domain::PaymentMethodData::CardWithNetworkTokenDetails(
card_with_network_token_details,
)),
- Some(&api_models::payments::MandateReferenceId::NetworkMandateId(_)),
+ Some(&mandates::MandateReferenceId::NetworkMandateId(_)),
) => {
let card_details = &card_with_network_token_details.card_details;
Some(
@@ -3329,7 +3330,7 @@ impl<'a>
// Card + NTI flow when NetworkMandateId is selected for CardWithOptionalCVC.
(
Some(domain::PaymentMethodData::CardWithOptionalCVC(card_data)),
- Some(&api_models::payments::MandateReferenceId::NetworkMandateId(_)),
+ Some(&mandates::MandateReferenceId::NetworkMandateId(_)),
) => Some(
domain::PaymentMethodData::CardDetailsForNetworkTransactionId(
domain::CardDetailsForNetworkTransactionId::foreign_try_from(card_data)?,
@@ -3372,7 +3373,7 @@ impl<'a>
// Wallet MIT via PSP token (ConnectorMandateId)
(
Some(domain::PaymentMethodData::Wallet(_)),
- Some(&api_models::payments::MandateReferenceId::ConnectorMandateId(_)),
+ Some(&mandates::MandateReferenceId::ConnectorMandateId(_)),
) => Some(domain::PaymentMethodData::MandatePayment),
// Wallet CIT flow - pass through as-is
(Some(domain::PaymentMethodData::Wallet(_)), _) => payment_method_data.cloned(),
@@ -4352,15 +4353,13 @@ pub fn generate_mandate(
Ok(Some(
match data.mandate_type.get_required_value("mandate_type")? {
- hyperswitch_domain_models::mandates::MandateDataType::SingleUse(data) => {
- new_mandate
- .set_mandate_amount(Some(data.amount.get_amount_as_i64()))
- .set_mandate_currency(Some(data.currency))
- .set_mandate_type(storage_enums::MandateType::SingleUse)
- .to_owned()
- }
+ mandates::MandateDataType::SingleUse(data) => new_mandate
+ .set_mandate_amount(Some(data.amount.get_amount_as_i64()))
+ .set_mandate_currency(Some(data.currency))
+ .set_mandate_type(storage_enums::MandateType::SingleUse)
+ .to_owned(),
- hyperswitch_domain_models::mandates::MandateDataType::MultiUse(op_data) => {
+ mandates::MandateDataType::MultiUse(op_data) => {
match op_data {
Some(data) => new_mandate
.set_mandate_amount(Some(data.amount.get_amount_as_i64()))
@@ -8329,7 +8328,7 @@ pub async fn decide_action_for_unified_authentication_service<F: Clone>(
business_profile: &domain::Profile,
payment_data: &mut PaymentData<F>,
connector_call_type: &api::ConnectorCallType,
- mandate_type: Option<api_models::payments::MandateTransactionType>,
+ mandate_type: Option<mandates::MandateTransactionType>,
) -> RouterResult<Option<UnifiedAuthenticationServiceFlow>> {
let external_authentication_flow = get_payment_external_authentication_flow_during_confirm(
state,
@@ -8399,7 +8398,7 @@ pub async fn get_payment_external_authentication_flow_during_confirm<F: Clone>(
business_profile: &domain::Profile,
payment_data: &mut PaymentData<F>,
connector_call_type: &api::ConnectorCallType,
- mandate_type: Option<api_models::payments::MandateTransactionType>,
+ mandate_type: Option<mandates::MandateTransactionType>,
) -> RouterResult<Option<PaymentExternalAuthenticationFlow>> {
let authentication_id = payment_data.payment_attempt.authentication_id.clone();
let is_authentication_type_3ds = payment_data.payment_attempt.authentication_type
@@ -8436,8 +8435,7 @@ pub async fn get_payment_external_authentication_flow_during_confirm<F: Clone>(
})
} else if separate_authentication_requested
&& is_authentication_type_3ds
- && mandate_type
- != Some(api_models::payments::MandateTransactionType::RecurringMandateTransaction)
+ && mandate_type != Some(mandates::MandateTransactionType::RecurringMandateTransaction)
{
if let Some((connector_data, card)) = connector_supports_separate_authn.zip(card) {
let token = payment_data
@@ -9208,20 +9206,18 @@ pub fn update_request_data_with_mandate_id(
{
if let Some(mandate_ref) = mandate_reference.as_ref() {
if let Some(connector_mandate_id) = &mandate_ref.connector_mandate_id {
- request_data.set_mandate_id(api_models::payments::MandateIds {
+ request_data.set_mandate_id(mandates::MandateIds {
mandate_id: Some(connector_mandate_id.clone()),
- mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
- Some(connector_mandate_id.clone()),
- None,
- None,
- None,
- None,
- None,
- ),
+ mandate_reference_id: Some(mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
+ Some(connector_mandate_id.clone()),
+ None,
+ None,
+ None,
+ None,
+ None,
),
- ),
+ )),
});
}
}
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index d395aefe5a..ef73b2d6ab 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -1,3 +1,4 @@
+use hyperswitch_domain_models::mandates;
#[cfg(feature = "v1")]
pub mod payment_approve;
#[cfg(feature = "v1")]
@@ -416,7 +417,7 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {
_business_profile: &domain::Profile,
_processor: &domain::Processor,
_initiator: Option<&domain::Initiator>,
- _mandate_type: Option<api_models::payments::MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> CustomResult<(), errors::ApiErrorResponse> {
Ok(())
}
@@ -430,7 +431,7 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {
_connector_call_type: &ConnectorCallType,
_business_profile: &domain::Profile,
_platform: &domain::Platform,
- _mandate_type: Option<api_models::payments::MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> CustomResult<(), errors::ApiErrorResponse> {
Ok(())
}
diff --git a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
index 161f345901..35804a59e1 100644
--- a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
+++ b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
@@ -8,7 +8,7 @@ use common_utils::{
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
- payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
+ mandates, payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use hyperswitch_interfaces::api::ConnectorSpecifications;
use hyperswitch_masking::PeekInterface;
@@ -271,11 +271,11 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ExternalVaultP
);
// TODO: Implement external vault specific mandate data handling
- let mandate_data_input = api_models::payments::MandateIds {
+ let mandate_data_input = mandates::MandateIds {
mandate_id: None,
mandate_reference_id: processor_payment_token.map(|token| {
- api_models::payments::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
+ mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
Some(token),
None,
None,
diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
index a730b59c2f..926c7bce2a 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
@@ -1,8 +1,9 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
@@ -251,7 +252,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsCancelPostCaptureRequest, Pa
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- _mandate_type: Option<MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> errors::CustomResult<
(
PaymentCancelPostCaptureOperation<'a, F>,
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index 07de33da39..3001593eb8 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -1,9 +1,10 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use common_utils::ext_traits::AsyncExt;
use error_stack::{report, ResultExt};
+use hyperswitch_domain_models::mandates;
use router_derive::PaymentOperation;
use router_env::{instrument, tracing};
@@ -414,7 +415,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- _mandate_type: Option<MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> CustomResult<
(CompleteAuthorizeOperation<'a, F>, Option<domain::Customer>),
errors::StorageError,
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 459500a3de..d71baf8300 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -6,10 +6,7 @@ use api_models::{
admin::ExtendedCardInfoConfig,
enums::FrmSuggestion,
mandates::RecurringDetails,
- payments::{
- ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData,
- MandateTransactionType,
- },
+ payments::{ExtendedCardInfo, GetAddressFromPaymentMethodData},
};
use async_trait::async_trait;
use common_utils::ext_traits::{AsyncExt, Encode, StringExt, ValueExt};
@@ -17,6 +14,8 @@ use diesel_models::payment_attempt::ConnectorMandateReferenceId as DieselConnect
use error_stack::{report, ResultExt};
use futures::FutureExt;
use hyperswitch_domain_models::{
+ mandates,
+ mandates::{ConnectorMandateReferenceId, MandateTransactionType},
payment_method_data::RecurringDetails as domain_recurring_details,
payment_methods::PaymentMethodWithRawData,
payments::{self as domain_payments, payment_intent::PaymentIntentUpdateFields},
@@ -817,10 +816,10 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
.and_then(|recurring_details| match recurring_details {
RecurringDetails::ProcessorPaymentToken(token) => {
payment_intent.is_payment_processor_token_flow = Some(true);
- Some(api_models::payments::MandateIds {
+ Some(mandates::MandateIds {
mandate_id: None,
mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::ConnectorMandateId(
+ mandates::MandateReferenceId::ConnectorMandateId(
ConnectorMandateReferenceId::new(
Some(token.processor_payment_token.clone()), // connector_mandate_id
None, // payment_method_id
@@ -837,7 +836,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
| RecurringDetails::NetworkTransactionIdAndNetworkTokenDetails(_)
| RecurringDetails::NetworkTransactionIdAndDecryptedWalletTokenDetails(_)
| RecurringDetails::NetworkTransactionIdAndCardDetails(_) => {
- Some(api_models::payments::MandateIds {
+ Some(mandates::MandateIds {
mandate_id: None,
mandate_reference_id: mandate_reference_id_from_recurring_details,
})
diff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
index 8348d2e9c7..88e0683721 100644
--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
@@ -2,7 +2,7 @@ use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use async_trait::async_trait;
use common_utils::{ext_traits::Encode, fp_utils::when, id_type, types::keymanager::ToEncryptable};
use error_stack::ResultExt;
-use hyperswitch_domain_models::payments::PaymentConfirmData;
+use hyperswitch_domain_models::{mandates, payments::PaymentConfirmData};
use hyperswitch_interfaces::api::ConnectorSpecifications;
use hyperswitch_masking::{ExposeOptionInterface, PeekInterface};
use router_env::{instrument, tracing};
@@ -701,10 +701,10 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsConfirmIntentRequest, PaymentConf
.as_ref()
.and_then(|mandate_details| mandate_details.mandate_reference_id.as_ref())
.map(|mandate_reference| match mandate_reference {
- api_models::payments::MandateReferenceId::ConnectorMandateId(_) => true,
- api_models::payments::MandateReferenceId::NetworkMandateId(_)
- | api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_)
- | api_models::payments::MandateReferenceId::CardWithLimitedData => false,
+ mandates::MandateReferenceId::ConnectorMandateId(_) => true,
+ mandates::MandateReferenceId::NetworkMandateId(_)
+ | mandates::MandateReferenceId::NetworkTokenWithNTI(_)
+ | mandates::MandateReferenceId::CardWithLimitedData => false,
})
.unwrap_or(false);
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index e7e84bf0db..899706bde7 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -1,10 +1,8 @@
use std::marker::PhantomData;
use api_models::{
- enums::FrmSuggestion,
- mandates::RecurringDetails,
- payment_methods::PaymentMethodsData,
- payments::{GetAddressFromPaymentMethodData, MandateTransactionType},
+ enums::FrmSuggestion, mandates::RecurringDetails, payment_methods::PaymentMethodsData,
+ payments::GetAddressFromPaymentMethodData,
};
use async_trait::async_trait;
use common_types::payments as common_payments_types;
@@ -19,7 +17,8 @@ use common_utils::{
use diesel_models::payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId;
use error_stack::{self, ResultExt};
use hyperswitch_domain_models::{
- mandates::MandateDetails,
+ mandates,
+ mandates::{MandateDetails, MandateTransactionType},
payment_method_data::RecurringDetails as domain_recurring_details,
payment_methods::PaymentMethodWithRawData,
payments::{payment_attempt::PaymentAttempt, FromRequestEncryptablePaymentIntent},
@@ -415,16 +414,21 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
.mandate_id
.as_ref()
.or_else(|| {
- request.recurring_details
- .as_ref()
- .and_then(|recurring_details| match recurring_details {
- RecurringDetails::MandateId(id) => Some(id),
- _ => None,
- })
- })
+ request
+ .recurring_details
+ .as_ref()
+ .and_then(|recurring_details| match recurring_details {
+ RecurringDetails::MandateId(id) => Some(id),
+ _ => None,
+ })
+ })
.async_and_then(|mandate_id| async {
let mandate = db
- .find_mandate_by_merchant_id_mandate_id(platform.get_processor().get_account().get_id(), mandate_id, platform.get_processor().get_account().storage_scheme)
+ .find_mandate_by_merchant_id_mandate_id(
+ platform.get_processor().get_account().get_id(),
+ mandate_id,
+ platform.get_processor().get_account().storage_scheme,
+ )
.await
.to_not_found_response(errors::ApiErrorResponse::MandateNotFound);
Some(mandate.and_then(|mandate_obj| {
@@ -433,35 +437,39 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
mandate_obj.connector_mandate_ids,
) {
(_, Some(connector_mandate_id)) => connector_mandate_id
- .parse_value("ConnectorMandateId")
- .change_context(errors::ApiErrorResponse::MandateNotFound)
- .map(|connector_id: api_models::payments::ConnectorMandateReferenceId| {
- api_models::payments::MandateIds {
- mandate_id: Some(mandate_obj.mandate_id),
- mandate_reference_id: Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
- connector_id.get_connector_mandate_id(),
- connector_id.get_payment_method_id(),
- None,
- None,
- connector_id.get_connector_mandate_request_reference_id(),
- None
- )
- ))
- }
- }),
- (Some(network_tx_id), _) => Ok(api_models::payments::MandateIds {
+ .parse_value("ConnectorMandateId")
+ .change_context(errors::ApiErrorResponse::MandateNotFound)
+ .map(|connector_id: mandates::ConnectorMandateReferenceId| {
+ mandates::MandateIds {
+ mandate_id: Some(mandate_obj.mandate_id),
+ mandate_reference_id: Some(
+ mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
+ connector_id.get_connector_mandate_id(),
+ connector_id.get_payment_method_id(),
+ None,
+ None,
+ connector_id
+ .get_connector_mandate_request_reference_id(),
+ None,
+ ),
+ ),
+ ),
+ }
+ }),
+ (Some(network_tx_id), _) => Ok(mandates::MandateIds {
mandate_id: Some(mandate_obj.mandate_id),
mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::NetworkMandateId(
- api_models::payments::NetworkMandateIdRef {
+ mandates::MandateReferenceId::NetworkMandateId(
+ mandates::NetworkMandateIdRef {
network_transaction_id: network_tx_id,
- transaction_link_id: mandate_obj.network_transaction_link_id,
+ transaction_link_id: mandate_obj
+ .network_transaction_link_id,
},
),
),
}),
- (_, _) => Ok(api_models::payments::MandateIds {
+ (_, _) => Ok(mandates::MandateIds {
mandate_id: Some(mandate_obj.mandate_id),
mandate_reference_id: None,
}),
@@ -476,28 +484,26 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
.recurring_details
.as_ref()
.and_then(|recurring_details| match recurring_details {
- RecurringDetails::ProcessorPaymentToken(token) => {
- Some(api_models::payments::MandateIds {
- mandate_id: None,
- mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
- Some(token.processor_payment_token.clone()),
- None,
- None,
- None,
- None,
- None,
- ),
+ RecurringDetails::ProcessorPaymentToken(token) => Some(mandates::MandateIds {
+ mandate_id: None,
+ mandate_reference_id: Some(
+ mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
+ Some(token.processor_payment_token.clone()),
+ None,
+ None,
+ None,
+ None,
+ None,
),
),
- })
- }
+ ),
+ }),
RecurringDetails::CardWithLimitedData(_)
| RecurringDetails::NetworkTransactionIdAndNetworkTokenDetails(_)
| RecurringDetails::NetworkTransactionIdAndDecryptedWalletTokenDetails(_)
| RecurringDetails::NetworkTransactionIdAndCardDetails(_) => {
- Some(api_models::payments::MandateIds {
+ Some(mandates::MandateIds {
mandate_id: None,
mandate_reference_id: mandate_reference_id_from_recurring_details,
})
@@ -599,7 +605,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
payment_attempt.connector_mandate_detail =
Some(DieselConnectorMandateReferenceId::foreign_from(
- api_models::payments::ConnectorMandateReferenceId::new(
+ mandates::ConnectorMandateReferenceId::new(
None,
None,
None, // update_history
diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
index 4f4d8a4ea0..0f3d309e6b 100644
--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
@@ -1,8 +1,9 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates::MandateTransactionType;
use hyperswitch_masking::PeekInterface;
use router_derive::PaymentOperation;
use router_env::{instrument, tracing};
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index ef0bb3a34d..7789485c48 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -4,7 +4,6 @@ use std::{collections::HashMap, ops::Deref};
use ::payment_methods::client::{
BankDebitDetailUpdate, CardDetailUpdate, PaymentMethodUpdateData, UpdatePaymentMethodV1Payload,
};
-use api_models::payments::{ConnectorMandateReferenceId, MandateReferenceId};
#[cfg(feature = "dynamic_routing")]
use api_models::routing::RoutableConnectorChoice;
use async_trait::async_trait;
@@ -21,7 +20,11 @@ use futures::FutureExt;
use hyperswitch_domain_models::payments::{
PaymentConfirmData, PaymentIntentData, PaymentStatusData,
};
-use hyperswitch_domain_models::{behaviour::Conversion, payments::payment_attempt::PaymentAttempt};
+use hyperswitch_domain_models::{
+ behaviour::Conversion,
+ mandates::{self, ConnectorMandateReferenceId, MandateReferenceId},
+ payments::payment_attempt::PaymentAttempt,
+};
#[cfg(feature = "v2")]
use hyperswitch_masking::{ExposeInterface, PeekInterface};
use router_derive;
@@ -650,7 +653,7 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor
connector_mandate_reference_id
.clone()
.map(ForeignFrom::foreign_from);
- payment_data.set_mandate_id(api_models::payments::MandateIds {
+ payment_data.set_mandate_id(mandates::MandateIds {
mandate_id: None,
mandate_reference_id: connector_mandate_reference_id.map(
|connector_mandate_id| {
@@ -1678,7 +1681,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
{
payment_data.mandate_id = payment_data.mandate_id.or_else(|| {
router_data.request.mandate_id.clone()
- // .map(api_models::payments::MandateIds::new)
+ // .map(mandates::MandateIds::new)
});
payment_data = Box::pin(payment_response_update_tracker(
@@ -1805,7 +1808,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
payment_data.payment_attempt.connector_mandate_detail = connector_mandate_reference_id
.clone()
.map(ForeignFrom::foreign_from);
- payment_data.set_mandate_id(api_models::payments::MandateIds {
+ payment_data.set_mandate_id(mandates::MandateIds {
mandate_id: None,
mandate_reference_id: connector_mandate_reference_id.map(|connector_mandate_id| {
MandateReferenceId::ConnectorMandateId(connector_mandate_id)
@@ -3322,9 +3325,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
let updated_metadata_info = updated_metadata_details
.map(|data| {
- serde_json::from_value::<api_models::payments::UpdatedMandateDetails>(
- data.peek().clone(),
- )
+ serde_json::from_value::<mandates::UpdatedMandateDetails>(data.peek().clone())
})
.transpose()
.inspect_err(|e| {
@@ -3337,20 +3338,18 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
.flatten();
let mandate_data_updated = match updated_metadata_info {
- Some(data) => Some(api_models::payments::MandateIds {
+ Some(data) => Some(mandates::MandateIds {
mandate_id: None,
- mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
- mandate_reference_id,
- None,
- None,
- None,
- None,
- Some(data),
- ),
+ mandate_reference_id: Some(mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
+ mandate_reference_id,
+ None,
+ None,
+ None,
+ None,
+ Some(data),
),
- ),
+ )),
}),
None => payment_data.mandate_data,
};
@@ -3874,7 +3873,7 @@ fn update_connector_mandate_details_for_the_flow<F: Clone>(
.clone()
.map(ForeignFrom::foreign_from);
- payment_data.set_mandate_id(api_models::payments::MandateIds {
+ payment_data.set_mandate_id(mandates::MandateIds {
mandate_id: None,
mandate_reference_id: connector_mandate_reference_id.map(|connector_mandate_id| {
MandateReferenceId::ConnectorMandateId(connector_mandate_id)
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index 6e337ab70d..b4a15c84b9 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -1,11 +1,10 @@
use std::marker::PhantomData;
-use api_models::{
- admin::PaymentMethodsEnabled, enums::FrmSuggestion, payments::MandateTransactionType,
-};
+use api_models::{admin::PaymentMethodsEnabled, enums::FrmSuggestion};
use async_trait::async_trait;
use common_utils::ext_traits::{AsyncExt, ValueExt};
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
use router_derive::PaymentOperation;
use router_env::{instrument, logger, tracing};
@@ -337,7 +336,7 @@ where
provider: &domain::Provider,
initiator: Option<&domain::Initiator>,
dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- _mandate_type: Option<MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> errors::CustomResult<
(PaymentSessionOperation<'a, F>, Option<domain::Customer>),
errors::StorageError,
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index 38b1c2ba9c..fe2fd4c3e2 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -1,8 +1,9 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
use router_derive::PaymentOperation;
use router_env::{instrument, logger, tracing};
@@ -315,7 +316,7 @@ where
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- _mandate_type: Option<MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> CustomResult<
(PaymentSessionOperation<'a, F>, Option<domain::Customer>),
errors::StorageError,
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index ea3c6ffc26..b8c1c0a3df 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -1,9 +1,10 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use common_utils::ext_traits::AsyncExt;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates::{self, MandateTransactionType};
use router_derive::PaymentOperation;
use router_env::{instrument, logger, tracing};
@@ -517,7 +518,7 @@ async fn get_tracker_for_sync<
mandate_id: payment_attempt
.mandate_id
.clone()
- .map(|id| api_models::payments::MandateIds {
+ .map(|id| mandates::MandateIds {
mandate_id: Some(id),
mandate_reference_id: None,
}),
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index 015bbcb270..58b661b670 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -1,10 +1,8 @@
use std::marker::PhantomData;
use api_models::{
- customers::CustomerDocumentDetails,
- enums::FrmSuggestion,
- mandates::RecurringDetails,
- payments::{MandateTransactionType, RequestSurchargeDetails},
+ customers::CustomerDocumentDetails, enums::FrmSuggestion, mandates::RecurringDetails,
+ payments::RequestSurchargeDetails,
};
use async_trait::async_trait;
use common_utils::{
@@ -12,8 +10,9 @@ use common_utils::{
pii::Email,
};
use error_stack::{report, ResultExt};
-use hyperswitch_domain_models::payments::payment_intent::{
- CustomerData, PaymentIntentUpdateFields,
+use hyperswitch_domain_models::{
+ mandates::{self, MandateTransactionType},
+ payments::payment_intent::{CustomerData, PaymentIntentUpdateFields},
};
use router_derive::PaymentOperation;
use router_env::{instrument, tracing};
@@ -323,16 +322,21 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
.mandate_id
.as_ref()
.or_else(|| {
- request.recurring_details
- .as_ref()
- .and_then(|recurring_details| match recurring_details {
- RecurringDetails::MandateId(id) => Some(id),
- _ => None,
- })
- })
+ request
+ .recurring_details
+ .as_ref()
+ .and_then(|recurring_details| match recurring_details {
+ RecurringDetails::MandateId(id) => Some(id),
+ _ => None,
+ })
+ })
.async_and_then(|mandate_id| async {
let mandate = db
- .find_mandate_by_merchant_id_mandate_id(processor_merchant_id, mandate_id, platform.get_processor().get_account().storage_scheme)
+ .find_mandate_by_merchant_id_mandate_id(
+ processor_merchant_id,
+ mandate_id,
+ platform.get_processor().get_account().storage_scheme,
+ )
.await
.change_context(errors::ApiErrorResponse::MandateNotFound);
Some(mandate.and_then(|mandate_obj| {
@@ -340,36 +344,40 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
mandate_obj.network_transaction_id,
mandate_obj.connector_mandate_ids,
) {
- (Some(network_tx_id), _) => Ok(api_models::payments::MandateIds {
+ (Some(network_tx_id), _) => Ok(mandates::MandateIds {
mandate_id: Some(mandate_obj.mandate_id),
mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::NetworkMandateId(
- api_models::payments::NetworkMandateIdRef {
+ mandates::MandateReferenceId::NetworkMandateId(
+ mandates::NetworkMandateIdRef {
network_transaction_id: network_tx_id,
- transaction_link_id: mandate_obj.network_transaction_link_id,
+ transaction_link_id: mandate_obj
+ .network_transaction_link_id,
},
),
),
}),
(_, Some(connector_mandate_id)) => connector_mandate_id
- .parse_value("ConnectorMandateId")
- .change_context(errors::ApiErrorResponse::MandateNotFound)
- .map(|connector_id: api_models::payments::ConnectorMandateReferenceId| {
- api_models::payments::MandateIds {
- mandate_id: Some(mandate_obj.mandate_id),
- mandate_reference_id: Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
- connector_id.get_connector_mandate_id(), // connector_mandate_id
- connector_id.get_payment_method_id(), // payment_method_id
- None, // update_history
- connector_id.get_mandate_metadata(), // mandate_metadata
- connector_id.get_connector_mandate_request_reference_id(),
- None // connector_mandate_request_reference_id
- )
- ))
- }
- }),
- (_, _) => Ok(api_models::payments::MandateIds {
+ .parse_value("ConnectorMandateId")
+ .change_context(errors::ApiErrorResponse::MandateNotFound)
+ .map(|connector_id: mandates::ConnectorMandateReferenceId| {
+ mandates::MandateIds {
+ mandate_id: Some(mandate_obj.mandate_id),
+ mandate_reference_id: Some(
+ mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
+ connector_id.get_connector_mandate_id(), // connector_mandate_id
+ connector_id.get_payment_method_id(), // payment_method_id
+ None, // update_history
+ connector_id.get_mandate_metadata(), // mandate_metadata
+ connector_id
+ .get_connector_mandate_request_reference_id(),
+ None, // connector_mandate_request_reference_id
+ ),
+ ),
+ ),
+ }
+ }),
+ (_, _) => Ok(mandates::MandateIds {
mandate_id: Some(mandate_obj.mandate_id),
mandate_reference_id: None,
}),
diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rs
index cbeaa7068d..dbfbe86fd8 100644
--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs
+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs
@@ -1,9 +1,10 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use common_utils::ext_traits::ValueExt;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
use hyperswitch_masking::ExposeInterface;
use router_derive::PaymentOperation;
use router_env::{instrument, tracing};
@@ -217,7 +218,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsUpdateMetadataRequest, Payme
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- _mandate_type: Option<MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> errors::CustomResult<
(
PaymentUpdateMetadataOperation<'a, F>,
diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
index cea8b1a716..42f131a12f 100644
--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs
@@ -1,8 +1,9 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
@@ -233,7 +234,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsExtendAuthorizationRequest,
_provider: &domain::Provider,
_initiator: Option<&domain::Initiator>,
_dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
- _mandate_type: Option<MandateTransactionType>,
+ _mandate_type: Option<mandates::MandateTransactionType>,
) -> errors::CustomResult<
(
PaymentExtendAuthorizationOperation<'a, F>,
diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
index f8466f67d4..230d3ae2f3 100644
--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
@@ -1,13 +1,11 @@
use std::marker::PhantomData;
-use api_models::{
- enums::FrmSuggestion,
- payments::{MandateTransactionType, PaymentsIncrementalAuthorizationRequest},
-};
+use api_models::{enums::FrmSuggestion, payments::PaymentsIncrementalAuthorizationRequest};
use async_trait::async_trait;
use common_utils::errors::CustomResult;
use diesel_models::authorization::AuthorizationNew;
use error_stack::{report, ResultExt};
+use hyperswitch_domain_models::mandates::MandateTransactionType;
use router_env::{instrument, tracing};
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
diff --git a/crates/router/src/core/payments/operations/proxy_payments_intent.rs b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
index d8655965b9..92bf0b9458 100644
--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs
+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
@@ -4,7 +4,7 @@ use common_enums::enums;
use common_utils::types::keymanager::ToEncryptable;
use error_stack::ResultExt;
use hyperswitch_domain_models::{
- payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
+ mandates, payment_method_data::PaymentMethodData, payments::PaymentConfirmData,
};
use hyperswitch_interfaces::api::ConnectorSpecifications;
use hyperswitch_masking::PeekInterface;
@@ -247,20 +247,18 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentConfirmData<F>, ProxyPaymentsR
.map(|address| address.into_inner()),
Some(true),
);
- let mandate_data_input = api_models::payments::MandateIds {
+ let mandate_data_input = mandates::MandateIds {
mandate_id: None,
- mandate_reference_id: Some(
- api_models::payments::MandateReferenceId::ConnectorMandateId(
- api_models::payments::ConnectorMandateReferenceId::new(
- Some(processor_payment_token),
- None,
- None,
- None,
- None,
- None,
- ),
+ mandate_reference_id: Some(mandates::MandateReferenceId::ConnectorMandateId(
+ mandates::ConnectorMandateReferenceId::new(
+ Some(processor_payment_token),
+ None,
+ None,
+ None,
+ None,
+ None,
),
- ),
+ )),
};
let payment_data = PaymentConfirmData {
diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs
index b241c96a87..64e7fc63ec 100644
--- a/crates/router/src/core/payments/operations/tax_calculation.rs
+++ b/crates/router/src/core/payments/operations/tax_calculation.rs
@@ -1,9 +1,10 @@
use std::marker::PhantomData;
-use api_models::{enums::FrmSuggestion, payments::MandateTransactionType};
+use api_models::enums::FrmSuggestion;
use async_trait::async_trait;
use common_utils::ext_traits::AsyncExt;
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates::MandateTransactionType;
use hyperswitch_masking::PeekInterface;
use router_derive::PaymentOperation;
use router_env::{instrument, tracing};
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index b68b658fec..de394ba687 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -3,7 +3,7 @@ use std::vec::IntoIter;
use common_utils::{ext_traits::Encode, types::MinorUnit};
use diesel_models::enums as storage_enums;
use error_stack::ResultExt;
-use hyperswitch_domain_models::ext_traits::OptionExt;
+use hyperswitch_domain_models::{ext_traits::OptionExt, mandates};
use router_env::{
logger,
tracing::{self, instrument},
@@ -188,7 +188,7 @@ where
payment_data,
&payment_method_info,
)?;
- payment_data.set_mandate_id(api_models::payments::MandateIds {
+ payment_data.set_mandate_id(mandates::MandateIds {
mandate_id: None,
mandate_reference_id, //mandate_ref_id
});
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index 8d55978560..0a6fb879d2 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -1,3 +1,4 @@
+use hyperswitch_domain_models::mandates;
mod transformers;
pub mod utils;
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
@@ -248,10 +249,10 @@ pub fn make_dsl_input(
.mandate_type
.clone()
.map(|mandate_type| match mandate_type {
- hyperswitch_domain_models::mandates::MandateDataType::SingleUse(_) => {
+ mandates::MandateDataType::SingleUse(_) => {
euclid_enums::MandateType::SingleUse
}
- hyperswitch_domain_models::mandates::MandateDataType::MultiUse(_) => {
+ mandates::MandateDataType::MultiUse(_) => {
euclid_enums::MandateType::MultiUse
}
})
@@ -371,12 +372,8 @@ pub fn make_dsl_input(
.as_ref()
.and_then(|mandate_data| {
mandate_data.mandate_type.clone().map(|mt| match mt {
- hyperswitch_domain_models::mandates::MandateDataType::SingleUse(_) => {
- euclid_enums::MandateType::SingleUse
- }
- hyperswitch_domain_models::mandates::MandateDataType::MultiUse(_) => {
- euclid_enums::MandateType::MultiUse
- }
+ mandates::MandateDataType::SingleUse(_) => euclid_enums::MandateType::SingleUse,
+ mandates::MandateDataType::MultiUse(_) => euclid_enums::MandateType::MultiUse,
})
}),
payment_type: Some(
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index 99b124e58c..8ebac8c7f3 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -1,7 +1,6 @@
use std::collections::HashMap;
use ::payment_methods::controller::PaymentMethodsController;
-use api_models::payments::ConnectorMandateReferenceId;
use common_enums::{ConnectorMandateStatus, PaymentMethod};
use common_types::{self, callback_mapper::CallbackMapperData};
use common_utils::{
@@ -13,15 +12,16 @@ use common_utils::{
};
use diesel_models::business_profile::ExternalVaultConnectorDetails;
use error_stack::{report, ResultExt};
-use hyperswitch_domain_models::payment_method_data::{
- get_applepay_wallet_info, get_googlepay_wallet_info,
-};
#[cfg(feature = "v1")]
use hyperswitch_domain_models::{
callback_mapper::CallbackMapper,
mandates::{CommonMandateReference, PaymentsMandateReference, PaymentsMandateReferenceRecord},
payment_method_data,
};
+use hyperswitch_domain_models::{
+ mandates::ConnectorMandateReferenceId,
+ payment_method_data::{get_applepay_wallet_info, get_googlepay_wallet_info},
+};
use hyperswitch_interfaces::api::gateway;
use hyperswitch_masking::{ExposeInterface, Secret};
use router_env::{instrument, tracing};
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 9d0c2bcb8a..f53d87052a 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -7,8 +7,8 @@ use api_models::payments as api_payments;
#[cfg(feature = "v2")]
use api_models::payments::RevenueRecoveryGetIntentResponse;
use api_models::payments::{
- Address, ConnectorMandateReferenceId, CustomerDetails, CustomerDetailsResponse, FrmMessage,
- MandateIds, NetworkDetails, RequestSurchargeDetails,
+ Address, CustomerDetails, CustomerDetailsResponse, FrmMessage, NetworkDetails,
+ RequestSurchargeDetails,
};
use common_enums::{Currency, MerchantAccountType, RequestIncrementalAuthorization};
#[cfg(feature = "v1")]
@@ -38,7 +38,11 @@ use diesel_models::{
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
- payments::payment_intent::CustomerData, router_request_types, sdk_auth::SdkAuthorization,
+ mandates,
+ mandates::{ConnectorMandateReferenceId, MandateIds},
+ payments::payment_intent::CustomerData,
+ router_request_types,
+ sdk_auth::SdkAuthorization,
};
#[cfg(feature = "v2")]
use hyperswitch_domain_models::{
@@ -3928,7 +3932,7 @@ where
customer_acceptance: d.customer_acceptance.clone(),
mandate_type: d.mandate_type.clone().map(|d| match d {
- hyperswitch_domain_models::mandates::MandateDataType::MultiUse(Some(i)) => {
+ mandates::MandateDataType::MultiUse(Some(i)) => {
api::MandateType::MultiUse(Some(api::MandateAmountData {
amount: i.amount,
currency: i.currency,
@@ -3937,7 +3941,7 @@ where
metadata: i.metadata,
}))
}
- hyperswitch_domain_models::mandates::MandateDataType::SingleUse(i) => {
+ mandates::MandateDataType::SingleUse(i) => {
api::MandateType::SingleUse(api::payments::MandateAmountData {
amount: i.amount,
currency: i.currency,
@@ -3946,9 +3950,7 @@ where
metadata: i.metadata,
})
}
- hyperswitch_domain_models::mandates::MandateDataType::MultiUse(None) => {
- api::MandateType::MultiUse(None)
- }
+ mandates::MandateDataType::MultiUse(None) => api::MandateType::MultiUse(None),
}),
update_mandate_id: d.update_mandate_id.clone(),
});
@@ -3973,7 +3975,7 @@ where
.mandate_reference_id
.as_ref()
.and_then(|mandate_ref| match mandate_ref {
- api_models::payments::MandateReferenceId::ConnectorMandateId(
+ mandates::MandateReferenceId::ConnectorMandateId(
connector_mandate_reference_id,
) => connector_mandate_reference_id.get_connector_mandate_id(),
_ => None,
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index fdaac33ea8..f48addf7e3 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -18,6 +18,7 @@ use diesel_models::enums as storage_enums;
use error_stack::{report, ResultExt};
use external_services::grpc_client::unified_connector_service::UnifiedConnectorServiceError;
use hyperswitch_domain_models::{
+ mandates,
mandates::{MandateData, MandateDataType},
router_data::{AccessToken, ErrorResponse, RouterData},
router_flow_types::{
@@ -1792,51 +1793,51 @@ impl
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
let connector_recurring_payment_id = match &router_data.request.mandate_id {
Some(mandate) => match &mandate.mandate_reference_id {
- Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
- connector_mandate_id,
- )) => Some(payments_grpc::MandateReference {
- mandate_id_type: Some(
- payments_grpc::mandate_reference::MandateIdType::ConnectorMandateId(
- payments_grpc::ConnectorMandateReferenceId {
- connector_mandate_id: connector_mandate_id
- .get_connector_mandate_id(),
- payment_method_id: connector_mandate_id.get_payment_method_id(),
- connector_mandate_request_reference_id: connector_mandate_id
- .get_connector_mandate_request_reference_id(),
- },
+ Some(mandates::MandateReferenceId::ConnectorMandateId(connector_mandate_id)) => {
+ Some(payments_grpc::MandateReference {
+ mandate_id_type: Some(
+ payments_grpc::mandate_reference::MandateIdType::ConnectorMandateId(
+ payments_grpc::ConnectorMandateReferenceId {
+ connector_mandate_id: connector_mandate_id
+ .get_connector_mandate_id(),
+ payment_method_id: connector_mandate_id.get_payment_method_id(),
+ connector_mandate_request_reference_id: connector_mandate_id
+ .get_connector_mandate_request_reference_id(),
+ },
+ ),
),
- ),
- }),
- Some(api_models::payments::MandateReferenceId::NetworkMandateId(
- network_mandate_id,
- )) => Some(payments_grpc::MandateReference {
- mandate_id_type: Some(
- payments_grpc::mandate_reference::MandateIdType::NetworkMandateId(
- network_mandate_id.network_transaction_id.clone(),
+ })
+ }
+ Some(mandates::MandateReferenceId::NetworkMandateId(network_mandate_id)) => {
+ Some(payments_grpc::MandateReference {
+ mandate_id_type: Some(
+ payments_grpc::mandate_reference::MandateIdType::NetworkMandateId(
+ network_mandate_id.network_transaction_id.clone(),
+ ),
),
- ),
- }),
- Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(
- network_token_with_nti,
- )) => Some(payments_grpc::MandateReference {
- mandate_id_type: Some(
- payments_grpc::mandate_reference::MandateIdType::NetworkTokenWithNti(
- payments_grpc::NetworkTokenWithNti {
- network_transaction_id: network_token_with_nti
- .network_transaction_id
- .clone(),
- token_exp_month: network_token_with_nti
- .token_exp_month
- .clone()
- .map(|exp| exp.expose().into()),
- token_exp_year: network_token_with_nti
- .token_exp_year
- .clone()
- .map(|exp| exp.expose().into()),
- },
+ })
+ }
+ Some(mandates::MandateReferenceId::NetworkTokenWithNTI(network_token_with_nti)) => {
+ Some(payments_grpc::MandateReference {
+ mandate_id_type: Some(
+ payments_grpc::mandate_reference::MandateIdType::NetworkTokenWithNti(
+ payments_grpc::NetworkTokenWithNti {
+ network_transaction_id: network_token_with_nti
+ .network_transaction_id
+ .clone(),
+ token_exp_month: network_token_with_nti
+ .token_exp_month
+ .clone()
+ .map(|exp| exp.expose().into()),
+ token_exp_year: network_token_with_nti
+ .token_exp_year
+ .clone()
+ .map(|exp| exp.expose().into()),
+ },
+ ),
),
- ),
- }),
+ })
+ }
_ => {
return Err(UnifiedConnectorServiceError::MissingRequiredField {
field_name: "connector_mandate_id",
diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs
index 66bf1a5bd1..244aa8864c 100644
--- a/crates/router/src/types/api/payments.rs
+++ b/crates/router/src/types/api/payments.rs
@@ -16,26 +16,26 @@ pub use api_models::{
payments::{
Address, AddressDetails, Amount, ApplepayPaymentMethod, AuthenticationForStartResponse,
Card, CryptoData, CustomerDetails, CustomerDetailsResponse, HyperswitchVaultSessionDetails,
- MandateAmountData, MandateData, MandateTransactionType, MandateType,
- MandateValidationFields, NextActionType, OpenBankingSessionToken, PayLaterData,
- PaymentIdType, PaymentListConstraints, PaymentListFilters, PaymentListFiltersV2,
- PaymentMethodData, PaymentMethodDataRequest, PaymentMethodDataResponse, PaymentOp,
- PaymentsAggregateResponse, PaymentsApproveRequest, PaymentsCancelPostCaptureRequest,
- PaymentsCancelRequest, PaymentsCaptureRequest, PaymentsCompleteAuthorizeRequest,
- PaymentsDynamicTaxCalculationRequest, PaymentsDynamicTaxCalculationResponse,
- PaymentsExtendAuthorizationRequest, PaymentsExternalAuthenticationRequest,
- PaymentsIncrementalAuthorizationRequest, PaymentsManualUpdateRequest,
- PaymentsPostSessionTokensRequest, PaymentsPostSessionTokensResponse,
- PaymentsRedirectRequest, PaymentsRedirectionResponse, PaymentsRejectRequest,
- PaymentsRequest, PaymentsResponse, PaymentsResponseForm, PaymentsRetrieveRequest,
- PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest,
- PaymentsUpdateMetadataRequest, PaymentsUpdateMetadataResponse, PgRedirectResponse,
- PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VaultSessionDetails,
- VerifyRequest, VerifyResponse, VgsSessionDetails, WalletData,
+ MandateAmountData, MandateData, MandateType, MandateValidationFields, NextActionType,
+ OpenBankingSessionToken, PayLaterData, PaymentIdType, PaymentListConstraints,
+ PaymentListFilters, PaymentListFiltersV2, PaymentMethodData, PaymentMethodDataRequest,
+ PaymentMethodDataResponse, PaymentOp, PaymentsAggregateResponse, PaymentsApproveRequest,
+ PaymentsCancelPostCaptureRequest, PaymentsCancelRequest, PaymentsCaptureRequest,
+ PaymentsCompleteAuthorizeRequest, PaymentsDynamicTaxCalculationRequest,
+ PaymentsDynamicTaxCalculationResponse, PaymentsExtendAuthorizationRequest,
+ PaymentsExternalAuthenticationRequest, PaymentsIncrementalAuthorizationRequest,
+ PaymentsManualUpdateRequest, PaymentsPostSessionTokensRequest,
+ PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, PaymentsRedirectionResponse,
+ PaymentsRejectRequest, PaymentsRequest, PaymentsResponse, PaymentsResponseForm,
+ PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse,
+ PaymentsStartRequest, PaymentsUpdateMetadataRequest, PaymentsUpdateMetadataResponse,
+ PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, UrlDetails,
+ VaultSessionDetails, VerifyRequest, VerifyResponse, VgsSessionDetails, WalletData,
},
};
pub use common_types::payments::{AcceptanceType, CustomerAcceptance, OnlineMandate};
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
pub use hyperswitch_domain_models::router_flow_types::payments::{
Approve, Authorize, AuthorizeSessionToken, Balance, CalculateTax, Capture, CompleteAuthorize,
CreateConnectorCustomer, CreateOrder, ExtendAuthorization, ExternalVaultProxy, GenerateQr,
@@ -53,6 +53,7 @@ pub use hyperswitch_interfaces::api::payments::{
PaymentsPreProcessing, PaymentsPushNotification, SurchargeCalculation, SurchargeComplete,
SurchargeRefund, TaxCalculation,
};
+pub use mandates::MandateTransactionType;
pub use super::payments_v2::{
ConnectorCustomerV2, MandateSetupV2, PaymentApproveV2, PaymentAuthorizeSessionTokenV2,
diff --git a/crates/router/src/types/storage/revenue_recovery_redis_operation.rs b/crates/router/src/types/storage/revenue_recovery_redis_operation.rs
index b292ec6fd7..749acbd097 100644
--- a/crates/router/src/types/storage/revenue_recovery_redis_operation.rs
+++ b/crates/router/src/types/storage/revenue_recovery_redis_operation.rs
@@ -4,6 +4,7 @@ use api_models::revenue_recovery_data_backfill::{self, AccountUpdateHistoryRecor
use common_enums::enums::CardNetwork;
use common_utils::{date_time, errors::CustomResult, id_type};
use error_stack::ResultExt;
+use hyperswitch_domain_models::mandates;
use hyperswitch_masking::{ExposeInterface, PeekInterface, Secret};
use redis_interface::{DelReply, SetnxReply};
use router_env::{instrument, logger, tracing};
@@ -1217,7 +1218,7 @@ impl RedisTokenManager {
state: &SessionState,
customer_id: &str,
scheduled_token: &PaymentProcessorTokenStatus,
- mandate_data: Option<api_models::payments::MandateIds>,
+ mandate_data: Option<mandates::MandateIds>,
payment_attempt_id: &id_type::GlobalAttemptId,
) -> CustomResult<AccountUpdaterAction, errors::StorageError> {
match mandate_data {
@@ -1252,7 +1253,7 @@ impl RedisTokenManager {
fn determine_account_updater_action_based_on_old_token_and_mandate_data(
old_token: &str,
- mandate_data: api_models::payments::MandateIds,
+ mandate_data: mandates::MandateIds,
) -> CustomResult<AccountUpdaterAction, errors::StorageError> {
let new_token = mandate_data.get_connector_mandate_id();
let account_updater_action = match new_token {
@@ -1302,8 +1303,8 @@ impl RedisTokenManager {
}
pub enum AccountUpdaterAction {
- TokenUpdate(String, api_models::payments::UpdatedMandateDetails),
- ExpiryUpdate(api_models::payments::UpdatedMandateDetails),
+ TokenUpdate(String, mandates::UpdatedMandateDetails),
+ ExpiryUpdate(mandates::UpdatedMandateDetails),
ExistingToken,
NoAction,
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index e91379aec1..405cc6a95e 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -16,7 +16,7 @@ use common_utils::{
};
use diesel_models::enums as storage_enums;
use error_stack::{report, ResultExt};
-use hyperswitch_domain_models::payments::payment_intent::CustomerData;
+use hyperswitch_domain_models::{mandates, payments::payment_intent::CustomerData};
use hyperswitch_interfaces::api::ConnectorSpecifications;
use hyperswitch_masking::{ExposeInterface, PeekInterface, Secret};
@@ -247,36 +247,30 @@ impl ForeignFrom<storage_enums::MandateAmountData> for payments::MandateAmountDa
}
// TODO: remove foreign from since this conversion won't be needed in the router crate once data models is treated as a single & primary source of truth for structure information
-impl ForeignFrom<payments::MandateData> for hyperswitch_domain_models::mandates::MandateData {
+impl ForeignFrom<payments::MandateData> for mandates::MandateData {
fn foreign_from(d: payments::MandateData) -> Self {
Self {
customer_acceptance: d.customer_acceptance,
mandate_type: d.mandate_type.map(|d| match d {
payments::MandateType::MultiUse(Some(i)) => {
- hyperswitch_domain_models::mandates::MandateDataType::MultiUse(Some(
- hyperswitch_domain_models::mandates::MandateAmountData {
- amount: i.amount,
- currency: i.currency,
- start_date: i.start_date,
- end_date: i.end_date,
- metadata: i.metadata,
- },
- ))
+ mandates::MandateDataType::MultiUse(Some(mandates::MandateAmountData {
+ amount: i.amount,
+ currency: i.currency,
+ start_date: i.start_date,
+ end_date: i.end_date,
+ metadata: i.metadata,
+ }))
}
payments::MandateType::SingleUse(i) => {
- hyperswitch_domain_models::mandates::MandateDataType::SingleUse(
- hyperswitch_domain_models::mandates::MandateAmountData {
- amount: i.amount,
- currency: i.currency,
- start_date: i.start_date,
- end_date: i.end_date,
- metadata: i.metadata,
- },
- )
- }
- payments::MandateType::MultiUse(None) => {
- hyperswitch_domain_models::mandates::MandateDataType::MultiUse(None)
+ mandates::MandateDataType::SingleUse(mandates::MandateAmountData {
+ amount: i.amount,
+ currency: i.currency,
+ start_date: i.start_date,
+ end_date: i.end_date,
+ metadata: i.metadata,
+ })
}
+ payments::MandateType::MultiUse(None) => mandates::MandateDataType::MultiUse(None),
}),
update_mandate_id: d.update_mandate_id,
}