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(core): rename `MandateTxnType` to `MandateTransactionType` (#1322)

Shankar Singh C10691728d2d6
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index bcdb75824c..c5e0e6977c 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -341,9 +341,9 @@ pub struct VerifyRequest {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
-pub enum MandateTxnType {
- NewMandateTxn,
- RecurringMandateTxn,
+pub enum MandateTransactionType {
+ NewMandateTransaction,
+ RecurringMandateTransaction,
}
#[derive(Default, Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index c32f710cf8..8e7240bcc8 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -267,7 +267,7 @@ pub async fn get_address_by_id(
pub async fn get_token_pm_type_mandate_details(
state: &AppState,
request: &api::PaymentsRequest,
- mandate_type: Option<api::MandateTxnType>,
+ mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
) -> RouterResult<(
Option<String>,
@@ -277,7 +277,7 @@ pub async fn get_token_pm_type_mandate_details(
Option<String>,
)> {
match mandate_type {
- Some(api::MandateTxnType::NewMandateTxn) => {
+ Some(api::MandateTransactionType::NewMandateTransaction) => {
let setup_mandate = request
.mandate_data
.clone()
@@ -290,7 +290,7 @@ pub async fn get_token_pm_type_mandate_details(
None,
))
}
- Some(api::MandateTxnType::RecurringMandateTxn) => {
+ Some(api::MandateTransactionType::RecurringMandateTransaction) => {
let (token_, payment_method_, payment_method_type_, mandate_connector) =
get_token_for_recurring_mandate(state, request, merchant_account).await?;
Ok((
@@ -515,20 +515,22 @@ pub fn validate_card_data(
pub fn validate_mandate(
req: impl Into<api::MandateValidationFields>,
is_confirm_operation: bool,
-) -> CustomResult<Option<api::MandateTxnType>, errors::ApiErrorResponse> {
+) -> CustomResult<Option<api::MandateTransactionType>, errors::ApiErrorResponse> {
let req: api::MandateValidationFields = req.into();
match req.validate_and_get_mandate_type().change_context(
errors::ApiErrorResponse::MandateValidationFailed {
reason: "Expected one out of mandate_id and mandate_data but got both".to_string(),
},
)? {
- Some(api::MandateTxnType::NewMandateTxn) => {
+ Some(api::MandateTransactionType::NewMandateTransaction) => {
validate_new_mandate_request(req, is_confirm_operation)?;
- Ok(Some(api::MandateTxnType::NewMandateTxn))
+ Ok(Some(api::MandateTransactionType::NewMandateTransaction))
}
- Some(api::MandateTxnType::RecurringMandateTxn) => {
+ Some(api::MandateTransactionType::RecurringMandateTransaction) => {
validate_recurring_mandate(req)?;
- Ok(Some(api::MandateTxnType::RecurringMandateTxn))
+ Ok(Some(
+ api::MandateTransactionType::RecurringMandateTransaction,
+ ))
}
None => Ok(None),
}
@@ -1718,15 +1720,17 @@ pub(crate) fn validate_pm_or_token_given(
payment_method: &Option<api_enums::PaymentMethod>,
payment_method_data: &Option<api::PaymentMethodData>,
payment_method_type: &Option<api_enums::PaymentMethodType>,
- mandate_type: &Option<api::MandateTxnType>,
+ mandate_type: &Option<api::MandateTransactionType>,
token: &Option<String>,
) -> Result<(), errors::ApiErrorResponse> {
utils::when(
!matches!(
payment_method_type,
Some(api_enums::PaymentMethodType::Paypal)
- ) && !matches!(mandate_type, Some(api::MandateTxnType::RecurringMandateTxn))
- && token.is_none()
+ ) && !matches!(
+ mandate_type,
+ Some(api::MandateTransactionType::RecurringMandateTransaction)
+ ) && token.is_none()
&& (payment_method_data.is_none() || payment_method.is_none()),
|| {
Err(errors::ApiErrorResponse::InvalidRequestData {
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index dc39c073a9..7b39d6e447 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -69,7 +69,7 @@ pub trait Operation<F: Clone, T>: Send + std::fmt::Debug {
pub struct ValidateResult<'a> {
pub merchant_id: &'a str,
pub payment_id: api::PaymentIdType,
- pub mandate_type: Option<api::MandateTxnType>,
+ pub mandate_type: Option<api::MandateTransactionType>,
pub storage_scheme: enums::MerchantStorageScheme,
}
@@ -90,7 +90,7 @@ pub trait GetTracker<F, D, R>: Send {
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &R,
- mandate_type: Option<api::MandateTxnType>,
+ mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
mechant_key_store: &domain::MerchantKeyStore,
) -> RouterResult<(BoxedOperation<'a, F, R>, D, Option<CustomerDetails>)>;
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index fd11946561..b522be8065 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -34,7 +34,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCancelRequest>
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsCancelRequest,
- _mandate_type: Option<api::MandateTxnType>,
+ _mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs
index 2f6696dedb..82f6b895db 100644
--- a/crates/router/src/core/payments/operations/payment_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_capture.rs
@@ -35,7 +35,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentData<F>, api::PaymentsCaptu
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsCaptureRequest,
- _mandate_type: Option<api::MandateTxnType>,
+ _mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
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 eb581f9cde..9f52c47145 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -36,7 +36,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsRequest,
- mandate_type: Option<api::MandateTxnType>,
+ mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index c6a9ef6c0e..91809e1415 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -37,7 +37,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsRequest,
- mandate_type: Option<api::MandateTxnType>,
+ mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 4b9d78c3a7..f595818823 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -45,7 +45,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsRequest,
- mandate_type: Option<api::MandateTxnType>,
+ mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
merchant_key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_method_validate.rs b/crates/router/src/core/payments/operations/payment_method_validate.rs
index ff63ed050a..f2bc4abb8f 100644
--- a/crates/router/src/core/payments/operations/payment_method_validate.rs
+++ b/crates/router/src/core/payments/operations/payment_method_validate.rs
@@ -69,7 +69,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::VerifyRequest> for Paym
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::VerifyRequest,
- _mandate_type: Option<api::MandateTxnType>,
+ _mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
_mechant_key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index f96efe544e..5589fca3f9 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -37,7 +37,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsSessionRequest>
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsSessionRequest,
- _mandate_type: Option<api::MandateTxnType>,
+ _mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index fd36baffb5..5cd2d11c08 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -33,7 +33,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsStartRequest> f
state: &'a AppState,
payment_id: &api::PaymentIdType,
_request: &api::PaymentsStartRequest,
- _mandate_type: Option<api::MandateTxnType>,
+ _mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
mechant_key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index 6b66c90223..5d22bd3b0a 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -158,7 +158,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRetrieveRequest
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsRetrieveRequest,
- _mandate_type: Option<api::MandateTxnType>,
+ _mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index 3acae6a2fb..507f4034e6 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -36,7 +36,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
state: &'a AppState,
payment_id: &api::PaymentIdType,
request: &api::PaymentsRequest,
- mandate_type: Option<api::MandateTxnType>,
+ mandate_type: Option<api::MandateTransactionType>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> RouterResult<(
diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs
index 067121d22b..7cccae18e1 100644
--- a/crates/router/src/types/api/payments.rs
+++ b/crates/router/src/types/api/payments.rs
@@ -1,6 +1,6 @@
pub use api_models::payments::{
AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card,
- CustomerAcceptance, MandateData, MandateTxnType, MandateType, MandateValidationFields,
+ CustomerAcceptance, MandateData, MandateTransactionType, MandateType, MandateValidationFields,
NextActionType, OnlineMandate, PayLaterData, PaymentIdType, PaymentListConstraints,
PaymentListResponse, PaymentMethodData, PaymentMethodDataResponse, PaymentOp,
PaymentRetrieveBody, PaymentRetrieveBodyWithCredentials, PaymentsCancelRequest,
@@ -20,15 +20,15 @@ use crate::{
};
pub(crate) trait PaymentsRequestExt {
- fn is_mandate(&self) -> Option<MandateTxnType>;
+ fn is_mandate(&self) -> Option<MandateTransactionType>;
}
impl PaymentsRequestExt for PaymentsRequest {
- fn is_mandate(&self) -> Option<MandateTxnType> {
+ fn is_mandate(&self) -> Option<MandateTransactionType> {
match (&self.mandate_data, &self.mandate_id) {
(None, None) => None,
- (_, Some(_)) => Some(MandateTxnType::RecurringMandateTxn),
- (Some(_), _) => Some(MandateTxnType::NewMandateTxn),
+ (_, Some(_)) => Some(MandateTransactionType::RecurringMandateTransaction),
+ (Some(_), _) => Some(MandateTransactionType::NewMandateTransaction),
}
}
}
@@ -115,21 +115,21 @@ impl PaymentIdTypeExt for PaymentIdType {
pub(crate) trait MandateValidationFieldsExt {
fn validate_and_get_mandate_type(
&self,
- ) -> errors::CustomResult<Option<MandateTxnType>, errors::ValidationError>;
+ ) -> errors::CustomResult<Option<MandateTransactionType>, errors::ValidationError>;
}
impl MandateValidationFieldsExt for MandateValidationFields {
fn validate_and_get_mandate_type(
&self,
- ) -> errors::CustomResult<Option<MandateTxnType>, errors::ValidationError> {
+ ) -> errors::CustomResult<Option<MandateTransactionType>, errors::ValidationError> {
match (&self.mandate_data, &self.mandate_id) {
(None, None) => Ok(None),
(Some(_), Some(_)) => Err(errors::ValidationError::InvalidValue {
message: "Expected one out of mandate_id and mandate_data but got both".to_string(),
})
.into_report(),
- (_, Some(_)) => Ok(Some(MandateTxnType::RecurringMandateTxn)),
- (Some(_), _) => Ok(Some(MandateTxnType::NewMandateTxn)),
+ (_, Some(_)) => Ok(Some(MandateTransactionType::RecurringMandateTransaction)),
+ (Some(_), _) => Ok(Some(MandateTransactionType::NewMandateTransaction)),
}
}
}