From fbe395198aea7252e9c4e3fad97956a548d07002 Mon Sep 17 00:00:00 2001 From: Anish Kacham <79566582+AnishKacham@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:07:04 +0530 Subject: [PATCH 01/46] refactor(connector): add amount conversion framework to Shift4 (#6250) --- crates/router/src/connector/shift4.rs | 62 ++++++++++++--- .../src/connector/shift4/transformers.rs | 78 +++++++++++-------- crates/router/src/types/api.rs | 4 +- crates/router/tests/connectors/shift4.rs | 2 +- 4 files changed, 103 insertions(+), 43 deletions(-) diff --git a/crates/router/src/connector/shift4.rs b/crates/router/src/connector/shift4.rs index 895487db3ba8..08c23bc57109 100644 --- a/crates/router/src/connector/shift4.rs +++ b/crates/router/src/connector/shift4.rs @@ -1,8 +1,10 @@ pub mod transformers; -use std::fmt::Debug; - -use common_utils::{ext_traits::ByteSliceExt, request::RequestContent}; +use common_utils::{ + ext_traits::ByteSliceExt, + request::RequestContent, + types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, +}; use diesel_models::enums; use error_stack::{report, ResultExt}; use transformers as shift4; @@ -27,8 +29,18 @@ use crate::{ utils::BytesExt, }; -#[derive(Debug, Clone)] -pub struct Shift4; +#[derive(Clone)] +pub struct Shift4 { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Shift4 { + pub fn new() -> &'static Self { + &Self { + amount_converter: &MinorUnitForConnector, + } + } +} impl ConnectorCommonExt for Shift4 where @@ -206,7 +218,13 @@ impl ConnectorIntegration CustomResult { - let connector_req = shift4::Shift4PaymentsRequest::try_from(req)?; + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?; + let connector_req = shift4::Shift4PaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -470,7 +488,21 @@ impl req: &types::PaymentsPreProcessingRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_req = shift4::Shift4PaymentsRequest::try_from(req)?; + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_amount.ok_or_else(|| { + errors::ConnectorError::MissingRequiredField { + field_name: "minor_amount", + } + })?, + req.request + .currency + .ok_or_else(|| errors::ConnectorError::MissingRequiredField { + field_name: "currency", + })?, + )?; + let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?; + let connector_req = shift4::Shift4PaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -559,7 +591,13 @@ impl req: &types::PaymentsCompleteAuthorizeRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_req = shift4::Shift4PaymentsRequest::try_from(req)?; + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?; + let connector_req = shift4::Shift4PaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -641,7 +679,13 @@ impl ConnectorIntegration, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_req = shift4::Shift4RefundRequest::try_from(req)?; + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_refund_amount, + req.request.currency, + )?; + let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?; + let connector_req = shift4::Shift4RefundRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } diff --git a/crates/router/src/connector/shift4/transformers.rs b/crates/router/src/connector/shift4/transformers.rs index 2210ab0a3614..3b7681511154 100644 --- a/crates/router/src/connector/shift4/transformers.rs +++ b/crates/router/src/connector/shift4/transformers.rs @@ -1,6 +1,6 @@ use api_models::payments; use cards::CardNumber; -use common_utils::pii::SecretSerdeValue; +use common_utils::{pii::SecretSerdeValue, types::MinorUnit}; use error_stack::ResultExt; use masking::Secret; use serde::{Deserialize, Serialize}; @@ -23,11 +23,25 @@ trait Shift4AuthorizePreprocessingCommon { fn get_router_return_url(&self) -> Option; fn get_email_optional(&self) -> Option; fn get_complete_authorize_url(&self) -> Option; - fn get_amount_required(&self) -> Result; fn get_currency_required(&self) -> Result; fn get_payment_method_data_required(&self) -> Result; } +pub struct Shift4RouterData { + pub amount: MinorUnit, + pub router_data: T, +} + +impl TryFrom<(MinorUnit, T)> for Shift4RouterData { + type Error = error_stack::Report; + fn try_from((amount, item): (MinorUnit, T)) -> Result { + Ok(Self { + amount, + router_data: item, + }) + } +} + impl Shift4AuthorizePreprocessingCommon for types::PaymentsAuthorizeData { fn get_email_optional(&self) -> Option { self.email.clone() @@ -37,10 +51,6 @@ impl Shift4AuthorizePreprocessingCommon for types::PaymentsAuthorizeData { self.complete_authorize_url.clone() } - fn get_amount_required(&self) -> Result> { - Ok(self.amount) - } - fn get_currency_required( &self, ) -> Result> { @@ -70,10 +80,6 @@ impl Shift4AuthorizePreprocessingCommon for types::PaymentsPreProcessingData { self.complete_authorize_url.clone() } - fn get_amount_required(&self) -> Result { - self.get_amount() - } - fn get_currency_required(&self) -> Result { self.get_currency() } @@ -95,7 +101,7 @@ impl Shift4AuthorizePreprocessingCommon for types::PaymentsPreProcessingData { } #[derive(Debug, Serialize)] pub struct Shift4PaymentsRequest { - amount: String, + amount: MinorUnit, currency: enums::Currency, captured: bool, #[serde(flatten)] @@ -195,19 +201,19 @@ pub enum CardPayment { CardToken(Secret), } -impl TryFrom<&types::RouterData> +impl TryFrom<&Shift4RouterData<&types::RouterData>> for Shift4PaymentsRequest where Req: Shift4AuthorizePreprocessingCommon, { type Error = Error; fn try_from( - item: &types::RouterData, + item: &Shift4RouterData<&types::RouterData>, ) -> Result { - let submit_for_settlement = item.request.is_automatic_capture()?; - let amount = item.request.get_amount_required()?.to_string(); - let currency = item.request.get_currency_required()?; - let payment_method = Shift4PaymentMethod::try_from(item)?; + let submit_for_settlement = item.router_data.request.is_automatic_capture()?; + let amount = item.amount.to_owned(); + let currency = item.router_data.request.get_currency_required()?; + let payment_method = Shift4PaymentMethod::try_from(item.router_data)?; Ok(Self { amount, currency, @@ -437,27 +443,33 @@ where } } -impl TryFrom<&types::RouterData> - for Shift4PaymentsRequest +impl + TryFrom< + &Shift4RouterData< + &types::RouterData, + >, + > for Shift4PaymentsRequest { type Error = Error; fn try_from( - item: &types::RouterData, + item: &Shift4RouterData< + &types::RouterData, + >, ) -> Result { - match &item.request.payment_method_data { + match &item.router_data.request.payment_method_data { Some(domain::PaymentMethodData::Card(_)) => { let card_token: Shift4CardToken = - to_connector_meta(item.request.connector_meta.clone())?; + to_connector_meta(item.router_data.request.connector_meta.clone())?; Ok(Self { - amount: item.request.amount.to_string(), - currency: item.request.currency, + amount: item.amount.to_owned(), + currency: item.router_data.request.currency, payment_method: Shift4PaymentMethod::CardsNon3DSRequest(Box::new( CardsNon3DSRequest { card: CardPayment::CardToken(card_token.id), - description: item.description.clone(), + description: item.router_data.description.clone(), }, )), - captured: item.request.is_auto_capture()?, + captured: item.router_data.request.is_auto_capture()?, }) } Some(domain::PaymentMethodData::Wallet(_)) @@ -687,7 +699,7 @@ pub struct Token { #[derive(Default, Debug, Deserialize, Serialize)] pub struct ThreeDSecureInfo { - pub amount: i64, + pub amount: MinorUnit, pub currency: String, pub enrolled: bool, #[serde(rename = "liabilityShift")] @@ -814,15 +826,17 @@ impl #[serde(rename_all = "camelCase")] pub struct Shift4RefundRequest { charge_id: String, - amount: i64, + amount: MinorUnit, } -impl TryFrom<&types::RefundsRouterData> for Shift4RefundRequest { +impl TryFrom<&Shift4RouterData<&types::RefundsRouterData>> for Shift4RefundRequest { type Error = Error; - fn try_from(item: &types::RefundsRouterData) -> Result { + fn try_from( + item: &Shift4RouterData<&types::RefundsRouterData>, + ) -> Result { Ok(Self { - charge_id: item.request.connector_transaction_id.clone(), - amount: item.request.refund_amount, + charge_id: item.router_data.request.connector_transaction_id.clone(), + amount: item.amount.to_owned(), }) } } diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index ad878e0b52b3..ec40531ebb92 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -470,7 +470,9 @@ impl ConnectorData { Ok(ConnectorEnum::Old(Box::new(connector::Razorpay::new()))) } enums::Connector::Rapyd => Ok(ConnectorEnum::Old(Box::new(&connector::Rapyd))), - enums::Connector::Shift4 => Ok(ConnectorEnum::Old(Box::new(&connector::Shift4))), + enums::Connector::Shift4 => { + Ok(ConnectorEnum::Old(Box::new(connector::Shift4::new()))) + } enums::Connector::Square => Ok(ConnectorEnum::Old(Box::new(&connector::Square))), enums::Connector::Stax => Ok(ConnectorEnum::Old(Box::new(&connector::Stax))), enums::Connector::Stripe => { diff --git a/crates/router/tests/connectors/shift4.rs b/crates/router/tests/connectors/shift4.rs index fdaa1ebedefc..ce10c9dad1a6 100644 --- a/crates/router/tests/connectors/shift4.rs +++ b/crates/router/tests/connectors/shift4.rs @@ -15,7 +15,7 @@ impl utils::Connector for Shift4Test { fn get_data(&self) -> types::api::ConnectorData { use router::connector::Shift4; utils::construct_connector_data_old( - Box::new(&Shift4), + Box::new(Shift4::new()), types::Connector::Shift4, types::api::GetToken::Connector, None, From c3b0f7c1d6ad95034535048aa50ff6abe9ed6aa0 Mon Sep 17 00:00:00 2001 From: Sidharth-Singh10 <70999945+Sidharth-Singh10@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:08:10 +0530 Subject: [PATCH 02/46] refactor(connector): add amount conversion framework to Wellsfargo (#6298) --- crates/common_utils/src/types.rs | 4 + crates/router/src/connector/wellsfargo.rs | 84 +++++++++++-------- .../src/connector/wellsfargo/transformers.rs | 28 +++---- crates/router/src/types/api.rs | 2 +- crates/router/tests/connectors/wellsfargo.rs | 2 +- 5 files changed, 69 insertions(+), 51 deletions(-) diff --git a/crates/common_utils/src/types.rs b/crates/common_utils/src/types.rs index 2e7977613d62..6a048e53147a 100644 --- a/crates/common_utils/src/types.rs +++ b/crates/common_utils/src/types.rs @@ -580,6 +580,10 @@ impl StringMajorUnit { .ok_or(ParsingError::DecimalToI64ConversionFailure)?; Ok(MinorUnit::new(amount_i64)) } + /// forms a new StringMajorUnit default unit i.e zero + pub fn zero() -> Self { + Self("0".to_string()) + } /// Get string amount from struct to be removed in future pub fn get_amount_as_string(&self) -> String { diff --git a/crates/router/src/connector/wellsfargo.rs b/crates/router/src/connector/wellsfargo.rs index f5cdb6431b35..a63007f0a273 100644 --- a/crates/router/src/connector/wellsfargo.rs +++ b/crates/router/src/connector/wellsfargo.rs @@ -1,9 +1,10 @@ pub mod transformers; -use std::fmt::Debug; - use base64::Engine; -use common_utils::request::RequestContent; +use common_utils::{ + request::RequestContent, + types::{AmountConvertor, MinorUnit, StringMajorUnit, StringMajorUnitForConnector}, +}; use diesel_models::enums; use error_stack::{report, Report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; @@ -12,6 +13,7 @@ use time::OffsetDateTime; use transformers as wellsfargo; use url::Url; +use super::utils::convert_amount; use crate::{ configs::settings, connector::{ @@ -35,10 +37,18 @@ use crate::{ utils::BytesExt, }; -#[derive(Debug, Clone)] -pub struct Wellsfargo; +#[derive(Clone)] +pub struct Wellsfargo { + amount_converter: &'static (dyn AmountConvertor + Sync), +} impl Wellsfargo { + pub fn new() -> &'static Self { + &Self { + amount_converter: &StringMajorUnitForConnector, + } + } + pub fn generate_digest(&self, payload: &[u8]) -> String { let payload_digest = digest::digest(&digest::SHA256, payload); consts::BASE64_ENGINE.encode(payload_digest) @@ -600,12 +610,14 @@ impl ConnectorIntegration CustomResult { - let connector_router_data = wellsfargo::WellsfargoRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + MinorUnit::new(req.request.amount_to_capture), req.request.currency, - req.request.amount_to_capture, - req, - ))?; + )?; + + let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req)); + let connector_req = wellsfargo::WellsfargoPaymentsCaptureRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -792,12 +804,13 @@ impl ConnectorIntegration CustomResult { - let connector_router_data = wellsfargo::WellsfargoRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + MinorUnit::new(req.request.amount), req.request.currency, - req.request.amount, - req, - ))?; + )?; + + let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req)); let connector_req = wellsfargo::WellsfargoPaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -915,20 +928,21 @@ impl ConnectorIntegration CustomResult { - let connector_router_data = wellsfargo::WellsfargoRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + MinorUnit::new(req.request.amount.ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "Amount", + }, + )?), req.request .currency .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "Currency", })?, - req.request - .amount - .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "Amount", - })?, - req, - ))?; + )?; + + let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req)); let connector_req = wellsfargo::WellsfargoVoidRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -1040,12 +1054,13 @@ impl ConnectorIntegration CustomResult { - let connector_router_data = wellsfargo::WellsfargoRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + MinorUnit::new(req.request.refund_amount), req.request.currency, - req.request.refund_amount, - req, - ))?; + )?; + + let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req)); let connector_req = wellsfargo::WellsfargoRefundRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -1204,12 +1219,13 @@ impl req: &types::PaymentsIncrementalAuthorizationRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = wellsfargo::WellsfargoRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + MinorUnit::new(req.request.additional_amount), req.request.currency, - req.request.additional_amount, - req, - ))?; + )?; + + let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req)); let connector_request = wellsfargo::WellsfargoPaymentsIncrementalAuthorizationRequest::try_from( &connector_router_data, diff --git a/crates/router/src/connector/wellsfargo/transformers.rs b/crates/router/src/connector/wellsfargo/transformers.rs index c57306efe318..999b81a2ff9d 100644 --- a/crates/router/src/connector/wellsfargo/transformers.rs +++ b/crates/router/src/connector/wellsfargo/transformers.rs @@ -1,7 +1,10 @@ use api_models::payments; use base64::Engine; use common_enums::FutureUsage; -use common_utils::{pii, types::SemanticVersion}; +use common_utils::{ + pii, + types::{SemanticVersion, StringMajorUnit}, +}; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -26,21 +29,16 @@ use crate::{ #[derive(Debug, Serialize)] pub struct WellsfargoRouterData { - pub amount: String, + pub amount: StringMajorUnit, pub router_data: T, } -impl TryFrom<(&api::CurrencyUnit, enums::Currency, i64, T)> for WellsfargoRouterData { - type Error = error_stack::Report; - fn try_from( - (currency_unit, currency, amount, item): (&api::CurrencyUnit, enums::Currency, i64, T), - ) -> Result { - // This conversion function is used at different places in the file, if updating this, keep a check for those - let amount = utils::get_amount_as_string(currency_unit, amount, currency)?; - Ok(Self { +impl From<(StringMajorUnit, T)> for WellsfargoRouterData { + fn from((amount, router_data): (StringMajorUnit, T)) -> Self { + Self { amount, - router_data: item, - }) + router_data, + } } } @@ -61,7 +59,7 @@ impl TryFrom<&types::SetupMandateRouterData> for WellsfargoZeroMandateRequest { let order_information = OrderInformationWithBill { amount_details: Amount { - total_amount: "0".to_string(), + total_amount: StringMajorUnit::zero(), currency: item.request.currency, }, bill_to: Some(bill_to), @@ -472,14 +470,14 @@ pub struct OrderInformation { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Amount { - total_amount: String, + total_amount: StringMajorUnit, currency: api_models::enums::Currency, } #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct AdditionalAmount { - additional_amount: String, + additional_amount: StringMajorUnit, currency: String, } diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index ec40531ebb92..434352fa1174 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -511,7 +511,7 @@ impl ConnectorData { enums::Connector::Volt => Ok(ConnectorEnum::Old(Box::new(connector::Volt::new()))), enums::Connector::Wellsfargo => { - Ok(ConnectorEnum::Old(Box::new(&connector::Wellsfargo))) + Ok(ConnectorEnum::Old(Box::new(connector::Wellsfargo::new()))) } // enums::Connector::Wellsfargopayout => { diff --git a/crates/router/tests/connectors/wellsfargo.rs b/crates/router/tests/connectors/wellsfargo.rs index 4425c0773772..cab82c59ac85 100644 --- a/crates/router/tests/connectors/wellsfargo.rs +++ b/crates/router/tests/connectors/wellsfargo.rs @@ -11,7 +11,7 @@ impl utils::Connector for WellsfargoTest { fn get_data(&self) -> api::ConnectorData { use router::connector::Wellsfargo; utils::construct_connector_data_old( - Box::new(&Wellsfargo), + Box::new(Wellsfargo::new()), types::Connector::Wellsfargo, api::GetToken::Connector, None, From 4b569c9d5eb9b6403175c958b887d7ace4d9cbbb Mon Sep 17 00:00:00 2001 From: Rutam Prita Mishra Date: Thu, 24 Oct 2024 17:19:22 +0530 Subject: [PATCH 03/46] feat(connector): [Airwallex] Use connector_response_reference_id as reference to merchant (#2747) Co-authored-by: swangi-kumari Co-authored-by: Sakil Mostak <73734619+Sakilmostak@users.noreply.github.com> --- crates/router/src/connector/airwallex/transformers.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/router/src/connector/airwallex/transformers.rs b/crates/router/src/connector/airwallex/transformers.rs index e38999d495b4..d3824e9d0da2 100644 --- a/crates/router/src/connector/airwallex/transformers.rs +++ b/crates/router/src/connector/airwallex/transformers.rs @@ -569,12 +569,12 @@ impl status, reference_id: Some(item.response.id.clone()), response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId(item.response.id), + resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), redirection_data, mandate_reference: None, connector_metadata: None, network_txn_id: None, - connector_response_reference_id: None, + connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, charge_id: None, }), @@ -612,12 +612,12 @@ impl status, reference_id: Some(item.response.id.clone()), response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId(item.response.id), + resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), redirection_data, mandate_reference: None, connector_metadata: None, network_txn_id: None, - connector_response_reference_id: None, + connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, charge_id: None, }), From a31d1641fb9e1c9efd652c6f191f6b29c75dc69b Mon Sep 17 00:00:00 2001 From: Piotr Idzik <65706193+vil02@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:49:39 +0200 Subject: [PATCH 04/46] docs(openapi): improve `rust_locker_open_api_spec` (#6322) --- api-reference-v2/rust_locker_open_api_spec.yml | 8 ++++---- api-reference/rust_locker_open_api_spec.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api-reference-v2/rust_locker_open_api_spec.yml b/api-reference-v2/rust_locker_open_api_spec.yml index 729886d9cd0d..17a19fec44da 100644 --- a/api-reference-v2/rust_locker_open_api_spec.yml +++ b/api-reference-v2/rust_locker_open_api_spec.yml @@ -2,16 +2,16 @@ openapi: "3.0.2" info: title: Tartarus - OpenAPI 3.0 description: |- - This the the open API 3.0 specification for the card locker. + This is the OpenAPI 3.0 specification for the card locker. This is used by the [hyperswitch](https://github.com/juspay/hyperswitch) for storing card information securely. version: "1.0" tags: - name: Key Custodian description: API used to initialize the locker after deployment. - name: Data - description: CRUD APIs to for working with data to be stored in the locker + description: CRUD APIs for working with data to be stored in the locker - name: Cards - description: CRUD APIs to for working with cards data to be stored in the locker (deprecated) + description: CRUD APIs for working with cards data to be stored in the locker (deprecated) paths: /custodian/key1: post: @@ -39,7 +39,7 @@ paths: tags: - Key Custodian summary: Provide Key 2 - description: Provide the first key to unlock the locker + description: Provide the second key to unlock the locker operationId: setKey2 requestBody: description: Provide key 2 to unlock the locker diff --git a/api-reference/rust_locker_open_api_spec.yml b/api-reference/rust_locker_open_api_spec.yml index 729886d9cd0d..17a19fec44da 100644 --- a/api-reference/rust_locker_open_api_spec.yml +++ b/api-reference/rust_locker_open_api_spec.yml @@ -2,16 +2,16 @@ openapi: "3.0.2" info: title: Tartarus - OpenAPI 3.0 description: |- - This the the open API 3.0 specification for the card locker. + This is the OpenAPI 3.0 specification for the card locker. This is used by the [hyperswitch](https://github.com/juspay/hyperswitch) for storing card information securely. version: "1.0" tags: - name: Key Custodian description: API used to initialize the locker after deployment. - name: Data - description: CRUD APIs to for working with data to be stored in the locker + description: CRUD APIs for working with data to be stored in the locker - name: Cards - description: CRUD APIs to for working with cards data to be stored in the locker (deprecated) + description: CRUD APIs for working with cards data to be stored in the locker (deprecated) paths: /custodian/key1: post: @@ -39,7 +39,7 @@ paths: tags: - Key Custodian summary: Provide Key 2 - description: Provide the first key to unlock the locker + description: Provide the second key to unlock the locker operationId: setKey2 requestBody: description: Provide key 2 to unlock the locker From 673b8691e092e145ba211050db4f5c7e021a0ce2 Mon Sep 17 00:00:00 2001 From: Debarati Ghatak <88573135+cookieg13@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:54:59 +0530 Subject: [PATCH 05/46] feat(connector): [Novalnet] Integrate wallets Paypal and Googlepay (#6370) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- .../connector_configs/toml/development.toml | 23 ++ crates/connector_configs/toml/production.toml | 23 ++ crates/connector_configs/toml/sandbox.toml | 23 ++ .../src/connectors/novalnet.rs | 7 +- .../src/connectors/novalnet/transformers.rs | 232 ++++++++++++++++-- 5 files changed, 285 insertions(+), 23 deletions(-) diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index 180aadffde36..ba6d3cb2b432 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -2260,12 +2260,35 @@ type="Text" payment_method_type = "CartesBancaires" [[novalnet.debit]] payment_method_type = "UnionPay" +[[novalnet.wallet]] + payment_method_type = "google_pay" +[[novalnet.wallet]] + payment_method_type = "paypal" [novalnet.connector_auth.SignatureKey] api_key="Product Activation Key" key1="Payment Access Key" api_secret="Tariff ID" [novalnet.connector_webhook_details] merchant_secret="Source verification key" +placeholder="Enter Payment Access Key" +[[novalnet.metadata.google_pay]] +name="merchant_name" +label="Google Pay Merchant Name" +placeholder="Enter Google Pay Merchant Name" +required=true +type="Text" +[[novalnet.metadata.google_pay]] +name="merchant_id" +label="Google Pay Merchant Id" +placeholder="Enter Google Pay Merchant Id" +required=true +type="Text" +[[novalnet.metadata.google_pay]] +name="gateway_merchant_id" +label="Google Pay Merchant Key" +placeholder="Enter Google Pay Merchant Key" +required=true +type="Text" [nuvei] [[nuvei.credit]] diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml index c7849fcc2278..0e7ffe782f1e 100644 --- a/crates/connector_configs/toml/production.toml +++ b/crates/connector_configs/toml/production.toml @@ -1782,12 +1782,35 @@ merchant_secret="Source verification key" payment_method_type = "CartesBancaires" [[novalnet.debit]] payment_method_type = "UnionPay" +[[novalnet.wallet]] + payment_method_type = "google_pay" +[[novalnet.wallet]] + payment_method_type = "paypal" [novalnet.connector_auth.SignatureKey] api_key="Product Activation Key" key1="Payment Access Key" api_secret="Tariff ID" [novalnet.connector_webhook_details] merchant_secret="Source verification key" +placeholder="Enter Payment Access Key" +[[novalnet.metadata.google_pay]] +name="merchant_name" +label="Google Pay Merchant Name" +placeholder="Enter Google Pay Merchant Name" +required=true +type="Text" +[[novalnet.metadata.google_pay]] +name="merchant_id" +label="Google Pay Merchant Id" +placeholder="Enter Google Pay Merchant Id" +required=true +type="Text" +[[novalnet.metadata.google_pay]] +name="gateway_merchant_id" +label="Google Pay Merchant Key" +placeholder="Enter Google Pay Merchant Key" +required=true +type="Text" [nuvei] [[nuvei.credit]] diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml index 2a753008e81a..8f8ec9bc1c1c 100644 --- a/crates/connector_configs/toml/sandbox.toml +++ b/crates/connector_configs/toml/sandbox.toml @@ -2256,12 +2256,35 @@ type="Text" payment_method_type = "CartesBancaires" [[novalnet.debit]] payment_method_type = "UnionPay" +[[novalnet.wallet]] + payment_method_type = "google_pay" +[[novalnet.wallet]] + payment_method_type = "paypal" [novalnet.connector_auth.SignatureKey] api_key="Product Activation Key" key1="Payment Access Key" api_secret="Tariff ID" [novalnet.connector_webhook_details] merchant_secret="Source verification key" +placeholder="Enter Payment Access Key" +[[novalnet.metadata.google_pay]] +name="merchant_name" +label="Google Pay Merchant Name" +placeholder="Enter Google Pay Merchant Name" +required=true +type="Text" +[[novalnet.metadata.google_pay]] +name="merchant_id" +label="Google Pay Merchant Id" +placeholder="Enter Google Pay Merchant Id" +required=true +type="Text" +[[novalnet.metadata.google_pay]] +name="gateway_merchant_id" +label="Google Pay Merchant Key" +placeholder="Enter Google Pay Merchant Key" +required=true +type="Text" [nuvei] [[nuvei.credit]] diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs index 36fe04fdab10..acb3013dbaa4 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs @@ -195,8 +195,11 @@ impl ConnectorValidation for Novalnet { pm_type: Option, pm_data: PaymentMethodData, ) -> CustomResult<(), errors::ConnectorError> { - let mandate_supported_pmd: HashSet = - HashSet::from([PaymentMethodDataType::Card]); + let mandate_supported_pmd: HashSet = HashSet::from([ + PaymentMethodDataType::Card, + PaymentMethodDataType::GooglePay, + PaymentMethodDataType::PaypalRedirect, + ]); utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) } } diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs index 3c635f88cd4b..ab209a4db051 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs @@ -12,7 +12,7 @@ use common_utils::{ }; use error_stack::ResultExt; use hyperswitch_domain_models::{ - payment_method_data::PaymentMethodData, + payment_method_data::{PaymentMethodData, WalletData as WalletDataPaymentMethod}, router_data::{ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::refunds::{Execute, RSync}, router_request_types::{PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData, ResponseId}, @@ -55,6 +55,8 @@ impl From<(StringMinorUnit, T)> for NovalnetRouterData { #[derive(Debug, Copy, Serialize, Deserialize, Clone)] pub enum NovalNetPaymentTypes { CREDITCARD, + PAYPAL, + GOOGLEPAY, } #[derive(Default, Debug, Serialize, Clone)] @@ -96,10 +98,16 @@ pub struct NovalnetMandate { token: Secret, } +#[derive(Default, Debug, Clone, Serialize, Deserialize)] +pub struct NovalnetGooglePay { + wallet_data: Secret, +} + #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(untagged)] pub enum NovalNetPaymentData { - PaymentCard(NovalnetCard), + Card(NovalnetCard), + GooglePay(NovalnetGooglePay), MandatePayment(NovalnetMandate), } @@ -115,7 +123,7 @@ pub struct NovalnetPaymentsRequestTransaction { amount: StringMinorUnit, currency: common_enums::Currency, order_no: String, - payment_data: NovalNetPaymentData, + payment_data: Option, hook_url: Option, return_url: Option, error_return_url: Option, @@ -131,6 +139,50 @@ pub struct NovalnetPaymentsRequest { custom: NovalnetCustom, } +impl TryFrom<&api_enums::PaymentMethodType> for NovalNetPaymentTypes { + type Error = error_stack::Report; + fn try_from(item: &api_enums::PaymentMethodType) -> Result { + match item { + api_enums::PaymentMethodType::Credit => Ok(Self::CREDITCARD), + api_enums::PaymentMethodType::Debit + | api_enums::PaymentMethodType::Klarna + | api_enums::PaymentMethodType::BancontactCard + | api_enums::PaymentMethodType::Blik + | api_enums::PaymentMethodType::Eps + | api_enums::PaymentMethodType::Giropay + | api_enums::PaymentMethodType::Ideal + | api_enums::PaymentMethodType::OnlineBankingCzechRepublic + | api_enums::PaymentMethodType::OnlineBankingFinland + | api_enums::PaymentMethodType::OnlineBankingPoland + | api_enums::PaymentMethodType::OnlineBankingSlovakia + | api_enums::PaymentMethodType::Sofort + | api_enums::PaymentMethodType::Trustly => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Novalnet"), + ))? + } + api_enums::PaymentMethodType::GooglePay => Ok(Self::GOOGLEPAY), + api_enums::PaymentMethodType::AliPay + | api_enums::PaymentMethodType::ApplePay + | api_enums::PaymentMethodType::AliPayHk + | api_enums::PaymentMethodType::MbWay + | api_enums::PaymentMethodType::MobilePay + | api_enums::PaymentMethodType::WeChatPay + | api_enums::PaymentMethodType::SamsungPay + | api_enums::PaymentMethodType::Affirm + | api_enums::PaymentMethodType::AfterpayClearpay + | api_enums::PaymentMethodType::PayBright + | api_enums::PaymentMethodType::Walley => Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Novalnet"), + ))?, + api_enums::PaymentMethodType::Paypal => Ok(Self::PAYPAL), + _ => Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Novalnet"), + ))?, + } + } +} + impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaymentsRequest { type Error = error_stack::Report; fn try_from( @@ -182,6 +234,12 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym .unwrap_or(consts::DEFAULT_LOCALE.to_string().to_string()); let custom = NovalnetCustom { lang }; let hook_url = item.router_data.request.get_webhook_url()?; + let return_url = item.router_data.request.get_return_url()?; + let create_token = if item.router_data.request.is_mandate_payment() { + Some(1) + } else { + None + }; match item .router_data @@ -192,19 +250,13 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym { None => match item.router_data.request.payment_method_data { PaymentMethodData::Card(ref req_card) => { - let novalnet_card = NovalNetPaymentData::PaymentCard(NovalnetCard { + let novalnet_card = NovalNetPaymentData::Card(NovalnetCard { card_number: req_card.card_number.clone(), card_expiry_month: req_card.card_exp_month.clone(), card_expiry_year: req_card.card_exp_year.clone(), card_cvc: req_card.card_cvc.clone(), card_holder: item.router_data.get_billing_full_name()?, }); - let create_token = if item.router_data.request.is_mandate_payment() { - Some(1) - } else { - None - }; - let return_url = item.router_data.request.get_return_url()?; let transaction = NovalnetPaymentsRequestTransaction { test_mode, @@ -215,7 +267,7 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym hook_url: Some(hook_url), return_url: Some(return_url.clone()), error_return_url: Some(return_url.clone()), - payment_data: novalnet_card, + payment_data: Some(novalnet_card), enforce_3d, create_token, }; @@ -227,6 +279,95 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym custom, }) } + + PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { + WalletDataPaymentMethod::GooglePay(ref req_wallet) => { + let novalnet_google_pay: NovalNetPaymentData = + NovalNetPaymentData::GooglePay(NovalnetGooglePay { + wallet_data: Secret::new( + req_wallet.tokenization_data.token.clone(), + ), + }); + + let transaction = NovalnetPaymentsRequestTransaction { + test_mode, + payment_type: NovalNetPaymentTypes::GOOGLEPAY, + amount: 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: None, + error_return_url: None, + payment_data: Some(novalnet_google_pay), + enforce_3d: None, + create_token, + }; + + Ok(Self { + merchant, + transaction, + customer, + custom, + }) + } + WalletDataPaymentMethod::ApplePay(_) + | WalletDataPaymentMethod::AliPayQr(_) + | WalletDataPaymentMethod::AliPayRedirect(_) + | WalletDataPaymentMethod::AliPayHkRedirect(_) + | WalletDataPaymentMethod::MomoRedirect(_) + | WalletDataPaymentMethod::KakaoPayRedirect(_) + | WalletDataPaymentMethod::GoPayRedirect(_) + | WalletDataPaymentMethod::GcashRedirect(_) + | WalletDataPaymentMethod::ApplePayRedirect(_) + | WalletDataPaymentMethod::ApplePayThirdPartySdk(_) + | WalletDataPaymentMethod::DanaRedirect {} + | WalletDataPaymentMethod::GooglePayRedirect(_) + | WalletDataPaymentMethod::GooglePayThirdPartySdk(_) + | WalletDataPaymentMethod::MbWayRedirect(_) + | WalletDataPaymentMethod::MobilePayRedirect(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("novalnet"), + ) + .into()) + } + WalletDataPaymentMethod::PaypalRedirect(_) => { + let transaction = NovalnetPaymentsRequestTransaction { + test_mode, + payment_type: NovalNetPaymentTypes::PAYPAL, + amount: 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: None, + enforce_3d: None, + create_token, + }; + Ok(Self { + merchant, + transaction, + customer, + custom, + }) + } + WalletDataPaymentMethod::PaypalSdk(_) + | WalletDataPaymentMethod::Paze(_) + | WalletDataPaymentMethod::SamsungPay(_) + | WalletDataPaymentMethod::TwintRedirect {} + | WalletDataPaymentMethod::VippsRedirect {} + | WalletDataPaymentMethod::TouchNGoRedirect(_) + | WalletDataPaymentMethod::WeChatPayRedirect(_) + | WalletDataPaymentMethod::CashappQr(_) + | WalletDataPaymentMethod::SwishQr(_) + | WalletDataPaymentMethod::WeChatPayQr(_) + | WalletDataPaymentMethod::Mifinity(_) => { + 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"), ) @@ -243,16 +384,21 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym token: Secret::new(connector_mandate_id), }); + let payment_type = match item.router_data.request.payment_method_type { + Some(pm_type) => NovalNetPaymentTypes::try_from(&pm_type)?, + None => NovalNetPaymentTypes::CREDITCARD, + }; + let transaction = NovalnetPaymentsRequestTransaction { test_mode, - payment_type: NovalNetPaymentTypes::CREDITCARD, + payment_type, amount: 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: None, error_return_url: None, - payment_data: novalnet_mandate_data, + payment_data: Some(novalnet_mandate_data), enforce_3d, create_token: None, }; @@ -378,6 +524,24 @@ pub fn get_error_response(result: ResultData, status_code: u16) -> ErrorResponse } } +impl NovalnetPaymentsResponseTransactionData { + pub fn get_token(transaction_data: Option<&Self>) -> Option { + if let Some(data) = transaction_data { + match &data.payment_data { + Some(NovalnetResponsePaymentData::Card(card_data)) => { + card_data.token.clone().map(|token| token.expose()) + } + Some(NovalnetResponsePaymentData::Paypal(paypal_data)) => { + paypal_data.token.clone().map(|token| token.expose()) + } + None => None, + } + } else { + None + } + } +} + impl TryFrom> for RouterData { @@ -402,12 +566,20 @@ impl TryFrom TryFrom, pub cc_3d: Option>, pub last_four: Option>, - pub token: Option, + pub token: Option>, +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct NovalnetResponsePaypal { + pub paypal_account: Option, + pub paypal_transaction_id: Option>, + pub token: Option>, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -760,11 +946,15 @@ impl TryFrom<&PaymentsSyncRouterData> for NovalnetSyncRequest { impl NovalnetSyncResponseTransactionData { pub fn get_token(transaction_data: Option<&Self>) -> Option { - if let Some(payment_data) = - transaction_data.and_then(|transaction_data| transaction_data.payment_data.clone()) - { - match &payment_data { - NovalnetResponsePaymentData::PaymentCard(card_data) => card_data.token.clone(), + if let Some(data) = transaction_data { + match &data.payment_data { + Some(NovalnetResponsePaymentData::Card(card_data)) => { + card_data.token.clone().map(|token| token.expose()) + } + Some(NovalnetResponsePaymentData::Paypal(paypal_data)) => { + paypal_data.token.clone().map(|token| token.expose()) + } + None => None, } } else { None From ca325e969b24fbbb5aa7edcdf86d5b3022291db1 Mon Sep 17 00:00:00 2001 From: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:42:23 +0530 Subject: [PATCH 06/46] fix(payments): filter total count by card-network value (#6397) --- crates/api_models/src/payments.rs | 1 + crates/diesel_models/src/query/payment_attempt.rs | 4 ++++ .../hyperswitch_domain_models/src/payments/payment_attempt.rs | 1 + crates/router/src/core/payments.rs | 1 + crates/router/src/db/kafka_store.rs | 2 ++ crates/storage_impl/src/mock_db/payment_attempt.rs | 1 + crates/storage_impl/src/payments/payment_attempt.rs | 4 ++++ 7 files changed, 14 insertions(+) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index fd8419e7f974..61c7911170a3 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -4734,6 +4734,7 @@ impl PaymentListFilterConstraints { && self.payment_method_type.is_none() && self.authentication_type.is_none() && self.merchant_connector_id.is_none() + && self.card_network.is_none() } } diff --git a/crates/diesel_models/src/query/payment_attempt.rs b/crates/diesel_models/src/query/payment_attempt.rs index 549af3ace457..7141675c880a 100644 --- a/crates/diesel_models/src/query/payment_attempt.rs +++ b/crates/diesel_models/src/query/payment_attempt.rs @@ -378,6 +378,7 @@ impl PaymentAttempt { payment_method_type: Option>, authentication_type: Option>, merchant_connector_id: Option>, + card_network: Option>, ) -> StorageResult { let mut filter = ::table() .count() @@ -401,6 +402,9 @@ impl PaymentAttempt { if let Some(merchant_connector_id) = merchant_connector_id { filter = filter.filter(dsl::merchant_connector_id.eq_any(merchant_connector_id)) } + if let Some(card_network) = card_network { + filter = filter.filter(dsl::card_network.eq_any(card_network)) + } router_env::logger::debug!(query = %debug_query::(&filter).to_string()); diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs index 76749097b3b2..4b3fd1f8cf9f 100644 --- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs +++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs @@ -161,6 +161,7 @@ pub trait PaymentAttemptInterface { payment_method_type: Option>, authentication_type: Option>, merchant_connector_id: Option>, + card_network: Option>, storage_scheme: storage_enums::MerchantStorageScheme, ) -> error_stack::Result; } diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 2218197743ae..938d5e292351 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -4051,6 +4051,7 @@ pub async fn apply_filters_on_payments( constraints.payment_method_type, constraints.authentication_type, constraints.merchant_connector_id, + constraints.card_network, merchant.storage_scheme, ) .await diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs index 7ff580e37e17..8ca0b2937666 100644 --- a/crates/router/src/db/kafka_store.rs +++ b/crates/router/src/db/kafka_store.rs @@ -1601,6 +1601,7 @@ impl PaymentAttemptInterface for KafkaStore { payment_method_type: Option>, authentication_type: Option>, merchant_connector_id: Option>, + card_network: Option>, storage_scheme: MerchantStorageScheme, ) -> CustomResult { self.diesel_store @@ -1612,6 +1613,7 @@ impl PaymentAttemptInterface for KafkaStore { payment_method_type, authentication_type, merchant_connector_id, + card_network, storage_scheme, ) .await diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rs index 8171681d3e9e..8adeb7006425 100644 --- a/crates/storage_impl/src/mock_db/payment_attempt.rs +++ b/crates/storage_impl/src/mock_db/payment_attempt.rs @@ -52,6 +52,7 @@ impl PaymentAttemptInterface for MockDb { _payment_method_type: Option>, _authentication_type: Option>, _merchanat_connector_id: Option>, + _card_network: Option>, _storage_scheme: storage_enums::MerchantStorageScheme, ) -> CustomResult { Err(StorageError::MockDbError)? diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs index 36a9da5944b7..6c03bb718b1c 100644 --- a/crates/storage_impl/src/payments/payment_attempt.rs +++ b/crates/storage_impl/src/payments/payment_attempt.rs @@ -406,6 +406,7 @@ impl PaymentAttemptInterface for RouterStore { payment_method_type: Option>, authentication_type: Option>, merchant_connector_id: Option>, + card_network: Option>, _storage_scheme: MerchantStorageScheme, ) -> CustomResult { let conn = self @@ -429,6 +430,7 @@ impl PaymentAttemptInterface for RouterStore { payment_method_type, authentication_type, merchant_connector_id, + card_network, ) .await .map_err(|er| { @@ -1291,6 +1293,7 @@ impl PaymentAttemptInterface for KVRouterStore { payment_method_type: Option>, authentication_type: Option>, merchant_connector_id: Option>, + card_network: Option>, storage_scheme: MerchantStorageScheme, ) -> CustomResult { self.router_store @@ -1302,6 +1305,7 @@ impl PaymentAttemptInterface for KVRouterStore { payment_method_type, authentication_type, merchant_connector_id, + card_network, storage_scheme, ) .await From 4a0afb8213cce47cabe9e3f5d22ad1dccb02c20f Mon Sep 17 00:00:00 2001 From: Mani Chandra <84711804+ThisIsMani@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:45:21 +0530 Subject: [PATCH 07/46] feat(authz): Create a permission generator (#6394) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/user_role.rs | 16 +- crates/common_enums/src/enums.rs | 41 ++++ crates/router/src/analytics.rs | 144 +++++--------- crates/router/src/core/user_role.rs | 9 +- crates/router/src/routes/admin.rs | 50 ++--- crates/router/src/routes/api_keys.rs | 31 +-- crates/router/src/routes/blocklist.rs | 5 - .../router/src/routes/connector_onboarding.rs | 4 - crates/router/src/routes/customers.rs | 28 +-- crates/router/src/routes/disputes.rs | 37 ++-- crates/router/src/routes/mandates.rs | 4 +- crates/router/src/routes/payment_methods.rs | 7 +- crates/router/src/routes/payments.rs | 43 ++-- crates/router/src/routes/payouts.rs | 22 +-- crates/router/src/routes/profiles.rs | 21 +- crates/router/src/routes/recon.rs | 8 +- crates/router/src/routes/refunds.rs | 28 +-- crates/router/src/routes/routing.rs | 142 +++++-------- crates/router/src/routes/user.rs | 24 +-- crates/router/src/routes/user_role.rs | 32 ++- crates/router/src/routes/verification.rs | 5 +- crates/router/src/routes/verify_connector.rs | 4 +- crates/router/src/routes/webhook_events.rs | 10 +- crates/router/src/services/authentication.rs | 22 +-- crates/router/src/services/authorization.rs | 12 -- .../router/src/services/authorization/info.rs | 4 +- .../authorization/permission_groups.rs | 187 ++++++++++-------- .../src/services/authorization/permissions.rs | 110 +++++++---- .../src/services/authorization/roles.rs | 27 ++- crates/router_derive/src/lib.rs | 55 ++++++ crates/router_derive/src/macros.rs | 2 + .../src/macros/generate_permissions.rs | 135 +++++++++++++ 32 files changed, 646 insertions(+), 623 deletions(-) create mode 100644 crates/router_derive/src/macros/generate_permissions.rs diff --git a/crates/api_models/src/user_role.rs b/crates/api_models/src/user_role.rs index e64639646d1c..19027c3cbf86 100644 --- a/crates/api_models/src/user_role.rs +++ b/crates/api_models/src/user_role.rs @@ -1,23 +1,9 @@ -use common_enums::PermissionGroup; +use common_enums::{ParentGroup, PermissionGroup}; use common_utils::pii; use masking::Secret; pub mod role; -#[derive(Clone, Debug, serde::Serialize, PartialEq, Eq, Hash)] -pub enum ParentGroup { - Operations, - Connectors, - Workflows, - Analytics, - Users, - #[serde(rename = "MerchantAccess")] - Merchant, - #[serde(rename = "OrganizationAccess")] - Organization, - Recon, -} - #[derive(Debug, serde::Serialize)] pub struct AuthorizationInfoResponse(pub Vec); diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 3ce9d079c633..c103153eec80 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -2890,6 +2890,47 @@ pub enum PermissionGroup { ReconOps, } +#[derive(Clone, Debug, serde::Serialize, PartialEq, Eq, Hash, strum::EnumIter)] +pub enum ParentGroup { + Operations, + Connectors, + Workflows, + Analytics, + Users, + #[serde(rename = "MerchantAccess")] + Merchant, + #[serde(rename = "OrganizationAccess")] + Organization, + Recon, +} + +#[derive(Clone, Copy, Eq, PartialEq, Hash)] +pub enum Resource { + Payment, + Refund, + ApiKey, + Account, + Connector, + Routing, + Dispute, + Mandate, + Customer, + Analytics, + ThreeDsDecisionManager, + SurchargeDecisionManager, + User, + WebhookEvent, + Payout, + Report, + Recon, +} + +#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] +pub enum PermissionScope { + Read, + Write, +} + /// Name of banks supported by Hyperswitch #[derive( Clone, diff --git a/crates/router/src/analytics.rs b/crates/router/src/analytics.rs index aa6db56bb348..150931e9c8a7 100644 --- a/crates/router/src/analytics.rs +++ b/crates/router/src/analytics.rs @@ -402,8 +402,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -441,8 +440,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -487,8 +485,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -528,8 +525,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -567,8 +563,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -613,8 +608,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -654,8 +648,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -693,8 +686,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -739,8 +731,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -774,8 +765,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -813,8 +803,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -853,8 +842,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -893,8 +881,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -924,8 +911,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -953,8 +939,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -989,8 +974,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1018,8 +1002,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1049,8 +1032,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1078,8 +1060,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1114,8 +1095,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1139,8 +1119,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1168,8 +1147,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1201,8 +1179,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1235,8 +1212,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1267,8 +1243,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1318,8 +1293,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1367,8 +1341,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1423,8 +1396,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1474,8 +1446,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1523,8 +1494,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1579,8 +1549,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1630,8 +1599,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1679,8 +1647,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1734,8 +1701,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::GenerateReport, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileReportRead, }, api_locking::LockAction::NotApplicable, )) @@ -1773,8 +1739,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1798,8 +1763,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1830,8 +1794,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -1948,8 +1911,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2065,8 +2027,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2096,8 +2057,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2132,8 +2092,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2161,8 +2120,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2202,8 +2160,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2248,8 +2205,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2287,8 +2243,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2319,8 +2274,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2349,8 +2303,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Organization, + permission: Permission::OrganizationAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) @@ -2386,8 +2339,7 @@ pub mod routes { .map(ApplicationResponse::Json) }, &auth::JWTAuth { - permission: Permission::Analytics, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAnalyticsRead, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rs index 1d188168e5cf..284be4ab4baa 100644 --- a/crates/router/src/core/user_role.rs +++ b/crates/router/src/core/user_role.rs @@ -16,14 +16,14 @@ use crate::{ routes::{app::ReqState, SessionState}, services::{ authentication as auth, - authorization::{info, roles}, + authorization::{info, permission_groups::PermissionGroupExt, roles}, ApplicationResponse, }, types::domain, utils, }; pub mod role; -use common_enums::{EntityType, PermissionGroup}; +use common_enums::{EntityType, ParentGroup, PermissionGroup}; use strum::IntoEnumIterator; // TODO: To be deprecated @@ -44,11 +44,10 @@ pub async fn get_authorization_info_with_group_tag( ) -> UserResponse { static GROUPS_WITH_PARENT_TAGS: Lazy> = Lazy::new(|| { PermissionGroup::iter() - .map(|value| (info::get_parent_name(value), value)) + .map(|group| (group.parent(), group)) .fold( HashMap::new(), - |mut acc: HashMap>, - (key, value)| { + |mut acc: HashMap>, (key, value)| { acc.entry(key).or_default().push(value); acc }, diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rs index 78238d3af07c..b197101d65f2 100644 --- a/crates/router/src/routes/admin.rs +++ b/crates/router/src/routes/admin.rs @@ -1,5 +1,4 @@ use actix_web::{web, HttpRequest, HttpResponse}; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use super::app::AppState; @@ -52,8 +51,7 @@ pub async fn organization_update( &auth::AdminApiAuth, &auth::JWTAuthOrganizationFromRoute { organization_id, - required_permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Organization, + required_permission: Permission::OrganizationAccountWrite, }, req.headers(), ), @@ -85,8 +83,7 @@ pub async fn organization_retrieve( &auth::AdminApiAuth, &auth::JWTAuthOrganizationFromRoute { organization_id, - required_permission: Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Organization, + required_permission: Permission::OrganizationAccountRead, }, req.headers(), ), @@ -139,8 +136,11 @@ pub async fn retrieve_merchant_account( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Profile, + // This should ideally be MerchantAccountRead, but since FE is calling this API for + // profile level users currently keeping this as ProfileAccountRead. FE is removing + // this API call for profile level users. + // TODO: Convert this to MerchantAccountRead once FE changes are done. + required_permission: Permission::ProfileAccountRead, }, req.headers(), ), @@ -172,7 +172,6 @@ pub async fn merchant_account_list( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromHeader { required_permission: Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -200,7 +199,6 @@ pub async fn merchant_account_list( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromHeader { required_permission: Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -232,7 +230,6 @@ pub async fn update_merchant_account( &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), required_permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -298,8 +295,7 @@ pub async fn connector_create( &auth::AdminApiAuthWithMerchantIdFromRoute(merchant_id.clone()), &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileConnectorWrite, }, req.headers(), ), @@ -336,8 +332,7 @@ pub async fn connector_create( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantConnectorWrite, }, req.headers(), ), @@ -399,8 +394,7 @@ pub async fn connector_retrieve( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::MerchantConnectorAccountRead, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileConnectorRead, }, req.headers(), ), @@ -438,8 +432,7 @@ pub async fn connector_retrieve( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::MerchantConnectorAccountRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantConnectorRead, }, req.headers(), ), @@ -469,8 +462,7 @@ pub async fn connector_list( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::MerchantConnectorAccountRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantConnectorRead, }, req.headers(), ), @@ -517,8 +509,7 @@ pub async fn connector_list( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::MerchantConnectorAccountRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantConnectorRead, }, req.headers(), ), @@ -569,8 +560,7 @@ pub async fn connector_list_profile( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::MerchantConnectorAccountRead, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileConnectorRead, }, req.headers(), ), @@ -631,8 +621,7 @@ pub async fn connector_update( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileConnectorWrite, }, req.headers(), ), @@ -683,8 +672,7 @@ pub async fn connector_update( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantConnectorWrite, }, req.headers(), ), @@ -739,8 +727,7 @@ pub async fn connector_delete( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantConnectorWrite, }, req.headers(), ), @@ -778,8 +765,7 @@ pub async fn connector_delete( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantConnectorWrite, }, req.headers(), ), diff --git a/crates/router/src/routes/api_keys.rs b/crates/router/src/routes/api_keys.rs index bbecaae9e80b..1a2f60bcccb4 100644 --- a/crates/router/src/routes/api_keys.rs +++ b/crates/router/src/routes/api_keys.rs @@ -1,5 +1,4 @@ use actix_web::{web, HttpRequest, Responder}; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use super::app::AppState; @@ -33,8 +32,7 @@ pub async fn api_key_create( &auth::AdminApiAuthWithMerchantIdFromRoute(merchant_id.clone()), &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: Permission::ApiKeyWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyWrite, }, req.headers(), ), @@ -64,8 +62,7 @@ pub async fn api_key_create( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::ApiKeyWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyWrite, }, req.headers(), ), @@ -99,8 +96,7 @@ pub async fn api_key_retrieve( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::ApiKeyRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyRead, }, req.headers(), ), @@ -132,8 +128,7 @@ pub async fn api_key_retrieve( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: Permission::ApiKeyRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyRead, }, req.headers(), ), @@ -169,8 +164,7 @@ pub async fn api_key_update( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::ApiKeyWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyWrite, }, req.headers(), ), @@ -203,8 +197,7 @@ pub async fn api_key_update( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::ApiKeyRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyRead, }, req.headers(), ), @@ -236,8 +229,7 @@ pub async fn api_key_revoke( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: Permission::ApiKeyWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyWrite, }, req.headers(), ), @@ -269,8 +261,7 @@ pub async fn api_key_revoke( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: Permission::ApiKeyWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyWrite, }, req.headers(), ), @@ -305,8 +296,7 @@ pub async fn api_key_list( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::ApiKeyRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyRead, }, req.headers(), ), @@ -336,8 +326,7 @@ pub async fn api_key_list( auth::auth_type( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { - required_permission: Permission::ApiKeyRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantApiKeyRead, }, req.headers(), ), diff --git a/crates/router/src/routes/blocklist.rs b/crates/router/src/routes/blocklist.rs index 4738df5ed2ca..f54f61d8a002 100644 --- a/crates/router/src/routes/blocklist.rs +++ b/crates/router/src/routes/blocklist.rs @@ -1,6 +1,5 @@ use actix_web::{web, HttpRequest, HttpResponse}; use api_models::blocklist as api_blocklist; -use common_enums::EntityType; use router_env::Flow; use crate::{ @@ -39,7 +38,6 @@ pub async fn add_entry_to_blocklist( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -78,7 +76,6 @@ pub async fn remove_entry_from_blocklist( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -119,7 +116,6 @@ pub async fn list_blocked_payment_methods( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { permission: Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -160,7 +156,6 @@ pub async fn toggle_blocklist_guard( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), diff --git a/crates/router/src/routes/connector_onboarding.rs b/crates/router/src/routes/connector_onboarding.rs index f7494e182c19..8ecd321df948 100644 --- a/crates/router/src/routes/connector_onboarding.rs +++ b/crates/router/src/routes/connector_onboarding.rs @@ -1,6 +1,5 @@ use actix_web::{web, HttpRequest, HttpResponse}; use api_models::connector_onboarding as api_types; -use common_enums::EntityType; use router_env::Flow; use super::AppState; @@ -24,7 +23,6 @@ pub async fn get_action_url( core::get_action_url, &auth::JWTAuth { permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, api_locking::LockAction::NotApplicable, )) @@ -46,7 +44,6 @@ pub async fn sync_onboarding_status( core::sync_onboarding_status, &auth::JWTAuth { permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, api_locking::LockAction::NotApplicable, )) @@ -68,7 +65,6 @@ pub async fn reset_tracking_id( core::reset_tracking_id, &auth::JWTAuth { permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/routes/customers.rs b/crates/router/src/routes/customers.rs index 536bca10f3df..5ff155966a0f 100644 --- a/crates/router/src/routes/customers.rs +++ b/crates/router/src/routes/customers.rs @@ -1,5 +1,4 @@ use actix_web::{web, HttpRequest, HttpResponse, Responder}; -use common_enums::EntityType; #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] use common_utils::id_type; use router_env::{instrument, tracing, Flow}; @@ -29,8 +28,7 @@ pub async fn customers_create( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::CustomerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerWrite, }, req.headers(), ), @@ -55,8 +53,7 @@ pub async fn customers_retrieve( let auth = if auth::is_jwt_auth(req.headers()) { Box::new(auth::JWTAuth { - permission: Permission::CustomerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerRead, }) } else { match auth::is_ephemeral_auth(req.headers()) { @@ -98,8 +95,7 @@ pub async fn customers_retrieve( let auth = if auth::is_jwt_auth(req.headers()) { Box::new(auth::JWTAuth { - permission: Permission::CustomerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerRead, }) } else { match auth::is_ephemeral_auth(req.headers()) { @@ -148,8 +144,7 @@ pub async fn customers_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::CustomerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerRead, }, req.headers(), ), @@ -187,8 +182,7 @@ pub async fn customers_update( auth::auth_type( &auth::ApiKeyAuth, &auth::JWTAuth { - permission: Permission::CustomerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerWrite, }, req.headers(), ), @@ -225,8 +219,7 @@ pub async fn customers_update( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::CustomerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerWrite, }, req.headers(), ), @@ -256,8 +249,7 @@ pub async fn customers_delete( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::CustomerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerWrite, }, req.headers(), ), @@ -290,8 +282,7 @@ pub async fn customers_delete( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::CustomerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantCustomerWrite, }, req.headers(), ), @@ -328,8 +319,7 @@ pub async fn get_customer_mandates( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::MandateRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantMandateRead, }, req.headers(), ), diff --git a/crates/router/src/routes/disputes.rs b/crates/router/src/routes/disputes.rs index 22c1e3f19888..5577bb96ef01 100644 --- a/crates/router/src/routes/disputes.rs +++ b/crates/router/src/routes/disputes.rs @@ -1,7 +1,6 @@ use actix_multipart::Multipart; use actix_web::{web, HttpRequest, HttpResponse}; use api_models::disputes as dispute_models; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use crate::{core::api_locking, services::authorization::permissions::Permission}; @@ -50,8 +49,7 @@ pub async fn retrieve_dispute( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeRead, }, req.headers(), ), @@ -102,8 +100,7 @@ pub async fn retrieve_disputes_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantDisputeRead, }, req.headers(), ), @@ -160,8 +157,7 @@ pub async fn retrieve_disputes_list_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeRead, }, req.headers(), ), @@ -195,8 +191,7 @@ pub async fn get_disputes_filters(state: web::Data, req: HttpRequest) auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantDisputeRead, }, req.headers(), ), @@ -237,8 +232,7 @@ pub async fn get_disputes_filters_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeRead, }, req.headers(), ), @@ -289,8 +283,7 @@ pub async fn accept_dispute( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeWrite, }, req.headers(), ), @@ -335,8 +328,7 @@ pub async fn submit_dispute_evidence( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeWrite, }, req.headers(), ), @@ -389,8 +381,7 @@ pub async fn attach_dispute_evidence( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeWrite, }, req.headers(), ), @@ -435,8 +426,7 @@ pub async fn retrieve_dispute_evidence( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeRead, }, req.headers(), ), @@ -478,8 +468,7 @@ pub async fn delete_dispute_evidence( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeWrite, }, req.headers(), ), @@ -508,8 +497,7 @@ pub async fn get_disputes_aggregate( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantDisputeRead, }, req.headers(), ), @@ -543,8 +531,7 @@ pub async fn get_disputes_aggregate_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::DisputeRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileDisputeRead, }, req.headers(), ), diff --git a/crates/router/src/routes/mandates.rs b/crates/router/src/routes/mandates.rs index c0ccbfa9f8fe..cb832d81a165 100644 --- a/crates/router/src/routes/mandates.rs +++ b/crates/router/src/routes/mandates.rs @@ -1,5 +1,4 @@ use actix_web::{web, HttpRequest, HttpResponse}; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use super::app::AppState; @@ -117,8 +116,7 @@ pub async fn retrieve_mandates_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::MandateRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantMandateRead, }, req.headers(), ), diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs index 8d95ee64ad0d..0dbddbef77bf 100644 --- a/crates/router/src/routes/payment_methods.rs +++ b/crates/router/src/routes/payment_methods.rs @@ -4,7 +4,6 @@ ))] use actix_multipart::form::MultipartForm; use actix_web::{web, HttpRequest, HttpResponse}; -use common_enums::EntityType; use common_utils::{errors::CustomResult, id_type}; use diesel_models::enums::IntentStatus; use error_stack::ResultExt; @@ -881,15 +880,13 @@ pub async fn list_countries_currencies_for_connector_payment_method( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileConnectorWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileConnectorWrite, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs index f13a873473a9..bca7bd37cccb 100644 --- a/crates/router/src/routes/payments.rs +++ b/crates/router/src/routes/payments.rs @@ -5,7 +5,6 @@ use crate::{ pub mod helpers; use actix_web::{web, Responder}; -use common_enums::EntityType; use error_stack::report; use hyperswitch_domain_models::payments::HeaderPayload; use masking::PeekInterface; @@ -93,8 +92,7 @@ pub async fn payments_create( _ => auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PaymentWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentWrite, }, req.headers(), ), @@ -148,8 +146,7 @@ pub async fn payments_create_intent( _ => auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PaymentWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentWrite, }, req.headers(), ), @@ -285,8 +282,7 @@ pub async fn payments_retrieve( auth::auth_type( &*auth_type, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentRead, }, req.headers(), ), @@ -995,8 +991,7 @@ pub async fn payments_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPaymentRead, }, req.headers(), ), @@ -1031,8 +1026,7 @@ pub async fn profile_payments_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentRead, }, req.headers(), ), @@ -1065,8 +1059,7 @@ pub async fn payments_list_by_filter( ) }, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPaymentRead, }, api_locking::LockAction::NotApplicable, )) @@ -1097,8 +1090,7 @@ pub async fn profile_payments_list_by_filter( ) }, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentRead, }, api_locking::LockAction::NotApplicable, )) @@ -1123,8 +1115,7 @@ pub async fn get_filters_for_payments( payments::get_filters_for_payments(state, auth.merchant_account, auth.key_store, req) }, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPaymentRead, }, api_locking::LockAction::NotApplicable, )) @@ -1147,8 +1138,7 @@ pub async fn get_payment_filters( payments::get_payment_filters(state, auth.merchant_account, None) }, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPaymentRead, }, api_locking::LockAction::NotApplicable, )) @@ -1175,8 +1165,7 @@ pub async fn get_payment_filters_profile( ) }, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentRead, }, api_locking::LockAction::NotApplicable, )) @@ -1201,8 +1190,7 @@ pub async fn get_payments_aggregates( payments::get_aggregates_for_payments(state, auth.merchant_account, None, req) }, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPaymentRead, }, api_locking::LockAction::NotApplicable, )) @@ -1262,8 +1250,7 @@ pub async fn payments_approve( _ => auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PaymentWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentWrite, }, http_req.headers(), ), @@ -1327,8 +1314,7 @@ pub async fn payments_reject( _ => auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PaymentWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentWrite, }, http_req.headers(), ), @@ -1970,8 +1956,7 @@ pub async fn get_payments_aggregates_profile( ) }, &auth::JWTAuth { - permission: Permission::PaymentRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePaymentRead, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/routes/payouts.rs b/crates/router/src/routes/payouts.rs index ad860195a2a6..62d16c4c4d56 100644 --- a/crates/router/src/routes/payouts.rs +++ b/crates/router/src/routes/payouts.rs @@ -3,7 +3,6 @@ use actix_web::{ http::header::HeaderMap, web, HttpRequest, HttpResponse, Responder, }; -use common_enums::EntityType; use common_utils::consts; use router_env::{instrument, tracing, Flow}; @@ -84,8 +83,7 @@ pub async fn payouts_retrieve( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PayoutRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePayoutRead, }, req.headers(), ), @@ -237,8 +235,7 @@ pub async fn payouts_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PayoutRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPayoutRead, }, req.headers(), ), @@ -277,8 +274,7 @@ pub async fn payouts_list_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PayoutRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePayoutRead, }, req.headers(), ), @@ -317,8 +313,7 @@ pub async fn payouts_list_by_filter( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PayoutRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPayoutRead, }, req.headers(), ), @@ -357,8 +352,7 @@ pub async fn payouts_list_by_filter_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PayoutRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePayoutRead, }, req.headers(), ), @@ -390,8 +384,7 @@ pub async fn payouts_list_available_filters_for_merchant( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PayoutRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPayoutRead, }, req.headers(), ), @@ -429,8 +422,7 @@ pub async fn payouts_list_available_filters_for_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::PayoutRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfilePayoutRead, }, req.headers(), ), diff --git a/crates/router/src/routes/profiles.rs b/crates/router/src/routes/profiles.rs index f2dc322af17c..cbb7957987fc 100644 --- a/crates/router/src/routes/profiles.rs +++ b/crates/router/src/routes/profiles.rs @@ -1,5 +1,4 @@ use actix_web::{web, HttpRequest, HttpResponse}; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use super::app::AppState; @@ -34,7 +33,6 @@ pub async fn profile_create( &auth::JWTAuthMerchantFromRoute { merchant_id, required_permission: permissions::Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -65,7 +63,6 @@ pub async fn profile_create( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { required_permission: permissions::Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -97,8 +94,7 @@ pub async fn profile_retrieve( &auth::AdminApiAuthWithMerchantIdFromRoute(merchant_id.clone()), &auth::JWTAuthMerchantFromRoute { merchant_id: merchant_id.clone(), - required_permission: permissions::Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Profile, + required_permission: permissions::Permission::ProfileAccountRead, }, req.headers(), ), @@ -127,7 +123,6 @@ pub async fn profile_retrieve( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { required_permission: permissions::Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -161,8 +156,7 @@ pub async fn profile_update( &auth::JWTAuthMerchantAndProfileFromRoute { merchant_id: merchant_id.clone(), profile_id: profile_id.clone(), - required_permission: permissions::Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Profile, + required_permission: permissions::Permission::ProfileAccountWrite, }, req.headers(), ), @@ -192,7 +186,6 @@ pub async fn profile_update( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromHeader { required_permission: permissions::Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -244,7 +237,6 @@ pub async fn profiles_list( &auth::JWTAuthMerchantFromRoute { merchant_id, required_permission: permissions::Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), @@ -278,8 +270,7 @@ pub async fn profiles_list_at_profile_level( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: permissions::Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Profile, + required_permission: permissions::Permission::ProfileAccountRead, }, req.headers(), ), @@ -312,8 +303,7 @@ pub async fn toggle_connector_agnostic_mit( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: permissions::Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + permission: permissions::Permission::MerchantRoutingWrite, }, req.headers(), ), @@ -372,8 +362,7 @@ pub async fn payment_connector_list_profile( &auth::AdminApiAuthWithMerchantIdFromHeader, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: permissions::Permission::MerchantConnectorAccountRead, - minimum_entity_level: EntityType::Profile, + required_permission: permissions::Permission::ProfileConnectorRead, }, req.headers(), ), diff --git a/crates/router/src/routes/recon.rs b/crates/router/src/routes/recon.rs index 1ec571ff7c90..cdc2ae758e92 100644 --- a/crates/router/src/routes/recon.rs +++ b/crates/router/src/routes/recon.rs @@ -1,5 +1,5 @@ use actix_web::{web, HttpRequest, HttpResponse}; -use api_models::{enums::EntityType, recon as recon_api}; +use api_models::recon as recon_api; use router_env::Flow; use super::AppState; @@ -38,8 +38,7 @@ pub async fn request_for_recon(state: web::Data, http_req: HttpRequest (), |state, user, _, _| recon::send_recon_request(state, user), &authentication::JWTAuth { - permission: Permission::ReconAdmin, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantReconWrite, }, api_locking::LockAction::NotApplicable, )) @@ -55,8 +54,7 @@ pub async fn get_recon_token(state: web::Data, req: HttpRequest) -> Ht (), |state, user, _, _| recon::generate_recon_token(state, user), &authentication::JWTAuth { - permission: Permission::ReconAdmin, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantReconWrite, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/routes/refunds.rs b/crates/router/src/routes/refunds.rs index c76ee600efe2..cbcfbcdcbf10 100644 --- a/crates/router/src/routes/refunds.rs +++ b/crates/router/src/routes/refunds.rs @@ -1,5 +1,4 @@ use actix_web::{web, HttpRequest, HttpResponse}; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use super::app::AppState; @@ -49,8 +48,7 @@ pub async fn refunds_create( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRefundWrite, }, req.headers(), ), @@ -113,8 +111,7 @@ pub async fn refunds_retrieve( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRefundRead, }, req.headers(), ), @@ -245,8 +242,7 @@ pub async fn refunds_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRefundRead, }, req.headers(), ), @@ -293,8 +289,7 @@ pub async fn refunds_list_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRefundRead, }, req.headers(), ), @@ -336,8 +331,7 @@ pub async fn refunds_filter_list( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRefundRead, }, req.headers(), ), @@ -374,8 +368,7 @@ pub async fn get_refunds_filters(state: web::Data, req: HttpRequest) - auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRefundRead, }, req.headers(), ), @@ -419,8 +412,7 @@ pub async fn get_refunds_filters_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRefundRead, }, req.headers(), ), @@ -449,8 +441,7 @@ pub async fn get_refunds_aggregates( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRefundRead, }, req.headers(), ), @@ -507,8 +498,7 @@ pub async fn get_refunds_aggregate_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RefundRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRefundRead, }, req.headers(), ), diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs index 4c8d89fa87d5..3e0355a884a9 100644 --- a/crates/router/src/routes/routing.rs +++ b/crates/router/src/routes/routing.rs @@ -5,7 +5,6 @@ use actix_web::{web, HttpRequest, Responder}; use api_models::{enums, routing as routing_types, routing::RoutingRetrieveQuery}; -use common_enums::EntityType; use router_env::{ tracing::{self, instrument}, Flow, @@ -44,15 +43,13 @@ pub async fn routing_create_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -87,15 +84,13 @@ pub async fn routing_link_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -137,16 +132,14 @@ pub async fn routing_link_config( &auth::ApiKeyAuth, &auth::JWTAuthProfileFromRoute { profile_id: wrapper.profile_id, - required_permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuthProfileFromRoute { profile_id: wrapper.profile_id, - required_permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -180,15 +173,13 @@ pub async fn routing_retrieve_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -222,15 +213,13 @@ pub async fn list_routing_configs( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -264,15 +253,13 @@ pub async fn list_routing_configs_for_profile( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -308,16 +295,14 @@ pub async fn routing_unlink_config( &auth::ApiKeyAuth, &auth::JWTAuthProfileFromRoute { profile_id: path, - required_permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuthProfileFromRoute { profile_id: path, - required_permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -352,15 +337,13 @@ pub async fn routing_unlink_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -397,15 +380,13 @@ pub async fn routing_update_default_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -437,15 +418,13 @@ pub async fn routing_update_default_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -478,16 +457,14 @@ pub async fn routing_retrieve_default_config( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuthProfileFromRoute { profile_id: path, - required_permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuthProfileFromRoute { profile_id: path, - required_permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -513,15 +490,13 @@ pub async fn routing_retrieve_default_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -553,15 +528,13 @@ pub async fn upsert_surcharge_decision_manager_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantSurchargeDecisionManagerWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantSurchargeDecisionManagerWrite, }, api_locking::LockAction::NotApplicable, )) @@ -590,15 +563,13 @@ pub async fn delete_surcharge_decision_manager_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantSurchargeDecisionManagerWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantSurchargeDecisionManagerWrite, }, api_locking::LockAction::NotApplicable, )) @@ -627,15 +598,13 @@ pub async fn retrieve_surcharge_decision_manager_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantSurchargeDecisionManagerRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantSurchargeDecisionManagerRead, }, api_locking::LockAction::NotApplicable, )) @@ -667,15 +636,13 @@ pub async fn upsert_decision_manager_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantThreeDsDecisionManagerWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantThreeDsDecisionManagerWrite, }, api_locking::LockAction::NotApplicable, )) @@ -705,15 +672,13 @@ pub async fn delete_decision_manager_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantThreeDsDecisionManagerWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantThreeDsDecisionManagerWrite, }, api_locking::LockAction::NotApplicable, )) @@ -739,15 +704,13 @@ pub async fn retrieve_decision_manager_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantThreeDsDecisionManagerRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::SurchargeDecisionManagerRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantThreeDsDecisionManagerRead, }, api_locking::LockAction::NotApplicable, )) @@ -786,16 +749,14 @@ pub async fn routing_retrieve_linked_config( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuthProfileFromRoute { profile_id, - required_permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuthProfileFromRoute { profile_id, - required_permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -820,15 +781,13 @@ pub async fn routing_retrieve_linked_config( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -871,16 +830,14 @@ pub async fn routing_retrieve_linked_config( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuthProfileFromRoute { profile_id: wrapper.profile_id, - required_permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileRoutingRead, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuthProfileFromRoute { profile_id: wrapper.profile_id, - required_permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileRoutingRead, }, api_locking::LockAction::NotApplicable, )) @@ -911,8 +868,7 @@ pub async fn routing_retrieve_default_config_for_profiles( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingRead, }, req.headers(), ), @@ -920,8 +876,7 @@ pub async fn routing_retrieve_default_config_for_profiles( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::RoutingRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantRoutingRead, }, req.headers(), ), @@ -963,16 +918,14 @@ pub async fn routing_update_default_config_for_profile( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuthProfileFromRoute { profile_id: routing_payload_wrapper.profile_id, - required_permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileRoutingWrite, }, req.headers(), ), #[cfg(feature = "release")] &auth::JWTAuthProfileFromRoute { profile_id: routing_payload_wrapper.profile_id, - required_permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileRoutingWrite, }, api_locking::LockAction::NotApplicable, )) @@ -1013,8 +966,7 @@ pub async fn toggle_success_based_routing( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuthProfileFromRoute { profile_id: wrapper.profile_id, - required_permission: Permission::RoutingWrite, - minimum_entity_level: EntityType::Profile, + required_permission: Permission::ProfileRoutingWrite, }, req.headers(), ), diff --git a/crates/router/src/routes/user.rs b/crates/router/src/routes/user.rs index e07a2fa10ef4..f52d0dca7a83 100644 --- a/crates/router/src/routes/user.rs +++ b/crates/router/src/routes/user.rs @@ -5,7 +5,7 @@ use api_models::{ errors::types::ApiErrorResponse, user::{self as user_api}, }; -use common_enums::{EntityType, TokenPurpose}; +use common_enums::TokenPurpose; use common_utils::errors::ReportSwitchExt; use router_env::Flow; @@ -176,8 +176,7 @@ pub async fn set_dashboard_metadata( payload, user_core::dashboard_metadata::set_metadata, &auth::JWTAuth { - permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAccountWrite, }, api_locking::LockAction::NotApplicable, )) @@ -243,8 +242,7 @@ pub async fn user_merchant_account_create( user_core::create_merchant_account(state, auth, json_payload) }, &auth::JWTAuth { - permission: Permission::MerchantAccountCreate, - minimum_entity_level: EntityType::Merchant, + permission: Permission::OrganizationAccountWrite, }, api_locking::LockAction::NotApplicable, )) @@ -267,8 +265,7 @@ pub async fn generate_sample_data( payload.into_inner(), sample_data::generate_sample_data_for_user, &auth::JWTAuth { - permission: Permission::PaymentWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantPaymentWrite, }, api_locking::LockAction::NotApplicable, )) @@ -292,7 +289,6 @@ pub async fn delete_sample_data( sample_data::delete_sample_data_for_user, &auth::JWTAuth { permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Merchant, }, api_locking::LockAction::NotApplicable, )) @@ -312,8 +308,7 @@ pub async fn list_user_roles_details( payload.into_inner(), user_core::list_user_roles_details, &auth::JWTAuth { - permission: Permission::UsersRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserRead, }, api_locking::LockAction::NotApplicable, )) @@ -395,8 +390,7 @@ pub async fn invite_multiple_user( user_core::invite_multiple_user(state, user, payload, req_state, auth_id.clone()) }, &auth::JWTAuth { - permission: Permission::UsersWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserWrite, }, api_locking::LockAction::NotApplicable, )) @@ -421,8 +415,7 @@ pub async fn resend_invite( user_core::resend_invite(state, user, req_payload, auth_id.clone()) }, &auth::JWTAuth { - permission: Permission::UsersWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserWrite, }, api_locking::LockAction::NotApplicable, )) @@ -504,8 +497,7 @@ pub async fn verify_recon_token(state: web::Data, http_req: HttpReques (), |state, user, _req, _| user_core::verify_token(state, user), &auth::JWTAuth { - permission: Permission::ReconAdmin, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantReconWrite, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/routes/user_role.rs b/crates/router/src/routes/user_role.rs index 777cbe1fd950..74847f064747 100644 --- a/crates/router/src/routes/user_role.rs +++ b/crates/router/src/routes/user_role.rs @@ -1,6 +1,6 @@ use actix_web::{web, HttpRequest, HttpResponse}; use api_models::user_role::{self as user_role_api, role as role_api}; -use common_enums::{EntityType, TokenPurpose}; +use common_enums::TokenPurpose; use router_env::Flow; use super::AppState; @@ -31,8 +31,7 @@ pub async fn get_authorization_info( user_role_core::get_authorization_info_with_groups(state).await }, &auth::JWTAuth { - permission: Permission::UsersRead, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantUserRead, }, api_locking::LockAction::NotApplicable, )) @@ -69,8 +68,7 @@ pub async fn create_role( json_payload.into_inner(), role_core::create_role, &auth::JWTAuth { - permission: Permission::UsersWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantUserWrite, }, api_locking::LockAction::NotApplicable, )) @@ -95,8 +93,7 @@ pub async fn get_role( role_core::get_role_with_groups(state, user, payload).await }, &auth::JWTAuth { - permission: Permission::UsersRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserRead, }, api_locking::LockAction::NotApplicable, )) @@ -119,8 +116,7 @@ pub async fn update_role( json_payload.into_inner(), |state, user, req, _| role_core::update_role(state, user, req, &role_id), &auth::JWTAuth { - permission: Permission::UsersWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantUserWrite, }, api_locking::LockAction::NotApplicable, )) @@ -141,8 +137,7 @@ pub async fn update_user_role( payload, user_role_core::update_user_role, &auth::JWTAuth { - permission: Permission::UsersWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserWrite, }, api_locking::LockAction::NotApplicable, )) @@ -202,8 +197,7 @@ pub async fn delete_user_role( payload.into_inner(), user_role_core::delete_user_role, &auth::JWTAuth { - permission: Permission::UsersWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserWrite, }, api_locking::LockAction::NotApplicable, )) @@ -225,8 +219,7 @@ pub async fn get_role_information( user_role_core::get_authorization_info_with_group_tag().await }, &auth::JWTAuth { - permission: Permission::UsersRead, - minimum_entity_level: EntityType::Profile + permission: Permission::ProfileUserRead, }, api_locking::LockAction::NotApplicable, )) @@ -270,8 +263,7 @@ pub async fn list_roles_with_info( role_core::list_roles_with_info(state, user_from_token, request) }, &auth::JWTAuth { - permission: Permission::UsersRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserRead, }, api_locking::LockAction::NotApplicable, )) @@ -299,8 +291,7 @@ pub async fn list_invitable_roles_at_entity_level( ) }, &auth::JWTAuth { - permission: Permission::UsersRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserRead, }, api_locking::LockAction::NotApplicable, )) @@ -328,8 +319,7 @@ pub async fn list_updatable_roles_at_entity_level( ) }, &auth::JWTAuth { - permission: Permission::UsersRead, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileUserRead, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/routes/verification.rs b/crates/router/src/routes/verification.rs index 17c946c4810b..56ad42947c24 100644 --- a/crates/router/src/routes/verification.rs +++ b/crates/router/src/routes/verification.rs @@ -1,6 +1,5 @@ use actix_web::{web, HttpRequest, Responder}; use api_models::verifications; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use super::app::AppState; @@ -34,8 +33,7 @@ pub async fn apple_pay_merchant_registration( auth::auth_type( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { - permission: Permission::MerchantAccountWrite, - minimum_entity_level: EntityType::Profile, + permission: Permission::ProfileAccountWrite, }, req.headers(), ), @@ -70,7 +68,6 @@ pub async fn retrieve_apple_pay_verified_domains( &auth::HeaderAuth(auth::ApiKeyAuth), &auth::JWTAuth { permission: Permission::MerchantAccountRead, - minimum_entity_level: EntityType::Merchant, }, req.headers(), ), diff --git a/crates/router/src/routes/verify_connector.rs b/crates/router/src/routes/verify_connector.rs index 29f8c154bc0d..b8e089f0660e 100644 --- a/crates/router/src/routes/verify_connector.rs +++ b/crates/router/src/routes/verify_connector.rs @@ -1,6 +1,5 @@ use actix_web::{web, HttpRequest, HttpResponse}; use api_models::verify_connector::VerifyConnectorRequest; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use super::AppState; @@ -25,8 +24,7 @@ pub async fn payment_connector_verify( verify_connector::verify_connector_credentials(state, req, auth.profile_id) }, &auth::JWTAuth { - permission: Permission::MerchantConnectorAccountWrite, - minimum_entity_level: EntityType::Merchant, + permission: Permission::MerchantConnectorWrite, }, api_locking::LockAction::NotApplicable, )) diff --git a/crates/router/src/routes/webhook_events.rs b/crates/router/src/routes/webhook_events.rs index 8b94fb61f56b..5039f72db31e 100644 --- a/crates/router/src/routes/webhook_events.rs +++ b/crates/router/src/routes/webhook_events.rs @@ -1,5 +1,4 @@ use actix_web::{web, HttpRequest, Responder}; -use common_enums::EntityType; use router_env::{instrument, tracing, Flow}; use crate::{ @@ -44,8 +43,7 @@ pub async fn list_initial_webhook_delivery_attempts( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::WebhookEventRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantWebhookEventRead, }, req.headers(), ), @@ -84,8 +82,7 @@ pub async fn list_webhook_delivery_attempts( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::WebhookEventRead, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantWebhookEventRead, }, req.headers(), ), @@ -124,8 +121,7 @@ pub async fn retry_webhook_delivery_attempt( &auth::AdminApiAuth, &auth::JWTAuthMerchantFromRoute { merchant_id, - required_permission: Permission::WebhookEventWrite, - minimum_entity_level: EntityType::Merchant, + required_permission: Permission::MerchantWebhookEventWrite, }, req.headers(), ), diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs index b64c5d14f323..e6da2b23301f 100644 --- a/crates/router/src/services/authentication.rs +++ b/crates/router/src/services/authentication.rs @@ -10,7 +10,7 @@ use api_models::payment_methods::PaymentMethodIntentConfirm; use api_models::payouts; use api_models::{payment_methods::PaymentMethodListRequest, payments}; use async_trait::async_trait; -use common_enums::{EntityType, TokenPurpose}; +use common_enums::TokenPurpose; use common_utils::{date_time, id_type}; use error_stack::{report, ResultExt}; use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation}; @@ -1232,7 +1232,6 @@ where #[derive(Debug)] pub(crate) struct JWTAuth { pub permission: Permission, - pub minimum_entity_level: EntityType, } #[async_trait] @@ -1252,7 +1251,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; Ok(( (), @@ -1282,7 +1280,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; Ok(( UserFromToken { @@ -1318,7 +1315,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -1359,7 +1355,6 @@ where pub struct JWTAuthOrganizationFromRoute { pub organization_id: id_type::OrganizationId, pub required_permission: Permission, - pub minimum_entity_level: EntityType, } #[async_trait] @@ -1379,7 +1374,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.required_permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; // Check if token has access to Organization that has been requested in the route if payload.org_id != self.organization_id { @@ -1398,12 +1392,10 @@ where pub struct JWTAuthMerchantFromRoute { pub merchant_id: id_type::MerchantId, pub required_permission: Permission, - pub minimum_entity_level: EntityType, } pub struct JWTAuthMerchantFromHeader { pub required_permission: Permission, - pub minimum_entity_level: EntityType, } #[async_trait] @@ -1423,7 +1415,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.required_permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let merchant_id_from_header = HeaderMapStruct::new(request_headers) .get_id_type_from_header::(headers::X_MERCHANT_ID)?; @@ -1459,7 +1450,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.required_permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let merchant_id_from_header = HeaderMapStruct::new(request_headers) .get_id_type_from_header::(headers::X_MERCHANT_ID)?; @@ -1526,7 +1516,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.required_permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; // Check if token has access to MerchantId that has been requested through query param if payload.merchant_id != self.merchant_id { @@ -1563,7 +1552,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.required_permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -1606,7 +1594,6 @@ pub struct JWTAuthMerchantAndProfileFromRoute { pub merchant_id: id_type::MerchantId, pub profile_id: id_type::ProfileId, pub required_permission: Permission, - pub minimum_entity_level: EntityType, } #[async_trait] @@ -1638,7 +1625,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.required_permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -1682,7 +1668,6 @@ where pub struct JWTAuthProfileFromRoute { pub profile_id: id_type::ProfileId, pub required_permission: Permission, - pub minimum_entity_level: EntityType, } #[async_trait] @@ -1702,7 +1687,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.required_permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -1798,7 +1782,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -1859,7 +1842,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -1923,7 +1905,6 @@ where let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2349,7 +2330,6 @@ where } let role_info = authorization::get_role_info(state, &payload).await?; authorization::check_permission(&self.permission, &role_info)?; - authorization::check_entity(self.minimum_entity_level, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state diff --git a/crates/router/src/services/authorization.rs b/crates/router/src/services/authorization.rs index 78af4c00884e..fe6ffac6ffc0 100644 --- a/crates/router/src/services/authorization.rs +++ b/crates/router/src/services/authorization.rs @@ -112,18 +112,6 @@ pub fn check_permission( ) } -pub fn check_entity( - required_minimum_entity: common_enums::EntityType, - role_info: &roles::RoleInfo, -) -> RouterResult<()> { - if required_minimum_entity > role_info.get_entity_type() { - Err(ApiErrorResponse::AccessForbidden { - resource: required_minimum_entity.to_string(), - })?; - } - Ok(()) -} - fn get_redis_connection(state: &A) -> RouterResult> { state .store() diff --git a/crates/router/src/services/authorization/info.rs b/crates/router/src/services/authorization/info.rs index 031e0b567290..dba96dac1888 100644 --- a/crates/router/src/services/authorization/info.rs +++ b/crates/router/src/services/authorization/info.rs @@ -1,5 +1,5 @@ -use api_models::user_role::{GroupInfo, ParentGroup}; -use common_enums::PermissionGroup; +use api_models::user_role::GroupInfo; +use common_enums::{ParentGroup, PermissionGroup}; use strum::IntoEnumIterator; // TODO: To be deprecated diff --git a/crates/router/src/services/authorization/permission_groups.rs b/crates/router/src/services/authorization/permission_groups.rs index aafc9cee9430..3d1a0c8ea5b1 100644 --- a/crates/router/src/services/authorization/permission_groups.rs +++ b/crates/router/src/services/authorization/permission_groups.rs @@ -1,97 +1,122 @@ -use common_enums::PermissionGroup; - -use super::permissions::Permission; - -pub fn get_permissions_vec(permission_group: &PermissionGroup) -> &[Permission] { - match permission_group { - PermissionGroup::OperationsView => &OPERATIONS_VIEW, - PermissionGroup::OperationsManage => &OPERATIONS_MANAGE, - PermissionGroup::ConnectorsView => &CONNECTORS_VIEW, - PermissionGroup::ConnectorsManage => &CONNECTORS_MANAGE, - PermissionGroup::WorkflowsView => &WORKFLOWS_VIEW, - PermissionGroup::WorkflowsManage => &WORKFLOWS_MANAGE, - PermissionGroup::AnalyticsView => &ANALYTICS_VIEW, - PermissionGroup::UsersView => &USERS_VIEW, - PermissionGroup::UsersManage => &USERS_MANAGE, - PermissionGroup::MerchantDetailsView => &MERCHANT_DETAILS_VIEW, - PermissionGroup::MerchantDetailsManage => &MERCHANT_DETAILS_MANAGE, - PermissionGroup::OrganizationManage => &ORGANIZATION_MANAGE, - PermissionGroup::ReconOps => &RECON, - } +use common_enums::{ParentGroup, PermissionGroup, PermissionScope, Resource}; + +pub trait PermissionGroupExt { + fn scope(&self) -> PermissionScope; + fn parent(&self) -> ParentGroup; + fn resources(&self) -> Vec; + fn accessible_groups(&self) -> Vec; } -pub static OPERATIONS_VIEW: [Permission; 8] = [ - Permission::PaymentRead, - Permission::RefundRead, - Permission::MandateRead, - Permission::DisputeRead, - Permission::CustomerRead, - Permission::GenerateReport, - Permission::PayoutRead, - Permission::MerchantAccountRead, -]; +impl PermissionGroupExt for PermissionGroup { + fn scope(&self) -> PermissionScope { + match self { + Self::OperationsView + | Self::ConnectorsView + | Self::WorkflowsView + | Self::AnalyticsView + | Self::UsersView + | Self::MerchantDetailsView => PermissionScope::Read, -pub static OPERATIONS_MANAGE: [Permission; 7] = [ - Permission::PaymentWrite, - Permission::RefundWrite, - Permission::MandateWrite, - Permission::DisputeWrite, - Permission::CustomerWrite, - Permission::PayoutWrite, - Permission::MerchantAccountRead, -]; + Self::OperationsManage + | Self::ConnectorsManage + | Self::WorkflowsManage + | Self::UsersManage + | Self::MerchantDetailsManage + | Self::OrganizationManage + | Self::ReconOps => PermissionScope::Write, + } + } -pub static CONNECTORS_VIEW: [Permission; 2] = [ - Permission::MerchantConnectorAccountRead, - Permission::MerchantAccountRead, -]; + fn parent(&self) -> ParentGroup { + match self { + Self::OperationsView | Self::OperationsManage => ParentGroup::Operations, + Self::ConnectorsView | Self::ConnectorsManage => ParentGroup::Connectors, + Self::WorkflowsView | Self::WorkflowsManage => ParentGroup::Workflows, + Self::AnalyticsView => ParentGroup::Analytics, + Self::UsersView | Self::UsersManage => ParentGroup::Users, + Self::MerchantDetailsView | Self::MerchantDetailsManage => ParentGroup::Merchant, + Self::OrganizationManage => ParentGroup::Organization, + Self::ReconOps => ParentGroup::Recon, + } + } -pub static CONNECTORS_MANAGE: [Permission; 2] = [ - Permission::MerchantConnectorAccountWrite, - Permission::MerchantAccountRead, -]; + fn resources(&self) -> Vec { + self.parent().resources() + } -pub static WORKFLOWS_VIEW: [Permission; 5] = [ - Permission::RoutingRead, - Permission::ThreeDsDecisionManagerRead, - Permission::SurchargeDecisionManagerRead, - Permission::MerchantConnectorAccountRead, - Permission::MerchantAccountRead, -]; + fn accessible_groups(&self) -> Vec { + match self { + Self::OperationsView => vec![Self::OperationsView], + Self::OperationsManage => vec![Self::OperationsView, Self::OperationsManage], -pub static WORKFLOWS_MANAGE: [Permission; 5] = [ - Permission::RoutingWrite, - Permission::ThreeDsDecisionManagerWrite, - Permission::SurchargeDecisionManagerWrite, - Permission::MerchantConnectorAccountRead, - Permission::MerchantAccountRead, -]; + Self::ConnectorsView => vec![Self::ConnectorsView], + Self::ConnectorsManage => vec![Self::ConnectorsView, Self::ConnectorsManage], -pub static ANALYTICS_VIEW: [Permission; 3] = [ - Permission::Analytics, - Permission::GenerateReport, - Permission::MerchantAccountRead, -]; + Self::WorkflowsView => vec![Self::WorkflowsView], + Self::WorkflowsManage => vec![Self::WorkflowsView, Self::WorkflowsManage], + + Self::AnalyticsView => vec![Self::AnalyticsView], -pub static USERS_VIEW: [Permission; 2] = [Permission::UsersRead, Permission::MerchantAccountRead]; + Self::UsersView => vec![Self::UsersView], + Self::UsersManage => { + vec![Self::UsersView, Self::UsersManage] + } -pub static USERS_MANAGE: [Permission; 2] = - [Permission::UsersWrite, Permission::MerchantAccountRead]; + Self::ReconOps => vec![Self::ReconOps], -pub static MERCHANT_DETAILS_VIEW: [Permission; 1] = [Permission::MerchantAccountRead]; + Self::MerchantDetailsView => vec![Self::MerchantDetailsView], + Self::MerchantDetailsManage => { + vec![Self::MerchantDetailsView, Self::MerchantDetailsManage] + } -pub static MERCHANT_DETAILS_MANAGE: [Permission; 6] = [ - Permission::MerchantAccountWrite, - Permission::ApiKeyRead, - Permission::ApiKeyWrite, - Permission::MerchantAccountRead, - Permission::WebhookEventRead, - Permission::WebhookEventWrite, + Self::OrganizationManage => vec![Self::OrganizationManage], + } + } +} + +pub trait ParentGroupExt { + fn resources(&self) -> Vec; +} + +impl ParentGroupExt for ParentGroup { + fn resources(&self) -> Vec { + match self { + Self::Operations => OPERATIONS.to_vec(), + Self::Connectors => CONNECTORS.to_vec(), + Self::Workflows => WORKFLOWS.to_vec(), + Self::Analytics => ANALYTICS.to_vec(), + Self::Users => USERS.to_vec(), + Self::Merchant | Self::Organization => ACCOUNT.to_vec(), + Self::Recon => RECON.to_vec(), + } + } +} + +pub static OPERATIONS: [Resource; 8] = [ + Resource::Payment, + Resource::Refund, + Resource::Mandate, + Resource::Dispute, + Resource::Customer, + Resource::Payout, + Resource::Report, + Resource::Account, ]; -pub static ORGANIZATION_MANAGE: [Permission; 2] = [ - Permission::MerchantAccountCreate, - Permission::MerchantAccountRead, +pub static CONNECTORS: [Resource; 2] = [Resource::Connector, Resource::Account]; + +pub static WORKFLOWS: [Resource; 5] = [ + Resource::Routing, + Resource::ThreeDsDecisionManager, + Resource::SurchargeDecisionManager, + Resource::Connector, + Resource::Account, ]; -pub static RECON: [Permission; 1] = [Permission::ReconAdmin]; +pub static ANALYTICS: [Resource; 3] = [Resource::Analytics, Resource::Report, Resource::Account]; + +pub static USERS: [Resource; 2] = [Resource::User, Resource::Account]; + +pub static ACCOUNT: [Resource; 3] = [Resource::Account, Resource::ApiKey, Resource::WebhookEvent]; + +pub static RECON: [Resource; 1] = [Resource::Recon]; diff --git a/crates/router/src/services/authorization/permissions.rs b/crates/router/src/services/authorization/permissions.rs index 2121ba0f9440..0521db7acc15 100644 --- a/crates/router/src/services/authorization/permissions.rs +++ b/crates/router/src/services/authorization/permissions.rs @@ -1,39 +1,75 @@ -use strum::Display; +use common_enums::{EntityType, PermissionScope, Resource}; +use router_derive::generate_permissions; -#[derive( - PartialEq, Display, Clone, Debug, Copy, Eq, Hash, serde::Deserialize, serde::Serialize, -)] -pub enum Permission { - PaymentRead, - PaymentWrite, - RefundRead, - RefundWrite, - ApiKeyRead, - ApiKeyWrite, - MerchantAccountRead, - MerchantAccountWrite, - MerchantConnectorAccountRead, - MerchantConnectorAccountWrite, - RoutingRead, - RoutingWrite, - DisputeRead, - DisputeWrite, - MandateRead, - MandateWrite, - CustomerRead, - CustomerWrite, - Analytics, - ThreeDsDecisionManagerWrite, - ThreeDsDecisionManagerRead, - SurchargeDecisionManagerWrite, - SurchargeDecisionManagerRead, - UsersRead, - UsersWrite, - MerchantAccountCreate, - WebhookEventRead, - WebhookEventWrite, - PayoutRead, - PayoutWrite, - GenerateReport, - ReconAdmin, +generate_permissions! { + permissions: [ + Payment: { + scopes: [Read, Write], + entities: [Profile, Merchant] + }, + Refund: { + scopes: [Read, Write], + entities: [Profile, Merchant] + }, + Dispute: { + scopes: [Read, Write], + entities: [Profile, Merchant] + }, + Mandate: { + scopes: [Read, Write], + entities: [Merchant] + }, + Customer: { + scopes: [Read, Write], + entities: [Merchant] + }, + Payout: { + scopes: [Read], + entities: [Profile, Merchant] + }, + ApiKey: { + scopes: [Read, Write], + entities: [Merchant] + }, + Account: { + scopes: [Read, Write], + entities: [Profile, Merchant, Organization] + }, + Connector: { + scopes: [Read, Write], + entities: [Profile, Merchant] + }, + Routing: { + scopes: [Read, Write], + entities: [Profile, Merchant] + }, + ThreeDsDecisionManager: { + scopes: [Read, Write], + entities: [Merchant] + }, + SurchargeDecisionManager: { + scopes: [Read, Write], + entities: [Merchant] + }, + Analytics: { + scopes: [Read], + entities: [Profile, Merchant, Organization] + }, + Report: { + scopes: [Read], + entities: [Profile, Merchant, Organization] + }, + User: { + scopes: [Read, Write], + entities: [Profile, Merchant] + }, + WebhookEvent: { + scopes: [Read, Write], + entities: [Merchant] + }, + Recon: { + scopes: [Write], + entities: [Merchant] + }, + ] } diff --git a/crates/router/src/services/authorization/roles.rs b/crates/router/src/services/authorization/roles.rs index 19383f010f2f..63d547bfa67e 100644 --- a/crates/router/src/services/authorization/roles.rs +++ b/crates/router/src/services/authorization/roles.rs @@ -1,9 +1,9 @@ use std::collections::HashSet; -use common_enums::{EntityType, PermissionGroup, RoleScope}; +use common_enums::{EntityType, PermissionGroup, Resource, RoleScope}; use common_utils::{errors::CustomResult, id_type}; -use super::{permission_groups::get_permissions_vec, permissions::Permission}; +use super::{permission_groups::PermissionGroupExt, permissions::Permission}; use crate::{core::errors, routes::SessionState}; pub mod predefined_roles; @@ -30,8 +30,13 @@ impl RoleInfo { &self.role_name } - pub fn get_permission_groups(&self) -> &Vec { - &self.groups + pub fn get_permission_groups(&self) -> Vec { + self.groups + .iter() + .flat_map(|group| group.accessible_groups()) + .collect::>() + .into_iter() + .collect() } pub fn get_scope(&self) -> RoleScope { @@ -58,17 +63,19 @@ impl RoleInfo { self.is_updatable } - pub fn get_permissions_set(&self) -> HashSet { - self.groups + pub fn get_resources_set(&self) -> HashSet { + self.get_permission_groups() .iter() - .flat_map(|group| get_permissions_vec(group).iter().copied()) + .flat_map(|group| group.resources()) .collect() } pub fn check_permission_exists(&self, required_permission: &Permission) -> bool { - self.groups - .iter() - .any(|group| get_permissions_vec(group).contains(required_permission)) + required_permission.entity_type() <= self.entity_type + && self.get_permission_groups().iter().any(|group| { + required_permission.scope() <= group.scope() + && group.resources().contains(&required_permission.resource()) + }) } pub async fn from_role_id_in_merchant_scope( diff --git a/crates/router_derive/src/lib.rs b/crates/router_derive/src/lib.rs index 02179934e384..69865512a375 100644 --- a/crates/router_derive/src/lib.rs +++ b/crates/router_derive/src/lib.rs @@ -694,3 +694,58 @@ pub fn flat_struct_derive(input: proc_macro::TokenStream) -> proc_macro::TokenSt proc_macro::TokenStream::from(expanded) } + +/// Generates the permissions enum and implematations for the permissions +/// +/// **NOTE:** You have to make sure that all the identifiers used +/// in the macro input are present in the respective enums as well. +/// +/// ## Usage +/// ``` +/// use router_derive::generate_permissions; +/// +/// enum Scope { +/// Read, +/// Write, +/// } +/// +/// enum EntityType { +/// Profile, +/// Merchant, +/// Org, +/// } +/// +/// enum Resource { +/// Payments, +/// Refunds, +/// } +/// +/// generate_permissions! { +/// permissions: [ +/// Payments: { +/// scopes: [Read, Write], +/// entities: [Profile, Merchant, Org] +/// }, +/// Refunds: { +/// scopes: [Read], +/// entities: [Profile, Org] +/// } +/// ] +/// } +/// ``` +/// This will generate the following enum. +/// ``` +/// enum Permission { +/// ProfilePaymentsRead, +/// ProfilePaymentsWrite, +/// MerchantPaymentsRead, +/// MerchantPaymentsWrite, +/// OrgPaymentsRead, +/// OrgPaymentsWrite, +/// ProfileRefundsRead, +/// OrgRefundsRead, +/// ``` +#[proc_macro] +pub fn generate_permissions(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + macros::generate_permissions_inner(input) +} diff --git a/crates/router_derive/src/macros.rs b/crates/router_derive/src/macros.rs index 9a8e514c5c11..32e6c213ca6b 100644 --- a/crates/router_derive/src/macros.rs +++ b/crates/router_derive/src/macros.rs @@ -1,5 +1,6 @@ pub(crate) mod api_error; pub(crate) mod diesel; +pub(crate) mod generate_permissions; pub(crate) mod generate_schema; pub(crate) mod misc; pub(crate) mod operation; @@ -14,6 +15,7 @@ use syn::DeriveInput; pub(crate) use self::{ api_error::api_error_derive_inner, diesel::{diesel_enum_derive_inner, diesel_enum_text_derive_inner}, + generate_permissions::generate_permissions_inner, generate_schema::polymorphic_macro_derive_inner, }; diff --git a/crates/router_derive/src/macros/generate_permissions.rs b/crates/router_derive/src/macros/generate_permissions.rs new file mode 100644 index 000000000000..9b388f102cb6 --- /dev/null +++ b/crates/router_derive/src/macros/generate_permissions.rs @@ -0,0 +1,135 @@ +use proc_macro::TokenStream; +use quote::{format_ident, quote}; +use syn::{ + braced, bracketed, + parse::{Parse, ParseBuffer, ParseStream}, + parse_macro_input, + punctuated::Punctuated, + token::Comma, + Ident, Token, +}; + +struct ResourceInput { + resource_name: Ident, + scopes: Punctuated, + entities: Punctuated, +} + +struct Input { + permissions: Punctuated, +} + +impl Parse for Input { + fn parse(input: ParseStream<'_>) -> syn::Result { + let (_permission_label, permissions) = parse_label_with_punctuated_data(input)?; + + Ok(Self { permissions }) + } +} + +impl Parse for ResourceInput { + fn parse(input: ParseStream<'_>) -> syn::Result { + let resource_name: Ident = input.parse()?; + input.parse::()?; // Expect ':' + + let content; + braced!(content in input); + + let (_scopes_label, scopes) = parse_label_with_punctuated_data(&content)?; + content.parse::()?; + + let (_entities_label, entities) = parse_label_with_punctuated_data(&content)?; + + Ok(Self { + resource_name, + scopes, + entities, + }) + } +} + +fn parse_label_with_punctuated_data( + input: &ParseBuffer<'_>, +) -> syn::Result<(Ident, Punctuated)> { + let label: Ident = input.parse()?; + input.parse::()?; // Expect ':' + + let content; + bracketed!(content in input); // Parse the list inside [] + let data = Punctuated::::parse_terminated(&content)?; + + Ok((label, data)) +} + +pub fn generate_permissions_inner(input: TokenStream) -> TokenStream { + let input = parse_macro_input!(input as Input); + + let res = input.permissions.iter(); + + let mut enum_keys = Vec::new(); + let mut scope_impl_per = Vec::new(); + let mut entity_impl_per = Vec::new(); + let mut resource_impl_per = Vec::new(); + + let mut entity_impl_res = Vec::new(); + + for per in res { + let resource_name = &per.resource_name; + let mut permissions = Vec::new(); + + for scope in per.scopes.iter() { + for entity in per.entities.iter() { + let key = format_ident!("{}{}{}", entity, per.resource_name, scope); + + enum_keys.push(quote! { #key }); + scope_impl_per.push(quote! { Permission::#key => PermissionScope::#scope }); + entity_impl_per.push(quote! { Permission::#key => EntityType::#entity }); + resource_impl_per.push(quote! { Permission::#key => Resource::#resource_name }); + permissions.push(quote! { Permission::#key }); + } + let entities_iter = per.entities.iter(); + entity_impl_res + .push(quote! { Resource::#resource_name => vec![#(EntityType::#entities_iter),*] }); + } + } + + let expanded = quote! { + #[derive( + Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, serde::Serialize, serde::Deserialize, strum::Display + )] + pub enum Permission { + #(#enum_keys),* + } + + impl Permission { + pub fn scope(&self) -> PermissionScope { + match self { + #(#scope_impl_per),* + } + } + pub fn entity_type(&self) -> EntityType { + match self { + #(#entity_impl_per),* + } + } + pub fn resource(&self) -> Resource { + match self { + #(#resource_impl_per),* + } + } + } + + pub trait ResourceExt { + fn entities(&self) -> Vec; + } + + impl ResourceExt for Resource { + fn entities(&self) -> Vec { + match self { + #(#entity_impl_res),* + } + } + } + }; + expanded.into() +} From 842c4a2f47d4cc7b850a16abbe5431fe575f7a86 Mon Sep 17 00:00:00 2001 From: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:09:06 +0530 Subject: [PATCH 08/46] fix(payment_methods): fix merchant payment method list to retain a mca based on connector_name and mca_id (#6408) --- crates/api_models/src/payment_methods.rs | 3 +++ crates/router/src/core/payment_methods/cards.rs | 11 +++++++++++ crates/router/src/core/payments.rs | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index 84106a87d9b6..d5255b5e8c5d 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -1217,12 +1217,14 @@ pub struct ResponsePaymentMethodIntermediate { pub card_networks: Option>, pub payment_method: api_enums::PaymentMethod, pub connector: String, + pub merchant_connector_id: String, } impl ResponsePaymentMethodIntermediate { pub fn new( pm_type: RequestPaymentMethodTypes, connector: String, + merchant_connector_id: String, pm: api_enums::PaymentMethod, ) -> Self { Self { @@ -1231,6 +1233,7 @@ impl ResponsePaymentMethodIntermediate { card_networks: pm_type.card_networks, payment_method: pm, connector, + merchant_connector_id, } } } diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index da1c70ebcfcf..067b35e1e5ea 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -2980,6 +2980,7 @@ pub async fn list_payment_methods( api_enums::PaymentMethodType::ApplePay, api_enums::PaymentMethodType::Klarna, api_enums::PaymentMethodType::Paypal, + api_enums::PaymentMethodType::SamsungPay, ]); let mut chosen = Vec::::new(); @@ -3031,6 +3032,15 @@ pub async fn list_payment_methods( .connector .connector_name .to_string() + && first_routable_connector + .connector + .merchant_connector_id + .as_ref() + .map(|merchant_connector_id| { + *merchant_connector_id.get_string_repr() + == intermediate.merchant_connector_id + }) + .unwrap_or_default() } else { false } @@ -4070,6 +4080,7 @@ pub async fn filter_payment_methods( let response_pm_type = ResponsePaymentMethodIntermediate::new( payment_method_object, connector.clone(), + mca_id.get_string_repr().to_string(), payment_method, ); resp.push(response_pm_type); diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 938d5e292351..0b44989807ed 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -5520,7 +5520,10 @@ where let routing_choice = choice .first() .ok_or(errors::ApiErrorResponse::InternalServerError)?; - if connector_data.connector.connector_name == routing_choice.connector.connector_name { + if connector_data.connector.connector_name == routing_choice.connector.connector_name + && connector_data.connector.merchant_connector_id + == routing_choice.connector.merchant_connector_id + { final_list.push(connector_data); } } From ecaf70099671950287e9a6b7d30ffd02c0c5f51e Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:30:17 +0530 Subject: [PATCH 09/46] chore: Add samsung pay payment method support for cybersource (#6424) --- crates/connector_configs/src/common_config.rs | 2 +- crates/connector_configs/src/connector.rs | 63 ++++++++++--------- .../connector_configs/toml/development.toml | 29 +++++++++ 3 files changed, 65 insertions(+), 29 deletions(-) diff --git a/crates/connector_configs/src/common_config.rs b/crates/connector_configs/src/common_config.rs index d0becb80468f..26c9d33f405a 100644 --- a/crates/connector_configs/src/common_config.rs +++ b/crates/connector_configs/src/common_config.rs @@ -206,7 +206,7 @@ pub enum InputType { #[serde_with::skip_serializing_none] #[derive(Debug, Deserialize, serde::Serialize, Clone)] #[serde(rename_all = "snake_case")] -pub struct MetaDataInupt { +pub struct InputData { pub name: String, pub label: String, pub placeholder: String, diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs index 7916efc1a84d..923edd386de7 100644 --- a/crates/connector_configs/src/connector.rs +++ b/crates/connector_configs/src/connector.rs @@ -10,7 +10,7 @@ use serde::Deserialize; #[cfg(any(feature = "sandbox", feature = "development", feature = "production"))] use toml; -use crate::common_config::{CardProvider, MetaDataInupt, Provider, ZenApplePay}; +use crate::common_config::{CardProvider, InputData, Provider, ZenApplePay}; #[derive(Default, Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct Classic { @@ -83,38 +83,44 @@ pub enum KlarnaEndpoint { #[serde_with::skip_serializing_none] #[derive(Debug, Deserialize, serde::Serialize, Clone)] pub struct ConfigMerchantAdditionalDetails { - pub open_banking_recipient_data: Option, - pub account_data: Option, - pub iban: Option>, - pub bacs: Option>, - pub connector_recipient_id: Option, - pub wallet_id: Option, + pub open_banking_recipient_data: Option, + pub account_data: Option, + pub iban: Option>, + pub bacs: Option>, + pub connector_recipient_id: Option, + pub wallet_id: Option, } #[serde_with::skip_serializing_none] #[derive(Debug, Deserialize, serde::Serialize, Clone)] pub struct ConfigMetadata { - pub merchant_config_currency: Option, - pub merchant_account_id: Option, - pub account_name: Option, - pub terminal_id: Option, - pub google_pay: Option>, - pub apple_pay: Option>, - pub merchant_id: Option, - pub endpoint_prefix: Option, - pub mcc: Option, - pub merchant_country_code: Option, - pub merchant_name: Option, - pub acquirer_bin: Option, - pub acquirer_merchant_id: Option, - pub acquirer_country_code: Option, - pub three_ds_requestor_name: Option, - pub three_ds_requestor_id: Option, - pub pull_mechanism_for_external_3ds_enabled: Option, - pub klarna_region: Option, - pub source_balance_account: Option, - pub brand_id: Option, - pub destination_account_number: Option, + pub merchant_config_currency: Option, + pub merchant_account_id: Option, + pub account_name: Option, + pub terminal_id: Option, + pub google_pay: Option>, + pub apple_pay: Option>, + pub merchant_id: Option, + pub endpoint_prefix: Option, + pub mcc: Option, + pub merchant_country_code: Option, + pub merchant_name: Option, + pub acquirer_bin: Option, + pub acquirer_merchant_id: Option, + pub acquirer_country_code: Option, + pub three_ds_requestor_name: Option, + pub three_ds_requestor_id: Option, + pub pull_mechanism_for_external_3ds_enabled: Option, + pub klarna_region: Option, + pub source_balance_account: Option, + pub brand_id: Option, + pub destination_account_number: Option, +} + +#[serde_with::skip_serializing_none] +#[derive(Debug, Deserialize, serde::Serialize, Clone)] +pub struct ConnectorWalletDetailsConfig { + pub samsung_pay: Option>, } #[serde_with::skip_serializing_none] @@ -123,6 +129,7 @@ pub struct ConnectorTomlConfig { pub connector_auth: Option, pub connector_webhook_details: Option, pub metadata: Option>, + pub connector_wallets_details: Option>, pub additional_merchant_data: Option>, pub credit: Option>, pub debit: Option>, diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index ba6d3cb2b432..c903c189b5bd 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -1215,6 +1215,8 @@ merchant_secret="Source verification key" payment_method_type = "google_pay" [[cybersource.wallet]] payment_method_type = "paze" +[[cybersource.wallet]] + payment_method_type = "samsung_pay" [cybersource.connector_auth.SignatureKey] api_key="Key" key1="Merchant ID" @@ -1296,6 +1298,33 @@ placeholder="Enter Google Pay Merchant Key" required=true type="Text" +[[cybersource.connector_wallets_details.samsung_pay]] +name="service_id" +label="Samsung Pay Service Id" +placeholder="Enter Samsung Pay Service Id" +required=true +type="Text" +[[cybersource.connector_wallets_details.samsung_pay]] +name="merchant_display_name" +label="Display Name" +placeholder="Enter Display Name" +required=true +type="Text" +[[cybersource.connector_wallets_details.samsung_pay]] +name="merchant_business_country" +label="Merchant Business Country" +placeholder="Enter Merchant Business Country" +required=true +type="Select" +options=[] +[[cybersource.connector_wallets_details.samsung_pay]] +name="allowed_brands" +label="Allowed Brands" +placeholder="Enter Allowed Brands" +required=true +type="MultiSelect" +options=["visa","masterCard","amex","discover"] + [cybersource.metadata.acquirer_bin] name="acquirer_bin" label="Acquirer Bin" From 8e58b56b43ad2f823c51943c34aa8837297c70d6 Mon Sep 17 00:00:00 2001 From: Sakil Mostak <73734619+Sakilmostak@users.noreply.github.com> Date: Thu, 24 Oct 2024 20:57:46 +0530 Subject: [PATCH 10/46] fix(core): populate billing_address for payment with pm_id (#6411) --- crates/router/src/core/payment_methods.rs | 3 ++- crates/router/src/core/payments/operations/payment_response.rs | 3 ++- crates/router/src/core/payments/tokenization.rs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs index 005b5aeba6c3..87078dfa5aff 100644 --- a/crates/router/src/core/payment_methods.rs +++ b/crates/router/src/core/payment_methods.rs @@ -753,6 +753,7 @@ pub(crate) async fn get_payment_method_create_request( payment_method_type: Option, customer_id: &Option, billing_name: Option>, + payment_method_billing_address: Option<&api_models::payments::Address>, ) -> RouterResult { match payment_method_data { Some(pm_data) => match payment_method { @@ -787,7 +788,7 @@ pub(crate) async fn get_payment_method_create_request( .map(|card_network| card_network.to_string()), client_secret: None, payment_method_data: None, - billing: None, + billing: payment_method_billing_address.cloned(), connector_mandate_details: None, network_transaction_id: None, }; diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index ae64fe41b1ff..6b243ba72aac 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -1047,6 +1047,7 @@ impl PostUpdateTracker, types::SetupMandateRequestDa where F: 'b + Clone + Send + Sync, { + let payment_method_billing_address = payment_data.address.get_payment_method_billing(); let billing_name = resp .address .get_payment_method_billing() @@ -1079,7 +1080,7 @@ impl PostUpdateTracker, types::SetupMandateRequestDa resp.request.payment_method_type, key_store, billing_name, - None, + payment_method_billing_address, business_profile, )) .await?; diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs index b4e5ade56980..43353227c883 100644 --- a/crates/router/src/core/payments/tokenization.rs +++ b/crates/router/src/core/payments/tokenization.rs @@ -180,6 +180,7 @@ where payment_method_type, &customer_id.clone(), billing_name, + payment_method_billing_address, ) .await?; let customer_id = customer_id.to_owned().get_required_value("customer_id")?; From 8708a5cb8f7d64a382b2fe061c725d4854ba9e92 Mon Sep 17 00:00:00 2001 From: Chethan Rao <70657455+Chethan-rao@users.noreply.github.com> Date: Thu, 24 Oct 2024 21:06:07 +0530 Subject: [PATCH 11/46] chore: address Rust 1.82.0 clippy lints (#6401) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- add_connector.md | 2 +- connector-template/transformers.rs | 4 +- crates/api_models/src/connector_onboarding.rs | 2 +- crates/api_models/src/payouts.rs | 2 +- crates/api_models/src/webhooks.rs | 6 +- crates/diesel_models/src/kv.rs | 22 +++---- .../src/connectors/bambora/transformers.rs | 24 +++---- .../src/connectors/billwerk/transformers.rs | 4 +- .../src/connectors/bitpay/transformers.rs | 4 +- .../src/connectors/cashtocode/transformers.rs | 8 +-- .../src/connectors/coinbase/transformers.rs | 4 +- .../src/connectors/cryptopay/transformers.rs | 4 +- .../connectors/deutschebank/transformers.rs | 22 +++---- .../connectors/digitalvirgo/transformers.rs | 4 +- .../src/connectors/dlocal/transformers.rs | 16 ++--- .../src/connectors/fiserv/transformers.rs | 8 +-- .../src/connectors/fiservemea/transformers.rs | 4 +- .../src/connectors/fiuu/transformers.rs | 28 ++++---- .../src/connectors/forte/transformers.rs | 16 ++--- .../src/connectors/globepay/transformers.rs | 8 +-- .../src/connectors/helcim/transformers.rs | 20 +++--- .../src/connectors/mollie/transformers.rs | 4 +- .../src/connectors/nexinets/transformers.rs | 8 +-- .../src/connectors/nexixpay/transformers.rs | 24 +++---- .../src/connectors/novalnet/transformers.rs | 20 +++--- .../src/connectors/payeezy/transformers.rs | 4 +- .../src/connectors/payu/transformers.rs | 16 ++--- .../src/connectors/powertranz/transformers.rs | 4 +- .../src/connectors/square/transformers.rs | 4 +- .../src/connectors/stax/transformers.rs | 4 +- .../src/connectors/thunes/transformers.rs | 4 +- .../src/connectors/tsys/transformers.rs | 8 +-- .../src/connectors/volt/transformers.rs | 12 ++-- .../src/connectors/worldline/transformers.rs | 8 +-- .../src/connectors/zen/transformers.rs | 8 +-- .../hyperswitch_domain_models/src/customer.rs | 8 +-- .../src/merchant_connector_account.rs | 24 +++---- .../src/router_response_types.rs | 4 +- .../src/compatibility/stripe/webhooks.rs | 8 +-- .../router/src/connector/aci/transformers.rs | 4 +- .../src/connector/adyen/transformers.rs | 36 +++++------ .../src/connector/airwallex/transformers.rs | 8 +-- .../connector/authorizedotnet/transformers.rs | 31 +++++---- .../src/connector/bamboraapac/transformers.rs | 50 +++++++-------- .../connector/bankofamerica/transformers.rs | 16 ++--- crates/router/src/connector/bluesnap.rs | 6 +- .../src/connector/bluesnap/transformers.rs | 4 +- .../router/src/connector/boku/transformers.rs | 4 +- .../src/connector/braintree/transformers.rs | 64 +++++++++---------- .../src/connector/checkout/transformers.rs | 16 ++--- .../src/connector/cybersource/transformers.rs | 46 ++++++------- .../src/connector/datatrans/transformers.rs | 8 +-- .../connector/dummyconnector/transformers.rs | 4 +- .../src/connector/globalpay/transformers.rs | 4 +- .../src/connector/gocardless/transformers.rs | 12 ++-- .../src/connector/iatapay/transformers.rs | 8 +-- .../src/connector/itaubank/transformers.rs | 8 +-- .../src/connector/klarna/transformers.rs | 12 ++-- .../src/connector/mifinity/transformers.rs | 22 +++---- .../connector/multisafepay/transformers.rs | 24 +++---- .../router/src/connector/nmi/transformers.rs | 30 ++++----- .../router/src/connector/noon/transformers.rs | 4 +- .../src/connector/nuvei/transformers.rs | 20 +++--- .../src/connector/opayo/transformers.rs | 4 +- .../src/connector/opennode/transformers.rs | 4 +- .../src/connector/paybox/transformers.rs | 22 +++---- .../src/connector/payme/transformers.rs | 26 ++++---- crates/router/src/connector/paypal.rs | 12 ++-- .../src/connector/paypal/transformers.rs | 42 ++++++------ .../src/connector/placetopay/transformers.rs | 4 +- .../src/connector/plaid/transformers.rs | 8 +-- .../src/connector/prophetpay/transformers.rs | 16 ++--- .../src/connector/rapyd/transformers.rs | 4 +- .../src/connector/razorpay/transformers.rs | 8 +-- .../src/connector/shift4/transformers.rs | 19 +++--- .../src/connector/stripe/transformers.rs | 18 +++--- .../src/connector/trustpay/transformers.rs | 22 +++---- .../src/connector/wellsfargo/transformers.rs | 16 ++--- .../wellsfargopayout/transformers.rs | 4 +- crates/router/src/connector/worldpay.rs | 12 ++-- .../src/connector/worldpay/transformers.rs | 4 +- .../router/src/connector/zsl/transformers.rs | 10 +-- crates/router/src/core/admin.rs | 30 +++++---- .../router/src/core/connector_onboarding.rs | 2 +- crates/router/src/core/customers.rs | 8 +-- crates/router/src/core/mandate.rs | 8 +-- crates/router/src/core/payments.rs | 4 +- crates/router/src/core/payments/helpers.rs | 6 +- .../payments/operations/payment_confirm.rs | 2 +- .../payments/operations/payment_response.rs | 2 +- crates/router/src/core/payments/retry.rs | 2 +- .../router/src/core/payments/tokenization.rs | 5 +- .../router/src/core/payments/transformers.rs | 4 +- crates/router/src/core/payouts.rs | 4 +- crates/router/src/core/verification/utils.rs | 18 +++--- crates/router/src/core/webhooks/incoming.rs | 14 ++-- crates/router/src/core/webhooks/outgoing.rs | 10 +-- crates/router/src/core/webhooks/utils.rs | 2 +- .../src/core/webhooks/webhook_events.rs | 8 +-- crates/router/src/db/address.rs | 6 +- crates/router/src/db/customers.rs | 24 ++++--- crates/router/src/db/mandate.rs | 12 ++-- crates/router/src/db/payment_method.rs | 6 +- crates/router/src/db/refund.rs | 12 ++-- crates/router/src/db/reverse_lookup.rs | 2 +- crates/router/src/events/audit_events.rs | 2 +- crates/router/src/utils.rs | 4 +- .../src/workflows/outgoing_webhook_retry.rs | 6 +- crates/storage_impl/src/lookup.rs | 2 +- .../src/payments/payment_attempt.rs | 8 +-- .../src/payments/payment_intent.rs | 8 ++- .../src/payouts/payout_attempt.rs | 8 +-- crates/storage_impl/src/payouts/payouts.rs | 6 +- 113 files changed, 668 insertions(+), 647 deletions(-) diff --git a/add_connector.md b/add_connector.md index eda368db9c83..4d6e885b7edf 100644 --- a/add_connector.md +++ b/add_connector.md @@ -311,7 +311,7 @@ impl TryFrom> let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), redirection_data, - mandate_reference: None, + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some( diff --git a/connector-template/transformers.rs b/connector-template/transformers.rs index 1454be66c8b0..b508596cbc08 100644 --- a/connector-template/transformers.rs +++ b/connector-template/transformers.rs @@ -132,8 +132,8 @@ impl TryFrom), } #[derive(serde::Serialize, Debug, Clone)] diff --git a/crates/api_models/src/payouts.rs b/crates/api_models/src/payouts.rs index a7be9703d380..237d165d572c 100644 --- a/crates/api_models/src/payouts.rs +++ b/crates/api_models/src/payouts.rs @@ -19,7 +19,7 @@ use crate::{enums as api_enums, payment_methods::RequiredFieldInfo, payments}; #[derive(Debug, Deserialize, Serialize, Clone, ToSchema)] pub enum PayoutRequest { PayoutActionRequest(PayoutActionRequest), - PayoutCreateRequest(PayoutCreateRequest), + PayoutCreateRequest(Box), PayoutRetrieveRequest(PayoutRetrieveRequest), } diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs index ce9b303066ed..56a566d170ae 100644 --- a/crates/api_models/src/webhooks.rs +++ b/crates/api_models/src/webhooks.rs @@ -229,16 +229,16 @@ pub struct OutgoingWebhook { #[serde(tag = "type", content = "object", rename_all = "snake_case")] pub enum OutgoingWebhookContent { #[schema(value_type = PaymentsResponse, title = "PaymentsResponse")] - PaymentDetails(payments::PaymentsResponse), + PaymentDetails(Box), #[schema(value_type = RefundResponse, title = "RefundResponse")] - RefundDetails(refunds::RefundResponse), + RefundDetails(Box), #[schema(value_type = DisputeResponse, title = "DisputeResponse")] DisputeDetails(Box), #[schema(value_type = MandateResponse, title = "MandateResponse")] MandateDetails(Box), #[cfg(feature = "payouts")] #[schema(value_type = PayoutCreateResponse, title = "PayoutCreateResponse")] - PayoutDetails(payouts::PayoutCreateResponse), + PayoutDetails(Box), } #[derive(Debug, Clone, Serialize)] diff --git a/crates/diesel_models/src/kv.rs b/crates/diesel_models/src/kv.rs index d91e57a2b5d6..0bfa1434f69a 100644 --- a/crates/diesel_models/src/kv.rs +++ b/crates/diesel_models/src/kv.rs @@ -20,8 +20,8 @@ use crate::{ #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "snake_case", tag = "db_op", content = "data")] pub enum DBOperation { - Insert { insertable: Insertable }, - Update { updatable: Updateable }, + Insert { insertable: Box }, + Update { updatable: Box }, } impl DBOperation { @@ -33,7 +33,7 @@ impl DBOperation { } pub fn table<'a>(&self) -> &'a str { match self { - Self::Insert { insertable } => match insertable { + Self::Insert { insertable } => match **insertable { Insertable::PaymentIntent(_) => "payment_intent", Insertable::PaymentAttempt(_) => "payment_attempt", Insertable::Refund(_) => "refund", @@ -45,7 +45,7 @@ impl DBOperation { Insertable::PaymentMethod(_) => "payment_method", Insertable::Mandate(_) => "mandate", }, - Self::Update { updatable } => match updatable { + Self::Update { updatable } => match **updatable { Updateable::PaymentIntentUpdate(_) => "payment_intent", Updateable::PaymentAttemptUpdate(_) => "payment_attempt", Updateable::RefundUpdate(_) => "refund", @@ -83,7 +83,7 @@ pub struct TypedSql { impl DBOperation { pub async fn execute(self, conn: &PgPooledConn) -> crate::StorageResult { Ok(match self { - Self::Insert { insertable } => match insertable { + Self::Insert { insertable } => match *insertable { Insertable::PaymentIntent(a) => { DBResult::PaymentIntent(Box::new(a.insert(conn).await?)) } @@ -107,7 +107,7 @@ impl DBOperation { } Insertable::Mandate(m) => DBResult::Mandate(Box::new(m.insert(conn).await?)), }, - Self::Update { updatable } => match updatable { + Self::Update { updatable } => match *updatable { Updateable::PaymentIntentUpdate(a) => { DBResult::PaymentIntent(Box::new(a.orig.update(conn, a.update_data).await?)) } @@ -201,8 +201,8 @@ impl TypedSql { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "snake_case", tag = "table", content = "data")] pub enum Insertable { - PaymentIntent(PaymentIntentNew), - PaymentAttempt(PaymentAttemptNew), + PaymentIntent(Box), + PaymentAttempt(Box), Refund(RefundNew), Address(Box), Customer(CustomerNew), @@ -216,14 +216,14 @@ pub enum Insertable { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "snake_case", tag = "table", content = "data")] pub enum Updateable { - PaymentIntentUpdate(PaymentIntentUpdateMems), - PaymentAttemptUpdate(PaymentAttemptUpdateMems), + PaymentIntentUpdate(Box), + PaymentAttemptUpdate(Box), RefundUpdate(RefundUpdateMems), CustomerUpdate(CustomerUpdateMems), AddressUpdate(Box), PayoutsUpdate(PayoutsUpdateMems), PayoutAttemptUpdate(PayoutAttemptUpdateMems), - PaymentMethodUpdate(PaymentMethodUpdateMems), + PaymentMethodUpdate(Box), MandateUpdate(MandateUpdateMems), } diff --git a/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs b/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs index 4212f7168db3..567f519d7944 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs @@ -471,8 +471,8 @@ impl TryFrom TryFrom }, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.id.to_string()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), @@ -586,8 +586,8 @@ impl }, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.id.to_string()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), @@ -621,8 +621,8 @@ impl }, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.id.to_string()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), @@ -656,8 +656,8 @@ impl }, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.id.to_string()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs b/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs index cc63e1ad7cc1..798f28d1f0a4 100644 --- a/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs @@ -284,8 +284,8 @@ impl TryFrom TryFrom resource_id: ResponseId::ConnectorTransactionId( item.data.attempt_id.clone(), ), - redirection_data: Some(redirection_data), - mandate_reference: None, + redirection_data: Box::new(Some(redirection_data)), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -302,8 +302,8 @@ impl TryFrom TryFrom .map(|x| RedirectForm::from((x, common_utils::request::Method::Get))); Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.data.id.clone()), - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs index e4b011f62045..ccecdaa3d415 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs @@ -298,16 +298,16 @@ impl }, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::NoResponseId, - redirection_data: Some(RedirectForm::Form { + redirection_data: Box::new(Some(RedirectForm::Form { endpoint: item.data.request.get_complete_authorize_url()?, method: common_utils::request::Method::Get, form_fields: HashMap::from([ ("reference".to_string(), reference.clone()), ("signed_on".to_string(), signed_on.clone()), ]), - }), + })), mandate_reference: if item.data.request.is_mandate_payment() { - Some(MandateReference { + Box::new(Some(MandateReference { connector_mandate_id: item.response.mandate_id, payment_method_id: None, mandate_metadata: Some(serde_json::json!(DeutschebankMandateMetadata { @@ -325,9 +325,9 @@ impl reference: Secret::from(reference.clone()), signed_on, })), - }) + })) } else { - None + Box::new(None) }, connector_metadata: None, network_txn_id: None, @@ -375,8 +375,8 @@ impl }, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.tx_id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -578,8 +578,8 @@ impl }, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.tx_id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -637,8 +637,8 @@ impl Ok(Self { response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.tx_id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs index 722c78442da2..856736842f90 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs @@ -124,8 +124,8 @@ impl TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom status: enums::AttemptStatus::AuthenticationPending, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(response.txn_id.clone()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: get_qr_metadata(response)?, network_txn_id: None, connector_response_reference_id: None, @@ -640,8 +640,8 @@ impl status: enums::AttemptStatus::AuthenticationPending, response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(data.txn_id), - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -684,8 +684,8 @@ impl } else { Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(data.txn_id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -924,8 +924,8 @@ impl TryFrom> for PaymentsSy }; let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: item.data.request.connector_transaction_id.clone(), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -963,8 +963,8 @@ impl TryFrom> for PaymentsSy }; let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: item.data.request.connector_transaction_id.clone(), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1130,8 +1130,8 @@ impl TryFrom> }; let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.tran_id.to_string()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1241,8 +1241,8 @@ impl TryFrom> }; let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.tran_id.to_string()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs b/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs index d04ea7bfee4e..6e67409238d8 100644 --- a/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs @@ -299,8 +299,8 @@ impl TryFrom TryFrom> status: enums::AttemptStatus::from(item.response.response.response_code), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(transaction_id.clone()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(serde_json::json!(ForteMeta { auth_id: item.response.authorization_code, })), @@ -479,8 +479,8 @@ impl TryFrom TryFrom TryFrom resource_id: ResponseId::ConnectorTransactionId( item.response.transaction_id.to_string(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), @@ -430,8 +430,8 @@ impl Ok(Self { response: Ok(PaymentsResponseData::TransactionResponse { resource_id, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), @@ -479,8 +479,8 @@ impl resource_id: ResponseId::ConnectorTransactionId( item.response.transaction_id.to_string(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), @@ -559,8 +559,8 @@ impl resource_id: ResponseId::ConnectorTransactionId( item.response.transaction_id.to_string(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), @@ -616,8 +616,8 @@ impl resource_id: ResponseId::ConnectorTransactionId( item.response.transaction_id.to_string(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), diff --git a/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs b/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs index dc5f64bee184..cef3d684e7b0 100644 --- a/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs @@ -507,8 +507,8 @@ impl TryFrom TryFrom TryFrom resource_id: ResponseId::ConnectorTransactionId( item.response.operation.order_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some(item.response.operation.order_id), @@ -626,8 +626,8 @@ impl resource_id: ResponseId::ConnectorTransactionId( item.response.operation.order_id.clone(), ), - redirection_data: Some(redirection_form.clone()), - mandate_reference: None, + redirection_data: Box::new(Some(redirection_form.clone())), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some(item.response.operation.order_id), @@ -744,8 +744,8 @@ impl resource_id: ResponseId::ConnectorTransactionId( item.response.operation.order_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some(item.response.operation.order_id), @@ -867,8 +867,8 @@ impl status: AttemptStatus::from(item.response.operation_result), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.order_id.clone()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: item.data.request.connector_meta.clone(), network_txn_id: None, connector_response_reference_id: Some(item.response.order_id.clone()), @@ -923,8 +923,8 @@ impl resource_id: ResponseId::ConnectorTransactionId( item.data.request.connector_transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some( @@ -986,8 +986,8 @@ impl resource_id: ResponseId::ConnectorTransactionId( item.data.request.connector_transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some( diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs index ab209a4db051..1f16a14fde3c 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs @@ -594,14 +594,14 @@ impl TryFrom .clone() .map(ResponseId::ConnectorTransactionId) .unwrap_or(ResponseId::NoResponseId), - redirection_data: None, - mandate_reference: mandate_reference_id.as_ref().map(|id| { + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference_id.as_ref().map(|id| { MandateReference { connector_mandate_id: Some(id.clone()), payment_method_id: None, mandate_metadata: None, } - }), + })), connector_metadata: None, network_txn_id: None, connector_response_reference_id: transaction_id.clone(), @@ -1085,8 +1085,8 @@ impl .clone() .map(ResponseId::ConnectorTransactionId) .unwrap_or(ResponseId::NoResponseId), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: transaction_id.clone(), @@ -1254,8 +1254,8 @@ impl .clone() .map(ResponseId::ConnectorTransactionId) .unwrap_or(ResponseId::NoResponseId), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: transaction_id.clone(), diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs index 47c5c40363e5..af29d54117a0 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs @@ -432,8 +432,8 @@ impl TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom PaymentsResponseData { PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(connector_response.transaction_id.clone()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(connector_response.transaction_id), @@ -246,8 +246,8 @@ fn get_payments_sync_response( .transaction_id .clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some( diff --git a/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs b/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs index e04eae63b4c8..b13d029185f5 100644 --- a/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs @@ -277,8 +277,8 @@ impl TryFrom TryFrom TryFrom TryFrom> status: get_status((item.response.status, item.response.capture_method)), response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), @@ -621,8 +621,8 @@ impl TryFrom TryFrom, phone_country_code: Option, metadata: Option, - connector_customer: Option, + connector_customer: Box>, default_billing_address: Option, default_shipping_address: Option, default_payment_method_id: Option>, @@ -312,7 +312,7 @@ impl From for CustomerUpdateInternal { description, phone_country_code, metadata, - connector_customer, + connector_customer: *connector_customer, modified_at: date_time::now(), default_billing_address, default_shipping_address, @@ -366,7 +366,7 @@ pub enum CustomerUpdate { description: Option, phone_country_code: Option, metadata: Option, - connector_customer: Option, + connector_customer: Box>, address_id: Option, }, ConnectorCustomer { @@ -397,7 +397,7 @@ impl From for CustomerUpdateInternal { description, phone_country_code, metadata, - connector_customer, + connector_customer: *connector_customer, modified_at: date_time::now(), address_id, default_payment_method_id: None, diff --git a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs b/crates/hyperswitch_domain_models/src/merchant_connector_account.rs index 66b983898185..9418f6f8f1ed 100644 --- a/crates/hyperswitch_domain_models/src/merchant_connector_account.rs +++ b/crates/hyperswitch_domain_models/src/merchant_connector_account.rs @@ -88,20 +88,20 @@ pub enum MerchantConnectorAccountUpdate { Update { connector_type: Option, connector_name: Option, - connector_account_details: Option>, + connector_account_details: Box>>, test_mode: Option, disabled: Option, merchant_connector_id: Option, payment_methods_enabled: Option>, metadata: Option, frm_configs: Option>, - connector_webhook_details: Option, + connector_webhook_details: Box>, applepay_verified_domains: Option>, - pm_auth_config: Option, + pm_auth_config: Box>, connector_label: Option, status: Option, - connector_wallets_details: Option>, - additional_merchant_data: Option>, + connector_wallets_details: Box>>, + additional_merchant_data: Box>>, }, ConnectorWalletDetailsUpdate { connector_wallets_details: Encryptable, @@ -113,18 +113,18 @@ pub enum MerchantConnectorAccountUpdate { pub enum MerchantConnectorAccountUpdate { Update { connector_type: Option, - connector_account_details: Option>, + connector_account_details: Box>>, disabled: Option, payment_methods_enabled: Option>, metadata: Option, frm_configs: Option>, connector_webhook_details: Option, applepay_verified_domains: Option>, - pm_auth_config: Option, + pm_auth_config: Box>, connector_label: Option, status: Option, - connector_wallets_details: Option>, - additional_merchant_data: Option>, + connector_wallets_details: Box>>, + additional_merchant_data: Box>>, }, ConnectorWalletDetailsUpdate { connector_wallets_details: Encryptable, @@ -413,9 +413,9 @@ impl From for MerchantConnectorAccountUpdateInte frm_configs: None, frm_config: frm_configs, modified_at: Some(date_time::now()), - connector_webhook_details, + connector_webhook_details: *connector_webhook_details, applepay_verified_domains, - pm_auth_config, + pm_auth_config: *pm_auth_config, connector_label, status, connector_wallets_details: connector_wallets_details.map(Encryption::from), @@ -475,7 +475,7 @@ impl From for MerchantConnectorAccountUpdateInte modified_at: Some(date_time::now()), connector_webhook_details, applepay_verified_domains, - pm_auth_config, + pm_auth_config: *pm_auth_config, connector_label, status, connector_wallets_details: connector_wallets_details.map(Encryption::from), diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 6682ac1ad44c..2ed77c8072d2 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -17,8 +17,8 @@ pub struct RefundsResponseData { pub enum PaymentsResponseData { TransactionResponse { resource_id: ResponseId, - redirection_data: Option, - mandate_reference: Option, + redirection_data: Box>, + mandate_reference: Box>, connector_metadata: Option, network_txn_id: Option, connector_response_reference_id: Option, diff --git a/crates/router/src/compatibility/stripe/webhooks.rs b/crates/router/src/compatibility/stripe/webhooks.rs index 8445011f569f..ddc291e6b139 100644 --- a/crates/router/src/compatibility/stripe/webhooks.rs +++ b/crates/router/src/compatibility/stripe/webhooks.rs @@ -81,7 +81,7 @@ impl OutgoingWebhookType for StripeOutgoingWebhook { #[derive(Serialize, Debug)] #[serde(tag = "type", content = "object", rename_all = "snake_case")] pub enum StripeWebhookObject { - PaymentIntent(StripePaymentIntentResponse), + PaymentIntent(Box), Refund(StripeRefundResponse), Dispute(StripeDisputeResponse), Mandate(StripeMandateResponse), @@ -327,9 +327,9 @@ impl From for StripeWebhookObject { fn from(value: api::OutgoingWebhookContent) -> Self { match value { api::OutgoingWebhookContent::PaymentDetails(payment) => { - Self::PaymentIntent(payment.into()) + Self::PaymentIntent(Box::new((*payment).into())) } - api::OutgoingWebhookContent::RefundDetails(refund) => Self::Refund(refund.into()), + api::OutgoingWebhookContent::RefundDetails(refund) => Self::Refund((*refund).into()), api::OutgoingWebhookContent::DisputeDetails(dispute) => { Self::Dispute((*dispute).into()) } @@ -337,7 +337,7 @@ impl From for StripeWebhookObject { Self::Mandate((*mandate).into()) } #[cfg(feature = "payouts")] - api::OutgoingWebhookContent::PayoutDetails(payout) => Self::Payout(payout.into()), + api::OutgoingWebhookContent::PayoutDetails(payout) => Self::Payout((*payout).into()), } } } diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index 5e803b593ee4..7355617b53ae 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -763,8 +763,8 @@ impl }, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index ca13e57e401f..21c9c34409a7 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -3273,8 +3273,8 @@ impl TryFrom> resource_id: types::ResponseId::ConnectorTransactionId( item.response.payment_psp_reference, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.reference), @@ -3308,8 +3308,8 @@ impl Ok(Self { response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.psp_reference), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -3374,8 +3374,8 @@ pub fn get_adyen_response( let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(response.psp_reference), - redirection_data: None, - mandate_reference, + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id, connector_response_reference_id: Some(response.merchant_reference), @@ -3438,8 +3438,8 @@ pub fn get_webhook_response( .payment_reference .unwrap_or(response.transaction_id), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(response.merchant_reference_id), @@ -3508,8 +3508,8 @@ pub fn get_redirection_response( Some(psp) => types::ResponseId::ConnectorTransactionId(psp.to_string()), None => types::ResponseId::NoResponseId, }, - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: response @@ -3566,8 +3566,8 @@ pub fn get_present_to_shopper_response( Some(psp) => types::ResponseId::ConnectorTransactionId(psp.to_string()), None => types::ResponseId::NoResponseId, }, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: response @@ -3623,8 +3623,8 @@ pub fn get_qr_code_response( Some(psp) => types::ResponseId::ConnectorTransactionId(psp.to_string()), None => types::ResponseId::NoResponseId, }, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: response @@ -3666,8 +3666,8 @@ pub fn get_redirection_error_response( // We don't get connector transaction id for redirections in Adyen. let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: response @@ -4036,8 +4036,8 @@ impl TryFrom> status: storage_enums::AttemptStatus::Pending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(connector_transaction_id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.reference), diff --git a/crates/router/src/connector/airwallex/transformers.rs b/crates/router/src/connector/airwallex/transformers.rs index d3824e9d0da2..ad7ae2716f12 100644 --- a/crates/router/src/connector/airwallex/transformers.rs +++ b/crates/router/src/connector/airwallex/transformers.rs @@ -570,8 +570,8 @@ impl reference_id: Some(item.response.id.clone()), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), @@ -613,8 +613,8 @@ impl reference_id: Some(item.response.id.clone()), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs index 903470ae952a..6961a87326b1 100644 --- a/crates/router/src/connector/authorizedotnet/transformers.rs +++ b/crates/router/src/connector/authorizedotnet/transformers.rs @@ -388,20 +388,19 @@ impl status: enums::AttemptStatus::Charged, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: item.response.customer_profile_id.map( + redirection_data: Box::new(None), + mandate_reference: Box::new(item.response.customer_profile_id.map( |customer_profile_id| types::MandateReference { - connector_mandate_id: item - .response - .customer_payment_profile_id_list - .first() - .map(|payment_profile_id| { - format!("{customer_profile_id}-{payment_profile_id}") - }), + connector_mandate_id: + item.response.customer_payment_profile_id_list.first().map( + |payment_profile_id| { + format!("{customer_profile_id}-{payment_profile_id}") + }, + ), payment_method_id: None, mandate_metadata: None, }, - ), + )), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1125,8 +1124,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( transaction_response.transaction_id.clone(), ), - redirection_data, - mandate_reference, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(mandate_reference), connector_metadata: metadata, network_txn_id: transaction_response .network_trans_id @@ -1198,8 +1197,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( transaction_response.transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: metadata, network_txn_id: transaction_response .network_trans_id @@ -1528,8 +1527,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( transaction.transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(transaction.transaction_id.clone()), diff --git a/crates/router/src/connector/bamboraapac/transformers.rs b/crates/router/src/connector/bamboraapac/transformers.rs index 819c918338e7..8fcbcd98f090 100644 --- a/crates/router/src/connector/bamboraapac/transformers.rs +++ b/crates/router/src/connector/bamboraapac/transformers.rs @@ -39,14 +39,14 @@ pub fn get_payment_body( let transaction_data = get_transaction_body(req)?; let body = format!( r#" - + ]]> @@ -293,8 +293,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( connector_transaction_id.to_owned(), ), - redirection_data: None, - mandate_reference, + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(connector_transaction_id), @@ -354,12 +354,12 @@ pub fn get_setup_mandate_body(req: &types::SetupMandateRouterData) -> Result - {} + {} {} {} {} 2 - {} + {} {} ]]> @@ -460,12 +460,12 @@ impl status: enums::AttemptStatus::Charged, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: Some(types::MandateReference { + redirection_data: Box::new(None), + mandate_reference: Box::new(Some(types::MandateReference { connector_mandate_id: Some(connector_mandate_id), payment_method_id: None, mandate_metadata: None, - }), + })), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -501,7 +501,7 @@ pub fn get_capture_body( let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; let body = format!( r#" - @@ -514,8 +514,8 @@ pub fn get_capture_body( {} {} - - ]]> + + ]]> @@ -610,8 +610,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( connector_transaction_id.to_owned(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some(connector_transaction_id), @@ -663,7 +663,7 @@ pub fn get_refund_body( let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; let body = format!( r#" - @@ -677,9 +677,9 @@ pub fn get_refund_body( {} {} - + - ]]> + ]]> @@ -792,7 +792,7 @@ pub fn get_payment_sync_body(req: &types::PaymentsSyncRouterData) -> Result @@ -810,8 +810,8 @@ pub fn get_payment_sync_body(req: &types::PaymentsSyncRouterData) -> Result{} {} - - ]]> + + ]]> @@ -909,8 +909,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( connector_transaction_id.to_owned(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(connector_transaction_id), @@ -961,7 +961,7 @@ pub fn get_refund_sync_body(req: &types::RefundSyncRouterData) -> Result let body = format!( r#" - @@ -979,8 +979,8 @@ pub fn get_refund_sync_body(req: &types::RefundSyncRouterData) -> Result {} {} - - ]]> + + ]]> diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index ad75328322de..b5669decd867 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -412,8 +412,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( info_response.id.clone(), ), - redirection_data: None, - mandate_reference, + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some( @@ -1516,8 +1516,8 @@ fn get_payment_response( Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(info_response.id.clone()), - redirection_data: None, - mandate_reference, + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some( @@ -1829,8 +1829,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item @@ -1852,8 +1852,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index e6f01700c6d7..468f68dc340c 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -741,10 +741,10 @@ impl ConnectorIntegration resource_id: types::ResponseId::ConnectorTransactionId( item.response.transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.transaction_id), diff --git a/crates/router/src/connector/boku/transformers.rs b/crates/router/src/connector/boku/transformers.rs index bc9eb4e37220..777b795a438d 100644 --- a/crates/router/src/connector/boku/transformers.rs +++ b/crates/router/src/connector/boku/transformers.rs @@ -301,8 +301,8 @@ impl TryFrom } else { Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(transaction_data.id), - redirection_data: None, - mandate_reference: transaction_data.payment_method.as_ref().map(|pm| { - MandateReference { + redirection_data: Box::new(None), + mandate_reference: Box::new(transaction_data.payment_method.as_ref().map( + |pm| MandateReference { connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, - } - }), + }, + )), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -464,12 +464,12 @@ impl status: enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: Some(get_braintree_redirect_form( + redirection_data: Box::new(Some(get_braintree_redirect_form( *client_token_data, item.data.get_payment_method_token()?, item.data.request.payment_method_data.clone(), - )?), - mandate_reference: None, + )?)), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -614,14 +614,14 @@ impl } else { Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(transaction_data.id), - redirection_data: None, - mandate_reference: transaction_data.payment_method.as_ref().map(|pm| { - MandateReference { + redirection_data: Box::new(None), + mandate_reference: Box::new(transaction_data.payment_method.as_ref().map( + |pm| MandateReference { connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, - } - }), + }, + )), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -639,12 +639,12 @@ impl status: enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: Some(get_braintree_redirect_form( + redirection_data: Box::new(Some(get_braintree_redirect_form( *client_token_data, item.data.get_payment_method_token()?, item.data.request.payment_method_data.clone(), - )?), - mandate_reference: None, + )?)), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -696,14 +696,14 @@ impl } else { Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(transaction_data.id), - redirection_data: None, - mandate_reference: transaction_data.payment_method.as_ref().map(|pm| { - MandateReference { + redirection_data: Box::new(None), + mandate_reference: Box::new(transaction_data.payment_method.as_ref().map( + |pm| MandateReference { connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, - } - }), + }, + )), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -760,14 +760,14 @@ impl } else { Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(transaction_data.id), - redirection_data: None, - mandate_reference: transaction_data.payment_method.as_ref().map(|pm| { - MandateReference { + redirection_data: Box::new(None), + mandate_reference: Box::new(transaction_data.payment_method.as_ref().map( + |pm| MandateReference { connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, - } - }), + }, + )), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1274,8 +1274,8 @@ impl TryFrom> } else { Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(transaction_data.id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1384,8 +1384,8 @@ impl } else { Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1489,8 +1489,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( edge_data.node.id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rs index 3e951b3ac864..686a9d57ac3b 100644 --- a/crates/router/src/connector/checkout/transformers.rs +++ b/crates/router/src/connector/checkout/transformers.rs @@ -688,8 +688,8 @@ impl TryFrom> }; let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: Some( @@ -741,8 +741,8 @@ impl TryFrom> }; let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some( @@ -819,8 +819,8 @@ impl TryFrom> Ok(Self { response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(response.action_id.clone()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -920,8 +920,8 @@ impl TryFrom> Ok(Self { response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(resource_id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: item.response.reference, diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index da7682586145..4331b4d79832 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -2559,8 +2559,8 @@ fn get_payment_response( Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(info_response.id.clone()), - redirection_data: None, - mandate_reference, + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: info_response.processor_information.as_ref().and_then( |processor_information| processor_information.network_transaction_id.clone(), @@ -2647,18 +2647,20 @@ impl status: enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: Some(services::RedirectForm::CybersourceAuthSetup { - access_token: info_response - .consumer_authentication_information - .access_token, - ddc_url: info_response - .consumer_authentication_information - .device_data_collection_url, - reference_id: info_response - .consumer_authentication_information - .reference_id, - }), - mandate_reference: None, + redirection_data: Box::new(Some( + services::RedirectForm::CybersourceAuthSetup { + access_token: info_response + .consumer_authentication_information + .access_token, + ddc_url: info_response + .consumer_authentication_information + .device_data_collection_url, + reference_id: info_response + .consumer_authentication_information + .reference_id, + }, + )), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some( @@ -3066,8 +3068,8 @@ impl status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: Some(serde_json::json!({ "three_ds_data": three_ds_data })), @@ -3311,8 +3313,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.id.clone(), ), - redirection_data: None, - mandate_reference, + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: item.response.processor_information.as_ref().and_then( |processor_information| { @@ -3449,8 +3451,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item @@ -3471,8 +3473,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), diff --git a/crates/router/src/connector/datatrans/transformers.rs b/crates/router/src/connector/datatrans/transformers.rs index b28504a1d83c..e9dcfd87071e 100644 --- a/crates/router/src/connector/datatrans/transformers.rs +++ b/crates/router/src/connector/datatrans/transformers.rs @@ -293,8 +293,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( response.transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -411,8 +411,8 @@ impl TryFrom> status: enums::AttemptStatus::from(response), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/dummyconnector/transformers.rs b/crates/router/src/connector/dummyconnector/transformers.rs index 2cf5960bf753..79caa3d0a767 100644 --- a/crates/router/src/connector/dummyconnector/transformers.rs +++ b/crates/router/src/connector/dummyconnector/transformers.rs @@ -253,8 +253,8 @@ impl TryFrom Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(response.id), - redirection_data, - mandate_reference, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id: response.reference, diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/router/src/connector/gocardless/transformers.rs index c0360a94a517..dac90b283664 100644 --- a/crates/router/src/connector/gocardless/transformers.rs +++ b/crates/router/src/connector/gocardless/transformers.rs @@ -523,8 +523,8 @@ impl connector_response_reference_id: None, incremental_authorization_allowed: None, resource_id: ResponseId::NoResponseId, - redirection_data: None, - mandate_reference, + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), network_txn_id: None, charge_id: None, }), @@ -674,8 +674,8 @@ impl status: enums::AttemptStatus::from(item.response.payments.status), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.payments.id), - redirection_data: None, - mandate_reference: Some(mandate_reference), + redirection_data: Box::new(None), + mandate_reference: Box::new(Some(mandate_reference)), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -710,8 +710,8 @@ impl status: enums::AttemptStatus::from(item.response.payments.status), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.payments.id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index de92168036cf..ec94b322fe71 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -382,8 +382,8 @@ fn get_iatpay_response( types::PaymentsResponseData::TransactionResponse { resource_id: id, - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: connector_response_reference_id.clone(), @@ -393,8 +393,8 @@ fn get_iatpay_response( } None => types::PaymentsResponseData::TransactionResponse { resource_id: id.clone(), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: connector_response_reference_id.clone(), diff --git a/crates/router/src/connector/itaubank/transformers.rs b/crates/router/src/connector/itaubank/transformers.rs index 41c41408381c..15dfb1ce2401 100644 --- a/crates/router/src/connector/itaubank/transformers.rs +++ b/crates/router/src/connector/itaubank/transformers.rs @@ -280,8 +280,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.txid.to_owned(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some(item.response.txid), @@ -368,8 +368,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.txid.to_owned(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: Some(item.response.txid), diff --git a/crates/router/src/connector/klarna/transformers.rs b/crates/router/src/connector/klarna/transformers.rs index e6f0bab9c2c8..ea83e20d99d8 100644 --- a/crates/router/src/connector/klarna/transformers.rs +++ b/crates/router/src/connector/klarna/transformers.rs @@ -272,8 +272,8 @@ impl TryFrom> resource_id: types::ResponseId::ConnectorTransactionId( item.response.order_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.order_id.clone()), @@ -394,8 +394,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.order_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item @@ -474,8 +474,8 @@ impl Ok(Self { response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(resource_id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/mifinity/transformers.rs b/crates/router/src/connector/mifinity/transformers.rs index 03c63d667959..6ff52bb7eb1b 100644 --- a/crates/router/src/connector/mifinity/transformers.rs +++ b/crates/router/src/connector/mifinity/transformers.rs @@ -259,10 +259,10 @@ impl status: enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(trace_id.clone()), - redirection_data: Some(services::RedirectForm::Mifinity { + redirection_data: Box::new(Some(services::RedirectForm::Mifinity { initialization_token, - }), - mandate_reference: None, + })), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(trace_id), @@ -276,8 +276,8 @@ impl status: enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -345,8 +345,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( transaction_reference, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -360,8 +360,8 @@ impl status: enums::AttemptStatus::from(status), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -376,8 +376,8 @@ impl status: item.data.status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/multisafepay/transformers.rs b/crates/router/src/connector/multisafepay/transformers.rs index 9db1cb3701a1..2831b63fcbe0 100644 --- a/crates/router/src/connector/multisafepay/transformers.rs +++ b/crates/router/src/connector/multisafepay/transformers.rs @@ -930,7 +930,7 @@ pub struct MultisafepayPaymentsResponse { #[serde(untagged)] pub enum MultisafepayAuthResponse { ErrorResponse(MultisafepayErrorResponse), - PaymentResponse(MultisafepayPaymentsResponse), + PaymentResponse(Box), } impl @@ -979,16 +979,18 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( payment_response.data.order_id.clone(), ), - redirection_data, - mandate_reference: payment_response - .data - .payment_details - .and_then(|payment_details| payment_details.recurring_id) - .map(|id| types::MandateReference { - connector_mandate_id: Some(id.expose()), - payment_method_id: None, - mandate_metadata: None, - }), + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new( + payment_response + .data + .payment_details + .and_then(|payment_details| payment_details.recurring_id) + .map(|id| types::MandateReference { + connector_mandate_id: Some(id.expose()), + payment_method_id: None, + mandate_metadata: None, + }), + ), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some( diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rs index af2a9fe56bb1..0ec9cc948883 100644 --- a/crates/router/src/connector/nmi/transformers.rs +++ b/crates/router/src/connector/nmi/transformers.rs @@ -185,7 +185,7 @@ impl Response::Approved => ( Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: Some(services::RedirectForm::Nmi { + redirection_data: Box::new(Some(services::RedirectForm::Nmi { amount: utils::to_currency_base_unit_asf64( amount_data, currency_data.to_owned(), @@ -206,8 +206,8 @@ impl }, )?, order_id: item.data.connector_request_reference_id.clone(), - }), - mandate_reference: None, + })), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.transactionid), @@ -360,8 +360,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transactionid, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), @@ -743,8 +743,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transactionid.to_owned(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), @@ -838,8 +838,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transactionid.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), @@ -895,8 +895,8 @@ impl TryFrom> resource_id: types::ResponseId::ConnectorTransactionId( item.response.transactionid.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), @@ -946,8 +946,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transactionid.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), @@ -997,8 +997,8 @@ impl TryFrom resource_id: types::ResponseId::ConnectorTransactionId( order.id.to_string(), ), - redirection_data, - mandate_reference, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id, diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs index d1d7122f49ef..68c25f58acb9 100644 --- a/crates/router/src/connector/nuvei/transformers.rs +++ b/crates/router/src/connector/nuvei/transformers.rs @@ -1598,15 +1598,17 @@ where .map_or(response.order_id.clone(), Some) // For paypal there will be no transaction_id, only order_id will be present .map(types::ResponseId::ConnectorTransactionId) .ok_or(errors::ConnectorError::MissingConnectorTransactionID)?, - redirection_data, - mandate_reference: response - .payment_option - .and_then(|po| po.user_payment_option_id) - .map(|id| types::MandateReference { - connector_mandate_id: Some(id), - payment_method_id: None, - mandate_metadata: None, - }), + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new( + response + .payment_option + .and_then(|po| po.user_payment_option_id) + .map(|id| types::MandateReference { + connector_mandate_id: Some(id), + payment_method_id: None, + mandate_metadata: None, + }), + ), // we don't need to save session token for capture, void flow so ignoring if it is not present connector_metadata: if let Some(token) = response.session_token { Some( diff --git a/crates/router/src/connector/opayo/transformers.rs b/crates/router/src/connector/opayo/transformers.rs index 44069f3650b1..44445a3d7d94 100644 --- a/crates/router/src/connector/opayo/transformers.rs +++ b/crates/router/src/connector/opayo/transformers.rs @@ -144,8 +144,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.transaction_id), diff --git a/crates/router/src/connector/opennode/transformers.rs b/crates/router/src/connector/opennode/transformers.rs index 8f1579ac1ff4..1e8239d377bb 100644 --- a/crates/router/src/connector/opennode/transformers.rs +++ b/crates/router/src/connector/opennode/transformers.rs @@ -138,8 +138,8 @@ impl let response_data = if attempt_status != OpennodePaymentStatus::Underpaid { Ok(types::PaymentsResponseData::TransactionResponse { resource_id: connector_id, - redirection_data: Some(redirection_data), - mandate_reference: None, + redirection_data: Box::new(Some(redirection_data)), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item.response.data.order_id, diff --git a/crates/router/src/connector/paybox/transformers.rs b/crates/router/src/connector/paybox/transformers.rs index d02f75693c48..b52a6e463f63 100644 --- a/crates/router/src/connector/paybox/transformers.rs +++ b/crates/router/src/connector/paybox/transformers.rs @@ -597,8 +597,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( response.paybox_order_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(serde_json::json!(PayboxMeta { connector_request_id: response.transaction_number.clone() })), @@ -657,8 +657,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( response.paybox_order_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(serde_json::json!(PayboxMeta { connector_request_id: response.transaction_number.clone() })), @@ -686,10 +686,10 @@ impl status: enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: Some(RedirectForm::Html { + redirection_data: Box::new(Some(RedirectForm::Html { html_data: data.peek().to_string(), - }), - mandate_reference: None, + })), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -731,8 +731,8 @@ impl TryFrom resource_id: types::ResponseId::ConnectorTransactionId( response.paybox_order_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(serde_json::json!(PayboxMeta { connector_request_id: response.transaction_number.clone() })), diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rs index 4eac0a6f94d4..ceeafb50251f 100644 --- a/crates/router/src/connector/payme/transformers.rs +++ b/crates/router/src/connector/payme/transformers.rs @@ -246,12 +246,14 @@ impl TryFrom<&PaymePaySaleResponse> for types::PaymentsResponseData { }; Ok(Self::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(value.payme_sale_id.clone()), - redirection_data, - mandate_reference: value.buyer_key.clone().map(|buyer_key| MandateReference { - connector_mandate_id: Some(buyer_key.expose()), - payment_method_id: None, - mandate_metadata: None, - }), + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(value.buyer_key.clone().map(|buyer_key| { + MandateReference { + connector_mandate_id: Some(buyer_key.expose()), + payment_method_id: None, + mandate_metadata: None, + } + })), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -316,9 +318,9 @@ impl From<&SaleQuery> for types::PaymentsResponseData { fn from(value: &SaleQuery) -> Self { Self::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(value.sale_payme_id.clone()), - redirection_data: None, + redirection_data: Box::new(None), // mandate reference will be updated with webhooks only. That has been handled with PaymePaySaleResponse struct - mandate_reference: None, + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -536,8 +538,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.payme_sale_id.to_owned(), ), - redirection_data: Some(services::RedirectForm::Payme), - mandate_reference: None, + redirection_data: Box::new(Some(services::RedirectForm::Payme)), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1110,8 +1112,8 @@ impl TryFrom> // Since we are not receiving payme_sale_id, we are not populating the transaction response Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 274aab8e5047..7b866971b011 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -1117,14 +1117,14 @@ impl status: storage_enums::AttemptStatus::AuthenticationSuccessful, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, - }), + charge_id: None, + }), ..data.clone() }) } @@ -1168,8 +1168,8 @@ impl status: storage_enums::AttemptStatus::AuthenticationSuccessful, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index 30aaf5a84a86..e30a3f07c9b2 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -1388,8 +1388,8 @@ impl status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: order_id, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: purchase_units @@ -1511,11 +1511,11 @@ impl status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data: Some(services::RedirectForm::from(( + redirection_data: Box::new(Some(services::RedirectForm::from(( link.ok_or(errors::ConnectorError::ResponseDeserializationFailed)?, services::Method::Get, - ))), - mandate_reference: None, + )))), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: Some( @@ -1566,11 +1566,11 @@ impl status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data: Some(services::RedirectForm::from(( + redirection_data: Box::new(Some(services::RedirectForm::from(( link.ok_or(errors::ConnectorError::ResponseDeserializationFailed)?, services::Method::Get, - ))), - mandate_reference: None, + )))), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: Some( @@ -1624,8 +1624,8 @@ impl status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: None, @@ -1662,8 +1662,8 @@ impl status: storage_enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1712,11 +1712,11 @@ impl status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id), - redirection_data: Some(paypal_threeds_link(( + redirection_data: Box::new(Some(paypal_threeds_link(( link, item.data.request.complete_authorize_url.clone(), - ))?), - mandate_reference: None, + ))?)), + mandate_reference: Box::new(None), connector_metadata: Some(connector_meta), network_txn_id: None, connector_response_reference_id: None, @@ -1780,8 +1780,8 @@ impl .order_id .clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item @@ -2115,8 +2115,8 @@ impl TryFrom> resource_id: types::ResponseId::ConnectorTransactionId( item.data.request.connector_transaction_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: Some(serde_json::json!(PaypalMeta { authorize_id: connector_payment_id.authorize_id, capture_id: Some(item.response.id.clone()), @@ -2173,8 +2173,8 @@ impl status, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item diff --git a/crates/router/src/connector/placetopay/transformers.rs b/crates/router/src/connector/placetopay/transformers.rs index 32d651787b69..2d1ce4771cad 100644 --- a/crates/router/src/connector/placetopay/transformers.rs +++ b/crates/router/src/connector/placetopay/transformers.rs @@ -263,8 +263,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.internal_reference.to_string(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: item .response .authorization diff --git a/crates/router/src/connector/plaid/transformers.rs b/crates/router/src/connector/plaid/transformers.rs index f0cf91b9cf6f..29d4db1297f8 100644 --- a/crates/router/src/connector/plaid/transformers.rs +++ b/crates/router/src/connector/plaid/transformers.rs @@ -308,8 +308,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.payment_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.payment_id), @@ -394,8 +394,8 @@ impl TryFrom status: enums::AttemptStatus::AuthenticationPending, response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -401,8 +401,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transaction_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata, network_txn_id: None, connector_response_reference_id: None, @@ -452,8 +452,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transaction_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -503,8 +503,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.transaction_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index 044a64b413cf..bcd0693500a0 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -474,8 +474,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( data.id.to_owned(), ), //transaction_id is also the field but this id is used to initiate a refund - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/razorpay/transformers.rs b/crates/router/src/connector/razorpay/transformers.rs index fde72cac1004..6755a2d18161 100644 --- a/crates/router/src/connector/razorpay/transformers.rs +++ b/crates/router/src/connector/razorpay/transformers.rs @@ -789,8 +789,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( second_factor.epg_txn_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(second_factor.txn_id), @@ -1010,8 +1010,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.second_factor.epg_txn_id, ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.second_factor.txn_id), diff --git a/crates/router/src/connector/shift4/transformers.rs b/crates/router/src/connector/shift4/transformers.rs index 3b7681511154..570d3b90affd 100644 --- a/crates/router/src/connector/shift4/transformers.rs +++ b/crates/router/src/connector/shift4/transformers.rs @@ -759,8 +759,8 @@ impl TryFrom )), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: connector_id, - redirection_data: item - .response - .flow - .and_then(|flow| flow.redirect) - .and_then(|redirect| redirect.redirect_url) - .map(|url| services::RedirectForm::from((url, services::Method::Get))), - mandate_reference: None, + redirection_data: Box::new( + item.response + .flow + .and_then(|flow| flow.redirect) + .and_then(|redirect| redirect.redirect_url) + .map(|url| services::RedirectForm::from((url, services::Method::Get))), + ), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 63720696ef4b..fe69f43777e5 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -2490,8 +2490,8 @@ impl }); Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(mandate_reference), connector_metadata, network_txn_id, connector_response_reference_id: Some(item.response.id), @@ -2697,8 +2697,8 @@ impl }); Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(mandate_reference), connector_metadata, network_txn_id: network_transaction_id, connector_response_reference_id: Some(item.response.id.clone()), @@ -2776,8 +2776,8 @@ impl Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), - redirection_data, - mandate_reference, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: network_transaction_id, connector_response_reference_id: Some(item.response.id), @@ -3270,7 +3270,7 @@ pub struct MitExemption { #[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] #[serde(untagged)] pub enum LatestAttempt { - PaymentIntentAttempt(LatestPaymentAttempt), + PaymentIntentAttempt(Box), SetupAttempt(String), } #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)] @@ -3480,8 +3480,8 @@ impl TryFrom resource_id: types::ResponseId::ConnectorTransactionId( item.response.id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: item @@ -2163,8 +2163,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.id), diff --git a/crates/router/src/connector/wellsfargopayout/transformers.rs b/crates/router/src/connector/wellsfargopayout/transformers.rs index e335c3cf59ae..135cb5f53cbf 100644 --- a/crates/router/src/connector/wellsfargopayout/transformers.rs +++ b/crates/router/src/connector/wellsfargopayout/transformers.rs @@ -134,8 +134,8 @@ impl status: enums::AttemptStatus::from(item.response.status), response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs index 777594a4534e..79147a35b5e7 100644 --- a/crates/router/src/connector/worldpay.rs +++ b/crates/router/src/connector/worldpay.rs @@ -260,8 +260,8 @@ impl ConnectorIntegration router_data.response, optional_correlation_id.clone(), ))?, - redirection_data, - mandate_reference: None, + redirection_data: Box::new(redirection_data), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: optional_correlation_id.clone(), diff --git a/crates/router/src/connector/zsl/transformers.rs b/crates/router/src/connector/zsl/transformers.rs index c8758f5322ca..d6f9117d786a 100644 --- a/crates/router/src/connector/zsl/transformers.rs +++ b/crates/router/src/connector/zsl/transformers.rs @@ -328,12 +328,12 @@ impl status: enums::AttemptStatus::AuthenticationPending, // Redirect is always expected after success response response: Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::NoResponseId, - redirection_data: Some(services::RedirectForm::Form { + redirection_data: Box::new(Some(services::RedirectForm::Form { endpoint: redirect_url, method: services::Method::Get, form_fields: HashMap::new(), - }), - mandate_reference: None, + })), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.mer_ref.clone()), @@ -451,8 +451,8 @@ impl resource_id: types::ResponseId::ConnectorTransactionId( item.response.txn_id.clone(), ), - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: Some(item.response.mer_ref.clone()), diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index 545f94cfeb4e..f49f4096340b 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -2122,7 +2122,7 @@ impl MerchantConnectorAccountUpdateBridge for api_models::admin::MerchantConnect Ok(storage::MerchantConnectorAccountUpdate::Update { connector_type: Some(self.connector_type), connector_label: self.connector_label.clone(), - connector_account_details: encrypted_data.connector_account_details, + connector_account_details: Box::new(encrypted_data.connector_account_details), disabled, payment_methods_enabled, metadata: self.metadata, @@ -2136,10 +2136,10 @@ impl MerchantConnectorAccountUpdateBridge for api_models::admin::MerchantConnect None => None, }, applepay_verified_domains: None, - pm_auth_config: self.pm_auth_config, + pm_auth_config: Box::new(self.pm_auth_config), status: Some(connector_status), - additional_merchant_data: encrypted_data.additional_merchant_data, - connector_wallets_details: encrypted_data.connector_wallets_details, + additional_merchant_data: Box::new(encrypted_data.additional_merchant_data), + connector_wallets_details: Box::new(encrypted_data.connector_wallets_details), }) } } @@ -2291,25 +2291,27 @@ impl MerchantConnectorAccountUpdateBridge for api_models::admin::MerchantConnect connector_name: None, merchant_connector_id: None, connector_label: self.connector_label.clone(), - connector_account_details: encrypted_data.connector_account_details, + connector_account_details: Box::new(encrypted_data.connector_account_details), test_mode: self.test_mode, disabled, payment_methods_enabled, metadata: self.metadata, frm_configs, connector_webhook_details: match &self.connector_webhook_details { - Some(connector_webhook_details) => connector_webhook_details - .encode_to_value() - .change_context(errors::ApiErrorResponse::InternalServerError) - .map(Some)? - .map(Secret::new), - None => None, + Some(connector_webhook_details) => Box::new( + connector_webhook_details + .encode_to_value() + .change_context(errors::ApiErrorResponse::InternalServerError) + .map(Some)? + .map(Secret::new), + ), + None => Box::new(None), }, applepay_verified_domains: None, - pm_auth_config: self.pm_auth_config, + pm_auth_config: Box::new(self.pm_auth_config), status: Some(connector_status), - additional_merchant_data: encrypted_data.additional_merchant_data, - connector_wallets_details: encrypted_data.connector_wallets_details, + additional_merchant_data: Box::new(encrypted_data.additional_merchant_data), + connector_wallets_details: Box::new(encrypted_data.connector_wallets_details), }) } } diff --git a/crates/router/src/core/connector_onboarding.rs b/crates/router/src/core/connector_onboarding.rs index c3de228d9a7b..5813a5bcd0cc 100644 --- a/crates/router/src/core/connector_onboarding.rs +++ b/crates/router/src/core/connector_onboarding.rs @@ -95,7 +95,7 @@ pub async fn sync_onboarding_status( .await?; return Ok(ApplicationResponse::Json(api::OnboardingStatus::PayPal( - api::PayPalOnboardingStatus::ConnectorIntegrated(update_mca_data), + api::PayPalOnboardingStatus::ConnectorIntegrated(Box::new(update_mca_data)), ))); } Ok(ApplicationResponse::Json(status)) diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rs index 19fbbf1952bc..18cc8682eeef 100644 --- a/crates/router/src/core/customers.rs +++ b/crates/router/src/core/customers.rs @@ -662,7 +662,7 @@ impl CustomerDeleteBridge for customers::GlobalId { description: Some(Description::from_str_unchecked(REDACTED)), phone_country_code: Some(REDACTED.to_string()), metadata: None, - connector_customer: None, + connector_customer: Box::new(None), default_billing_address: None, default_shipping_address: None, default_payment_method_id: None, @@ -904,7 +904,7 @@ impl CustomerDeleteBridge for customers::CustomerId { description: Some(Description::from_str_unchecked(REDACTED)), phone_country_code: Some(REDACTED.to_string()), metadata: None, - connector_customer: None, + connector_customer: Box::new(None), address_id: None, }; @@ -1204,7 +1204,7 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest { phone_country_code: self.phone_country_code.clone(), metadata: self.metadata.clone(), description: self.description.clone(), - connector_customer: None, + connector_customer: Box::new(None), address_id: address.clone().map(|addr| addr.address_id), }, key_store, @@ -1296,7 +1296,7 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest { phone_country_code: self.phone_country_code.clone(), metadata: self.metadata.clone(), description: self.description.clone(), - connector_customer: None, + connector_customer: Box::new(None), default_billing_address: encrypted_customer_billing_address.map(Into::into), default_shipping_address: encrypted_customer_shipping_address.map(Into::into), default_payment_method_id: Some(self.default_payment_method_id.clone()), diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs index b5707979247b..5ed3e9105632 100644 --- a/crates/router/src/core/mandate.rs +++ b/crates/router/src/core/mandate.rs @@ -357,10 +357,10 @@ where network_txn_id, .. } => (mandate_reference.clone(), network_txn_id.clone()), - _ => (None, None), + _ => (Box::new(None), None), }; - let mandate_ids = mandate_reference + let mandate_ids = (*mandate_reference) .as_ref() .map(|md| { md.encode_to_value() @@ -379,7 +379,7 @@ where mandate_ids, network_txn_id, get_insensitive_payment_method_data_if_exists(resp), - mandate_reference, + *mandate_reference, merchant_connector_id, )? else { @@ -439,7 +439,7 @@ impl ForeignFrom> match resp { Ok(types::PaymentsResponseData::TransactionResponse { mandate_reference, .. - }) => mandate_reference, + }) => *mandate_reference, _ => None, } } diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 0b44989807ed..a76e24af0c26 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -3071,9 +3071,9 @@ where let should_continue = matches!( router_data.response, Ok(router_types::PaymentsResponseData::TransactionResponse { - redirection_data: None, + ref redirection_data, .. - }) + }) if redirection_data.is_none() ) && router_data.status != common_enums::AttemptStatus::AuthenticationFailed; (router_data, should_continue) diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 51cb5793adbf..0de7683097b1 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1620,7 +1620,7 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>( phone: Box::new(encryptable_customer.phone), phone_country_code: request_customer_details.phone_country_code, description: None, - connector_customer: None, + connector_customer: Box::new(None), metadata: None, address_id: None, }; @@ -3581,7 +3581,7 @@ pub async fn insert_merchant_connector_creds_to_config( #[derive(Clone)] pub enum MerchantConnectorAccountType { - DbVal(domain::MerchantConnectorAccount), + DbVal(Box), CacheVal(api_models::admin::MerchantConnectorDetails), } @@ -3795,7 +3795,7 @@ pub async fn get_merchant_connector_account( todo!() } }; - mca.map(MerchantConnectorAccountType::DbVal) + mca.map(Box::new).map(MerchantConnectorAccountType::DbVal) } } } diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index 74339a88fb65..69cf19b09bbe 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -1496,7 +1496,7 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen .event(AuditEvent::new(AuditEventType::PaymentConfirm { client_src, client_ver, - frm_message, + frm_message: Box::new(frm_message), })) .with(payment_data.to_event()) .emit(); diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index 6b243ba72aac..7aa67a9b50f6 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -1501,7 +1501,7 @@ async fn payment_response_update_tracker( let encoded_data = payment_data.payment_attempt.encoded_data.clone(); - let authentication_data = redirection_data + let authentication_data = (*redirection_data) .as_ref() .map(Encode::encode_to_value) .transpose() diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs index 060e93474b41..7fdccf9c60fa 100644 --- a/crates/router/src/core/payments/retry.rs +++ b/crates/router/src/core/payments/retry.rs @@ -424,7 +424,7 @@ where }) => { let encoded_data = payment_data.get_payment_attempt().encoded_data.clone(); - let authentication_data = redirection_data + let authentication_data = (*redirection_data) .as_ref() .map(Encode::encode_to_value) .transpose() diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs index 43353227c883..c14542de5476 100644 --- a/crates/router/src/core/payments/tokenization.rs +++ b/crates/router/src/core/payments/tokenization.rs @@ -157,10 +157,9 @@ where let (connector_mandate_id, mandate_metadata) = match responses { types::PaymentsResponseData::TransactionResponse { - ref mandate_reference, - .. + mandate_reference, .. } => { - if let Some(mandate_ref) = mandate_reference { + if let Some(ref mandate_ref) = *mandate_reference { ( mandate_ref.connector_mandate_id.clone(), mandate_ref.mandate_metadata.clone(), diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 58ea3b434625..66e5c996d34b 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -436,8 +436,8 @@ where // [#44]: why should response be filled during request let response = Ok(types::PaymentsResponseData::TransactionResponse { resource_id, - redirection_data: None, - mandate_reference: None, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs index c1b8f78eeb13..02c619b68d9d 100644 --- a/crates/router/src/core/payouts.rs +++ b/crates/router/src/core/payouts.rs @@ -375,7 +375,7 @@ pub async fn payouts_confirm_core( &merchant_account, None, &key_store, - &payouts::PayoutRequest::PayoutCreateRequest(req.to_owned()), + &payouts::PayoutRequest::PayoutCreateRequest(Box::new(req.to_owned())), locale, ) .await?; @@ -448,7 +448,7 @@ pub async fn payouts_update_core( &merchant_account, None, &key_store, - &payouts::PayoutRequest::PayoutCreateRequest(req.to_owned()), + &payouts::PayoutRequest::PayoutCreateRequest(Box::new(req.to_owned())), locale, ) .await?; diff --git a/crates/router/src/core/verification/utils.rs b/crates/router/src/core/verification/utils.rs index 8193109c2508..a51b6c86a34f 100644 --- a/crates/router/src/core/verification/utils.rs +++ b/crates/router/src/core/verification/utils.rs @@ -68,36 +68,36 @@ pub async fn check_existence_and_add_domain_to_db( let updated_mca = storage::MerchantConnectorAccountUpdate::Update { connector_type: None, connector_name: None, - connector_account_details: None, + connector_account_details: Box::new(None), test_mode: None, disabled: None, merchant_connector_id: None, payment_methods_enabled: None, metadata: None, frm_configs: None, - connector_webhook_details: None, + connector_webhook_details: Box::new(None), applepay_verified_domains: Some(already_verified_domains.clone()), - pm_auth_config: None, + pm_auth_config: Box::new(None), connector_label: None, status: None, - connector_wallets_details: None, - additional_merchant_data: None, + connector_wallets_details: Box::new(None), + additional_merchant_data: Box::new(None), }; #[cfg(feature = "v2")] let updated_mca = storage::MerchantConnectorAccountUpdate::Update { connector_type: None, - connector_account_details: None, + connector_account_details: Box::new(None), disabled: None, payment_methods_enabled: None, metadata: None, frm_configs: None, connector_webhook_details: None, applepay_verified_domains: Some(already_verified_domains.clone()), - pm_auth_config: None, + pm_auth_config: Box::new(None), connector_label: None, status: None, - connector_wallets_details: None, - additional_merchant_data: None, + connector_wallets_details: Box::new(None), + additional_merchant_data: Box::new(None), }; state .store diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs index 66de5106e6f4..3627438547cd 100644 --- a/crates/router/src/core/webhooks/incoming.rs +++ b/crates/router/src/core/webhooks/incoming.rs @@ -613,7 +613,7 @@ async fn payments_incoming_webhook_flow( enums::EventClass::Payments, payment_id.get_string_repr().to_owned(), enums::EventObjectType::PaymentDetails, - api::OutgoingWebhookContent::PaymentDetails(payments_response), + api::OutgoingWebhookContent::PaymentDetails(Box::new(payments_response)), primary_object_created_at, )) .await?; @@ -745,7 +745,7 @@ async fn payouts_incoming_webhook_flow( enums::EventClass::Payouts, updated_payout_attempt.payout_id.clone(), enums::EventObjectType::PayoutDetails, - api::OutgoingWebhookContent::PayoutDetails(payout_create_response), + api::OutgoingWebhookContent::PayoutDetails(Box::new(payout_create_response)), Some(updated_payout_attempt.created_at), )) .await?; @@ -852,7 +852,7 @@ async fn refunds_incoming_webhook_flow( enums::EventClass::Refunds, refund_id, enums::EventObjectType::RefundDetails, - api::OutgoingWebhookContent::RefundDetails(refund_response), + api::OutgoingWebhookContent::RefundDetails(Box::new(refund_response)), Some(updated_refund.created_at), )) .await?; @@ -1128,7 +1128,9 @@ async fn external_authentication_incoming_webhook_flow( enums::EventClass::Payments, payment_id.get_string_repr().to_owned(), enums::EventObjectType::PaymentDetails, - api::OutgoingWebhookContent::PaymentDetails(payments_response), + api::OutgoingWebhookContent::PaymentDetails(Box::new( + payments_response, + )), primary_object_created_at, )) .await?; @@ -1334,7 +1336,7 @@ async fn frm_incoming_webhook_flow( enums::EventClass::Payments, payment_id.get_string_repr().to_owned(), enums::EventObjectType::PaymentDetails, - api::OutgoingWebhookContent::PaymentDetails(payments_response), + api::OutgoingWebhookContent::PaymentDetails(Box::new(payments_response)), primary_object_created_at, )) .await?; @@ -1498,7 +1500,7 @@ async fn bank_transfer_webhook_flow( enums::EventClass::Payments, payment_id.get_string_repr().to_owned(), enums::EventObjectType::PaymentDetails, - api::OutgoingWebhookContent::PaymentDetails(payments_response), + api::OutgoingWebhookContent::PaymentDetails(Box::new(payments_response)), primary_object_created_at, )) .await?; diff --git a/crates/router/src/core/webhooks/outgoing.rs b/crates/router/src/core/webhooks/outgoing.rs index fbf692783571..0a9c17ed3a07 100644 --- a/crates/router/src/core/webhooks/outgoing.rs +++ b/crates/router/src/core/webhooks/outgoing.rs @@ -361,7 +361,7 @@ async fn trigger_webhook_to_merchant( &event_id, client_error, delivery_attempt, - ScheduleWebhookRetry::WithProcessTracker(process_tracker), + ScheduleWebhookRetry::WithProcessTracker(Box::new(process_tracker)), ) .await?; } @@ -391,7 +391,7 @@ async fn trigger_webhook_to_merchant( delivery_attempt, status_code.as_u16(), "An error occurred when sending webhook to merchant", - ScheduleWebhookRetry::WithProcessTracker(process_tracker), + ScheduleWebhookRetry::WithProcessTracker(Box::new(process_tracker)), ) .await?; } @@ -668,7 +668,7 @@ pub(crate) fn get_outgoing_webhook_request( #[derive(Debug)] enum ScheduleWebhookRetry { - WithProcessTracker(storage::ProcessTracker), + WithProcessTracker(Box), NoSchedule, } @@ -757,7 +757,7 @@ async fn api_client_error_handler( outgoing_webhook_retry::retry_webhook_delivery_task( &*state.store, merchant_id, - process_tracker, + *process_tracker, ) .await .change_context(errors::WebhooksFlowError::OutgoingWebhookRetrySchedulingFailed)?; @@ -903,7 +903,7 @@ async fn error_response_handler( outgoing_webhook_retry::retry_webhook_delivery_task( &*state.store, merchant_id, - process_tracker, + *process_tracker, ) .await .change_context(errors::WebhooksFlowError::OutgoingWebhookRetrySchedulingFailed)?; diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rs index 8680e43eff3b..3d71f5f5553d 100644 --- a/crates/router/src/core/webhooks/utils.rs +++ b/crates/router/src/core/webhooks/utils.rs @@ -64,7 +64,7 @@ pub async fn construct_webhook_router_data<'a>( request_details: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { let auth_type: types::ConnectorAuthType = - helpers::MerchantConnectorAccountType::DbVal(merchant_connector_account.clone()) + helpers::MerchantConnectorAccountType::DbVal(Box::new(merchant_connector_account.clone())) .get_connector_account_details() .parse_value("ConnectorAuthType") .change_context(errors::ApiErrorResponse::InternalServerError)?; diff --git a/crates/router/src/core/webhooks/webhook_events.rs b/crates/router/src/core/webhooks/webhook_events.rs index 34a7c69d91a0..64b52b7995e3 100644 --- a/crates/router/src/core/webhooks/webhook_events.rs +++ b/crates/router/src/core/webhooks/webhook_events.rs @@ -14,8 +14,8 @@ const INITIAL_DELIVERY_ATTEMPTS_LIST_MAX_LIMIT: i64 = 100; #[derive(Debug)] enum MerchantAccountOrProfile { - MerchantAccount(domain::MerchantAccount), - Profile(domain::Profile), + MerchantAccount(Box), + Profile(Box), } #[instrument(skip(state))] @@ -302,7 +302,7 @@ async fn get_account_and_key_store( })?; Ok(( - MerchantAccountOrProfile::Profile(business_profile), + MerchantAccountOrProfile::Profile(Box::new(business_profile)), merchant_key_store, )) } @@ -318,7 +318,7 @@ async fn get_account_and_key_store( .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?; Ok(( - MerchantAccountOrProfile::MerchantAccount(merchant_account), + MerchantAccountOrProfile::MerchantAccount(Box::new(merchant_account)), merchant_key_store, )) } diff --git a/crates/router/src/db/address.rs b/crates/router/src/db/address.rs index 3a8750feff93..2e2bb7dccbbe 100644 --- a/crates/router/src/db/address.rs +++ b/crates/router/src/db/address.rs @@ -493,12 +493,12 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::AddressUpdate(Box::new( + updatable: Box::new(kv::Updateable::AddressUpdate(Box::new( kv::AddressUpdateMems { orig: address, update_data: address_update.into(), }, - )), + ))), }, }; @@ -597,7 +597,7 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::Address(Box::new(address_new)), + insertable: Box::new(kv::Insertable::Address(Box::new(address_new))), }, }; diff --git a/crates/router/src/db/customers.rs b/crates/router/src/db/customers.rs index 5020c238e4a6..ae23f81e2ead 100644 --- a/crates/router/src/db/customers.rs +++ b/crates/router/src/db/customers.rs @@ -446,10 +446,12 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::CustomerUpdate(kv::CustomerUpdateMems { - orig: customer, - update_data: customer_update.into(), - }), + updatable: Box::new(kv::Updateable::CustomerUpdate( + kv::CustomerUpdateMems { + orig: customer, + update_data: customer_update.into(), + }, + )), }, }; @@ -689,7 +691,7 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::Customer(new_customer.clone()), + insertable: Box::new(kv::Insertable::Customer(new_customer.clone())), }, }; let storage_customer = new_customer.into(); @@ -768,7 +770,7 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::Customer(new_customer.clone()), + insertable: Box::new(kv::Insertable::Customer(new_customer.clone())), }, }; let storage_customer = new_customer.into(); @@ -931,10 +933,12 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::CustomerUpdate(kv::CustomerUpdateMems { - orig: customer, - update_data: customer_update.into(), - }), + updatable: Box::new(kv::Updateable::CustomerUpdate( + kv::CustomerUpdateMems { + orig: customer, + update_data: customer_update.into(), + }, + )), }, }; diff --git a/crates/router/src/db/mandate.rs b/crates/router/src/db/mandate.rs index 95733805b436..076cb768e611 100644 --- a/crates/router/src/db/mandate.rs +++ b/crates/router/src/db/mandate.rs @@ -274,10 +274,12 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::MandateUpdate(kv::MandateUpdateMems { - orig: mandate, - update_data: m_update, - }), + updatable: Box::new(kv::Updateable::MandateUpdate( + kv::MandateUpdateMems { + orig: mandate, + update_data: m_update, + }, + )), }, }; @@ -346,7 +348,7 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::Mandate(mandate), + insertable: Box::new(kv::Insertable::Mandate(mandate)), }, }; diff --git a/crates/router/src/db/payment_method.rs b/crates/router/src/db/payment_method.rs index e75fb940a35b..ac66ed707f13 100644 --- a/crates/router/src/db/payment_method.rs +++ b/crates/router/src/db/payment_method.rs @@ -496,7 +496,7 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::PaymentMethod(payment_method_new), + insertable: Box::new(kv::Insertable::PaymentMethod(payment_method_new)), }, }; @@ -588,12 +588,12 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::PaymentMethodUpdate( + updatable: Box::new(kv::Updateable::PaymentMethodUpdate(Box::new( kv::PaymentMethodUpdateMems { orig: payment_method, update_data: p_update, }, - ), + ))), }, }; diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rs index 41cb3cef5c63..745170d70754 100644 --- a/crates/router/src/db/refund.rs +++ b/crates/router/src/db/refund.rs @@ -445,7 +445,7 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::Refund(new), + insertable: Box::new(kv::Insertable::Refund(new)), }, }; @@ -617,10 +617,12 @@ mod storage { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::RefundUpdate(kv::RefundUpdateMems { - orig: this, - update_data: refund, - }), + updatable: Box::new(kv::Updateable::RefundUpdate( + kv::RefundUpdateMems { + orig: this, + update_data: refund, + }, + )), }, }; diff --git a/crates/router/src/db/reverse_lookup.rs b/crates/router/src/db/reverse_lookup.rs index 06bd84675b11..c022c70d9e23 100644 --- a/crates/router/src/db/reverse_lookup.rs +++ b/crates/router/src/db/reverse_lookup.rs @@ -116,7 +116,7 @@ mod storage { }; let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::ReverseLookUp(new), + insertable: Box::new(kv::Insertable::ReverseLookUp(new)), }, }; diff --git a/crates/router/src/events/audit_events.rs b/crates/router/src/events/audit_events.rs index 367a573a93b3..9b7a688f7eba 100644 --- a/crates/router/src/events/audit_events.rs +++ b/crates/router/src/events/audit_events.rs @@ -18,7 +18,7 @@ pub enum AuditEventType { PaymentConfirm { client_src: Option, client_ver: Option, - frm_message: Option, + frm_message: Box>, }, PaymentCancelled { cancellation_reason: Option, diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rs index a54c2bc8ad6b..f56a741dc1ae 100644 --- a/crates/router/src/utils.rs +++ b/crates/router/src/utils.rs @@ -1166,9 +1166,9 @@ where diesel_models::enums::EventClass::Payments, payment_id.get_string_repr().to_owned(), diesel_models::enums::EventObjectType::PaymentDetails, - webhooks::OutgoingWebhookContent::PaymentDetails( + webhooks::OutgoingWebhookContent::PaymentDetails(Box::new( payments_response_json, - ), + )), primary_object_created_at, )) .await diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rs index eb4530bbe54e..1bfcc8ebe7bb 100644 --- a/crates/router/src/workflows/outgoing_webhook_retry.rs +++ b/crates/router/src/workflows/outgoing_webhook_retry.rs @@ -423,7 +423,7 @@ async fn get_outgoing_webhook_content_and_event_type( logger::debug!(current_resource_status=%payments_response.status); Ok(( - OutgoingWebhookContent::PaymentDetails(payments_response), + OutgoingWebhookContent::PaymentDetails(Box::new(payments_response)), event_type, )) } @@ -449,7 +449,7 @@ async fn get_outgoing_webhook_content_and_event_type( let refund_response = RefundResponse::foreign_from(refund); Ok(( - OutgoingWebhookContent::RefundDetails(refund_response), + OutgoingWebhookContent::RefundDetails(Box::new(refund_response)), event_type, )) } @@ -548,7 +548,7 @@ async fn get_outgoing_webhook_content_and_event_type( logger::debug!(current_resource_status=%payout_data.payout_attempt.status); Ok(( - OutgoingWebhookContent::PayoutDetails(payout_create_response), + OutgoingWebhookContent::PayoutDetails(Box::new(payout_create_response)), event_type, )) } diff --git a/crates/storage_impl/src/lookup.rs b/crates/storage_impl/src/lookup.rs index 54377e452673..eec85e267b99 100644 --- a/crates/storage_impl/src/lookup.rs +++ b/crates/storage_impl/src/lookup.rs @@ -93,7 +93,7 @@ impl ReverseLookupInterface for KVRouterStore { }; let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::ReverseLookUp(new), + insertable: Box::new(kv::Insertable::ReverseLookUp(new)), }, }; diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs index 6c03bb718b1c..899ba08244b3 100644 --- a/crates/storage_impl/src/payments/payment_attempt.rs +++ b/crates/storage_impl/src/payments/payment_attempt.rs @@ -540,9 +540,9 @@ impl PaymentAttemptInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::PaymentAttempt( + insertable: Box::new(kv::Insertable::PaymentAttempt(Box::new( payment_attempt.to_storage_model(), - ), + ))), }, }; @@ -647,12 +647,12 @@ impl PaymentAttemptInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::PaymentAttemptUpdate( + updatable: Box::new(kv::Updateable::PaymentAttemptUpdate(Box::new( kv::PaymentAttemptUpdateMems { orig: this.clone().to_storage_model(), update_data: payment_attempt.to_storage_model(), }, - ), + ))), }, }; diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs index 8ca63e790371..3fcd30f1e890 100644 --- a/crates/storage_impl/src/payments/payment_intent.rs +++ b/crates/storage_impl/src/payments/payment_intent.rs @@ -103,7 +103,9 @@ impl PaymentIntentInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::PaymentIntent(new_payment_intent), + insertable: Box::new(kv::Insertable::PaymentIntent(Box::new( + new_payment_intent, + ))), }, }; @@ -219,12 +221,12 @@ impl PaymentIntentInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::PaymentIntentUpdate( + updatable: Box::new(kv::Updateable::PaymentIntentUpdate(Box::new( kv::PaymentIntentUpdateMems { orig: origin_diesel_intent, update_data: diesel_intent_update, }, - ), + ))), }, }; diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rs index 81d06a1cbd5f..3ac66a2c3012 100644 --- a/crates/storage_impl/src/payouts/payout_attempt.rs +++ b/crates/storage_impl/src/payouts/payout_attempt.rs @@ -93,9 +93,9 @@ impl PayoutAttemptInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::PayoutAttempt( + insertable: Box::new(kv::Insertable::PayoutAttempt( new_payout_attempt.to_storage_model(), - ), + )), }, }; @@ -182,12 +182,12 @@ impl PayoutAttemptInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::PayoutAttemptUpdate( + updatable: Box::new(kv::Updateable::PayoutAttemptUpdate( kv::PayoutAttemptUpdateMems { orig: origin_diesel_payout, update_data: diesel_payout_update, }, - ), + )), }, }; diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rs index 9a94743da3f1..2f6540732fd6 100644 --- a/crates/storage_impl/src/payouts/payouts.rs +++ b/crates/storage_impl/src/payouts/payouts.rs @@ -130,7 +130,7 @@ impl PayoutsInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Insert { - insertable: kv::Insertable::Payouts(new.to_storage_model()), + insertable: Box::new(kv::Insertable::Payouts(new.to_storage_model())), }, }; @@ -201,10 +201,10 @@ impl PayoutsInterface for KVRouterStore { let redis_entry = kv::TypedSql { op: kv::DBOperation::Update { - updatable: kv::Updateable::PayoutsUpdate(kv::PayoutsUpdateMems { + updatable: Box::new(kv::Updateable::PayoutsUpdate(kv::PayoutsUpdateMems { orig: origin_diesel_payout, update_data: diesel_payout_update, - }), + })), }, }; From 4cb26bf4fd1ac4339ac94691fa7f3dd7e42da70b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:25:13 +0000 Subject: [PATCH 12/46] chore(version): 2024.10.25.0 --- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de928c93d090..38907d9add97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,42 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.10.25.0 + +### Features + +- **authz:** Create a permission generator ([#6394](https://github.com/juspay/hyperswitch/pull/6394)) ([`4a0afb8`](https://github.com/juspay/hyperswitch/commit/4a0afb8213cce47cabe9e3f5d22ad1dccb02c20f)) +- **connector:** + - [Airwallex] Use connector_response_reference_id as reference to merchant ([#2747](https://github.com/juspay/hyperswitch/pull/2747)) ([`4b569c9`](https://github.com/juspay/hyperswitch/commit/4b569c9d5eb9b6403175c958b887d7ace4d9cbbb)) + - [Novalnet] Integrate wallets Paypal and Googlepay ([#6370](https://github.com/juspay/hyperswitch/pull/6370)) ([`673b869`](https://github.com/juspay/hyperswitch/commit/673b8691e092e145ba211050db4f5c7e021a0ce2)) +- **payments_v2:** Add payment_confirm_intent api endpoint ([#6263](https://github.com/juspay/hyperswitch/pull/6263)) ([`c7c1e1a`](https://github.com/juspay/hyperswitch/commit/c7c1e1adabceeb0a03659bf8feb9aa06d85960ea)) + +### Bug Fixes + +- **core:** Populate billing_address for payment with pm_id ([#6411](https://github.com/juspay/hyperswitch/pull/6411)) ([`8e58b56`](https://github.com/juspay/hyperswitch/commit/8e58b56b43ad2f823c51943c34aa8837297c70d6)) +- **payment_methods:** Fix merchant payment method list to retain a mca based on connector_name and mca_id ([#6408](https://github.com/juspay/hyperswitch/pull/6408)) ([`842c4a2`](https://github.com/juspay/hyperswitch/commit/842c4a2f47d4cc7b850a16abbe5431fe575f7a86)) +- **payments:** Filter total count by card-network value ([#6397](https://github.com/juspay/hyperswitch/pull/6397)) ([`ca325e9`](https://github.com/juspay/hyperswitch/commit/ca325e969b24fbbb5aa7edcdf86d5b3022291db1)) + +### Refactors + +- **connector:** + - Add amount conversion framework to Shift4 ([#6250](https://github.com/juspay/hyperswitch/pull/6250)) ([`fbe3951`](https://github.com/juspay/hyperswitch/commit/fbe395198aea7252e9c4e3fad97956a548d07002)) + - Add amount conversion framework to Wellsfargo ([#6298](https://github.com/juspay/hyperswitch/pull/6298)) ([`c3b0f7c`](https://github.com/juspay/hyperswitch/commit/c3b0f7c1d6ad95034535048aa50ff6abe9ed6aa0)) + +### Documentation + +- **cypress:** Refactor cypress documentation for more clarity ([#6415](https://github.com/juspay/hyperswitch/pull/6415)) ([`26e0c32`](https://github.com/juspay/hyperswitch/commit/26e0c32f4da5689a1c01fbb456ac008a0b831710)) +- **openapi:** Improve `rust_locker_open_api_spec` ([#6322](https://github.com/juspay/hyperswitch/pull/6322)) ([`a31d164`](https://github.com/juspay/hyperswitch/commit/a31d1641fb9e1c9efd652c6f191f6b29c75dc69b)) + +### Miscellaneous Tasks + +- Add samsung pay payment method support for cybersource ([#6424](https://github.com/juspay/hyperswitch/pull/6424)) ([`ecaf700`](https://github.com/juspay/hyperswitch/commit/ecaf70099671950287e9a6b7d30ffd02c0c5f51e)) +- Address Rust 1.82.0 clippy lints ([#6401](https://github.com/juspay/hyperswitch/pull/6401)) ([`8708a5c`](https://github.com/juspay/hyperswitch/commit/8708a5cb8f7d64a382b2fe061c725d4854ba9e92)) + +**Full Changelog:** [`2024.10.24.0...2024.10.25.0`](https://github.com/juspay/hyperswitch/compare/2024.10.24.0...2024.10.25.0) + +- - - + ## 2024.10.24.0 ### Features From a845d46899d87ba7f3ca4386719c1934ce3da90e Mon Sep 17 00:00:00 2001 From: Nabeel Hussain M N <68153692+nabeel001@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:42:36 +0530 Subject: [PATCH 13/46] feat(connector): [Rapyd] Use connector_response_reference_id (#6302) Co-authored-by: DEEPANSHU BANSAL <41580413+deepanshu-iiitu@users.noreply.github.com> --- crates/router/src/connector/rapyd/transformers.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index bcd0693500a0..63f9287860c4 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -274,6 +274,7 @@ pub struct ResponseData { pub country_code: Option, pub captured: Option, pub transaction_id: String, + pub merchant_reference_id: Option, pub paid: Option, pub failure_code: Option, pub failure_message: Option, @@ -478,7 +479,9 @@ impl mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, - connector_response_reference_id: None, + connector_response_reference_id: data + .merchant_reference_id + .to_owned(), incremental_authorization_allowed: None, charge_id: None, }), From 4105d98d7aca885f9c622d5b56c6dbacb85a688b Mon Sep 17 00:00:00 2001 From: Nabeel Hussain M N <68153692+nabeel001@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:43:09 +0530 Subject: [PATCH 14/46] feat(connector): [Rapyd] Use connector_request_reference_id (#6296) Co-authored-by: DEEPANSHU BANSAL <41580413+deepanshu-iiitu@users.noreply.github.com> --- crates/router/src/connector/rapyd/transformers.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index 63f9287860c4..1246444ff313 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -37,6 +37,7 @@ pub struct RapydPaymentsRequest { pub currency: enums::Currency, pub payment_method: PaymentMethod, pub payment_method_options: Option, + pub merchant_reference_id: Option, pub capture: Option, pub description: Option, pub complete_payment_url: Option, @@ -162,6 +163,7 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay payment_method, capture, payment_method_options, + merchant_reference_id: Some(item.router_data.connector_request_reference_id.clone()), description: None, error_payment_url: Some(return_url.clone()), complete_payment_url: Some(return_url), From e36ea184ae6d1363fb1af55c790162df9f8b451c Mon Sep 17 00:00:00 2001 From: Tommy shu Date: Fri, 25 Oct 2024 04:15:28 -0400 Subject: [PATCH 15/46] feat(sample_data): generate random disputes for sample data (#6341) --- crates/router/src/core/user/sample_data.rs | 24 ++++++-- crates/router/src/utils/user/sample_data.rs | 63 +++++++++++++++++++-- 2 files changed, 77 insertions(+), 10 deletions(-) diff --git a/crates/router/src/core/user/sample_data.rs b/crates/router/src/core/user/sample_data.rs index 453b3edf00fe..d098d1f76d92 100644 --- a/crates/router/src/core/user/sample_data.rs +++ b/crates/router/src/core/user/sample_data.rs @@ -1,6 +1,6 @@ use api_models::user::sample_data::SampleDataRequest; use common_utils::errors::ReportSwitchExt; -use diesel_models::RefundNew; +use diesel_models::{DisputeNew, RefundNew}; use error_stack::ResultExt; use hyperswitch_domain_models::payments::PaymentIntent; @@ -39,19 +39,23 @@ pub async fn generate_sample_data_for_user( .change_context(SampleDataError::InternalServerError) .attach_printable("Not able to fetch merchant key store")?; // If not able to fetch merchant key store for any reason, this should be an internal server error - let (payment_intents, payment_attempts, refunds): ( + let (payment_intents, payment_attempts, refunds, disputes): ( Vec, Vec, Vec, + Vec, ) = sample_data.into_iter().fold( - (Vec::new(), Vec::new(), Vec::new()), - |(mut pi, mut pa, mut rf), (payment_intent, payment_attempt, refund)| { + (Vec::new(), Vec::new(), Vec::new(), Vec::new()), + |(mut pi, mut pa, mut rf, mut dp), (payment_intent, payment_attempt, refund, dispute)| { pi.push(payment_intent); pa.push(payment_attempt); if let Some(refund) = refund { rf.push(refund); } - (pi, pa, rf) + if let Some(dispute) = dispute { + dp.push(dispute); + } + (pi, pa, rf, dp) }, ); @@ -70,6 +74,11 @@ pub async fn generate_sample_data_for_user( .insert_refunds_batch_for_sample_data(refunds) .await .switch()?; + state + .store + .insert_disputes_batch_for_sample_data(disputes) + .await + .switch()?; Ok(ApplicationResponse::StatusOk) } @@ -109,6 +118,11 @@ pub async fn delete_sample_data_for_user( .delete_refunds_for_sample_data(&merchant_id_del) .await .switch()?; + state + .store + .delete_disputes_for_sample_data(&merchant_id_del) + .await + .switch()?; Ok(ApplicationResponse::StatusOk) } diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs index ea2556a5151c..4f859d8e56a9 100644 --- a/crates/router/src/utils/user/sample_data.rs +++ b/crates/router/src/utils/user/sample_data.rs @@ -8,7 +8,7 @@ use common_utils::{ }; #[cfg(feature = "v1")] use diesel_models::user::sample_data::PaymentAttemptBatchNew; -use diesel_models::RefundNew; +use diesel_models::{enums as storage_enums, DisputeNew, RefundNew}; use error_stack::ResultExt; use hyperswitch_domain_models::payments::PaymentIntent; use rand::{prelude::SliceRandom, thread_rng, Rng}; @@ -27,7 +27,14 @@ pub async fn generate_sample_data( req: SampleDataRequest, merchant_id: &id_type::MerchantId, org_id: &id_type::OrganizationId, -) -> SampleDataResult)>> { +) -> SampleDataResult< + Vec<( + PaymentIntent, + PaymentAttemptBatchNew, + Option, + Option, + )>, +> { let sample_data_size: usize = req.record.unwrap_or(100); let key_manager_state = &state.into(); if !(10..=100).contains(&sample_data_size) { @@ -120,13 +127,23 @@ pub async fn generate_sample_data( let mut refunds_count = 0; + // 2 disputes if generated data size is between 50 and 100, 1 dispute if it is less than 50. + let number_of_disputes: usize = if sample_data_size >= 50 { 2 } else { 1 }; + + let mut disputes_count = 0; + let mut random_array: Vec = (1..=sample_data_size).collect(); // Shuffle the array let mut rng = thread_rng(); random_array.shuffle(&mut rng); - let mut res: Vec<(PaymentIntent, PaymentAttemptBatchNew, Option)> = Vec::new(); + let mut res: Vec<( + PaymentIntent, + PaymentAttemptBatchNew, + Option, + Option, + )> = Vec::new(); let start_time = req .start_time .unwrap_or(common_utils::date_time::now() - time::Duration::days(7)) @@ -353,7 +370,7 @@ pub async fn generate_sample_data( internal_reference_id: common_utils::generate_id_with_default_len("test"), external_reference_id: None, payment_id: payment_id.clone(), - attempt_id, + attempt_id: attempt_id.clone(), merchant_id: merchant_id.clone(), connector_transaction_id, connector_refund_id: None, @@ -387,7 +404,43 @@ pub async fn generate_sample_data( None }; - res.push((payment_intent, payment_attempt, refund)); + let dispute = + if disputes_count < number_of_disputes && !is_failed_payment && refund.is_none() { + disputes_count += 1; + Some(DisputeNew { + dispute_id: common_utils::generate_id_with_default_len("test"), + amount: (amount * 100).to_string(), + currency: payment_intent + .currency + .unwrap_or(common_enums::Currency::USD) + .to_string(), + dispute_stage: storage_enums::DisputeStage::Dispute, + dispute_status: storage_enums::DisputeStatus::DisputeOpened, + payment_id: payment_id.clone(), + attempt_id: attempt_id.clone(), + merchant_id: merchant_id.clone(), + connector_status: "Sample connector status".into(), + connector_dispute_id: common_utils::generate_id_with_default_len("test"), + connector_reason: Some("Sample Dispute".into()), + connector_reason_code: Some("123".into()), + challenge_required_by: None, + connector_created_at: None, + connector_updated_at: None, + connector: payment_attempt + .connector + .clone() + .unwrap_or(DummyConnector4.to_string()), + evidence: None, + profile_id: payment_intent.profile_id.clone(), + merchant_connector_id: payment_attempt.merchant_connector_id.clone(), + dispute_amount: amount * 100, + organization_id: org_id.clone(), + }) + } else { + None + }; + + res.push((payment_intent, payment_attempt, refund, dispute)); } Ok(res) } From aaac9aa97d1b00d50bec4e02efb0658956463398 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Fri, 25 Oct 2024 15:37:13 +0530 Subject: [PATCH 16/46] feat(router): Move organization_id to request header from request body for v2 (#6277) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Narayan Bhat <48803246+Narayanbhat166@users.noreply.github.com> --- api-reference-v2/openapi_spec.json | 33 +++++++++------- crates/api_models/src/admin.rs | 15 +++++-- .../common_utils/src/id_type/organization.rs | 9 +++++ crates/openapi/src/openapi_v2.rs | 2 +- crates/openapi/src/routes/merchant_account.rs | 10 +++-- crates/router/src/lib.rs | 1 + crates/router/src/routes/admin.rs | 39 ++++++++++++++++++- crates/router/src/services/authentication.rs | 14 ++++++- .../cypress/fixtures/merchant_account.json | 3 +- cypress-tests-v2/cypress/support/commands.js | 4 +- 10 files changed, 101 insertions(+), 29 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index bd9de3a2962a..9a406e9c7330 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -453,6 +453,20 @@ "summary": "Merchant Account - Create", "description": "Create a new account for a *merchant* and the *merchant* could be a seller or retailer or client who likes to receive and send payments.\n\nBefore creating the merchant account, it is mandatory to create an organization.", "operationId": "Create a Merchant Account", + "parameters": [ + { + "name": "X-Organization-Id", + "in": "header", + "description": "Organization ID for which the merchant account has to be created.", + "required": true, + "schema": { + "type": "string" + }, + "example": { + "X-Organization-Id": "org_abcdefghijklmnop" + } + } + ], "requestBody": { "content": { "application/json": { @@ -466,8 +480,7 @@ "primary_contact_person": "John Doe", "primary_email": "example@company.com" }, - "merchant_name": "Cloth Store", - "organization_id": "org_abcdefghijklmnop" + "merchant_name": "Cloth Store" } }, "Create a merchant account with metadata": { @@ -476,14 +489,12 @@ "metadata": { "key_1": "John Doe", "key_2": "Trends" - }, - "organization_id": "org_abcdefghijklmnop" + } } }, "Create a merchant account with minimal fields": { "value": { - "merchant_name": "Cloth Store", - "organization_id": "org_abcdefghijklmnop" + "merchant_name": "Cloth Store" } } } @@ -9385,8 +9396,7 @@ "MerchantAccountCreate": { "type": "object", "required": [ - "merchant_name", - "organization_id" + "merchant_name" ], "properties": { "merchant_name": { @@ -9407,13 +9417,6 @@ "type": "object", "description": "Metadata is useful for storing additional, unstructured information about the merchant account.", "nullable": true - }, - "organization_id": { - "type": "string", - "description": "The id of the organization to which the merchant belongs to. Please use the organization endpoint to create an organization", - "example": "org_q98uSGAYbjEwqs0mJwnz", - "maxLength": 64, - "minLength": 1 } }, "additionalProperties": false diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs index 8f24bdf65bc5..c9da386a11de 100644 --- a/crates/api_models/src/admin.rs +++ b/crates/api_models/src/admin.rs @@ -178,7 +178,8 @@ impl MerchantAccountCreate { #[cfg(feature = "v2")] #[derive(Clone, Debug, Deserialize, ToSchema, Serialize)] #[serde(deny_unknown_fields)] -pub struct MerchantAccountCreate { +#[schema(as = MerchantAccountCreate)] +pub struct MerchantAccountCreateWithoutOrgId { /// Name of the Merchant Account, This will be used as a prefix to generate the id #[schema(value_type= String, max_length = 64, example = "NewAge Retailer")] pub merchant_name: Secret, @@ -189,9 +190,17 @@ pub struct MerchantAccountCreate { /// Metadata is useful for storing additional, unstructured information about the merchant account. #[schema(value_type = Option, example = r#"{ "city": "NY", "unit": "245" }"#)] pub metadata: Option, +} - /// The id of the organization to which the merchant belongs to. Please use the organization endpoint to create an organization - #[schema(value_type = String, max_length = 64, min_length = 1, example = "org_q98uSGAYbjEwqs0mJwnz")] +// In v2 the struct used in the API is MerchantAccountCreateWithoutOrgId +// The following struct is only used internally, so we can reuse the common +// part of `create_merchant_account` without duplicating its code for v2 +#[cfg(feature = "v2")] +#[derive(Clone, Debug, Serialize)] +pub struct MerchantAccountCreate { + pub merchant_name: Secret, + pub merchant_details: Option, + pub metadata: Option, pub organization_id: id_type::OrganizationId, } diff --git a/crates/common_utils/src/id_type/organization.rs b/crates/common_utils/src/id_type/organization.rs index f88a62daa1d6..a83f35db1d89 100644 --- a/crates/common_utils/src/id_type/organization.rs +++ b/crates/common_utils/src/id_type/organization.rs @@ -1,3 +1,5 @@ +use crate::errors::{CustomResult, ValidationError}; + crate::id_type!( OrganizationId, "A type for organization_id that can be used for organization ids" @@ -13,3 +15,10 @@ crate::impl_generate_id_id_type!(OrganizationId, "org"); crate::impl_serializable_secret_id_type!(OrganizationId); crate::impl_queryable_id_type!(OrganizationId); crate::impl_to_sql_from_sql_id_type!(OrganizationId); + +impl OrganizationId { + /// Get an organization id from String + pub fn wrap(org_id: String) -> CustomResult { + Self::try_from(std::borrow::Cow::from(org_id)) + } +} diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 0a19c5a63c5c..7bbe019dcbae 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -154,7 +154,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::organization::OrganizationCreateRequest, api_models::organization::OrganizationUpdateRequest, api_models::organization::OrganizationResponse, - api_models::admin::MerchantAccountCreate, + api_models::admin::MerchantAccountCreateWithoutOrgId, api_models::admin::MerchantAccountUpdate, api_models::admin::MerchantAccountDeleteResponse, api_models::admin::MerchantConnectorDeleteResponse, diff --git a/crates/openapi/src/routes/merchant_account.rs b/crates/openapi/src/routes/merchant_account.rs index b92285245a43..01571da1de9f 100644 --- a/crates/openapi/src/routes/merchant_account.rs +++ b/crates/openapi/src/routes/merchant_account.rs @@ -51,6 +51,13 @@ pub async fn merchant_account_create() {} #[utoipa::path( post, path = "/v2/merchant_accounts", + params( + ( + "X-Organization-Id" = String, Header, + description = "Organization ID for which the merchant account has to be created.", + example = json!({"X-Organization-Id": "org_abcdefghijklmnop"}) + ), + ), request_body( content = MerchantAccountCreate, examples( @@ -58,7 +65,6 @@ pub async fn merchant_account_create() {} "Create a merchant account with minimal fields" = ( value = json!({ "merchant_name": "Cloth Store", - "organization_id": "org_abcdefghijklmnop" }) ) ), @@ -66,7 +72,6 @@ pub async fn merchant_account_create() {} "Create a merchant account with merchant details" = ( value = json!({ "merchant_name": "Cloth Store", - "organization_id": "org_abcdefghijklmnop", "merchant_details": { "primary_contact_person": "John Doe", "primary_email": "example@company.com" @@ -78,7 +83,6 @@ pub async fn merchant_account_create() {} "Create a merchant account with metadata" = ( value = json!({ "merchant_name": "Cloth Store", - "organization_id": "org_abcdefghijklmnop", "metadata": { "key_1": "John Doe", "key_2": "Trends" diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs index 0eff78d38b4a..06ab971925bc 100644 --- a/crates/router/src/lib.rs +++ b/crates/router/src/lib.rs @@ -66,6 +66,7 @@ pub mod headers { pub const X_API_VERSION: &str = "X-ApiVersion"; pub const X_FORWARDED_FOR: &str = "X-Forwarded-For"; pub const X_MERCHANT_ID: &str = "X-Merchant-Id"; + pub const X_ORGANIZATION_ID: &str = "X-Organization-Id"; pub const X_LOGIN: &str = "X-Login"; pub const X_TRANS_KEY: &str = "X-Trans-Key"; pub const X_VERSION: &str = "X-Version"; diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rs index b197101d65f2..0996838b4cfa 100644 --- a/crates/router/src/routes/admin.rs +++ b/crates/router/src/routes/admin.rs @@ -92,7 +92,7 @@ pub async fn organization_retrieve( .await } -#[cfg(feature = "olap")] +#[cfg(all(feature = "olap", feature = "v1"))] #[instrument(skip_all, fields(flow = ?Flow::MerchantsAccountCreate))] pub async fn merchant_account_create( state: web::Data, @@ -112,6 +112,43 @@ pub async fn merchant_account_create( .await } +#[cfg(all(feature = "olap", feature = "v2"))] +#[instrument(skip_all, fields(flow = ?Flow::MerchantsAccountCreate))] +pub async fn merchant_account_create( + state: web::Data, + req: HttpRequest, + json_payload: web::Json, +) -> HttpResponse { + let flow = Flow::MerchantsAccountCreate; + let headers = req.headers(); + + let org_id = match auth::HeaderMapStruct::new(headers).get_organization_id_from_header() { + Ok(org_id) => org_id, + Err(e) => return api::log_and_return_error_response(e), + }; + + // Converting from MerchantAccountCreateWithoutOrgId to MerchantAccountCreate so we can use the existing + // `create_merchant_account` function for v2 as well + let json_payload = json_payload.into_inner(); + let new_request_payload_with_org_id = api_models::admin::MerchantAccountCreate { + merchant_name: json_payload.merchant_name, + merchant_details: json_payload.merchant_details, + metadata: json_payload.metadata, + organization_id: org_id, + }; + + Box::pin(api::server_wrap( + flow, + state, + &req, + new_request_payload_with_org_id, + |state, _, req, _| create_merchant_account(state, req), + &auth::AdminApiAuth, + api_locking::LockAction::NotApplicable, + )) + .await +} + /// Merchant Account - Retrieve /// /// Retrieve a merchant account details. diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs index e6da2b23301f..a3cc54de34f9 100644 --- a/crates/router/src/services/authentication.rs +++ b/crates/router/src/services/authentication.rs @@ -931,7 +931,7 @@ where } /// A helper struct to extract headers from the request -struct HeaderMapStruct<'a> { +pub(crate) struct HeaderMapStruct<'a> { headers: &'a HeaderMap, } @@ -981,6 +981,18 @@ impl<'a> HeaderMapStruct<'a> { ) }) } + #[cfg(feature = "v2")] + pub fn get_organization_id_from_header(&self) -> RouterResult { + self.get_mandatory_header_value_by_key(headers::X_ORGANIZATION_ID) + .map(|val| val.to_owned()) + .and_then(|organization_id| { + id_type::OrganizationId::wrap(organization_id).change_context( + errors::ApiErrorResponse::InvalidRequestData { + message: format!("`{}` header is invalid", headers::X_ORGANIZATION_ID), + }, + ) + }) + } } /// Get the merchant-id from `x-merchant-id` header diff --git a/cypress-tests-v2/cypress/fixtures/merchant_account.json b/cypress-tests-v2/cypress/fixtures/merchant_account.json index ac24e9565138..dbe88ae10d47 100644 --- a/cypress-tests-v2/cypress/fixtures/merchant_account.json +++ b/cypress-tests-v2/cypress/fixtures/merchant_account.json @@ -1,7 +1,6 @@ { "ma_create": { - "merchant_name": "Hyperswitch Seller", - "organization_id": "" + "merchant_name": "Hyperswitch Seller" }, "ma_update": { "merchant_name": "Hyperswitch" diff --git a/cypress-tests-v2/cypress/support/commands.js b/cypress-tests-v2/cypress/support/commands.js index c9d1ef3f24f5..abdf95194bb6 100644 --- a/cypress-tests-v2/cypress/support/commands.js +++ b/cypress-tests-v2/cypress/support/commands.js @@ -173,15 +173,13 @@ Cypress.Commands.add( .replaceAll(" ", "") .toLowerCase(); - // Update request body - merchantAccountCreateBody.organization_id = organization_id; - cy.request({ method: "POST", url: url, headers: { "Content-Type": "application/json", "api-key": api_key, + "X-Organization-Id": organization_id, }, body: merchantAccountCreateBody, failOnStatusCode: false, From 1d24b04596e6d2f7c44b93501d56fc4fb950bd3b Mon Sep 17 00:00:00 2001 From: Debarati Ghatak <88573135+cookieg13@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:58:15 +0530 Subject: [PATCH 17/46] feat(connector): [Novalnet] Integrate Applepay wallet token flow (#6409) --- .../connector_configs/toml/development.toml | 55 ++++++++++++++ crates/connector_configs/toml/production.toml | 54 +++++++++++++ crates/connector_configs/toml/sandbox.toml | 54 +++++++++++++ .../src/connectors/novalnet.rs | 1 + .../src/connectors/novalnet/transformers.rs | 75 +++++++++---------- 5 files changed, 200 insertions(+), 39 deletions(-) diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index c903c189b5bd..8cb42f33a26d 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -2293,6 +2293,8 @@ type="Text" payment_method_type = "google_pay" [[novalnet.wallet]] payment_method_type = "paypal" +[[novalnet.wallet]] + payment_method_type = "apple_pay" [novalnet.connector_auth.SignatureKey] api_key="Product Activation Key" key1="Payment Access Key" @@ -2319,6 +2321,59 @@ placeholder="Enter Google Pay Merchant Key" required=true type="Text" +[[novalnet.metadata.apple_pay]] +name="certificate" +label="Merchant Certificate (Base64 Encoded)" +placeholder="Enter Merchant Certificate (Base64 Encoded)" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="certificate_keys" +label="Merchant PrivateKey (Base64 Encoded)" +placeholder="Enter Merchant PrivateKey (Base64 Encoded)" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="merchant_identifier" +label="Apple Merchant Identifier" +placeholder="Enter Apple Merchant Identifier" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="display_name" +label="Display Name" +placeholder="Enter Display Name" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="initiative" +label="Domain" +placeholder="Enter Domain" +required=true +type="Select" +options=["web","ios"] +[[novalnet.metadata.apple_pay]] +name="initiative_context" +label="Domain Name" +placeholder="Enter Domain Name" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="merchant_business_country" +label="Merchant Business Country" +placeholder="Enter Merchant Business Country" +required=true +type="Select" +options=[] +[[novalnet.metadata.apple_pay]] +name="payment_processing_details_at" +label="Payment Processing Details At" +placeholder="Enter Payment Processing Details At" +required=true +type="Radio" +options=["Connector"] + + [nuvei] [[nuvei.credit]] payment_method_type = "Mastercard" diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml index 0e7ffe782f1e..b4b12318a6f2 100644 --- a/crates/connector_configs/toml/production.toml +++ b/crates/connector_configs/toml/production.toml @@ -1786,6 +1786,8 @@ merchant_secret="Source verification key" payment_method_type = "google_pay" [[novalnet.wallet]] payment_method_type = "paypal" +[[novalnet.wallet]] + payment_method_type = "apple_pay" [novalnet.connector_auth.SignatureKey] api_key="Product Activation Key" key1="Payment Access Key" @@ -1812,6 +1814,58 @@ placeholder="Enter Google Pay Merchant Key" required=true type="Text" +[[novalnet.metadata.apple_pay]] +name="certificate" +label="Merchant Certificate (Base64 Encoded)" +placeholder="Enter Merchant Certificate (Base64 Encoded)" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="certificate_keys" +label="Merchant PrivateKey (Base64 Encoded)" +placeholder="Enter Merchant PrivateKey (Base64 Encoded)" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="merchant_identifier" +label="Apple Merchant Identifier" +placeholder="Enter Apple Merchant Identifier" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="display_name" +label="Display Name" +placeholder="Enter Display Name" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="initiative" +label="Domain" +placeholder="Enter Domain" +required=true +type="Select" +options=["web","ios"] +[[novalnet.metadata.apple_pay]] +name="initiative_context" +label="Domain Name" +placeholder="Enter Domain Name" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="merchant_business_country" +label="Merchant Business Country" +placeholder="Enter Merchant Business Country" +required=true +type="Select" +options=[] +[[novalnet.metadata.apple_pay]] +name="payment_processing_details_at" +label="Payment Processing Details At" +placeholder="Enter Payment Processing Details At" +required=true +type="Radio" +options=["Connector"] + [nuvei] [[nuvei.credit]] payment_method_type = "Mastercard" diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml index 8f8ec9bc1c1c..7e83effb7a8b 100644 --- a/crates/connector_configs/toml/sandbox.toml +++ b/crates/connector_configs/toml/sandbox.toml @@ -2260,6 +2260,8 @@ type="Text" payment_method_type = "google_pay" [[novalnet.wallet]] payment_method_type = "paypal" +[[novalnet.wallet]] + payment_method_type = "apple_pay" [novalnet.connector_auth.SignatureKey] api_key="Product Activation Key" key1="Payment Access Key" @@ -2286,6 +2288,58 @@ placeholder="Enter Google Pay Merchant Key" required=true type="Text" +[[novalnet.metadata.apple_pay]] +name="certificate" +label="Merchant Certificate (Base64 Encoded)" +placeholder="Enter Merchant Certificate (Base64 Encoded)" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="certificate_keys" +label="Merchant PrivateKey (Base64 Encoded)" +placeholder="Enter Merchant PrivateKey (Base64 Encoded)" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="merchant_identifier" +label="Apple Merchant Identifier" +placeholder="Enter Apple Merchant Identifier" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="display_name" +label="Display Name" +placeholder="Enter Display Name" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="initiative" +label="Domain" +placeholder="Enter Domain" +required=true +type="Select" +options=["web","ios"] +[[novalnet.metadata.apple_pay]] +name="initiative_context" +label="Domain Name" +placeholder="Enter Domain Name" +required=true +type="Text" +[[novalnet.metadata.apple_pay]] +name="merchant_business_country" +label="Merchant Business Country" +placeholder="Enter Merchant Business Country" +required=true +type="Select" +options=[] +[[novalnet.metadata.apple_pay]] +name="payment_processing_details_at" +label="Payment Processing Details At" +placeholder="Enter Payment Processing Details At" +required=true +type="Radio" +options=["Connector"] + [nuvei] [[nuvei.credit]] payment_method_type = "Mastercard" diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs index acb3013dbaa4..7450a48884a7 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs @@ -199,6 +199,7 @@ impl ConnectorValidation for Novalnet { PaymentMethodDataType::Card, PaymentMethodDataType::GooglePay, PaymentMethodDataType::PaypalRedirect, + PaymentMethodDataType::ApplePay, ]); utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) } diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs index 1f16a14fde3c..577a587cf1af 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs @@ -33,8 +33,7 @@ use crate::{ types::{RefundsResponseRouterData, ResponseRouterData}, utils::{ self, BrowserInformationData, PaymentsAuthorizeRequestData, PaymentsCancelRequestData, - PaymentsCaptureRequestData, PaymentsSyncRequestData, RefundsRequestData, - RouterData as OtherRouterData, + PaymentsCaptureRequestData, PaymentsSyncRequestData, RefundsRequestData, RouterData as _, }, }; @@ -57,6 +56,7 @@ pub enum NovalNetPaymentTypes { CREDITCARD, PAYPAL, GOOGLEPAY, + APPLEPAY, } #[derive(Default, Debug, Serialize, Clone)] @@ -103,11 +103,17 @@ pub struct NovalnetGooglePay { wallet_data: Secret, } +#[derive(Default, Debug, Clone, Serialize, Deserialize)] +pub struct NovalnetApplePay { + wallet_data: Secret, +} + #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(untagged)] pub enum NovalNetPaymentData { Card(NovalnetCard), GooglePay(NovalnetGooglePay), + ApplePay(NovalnetApplePay), MandatePayment(NovalnetMandate), } @@ -143,38 +149,9 @@ impl TryFrom<&api_enums::PaymentMethodType> for NovalNetPaymentTypes { type Error = error_stack::Report; fn try_from(item: &api_enums::PaymentMethodType) -> Result { match item { + api_enums::PaymentMethodType::ApplePay => Ok(Self::APPLEPAY), api_enums::PaymentMethodType::Credit => Ok(Self::CREDITCARD), - api_enums::PaymentMethodType::Debit - | api_enums::PaymentMethodType::Klarna - | api_enums::PaymentMethodType::BancontactCard - | api_enums::PaymentMethodType::Blik - | api_enums::PaymentMethodType::Eps - | api_enums::PaymentMethodType::Giropay - | api_enums::PaymentMethodType::Ideal - | api_enums::PaymentMethodType::OnlineBankingCzechRepublic - | api_enums::PaymentMethodType::OnlineBankingFinland - | api_enums::PaymentMethodType::OnlineBankingPoland - | api_enums::PaymentMethodType::OnlineBankingSlovakia - | api_enums::PaymentMethodType::Sofort - | api_enums::PaymentMethodType::Trustly => { - Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Novalnet"), - ))? - } api_enums::PaymentMethodType::GooglePay => Ok(Self::GOOGLEPAY), - api_enums::PaymentMethodType::AliPay - | api_enums::PaymentMethodType::ApplePay - | api_enums::PaymentMethodType::AliPayHk - | api_enums::PaymentMethodType::MbWay - | api_enums::PaymentMethodType::MobilePay - | api_enums::PaymentMethodType::WeChatPay - | api_enums::PaymentMethodType::SamsungPay - | api_enums::PaymentMethodType::Affirm - | api_enums::PaymentMethodType::AfterpayClearpay - | api_enums::PaymentMethodType::PayBright - | api_enums::PaymentMethodType::Walley => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Novalnet"), - ))?, api_enums::PaymentMethodType::Paypal => Ok(Self::PAYPAL), _ => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Novalnet"), @@ -299,6 +276,30 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym return_url: None, error_return_url: None, payment_data: Some(novalnet_google_pay), + enforce_3d, + create_token, + }; + + Ok(Self { + merchant, + transaction, + customer, + custom, + }) + } + WalletDataPaymentMethod::ApplePay(payment_method_data) => { + let transaction = NovalnetPaymentsRequestTransaction { + test_mode, + payment_type: NovalNetPaymentTypes::APPLEPAY, + amount: 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: None, + error_return_url: None, + payment_data: Some(NovalNetPaymentData::ApplePay(NovalnetApplePay { + wallet_data: Secret::new(payment_method_data.payment_data.clone()), + })), enforce_3d: None, create_token, }; @@ -310,8 +311,7 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym custom, }) } - WalletDataPaymentMethod::ApplePay(_) - | WalletDataPaymentMethod::AliPayQr(_) + WalletDataPaymentMethod::AliPayQr(_) | WalletDataPaymentMethod::AliPayRedirect(_) | WalletDataPaymentMethod::AliPayHkRedirect(_) | WalletDataPaymentMethod::MomoRedirect(_) @@ -578,14 +578,11 @@ impl TryFrom Date: Fri, 25 Oct 2024 16:26:45 +0530 Subject: [PATCH 18/46] feat(connector): [PayU] Use connector_request_reference_id (#6360) --- .../hyperswitch_connectors/src/connectors/payu/transformers.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs index 0b2b70305281..4ebc09a0023b 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs @@ -34,6 +34,7 @@ pub struct PayuPaymentsRequest { description: String, pay_methods: PayuPaymentMethod, continue_url: Option, + ext_order_id: Option, } #[derive(Debug, Eq, PartialEq, Serialize)] @@ -133,6 +134,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest { .to_string(), ), merchant_pos_id: auth_type.merchant_pos_id, + ext_order_id: Some(item.connector_request_reference_id.clone()), total_amount: item.request.amount, currency_code: item.request.currency, description: item.description.clone().ok_or( From 90765bece1b12b208192e7ae4d54f4c70a301cea Mon Sep 17 00:00:00 2001 From: Gaurav Ghodinde <65962770+gauravghodinde@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:27:11 +0530 Subject: [PATCH 19/46] refactor(connector): add amount conversion framework to tsys (#6282) Co-authored-by: DEEPANSHU BANSAL <41580413+deepanshu-iiitu@users.noreply.github.com> --- .../src/connectors/tsys.rs | 43 +++++++++++++--- .../src/connectors/tsys/transformers.rs | 49 +++++++++++++------ crates/router/src/types/api.rs | 2 +- crates/router/tests/connectors/tsys.rs | 2 +- 4 files changed, 72 insertions(+), 24 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/tsys.rs b/crates/hyperswitch_connectors/src/connectors/tsys.rs index ec53a99316f5..25b47981def6 100644 --- a/crates/hyperswitch_connectors/src/connectors/tsys.rs +++ b/crates/hyperswitch_connectors/src/connectors/tsys.rs @@ -1,12 +1,11 @@ pub mod transformers; -use std::fmt::Debug; - use common_enums::enums; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, request::{Method, Request, RequestBuilder, RequestContent}, + types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector}, }; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ @@ -41,10 +40,18 @@ use hyperswitch_interfaces::{ use transformers as tsys; use crate::{constants::headers, types::ResponseRouterData, utils}; +#[derive(Clone)] +pub struct Tsys { + amount_converter: &'static (dyn AmountConvertor + Sync), +} -#[derive(Debug, Clone)] -pub struct Tsys; - +impl Tsys { + pub fn new() -> &'static Self { + &Self { + amount_converter: &StringMinorUnitForConnector, + } + } +} impl api::Payment for Tsys {} impl api::PaymentSession for Tsys {} impl api::ConnectorAccessToken for Tsys {} @@ -156,7 +163,14 @@ impl ConnectorIntegration CustomResult { - let connector_req = tsys::TsysPaymentsRequest::try_from(req)?; + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + let connector_router_data = tsys::TsysRouterData::from((amount, req)); + let connector_req: transformers::TsysPaymentsRequest = + tsys::TsysPaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -316,7 +330,13 @@ impl ConnectorIntegration fo req: &PaymentsCaptureRouterData, _connectors: &Connectors, ) -> CustomResult { - let connector_req = tsys::TsysPaymentsCaptureRequest::try_from(req)?; + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_amount_to_capture, + req.request.currency, + )?; + let connector_router_data = tsys::TsysRouterData::from((amount, req)); + let connector_req = tsys::TsysPaymentsCaptureRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -473,7 +493,14 @@ impl ConnectorIntegration for Tsys { req: &RefundsRouterData, _connectors: &Connectors, ) -> CustomResult { - let connector_req = tsys::TsysRefundRequest::try_from(req)?; + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_refund_amount, + req.request.currency, + )?; + let connector_router_data = tsys::TsysRouterData::from((amount, req)); + + let connector_req = tsys::TsysRefundRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } diff --git a/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs b/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs index fc485e657279..c867adaa23ea 100644 --- a/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs @@ -1,4 +1,5 @@ use common_enums::enums; +use common_utils::types::StringMinorUnit; use error_stack::ResultExt; use hyperswitch_domain_models::{ payment_method_data::PaymentMethodData, @@ -7,13 +8,26 @@ use hyperswitch_domain_models::{ router_request_types::ResponseId, router_response_types::{PaymentsResponseData, RefundsResponseData}, types::{ - self, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, - RefundSyncRouterData, RefundsRouterData, + self, PaymentsCancelRouterData, PaymentsSyncRouterData, RefundSyncRouterData, + RefundsRouterData, }, }; use hyperswitch_interfaces::errors; use masking::Secret; use serde::{Deserialize, Serialize}; +pub struct TsysRouterData { + pub amount: StringMinorUnit, + pub router_data: T, +} + +impl From<(StringMinorUnit, T)> for TsysRouterData { + fn from((amount, router_data): (StringMinorUnit, T)) -> Self { + Self { + amount, + router_data, + } + } +} use crate::{ types::{RefundsResponseRouterData, ResponseRouterData}, @@ -33,7 +47,7 @@ pub struct TsysPaymentAuthSaleRequest { device_id: Secret, transaction_key: Secret, card_data_source: String, - transaction_amount: String, + transaction_amount: StringMinorUnit, currency_code: enums::Currency, card_number: cards::CardNumber, expiration_date: Secret, @@ -46,9 +60,12 @@ pub struct TsysPaymentAuthSaleRequest { order_number: String, } -impl TryFrom<&types::PaymentsAuthorizeRouterData> for TsysPaymentsRequest { +impl TryFrom<&TsysRouterData<&types::PaymentsAuthorizeRouterData>> for TsysPaymentsRequest { type Error = error_stack::Report; - fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { + fn try_from( + item_data: &TsysRouterData<&types::PaymentsAuthorizeRouterData>, + ) -> Result { + let item = item_data.router_data.clone(); match item.request.payment_method_data.clone() { PaymentMethodData::Card(ccard) => { let connector_auth: TsysAuthType = @@ -57,7 +74,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for TsysPaymentsRequest { device_id: connector_auth.device_id, transaction_key: connector_auth.transaction_key, card_data_source: "INTERNET".to_string(), - transaction_amount: item.request.amount.to_string(), + transaction_amount: item_data.amount.clone(), currency_code: item.request.currency, card_number: ccard.card_number.clone(), expiration_date: ccard @@ -430,7 +447,7 @@ pub struct TsysCaptureRequest { #[serde(rename = "deviceID")] device_id: Secret, transaction_key: Secret, - transaction_amount: String, + transaction_amount: StringMinorUnit, #[serde(rename = "transactionID")] transaction_id: String, #[serde(rename = "developerID")] @@ -444,16 +461,19 @@ pub struct TsysPaymentsCaptureRequest { capture: TsysCaptureRequest, } -impl TryFrom<&PaymentsCaptureRouterData> for TsysPaymentsCaptureRequest { +impl TryFrom<&TsysRouterData<&types::PaymentsCaptureRouterData>> for TsysPaymentsCaptureRequest { type Error = error_stack::Report; - fn try_from(item: &PaymentsCaptureRouterData) -> Result { + fn try_from( + item_data: &TsysRouterData<&types::PaymentsCaptureRouterData>, + ) -> Result { + let item = item_data.router_data.clone(); let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?; let capture = TsysCaptureRequest { device_id: connector_auth.device_id, transaction_key: connector_auth.transaction_key, transaction_id: item.request.connector_transaction_id.clone(), developer_id: connector_auth.developer_id, - transaction_amount: item.request.amount_to_capture.to_string(), + transaction_amount: item_data.amount.clone(), }; Ok(Self { capture }) } @@ -466,7 +486,7 @@ pub struct TsysReturnRequest { #[serde(rename = "deviceID")] device_id: Secret, transaction_key: Secret, - transaction_amount: String, + transaction_amount: StringMinorUnit, #[serde(rename = "transactionID")] transaction_id: String, } @@ -478,14 +498,15 @@ pub struct TsysRefundRequest { return_request: TsysReturnRequest, } -impl TryFrom<&RefundsRouterData> for TsysRefundRequest { +impl TryFrom<&TsysRouterData<&RefundsRouterData>> for TsysRefundRequest { type Error = error_stack::Report; - fn try_from(item: &RefundsRouterData) -> Result { + fn try_from(item_data: &TsysRouterData<&RefundsRouterData>) -> Result { + let item = item_data.router_data; let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?; let return_request = TsysReturnRequest { device_id: connector_auth.device_id, transaction_key: connector_auth.transaction_key, - transaction_amount: item.request.refund_amount.to_string(), + transaction_amount: item_data.amount.clone(), transaction_id: item.request.connector_transaction_id.clone(), }; Ok(Self { return_request }) diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 434352fa1174..198d400b8542 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -507,7 +507,7 @@ impl ConnectorData { enums::Connector::Trustpay => { Ok(ConnectorEnum::Old(Box::new(connector::Trustpay::new()))) } - enums::Connector::Tsys => Ok(ConnectorEnum::Old(Box::new(&connector::Tsys))), + enums::Connector::Tsys => Ok(ConnectorEnum::Old(Box::new(connector::Tsys::new()))), enums::Connector::Volt => Ok(ConnectorEnum::Old(Box::new(connector::Volt::new()))), enums::Connector::Wellsfargo => { diff --git a/crates/router/tests/connectors/tsys.rs b/crates/router/tests/connectors/tsys.rs index 4cda0b479b24..6a4843ac2cd1 100644 --- a/crates/router/tests/connectors/tsys.rs +++ b/crates/router/tests/connectors/tsys.rs @@ -16,7 +16,7 @@ impl utils::Connector for TsysTest { fn get_data(&self) -> types::api::ConnectorData { use router::connector::Tsys; utils::construct_connector_data_old( - Box::new(&Tsys), + Box::new(Tsys::new()), types::Connector::Tsys, types::api::GetToken::Connector, None, From ce732db9b2f98924a2b1d44ea5eb1000b6cbb498 Mon Sep 17 00:00:00 2001 From: Prajjwal Kumar Date: Fri, 25 Oct 2024 16:38:38 +0530 Subject: [PATCH 20/46] feat(euclid): add dynamic routing in core flows (#6333) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- api-reference/openapi_spec.json | 184 +------- crates/api_models/src/routing.rs | 45 +- crates/openapi/src/openapi.rs | 7 +- crates/openapi/src/routes/routing.rs | 29 +- crates/router/src/core/errors.rs | 14 + crates/router/src/core/payments.rs | 13 + .../payments/operations/payment_response.rs | 4 +- crates/router/src/core/payments/routing.rs | 117 +++++ crates/router/src/core/routing.rs | 273 +++++++----- crates/router/src/core/routing/helpers.rs | 407 +++++++++++------- crates/router/src/routes/routing.rs | 4 +- 11 files changed, 605 insertions(+), 492 deletions(-) diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 9374acb024d1..4b0f33da3e76 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -3952,12 +3952,12 @@ } }, { - "name": "status", + "name": "enable", "in": "query", - "description": "Boolean value for mentioning the expected state of dynamic routing", + "description": "Feature to enable for success based routing", "required": true, "schema": { - "type": "boolean" + "$ref": "#/components/schemas/SuccessBasedRoutingFeatures" } } ], @@ -3998,87 +3998,6 @@ ] } }, - "/account/:account_id/business_profile/:profile_id/dynamic_routing/success_based/config/:algorithm_id": { - "patch": { - "tags": [ - "Routing" - ], - "summary": "Routing - Update config for success based dynamic routing", - "description": "Update config for success based dynamic routing", - "operationId": "Update configs for success based dynamic routing algorithm", - "parameters": [ - { - "name": "account_id", - "in": "path", - "description": "Merchant id", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "profile_id", - "in": "path", - "description": "The unique identifier for a profile", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "algorithm_id", - "in": "path", - "description": "The unique identifier for routing algorithm", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SuccessBasedRoutingConfig" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Routing Algorithm updated", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RoutingDictionaryRecord" - } - } - } - }, - "400": { - "description": "Request body is malformed" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Resource missing" - }, - "422": { - "description": "Unprocessable request" - }, - "500": { - "description": "Internal server error" - } - }, - "security": [ - { - "admin_api_key": [] - } - ] - } - }, "/blocklist": { "delete": { "tags": [ @@ -9458,23 +9377,6 @@ "ZWL" ] }, - "CurrentBlockThreshold": { - "type": "object", - "properties": { - "duration_in_mins": { - "type": "integer", - "format": "int64", - "nullable": true, - "minimum": 0 - }, - "max_total_count": { - "type": "integer", - "format": "int64", - "nullable": true, - "minimum": 0 - } - } - }, "CustomerAcceptance": { "type": "object", "description": "This \"CustomerAcceptance\" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.", @@ -23624,80 +23526,14 @@ "destination" ] }, - "SuccessBasedRoutingConfig": { - "type": "object", - "properties": { - "params": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SuccessBasedRoutingConfigParams" - }, - "nullable": true - }, - "config": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessBasedRoutingConfigBody" - } - ], - "nullable": true - } - } - }, - "SuccessBasedRoutingConfigBody": { - "type": "object", - "properties": { - "min_aggregates_size": { - "type": "integer", - "format": "int32", - "nullable": true, - "minimum": 0 - }, - "default_success_rate": { - "type": "number", - "format": "double", - "nullable": true - }, - "max_aggregates_size": { - "type": "integer", - "format": "int32", - "nullable": true, - "minimum": 0 - }, - "current_block_threshold": { - "allOf": [ - { - "$ref": "#/components/schemas/CurrentBlockThreshold" - } - ], - "nullable": true - } - } - }, - "SuccessBasedRoutingConfigParams": { + "SuccessBasedRoutingFeatures": { "type": "string", "enum": [ - "PaymentMethod", - "PaymentMethodType", - "Currency", - "AuthenticationType" + "metrics", + "dynamic_connector_selection", + "none" ] }, - "SuccessBasedRoutingUpdateConfigQuery": { - "type": "object", - "required": [ - "algorithm_id", - "profile_id" - ], - "properties": { - "algorithm_id": { - "type": "string" - }, - "profile_id": { - "type": "string" - } - } - }, "SurchargeDetailsResponse": { "type": "object", "required": [ @@ -23961,11 +23797,11 @@ "ToggleSuccessBasedRoutingQuery": { "type": "object", "required": [ - "status" + "enable" ], "properties": { - "status": { - "type": "boolean" + "enable": { + "$ref": "#/components/schemas/SuccessBasedRoutingFeatures" } } }, diff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rs index fc65ab037c2b..47d75b2e8357 100644 --- a/crates/api_models/src/routing.rs +++ b/crates/api_models/src/routing.rs @@ -522,22 +522,51 @@ pub struct DynamicAlgorithmWithTimestamp { #[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)] pub struct DynamicRoutingAlgorithmRef { - pub success_based_algorithm: - Option>, + pub success_based_algorithm: Option, +} + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct SuccessBasedAlgorithm { + pub algorithm_id_with_timestamp: + DynamicAlgorithmWithTimestamp, + #[serde(default)] + pub enabled_feature: SuccessBasedRoutingFeatures, +} + +impl SuccessBasedAlgorithm { + pub fn update_enabled_features(&mut self, feature_to_enable: SuccessBasedRoutingFeatures) { + self.enabled_feature = feature_to_enable + } } impl DynamicRoutingAlgorithmRef { - pub fn update_algorithm_id(&mut self, new_id: common_utils::id_type::RoutingId) { - self.success_based_algorithm = Some(DynamicAlgorithmWithTimestamp { - algorithm_id: Some(new_id), - timestamp: common_utils::date_time::now_unix_timestamp(), + pub fn update_algorithm_id( + &mut self, + new_id: common_utils::id_type::RoutingId, + enabled_feature: SuccessBasedRoutingFeatures, + ) { + self.success_based_algorithm = Some(SuccessBasedAlgorithm { + algorithm_id_with_timestamp: DynamicAlgorithmWithTimestamp { + algorithm_id: Some(new_id), + timestamp: common_utils::date_time::now_unix_timestamp(), + }, + enabled_feature, }) } } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)] pub struct ToggleSuccessBasedRoutingQuery { - pub status: bool, + pub enable: SuccessBasedRoutingFeatures, +} + +#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, ToSchema)] +#[serde(rename_all = "snake_case")] +pub enum SuccessBasedRoutingFeatures { + Metrics, + DynamicConnectorSelection, + #[default] + None, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)] @@ -551,7 +580,7 @@ pub struct SuccessBasedRoutingUpdateConfigQuery { #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct ToggleSuccessBasedRoutingWrapper { pub profile_id: common_utils::id_type::ProfileId, - pub status: bool, + pub feature_to_enable: SuccessBasedRoutingFeatures, } #[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 28a7f44c7a87..158456679993 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -160,7 +160,6 @@ Never share your secret api keys. Keep them guarded and secure. routes::routing::routing_retrieve_default_config_for_profiles, routes::routing::routing_update_default_config_for_profile, routes::routing::toggle_success_based_routing, - routes::routing::success_based_routing_update_configs, // Routes for blocklist routes::blocklist::remove_entry_from_blocklist, @@ -566,6 +565,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::routing::RoutingDictionaryRecord, api_models::routing::RoutingKind, api_models::routing::RoutableConnectorChoice, + api_models::routing::SuccessBasedRoutingFeatures, api_models::routing::LinkedRoutingConfigRetrieveResponse, api_models::routing::RoutingRetrieveResponse, api_models::routing::ProfileDefaultRoutingConfig, @@ -577,11 +577,6 @@ Never share your secret api keys. Keep them guarded and secure. api_models::routing::ConnectorVolumeSplit, api_models::routing::ConnectorSelection, api_models::routing::ToggleSuccessBasedRoutingQuery, - api_models::routing::SuccessBasedRoutingConfig, - api_models::routing::SuccessBasedRoutingConfigParams, - api_models::routing::SuccessBasedRoutingConfigBody, - api_models::routing::CurrentBlockThreshold, - api_models::routing::SuccessBasedRoutingUpdateConfigQuery, api_models::routing::ToggleSuccessBasedRoutingPath, api_models::routing::ast::RoutableChoiceKind, api_models::enums::RoutableConnectors, diff --git a/crates/openapi/src/routes/routing.rs b/crates/openapi/src/routes/routing.rs index 009708d860d0..0bb79a2bbe47 100644 --- a/crates/openapi/src/routes/routing.rs +++ b/crates/openapi/src/routes/routing.rs @@ -266,7 +266,7 @@ pub async fn routing_update_default_config_for_profile() {} params( ("account_id" = String, Path, description = "Merchant id"), ("profile_id" = String, Path, description = "Profile id under which Dynamic routing needs to be toggled"), - ("status" = bool, Query, description = "Boolean value for mentioning the expected state of dynamic routing"), + ("enable" = SuccessBasedRoutingFeatures, Query, description = "Feature to enable for success based routing"), ), responses( (status = 200, description = "Routing Algorithm created", body = RoutingDictionaryRecord), @@ -281,30 +281,3 @@ pub async fn routing_update_default_config_for_profile() {} security(("api_key" = []), ("jwt_key" = [])) )] pub async fn toggle_success_based_routing() {} - -#[cfg(feature = "v1")] -/// Routing - Update config for success based dynamic routing -/// -/// Update config for success based dynamic routing -#[utoipa::path( - patch, - path = "/account/:account_id/business_profile/:profile_id/dynamic_routing/success_based/config/:algorithm_id", - request_body = SuccessBasedRoutingConfig, - params( - ("account_id" = String, Path, description = "Merchant id"), - ("profile_id" = String, Path, description = "The unique identifier for a profile"), - ("algorithm_id" = String, Path, description = "The unique identifier for routing algorithm"), - ), - responses( - (status = 200, description = "Routing Algorithm updated", body = RoutingDictionaryRecord), - (status = 400, description = "Request body is malformed"), - (status = 500, description = "Internal server error"), - (status = 404, description = "Resource missing"), - (status = 422, description = "Unprocessable request"), - (status = 403, description = "Forbidden"), - ), - tag = "Routing", - operation_id = "Update configs for success based dynamic routing algorithm", - security(("admin_api_key" = [])) -)] -pub async fn success_based_routing_update_configs() {} diff --git a/crates/router/src/core/errors.rs b/crates/router/src/core/errors.rs index aa4ff406a2ce..d095b471e2dd 100644 --- a/crates/router/src/core/errors.rs +++ b/crates/router/src/core/errors.rs @@ -328,6 +328,20 @@ pub enum RoutingError { VolumeSplitFailed, #[error("Unable to parse metadata")] MetadataParsingError, + #[error("Unable to retrieve success based routing config")] + SuccessBasedRoutingConfigError, + #[error("Unable to calculate success based routing config from dynamic routing service")] + SuccessRateCalculationError, + #[error("Success rate client from dynamic routing gRPC service not initialized")] + SuccessRateClientInitializationError, + #[error("Unable to convert from '{from}' to '{to}'")] + GenericConversionError { from: String, to: String }, + #[error("Invalid success based connector label received from dynamic routing service: '{0}'")] + InvalidSuccessBasedConnectorLabel(String), + #[error("unable to find '{field}'")] + GenericNotFoundError { field: String }, + #[error("Unable to deserialize from '{from}' to '{to}'")] + DeserializationError { from: String, to: String }, } #[derive(Debug, Clone, thiserror::Error)] diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index a76e24af0c26..de58eeed1008 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -5583,6 +5583,19 @@ where .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("failed eligibility analysis and fallback")?; + // dynamic success based connector selection + #[cfg(all(feature = "v1", feature = "dynamic_routing"))] + let connectors = { + if business_profile.dynamic_routing_algorithm.is_some() { + routing::perform_success_based_routing(state, connectors.clone(), business_profile) + .await + .map_err(|e| logger::error!(success_rate_routing_error=?e)) + .unwrap_or(connectors) + } else { + connectors + } + }; + let connector_data = connectors .into_iter() .map(|conn| { diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index 7aa67a9b50f6..a18996ccc3b7 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -1918,8 +1918,7 @@ async fn payment_response_update_tracker( #[cfg(all(feature = "v1", feature = "dynamic_routing"))] { - if let Some(dynamic_routing_algorithm) = business_profile.dynamic_routing_algorithm.clone() - { + if business_profile.dynamic_routing_algorithm.is_some() { let state = state.clone(); let business_profile = business_profile.clone(); let payment_attempt = payment_attempt.clone(); @@ -1930,7 +1929,6 @@ async fn payment_response_update_tracker( &payment_attempt, routable_connectors, &business_profile, - dynamic_routing_algorithm, ) .await .map_err(|e| logger::error!(dynamic_routing_metrics_error=?e)) diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs index 11908ae0d994..40721e9b4c31 100644 --- a/crates/router/src/core/payments/routing.rs +++ b/crates/router/src/core/payments/routing.rs @@ -7,6 +7,8 @@ use std::{ sync::Arc, }; +#[cfg(all(feature = "v1", feature = "dynamic_routing"))] +use api_models::routing as api_routing; use api_models::{ admin as admin_api, enums::{self as api_enums, CountryAlpha2}, @@ -21,6 +23,10 @@ use euclid::{ enums as euclid_enums, frontend::{ast, dir as euclid_dir}, }; +#[cfg(all(feature = "v1", feature = "dynamic_routing"))] +use external_services::grpc_client::dynamic_routing::{ + success_rate::CalSuccessRateResponse, SuccessBasedDynamicRouting, +}; use kgraph_utils::{ mca as mca_graph, transformers::{IntoContext, IntoDirValue}, @@ -1227,3 +1233,114 @@ pub fn make_dsl_input_for_surcharge( }; Ok(backend_input) } + +/// success based dynamic routing +#[cfg(all(feature = "v1", feature = "dynamic_routing"))] +pub async fn perform_success_based_routing( + state: &SessionState, + routable_connectors: Vec, + business_profile: &domain::Profile, +) -> RoutingResult> { + let success_based_dynamic_routing_algo_ref: api_routing::DynamicRoutingAlgorithmRef = + business_profile + .dynamic_routing_algorithm + .clone() + .map(|val| val.parse_value("DynamicRoutingAlgorithmRef")) + .transpose() + .change_context(errors::RoutingError::DeserializationError { + from: "JSON".to_string(), + to: "DynamicRoutingAlgorithmRef".to_string(), + }) + .attach_printable("unable to deserialize DynamicRoutingAlgorithmRef from JSON")? + .unwrap_or_default(); + + let success_based_algo_ref = success_based_dynamic_routing_algo_ref + .success_based_algorithm + .ok_or(errors::RoutingError::GenericNotFoundError { field: "success_based_algorithm".to_string() }) + .attach_printable( + "success_based_algorithm not found in dynamic_routing_algorithm from business_profile table", + )?; + + if success_based_algo_ref.enabled_feature + == api_routing::SuccessBasedRoutingFeatures::DynamicConnectorSelection + { + logger::debug!( + "performing success_based_routing for profile {}", + business_profile.get_id().get_string_repr() + ); + let client = state + .grpc_client + .dynamic_routing + .success_rate_client + .as_ref() + .ok_or(errors::RoutingError::SuccessRateClientInitializationError) + .attach_printable("success_rate gRPC client not found")?; + + let success_based_routing_configs = routing::helpers::fetch_success_based_routing_configs( + state, + business_profile, + success_based_algo_ref + .algorithm_id_with_timestamp + .algorithm_id + .ok_or(errors::RoutingError::GenericNotFoundError { + field: "success_based_routing_algorithm_id".to_string(), + }) + .attach_printable( + "success_based_routing_algorithm_id not found in business_profile", + )?, + ) + .await + .change_context(errors::RoutingError::SuccessBasedRoutingConfigError) + .attach_printable("unable to fetch success_rate based dynamic routing configs")?; + + let tenant_business_profile_id = routing::helpers::generate_tenant_business_profile_id( + &state.tenant.redis_key_prefix, + business_profile.get_id().get_string_repr(), + ); + + let success_based_connectors: CalSuccessRateResponse = client + .calculate_success_rate( + tenant_business_profile_id, + success_based_routing_configs, + routable_connectors, + ) + .await + .change_context(errors::RoutingError::SuccessRateCalculationError) + .attach_printable( + "unable to calculate/fetch success rate from dynamic routing service", + )?; + + let mut connectors = Vec::with_capacity(success_based_connectors.labels_with_score.len()); + for label_with_score in success_based_connectors.labels_with_score { + let (connector, merchant_connector_id) = label_with_score.label + .split_once(':') + .ok_or(errors::RoutingError::InvalidSuccessBasedConnectorLabel(label_with_score.label.to_string())) + .attach_printable( + "unable to split connector_name and mca_id from the label obtained by the dynamic routing service", + )?; + connectors.push(api_routing::RoutableConnectorChoice { + choice_kind: api_routing::RoutableChoiceKind::FullStruct, + connector: common_enums::RoutableConnectors::from_str(connector) + .change_context(errors::RoutingError::GenericConversionError { + from: "String".to_string(), + to: "RoutableConnectors".to_string(), + }) + .attach_printable("unable to convert String to RoutableConnectors")?, + merchant_connector_id: Some( + common_utils::id_type::MerchantConnectorAccountId::wrap( + merchant_connector_id.to_string(), + ) + .change_context(errors::RoutingError::GenericConversionError { + from: "String".to_string(), + to: "MerchantConnectorAccountId".to_string(), + }) + .attach_printable("unable to convert MerchantConnectorAccountId from string")?, + ), + }); + } + logger::debug!(success_based_routing_connectors=?connectors); + Ok(connectors) + } else { + Ok(routable_connectors) + } +} diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rs index 926b30081bf6..0bd38918ee77 100644 --- a/crates/router/src/core/routing.rs +++ b/crates/router/src/core/routing.rs @@ -441,9 +441,13 @@ pub async fn link_routing_config( utils::when( matches!( dynamic_routing_ref.success_based_algorithm, - Some(routing_types::DynamicAlgorithmWithTimestamp { - algorithm_id: Some(ref id), - timestamp: _ + Some(routing::SuccessBasedAlgorithm { + algorithm_id_with_timestamp: + routing_types::DynamicAlgorithmWithTimestamp { + algorithm_id: Some(ref id), + timestamp: _ + }, + enabled_feature: _ }) if id == &algorithm_id ), || { @@ -453,7 +457,17 @@ pub async fn link_routing_config( }, )?; - dynamic_routing_ref.update_algorithm_id(algorithm_id); + dynamic_routing_ref.update_algorithm_id( + algorithm_id, + dynamic_routing_ref + .success_based_algorithm + .clone() + .ok_or(errors::ApiErrorResponse::InternalServerError) + .attach_printable( + "missing success_based_algorithm in dynamic_algorithm_ref from business_profile table", + )? + .enabled_feature, + ); helpers::update_business_profile_active_dynamic_algorithm_ref( db, key_manager_state, @@ -1169,7 +1183,7 @@ pub async fn toggle_success_based_routing( state: SessionState, merchant_account: domain::MerchantAccount, key_store: domain::MerchantKeyStore, - status: bool, + feature_to_enable: routing::SuccessBasedRoutingFeatures, profile_id: common_utils::id_type::ProfileId, ) -> RouterResponse { metrics::ROUTING_CREATE_REQUEST_RECEIVED.add( @@ -1205,115 +1219,158 @@ pub async fn toggle_success_based_routing( )? .unwrap_or_default(); - if status { - let default_success_based_routing_config = routing::SuccessBasedRoutingConfig::default(); - let algorithm_id = common_utils::generate_routing_id_of_default_length(); - let timestamp = common_utils::date_time::now(); - let algo = RoutingAlgorithm { - algorithm_id: algorithm_id.clone(), - profile_id: business_profile.get_id().to_owned(), - merchant_id: merchant_account.get_id().to_owned(), - name: "Dynamic routing algorithm".to_string(), - description: None, - kind: diesel_models::enums::RoutingAlgorithmKind::Dynamic, - algorithm_data: serde_json::json!(default_success_based_routing_config), - created_at: timestamp, - modified_at: timestamp, - algorithm_for: common_enums::TransactionType::Payment, - }; - - let record = db - .insert_routing_algorithm(algo) - .await - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Unable to insert record in routing algorithm table")?; - - success_based_dynamic_routing_algo_ref.update_algorithm_id(algorithm_id); - helpers::update_business_profile_active_dynamic_algorithm_ref( - db, - key_manager_state, - &key_store, - business_profile, - success_based_dynamic_routing_algo_ref, - ) - .await?; - - let new_record = record.foreign_into(); - - metrics::ROUTING_CREATE_SUCCESS_RESPONSE.add( - &metrics::CONTEXT, - 1, - &add_attributes([("profile_id", profile_id.get_string_repr().to_owned())]), - ); - Ok(service_api::ApplicationResponse::Json(new_record)) - } else { - let timestamp = common_utils::date_time::now_unix_timestamp(); - match success_based_dynamic_routing_algo_ref.success_based_algorithm { - Some(algorithm_ref) => { - if let Some(algorithm_id) = algorithm_ref.algorithm_id { - let dynamic_routing_algorithm = routing_types::DynamicRoutingAlgorithmRef { - success_based_algorithm: Some( - routing_types::DynamicAlgorithmWithTimestamp { - algorithm_id: None, - timestamp, - }, - ), - }; - - // redact cache for success based routing configs - let cache_key = format!( - "{}_{}", - business_profile.get_id().get_string_repr(), - algorithm_id.get_string_repr() - ); - let cache_entries_to_redact = - vec![cache::CacheKind::SuccessBasedDynamicRoutingCache( - cache_key.into(), - )]; - let _ = cache::publish_into_redact_channel( - state.store.get_cache_store().as_ref(), - cache_entries_to_redact, - ) - .await - .map_err(|e| { - logger::error!( - "unable to publish into the redact channel for evicting the success based routing config cache {e:?}" + match feature_to_enable { + routing::SuccessBasedRoutingFeatures::Metrics + | routing::SuccessBasedRoutingFeatures::DynamicConnectorSelection => { + if let Some(ref mut algo_with_timestamp) = + success_based_dynamic_routing_algo_ref.success_based_algorithm + { + match algo_with_timestamp + .algorithm_id_with_timestamp + .algorithm_id + .clone() + { + Some(algorithm_id) => { + // algorithm is already present in profile + if algo_with_timestamp.enabled_feature == feature_to_enable { + // algorithm already has the required feature + Err(errors::ApiErrorResponse::PreconditionFailed { + message: "Success rate based routing is already enabled" + .to_string(), + })? + } else { + // enable the requested feature for the algorithm + algo_with_timestamp.update_enabled_features(feature_to_enable); + let record = db + .find_routing_algorithm_by_profile_id_algorithm_id( + business_profile.get_id(), + &algorithm_id, + ) + .await + .to_not_found_response( + errors::ApiErrorResponse::ResourceIdNotFound, + )?; + let response = record.foreign_into(); + helpers::update_business_profile_active_dynamic_algorithm_ref( + db, + key_manager_state, + &key_store, + business_profile, + success_based_dynamic_routing_algo_ref, + ) + .await?; + + metrics::ROUTING_CREATE_SUCCESS_RESPONSE.add( + &metrics::CONTEXT, + 1, + &add_attributes([( + "profile_id", + profile_id.get_string_repr().to_owned(), + )]), + ); + Ok(service_api::ApplicationResponse::Json(response)) + } + } + None => { + // algorithm isn't present in profile + helpers::default_success_based_routing_setup( + &state, + key_store, + business_profile, + feature_to_enable, + merchant_account.get_id().to_owned(), + success_based_dynamic_routing_algo_ref, ) - }); + .await + } + } + } else { + // algorithm isn't present in profile + helpers::default_success_based_routing_setup( + &state, + key_store, + business_profile, + feature_to_enable, + merchant_account.get_id().to_owned(), + success_based_dynamic_routing_algo_ref, + ) + .await + } + } + routing::SuccessBasedRoutingFeatures::None => { + // disable success based routing for the requested profile + let timestamp = common_utils::date_time::now_unix_timestamp(); + match success_based_dynamic_routing_algo_ref.success_based_algorithm { + Some(algorithm_ref) => { + if let Some(algorithm_id) = + algorithm_ref.algorithm_id_with_timestamp.algorithm_id + { + let dynamic_routing_algorithm = routing_types::DynamicRoutingAlgorithmRef { + success_based_algorithm: Some(routing::SuccessBasedAlgorithm { + algorithm_id_with_timestamp: + routing_types::DynamicAlgorithmWithTimestamp { + algorithm_id: None, + timestamp, + }, + enabled_feature: routing::SuccessBasedRoutingFeatures::None, + }), + }; - let record = db - .find_routing_algorithm_by_profile_id_algorithm_id( - business_profile.get_id(), - &algorithm_id, + // redact cache for success based routing configs + let cache_key = format!( + "{}_{}", + business_profile.get_id().get_string_repr(), + algorithm_id.get_string_repr() + ); + let cache_entries_to_redact = + vec![cache::CacheKind::SuccessBasedDynamicRoutingCache( + cache_key.into(), + )]; + let _ = cache::publish_into_redact_channel( + state.store.get_cache_store().as_ref(), + cache_entries_to_redact, ) .await - .to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?; - let response = record.foreign_into(); - helpers::update_business_profile_active_dynamic_algorithm_ref( - db, - key_manager_state, - &key_store, - business_profile, - dynamic_routing_algorithm, - ) - .await?; - - metrics::ROUTING_UNLINK_CONFIG_SUCCESS_RESPONSE.add( - &metrics::CONTEXT, - 1, - &add_attributes([("profile_id", profile_id.get_string_repr().to_owned())]), - ); - - Ok(service_api::ApplicationResponse::Json(response)) - } else { - Err(errors::ApiErrorResponse::PreconditionFailed { - message: "Algorithm is already inactive".to_string(), - })? + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("unable to publish into the redact channel for evicting the success based routing config cache")?; + + let record = db + .find_routing_algorithm_by_profile_id_algorithm_id( + business_profile.get_id(), + &algorithm_id, + ) + .await + .to_not_found_response(errors::ApiErrorResponse::ResourceIdNotFound)?; + let response = record.foreign_into(); + helpers::update_business_profile_active_dynamic_algorithm_ref( + db, + key_manager_state, + &key_store, + business_profile, + dynamic_routing_algorithm, + ) + .await?; + + metrics::ROUTING_UNLINK_CONFIG_SUCCESS_RESPONSE.add( + &metrics::CONTEXT, + 1, + &add_attributes([( + "profile_id", + profile_id.get_string_repr().to_owned(), + )]), + ); + + Ok(service_api::ApplicationResponse::Json(response)) + } else { + Err(errors::ApiErrorResponse::PreconditionFailed { + message: "Algorithm is already inactive".to_string(), + })? + } } + None => Err(errors::ApiErrorResponse::PreconditionFailed { + message: "Success rate based routing is already disabled".to_string(), + })?, } - None => Err(errors::ApiErrorResponse::PreconditionFailed { - message: "Algorithm is already inactive".to_string(), - })?, } } } diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs index 22966208dd44..6b5845831745 100644 --- a/crates/router/src/core/routing/helpers.rs +++ b/crates/router/src/core/routing/helpers.rs @@ -12,10 +12,16 @@ use api_models::routing as routing_types; use common_utils::ext_traits::ValueExt; use common_utils::{ext_traits::Encode, id_type, types::keymanager::KeyManagerState}; use diesel_models::configs; +#[cfg(feature = "v1")] +use diesel_models::routing_algorithm; use error_stack::ResultExt; -#[cfg(feature = "dynamic_routing")] +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] use external_services::grpc_client::dynamic_routing::SuccessBasedDynamicRouting; +#[cfg(feature = "v1")] +use hyperswitch_domain_models::api::ApplicationResponse; #[cfg(all(feature = "dynamic_routing", feature = "v1"))] +use router_env::logger; +#[cfg(any(feature = "dynamic_routing", feature = "v1"))] use router_env::{instrument, metrics::add_attributes, tracing}; use rustc_hash::FxHashSet; use storage_impl::redis::cache; @@ -29,8 +35,10 @@ use crate::{ types::{domain, storage}, utils::StringExt, }; -#[cfg(all(feature = "dynamic_routing", feature = "v1"))] -use crate::{core::metrics as core_metrics, routes::metrics}; +#[cfg(feature = "v1")] +use crate::{core::metrics as core_metrics, routes::metrics, types::transformers::ForeignInto}; +pub const SUCCESS_BASED_DYNAMIC_ROUTING_ALGORITHM: &str = + "Success rate based dynamic routing algorithm"; /// Provides us with all the configured configs of the Merchant in the ascending time configured /// manner and chooses the first of them @@ -594,28 +602,8 @@ pub async fn refresh_success_based_routing_cache( pub async fn fetch_success_based_routing_configs( state: &SessionState, business_profile: &domain::Profile, - dynamic_routing_algorithm: serde_json::Value, + success_based_routing_id: id_type::RoutingId, ) -> RouterResult { - let dynamic_routing_algorithm_ref = dynamic_routing_algorithm - .parse_value::("DynamicRoutingAlgorithmRef") - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("unable to parse dynamic_routing_algorithm_ref")?; - - let success_based_routing_id = dynamic_routing_algorithm_ref - .success_based_algorithm - .ok_or(errors::ApiErrorResponse::GenericNotFoundError { - message: "success_based_algorithm not found in dynamic_routing_algorithm_ref" - .to_string(), - })? - .algorithm_id - // error can be possible when the feature is toggled off. - .ok_or(errors::ApiErrorResponse::GenericNotFoundError { - message: format!( - "unable to find algorithm_id in success based algorithm config as the feature is disabled for profile_id: {}", - business_profile.get_id().get_string_repr() - ), - })?; - let key = format!( "{}_{}", business_profile.get_id().get_string_repr(), @@ -657,156 +645,185 @@ pub async fn push_metrics_for_success_based_routing( payment_attempt: &storage::PaymentAttempt, routable_connectors: Vec, business_profile: &domain::Profile, - dynamic_routing_algorithm: serde_json::Value, ) -> RouterResult<()> { - let client = state - .grpc_client - .dynamic_routing - .success_rate_client - .as_ref() - .ok_or(errors::ApiErrorResponse::GenericNotFoundError { - message: "success_rate gRPC client not found".to_string(), - })?; - - let payment_connector = &payment_attempt.connector.clone().ok_or( - errors::ApiErrorResponse::GenericNotFoundError { - message: "unable to derive payment connector from payment attempt".to_string(), - }, - )?; - - let success_based_routing_configs = - fetch_success_based_routing_configs(state, business_profile, dynamic_routing_algorithm) - .await + let success_based_dynamic_routing_algo_ref: routing_types::DynamicRoutingAlgorithmRef = + business_profile + .dynamic_routing_algorithm + .clone() + .map(|val| val.parse_value("DynamicRoutingAlgorithmRef")) + .transpose() .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("unable to retrieve success_rate based dynamic routing configs")?; + .attach_printable("Failed to deserialize DynamicRoutingAlgorithmRef from JSON")? + .unwrap_or_default(); - let tenant_business_profile_id = format!( - "{}:{}", - state.tenant.redis_key_prefix, - business_profile.get_id().get_string_repr() - ); + let success_based_algo_ref = success_based_dynamic_routing_algo_ref + .success_based_algorithm + .ok_or(errors::ApiErrorResponse::InternalServerError) + .attach_printable("success_based_algorithm not found in dynamic_routing_algorithm from business_profile table")?; + + if success_based_algo_ref.enabled_feature != routing_types::SuccessBasedRoutingFeatures::None { + let client = state + .grpc_client + .dynamic_routing + .success_rate_client + .as_ref() + .ok_or(errors::ApiErrorResponse::GenericNotFoundError { + message: "success_rate gRPC client not found".to_string(), + })?; + + let payment_connector = &payment_attempt.connector.clone().ok_or( + errors::ApiErrorResponse::GenericNotFoundError { + message: "unable to derive payment connector from payment attempt".to_string(), + }, + )?; - let success_based_connectors = client - .calculate_success_rate( - tenant_business_profile_id.clone(), - success_based_routing_configs.clone(), - routable_connectors.clone(), + let success_based_routing_configs = fetch_success_based_routing_configs( + state, + business_profile, + success_based_algo_ref + .algorithm_id_with_timestamp + .algorithm_id + .ok_or(errors::ApiErrorResponse::InternalServerError) + .attach_printable( + "success_based_routing_algorithm_id not found in business_profile", + )?, ) .await .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("unable to calculate/fetch success rate from dynamic routing service")?; - - let payment_status_attribute = - get_desired_payment_status_for_success_routing_metrics(&payment_attempt.status); - - let first_success_based_connector_label = &success_based_connectors - .labels_with_score - .first() - .ok_or(errors::ApiErrorResponse::InternalServerError) - .attach_printable( - "unable to fetch the first connector from list of connectors obtained from dynamic routing service", - )? - .label - .to_string(); - - let (first_success_based_connector, merchant_connector_id) = first_success_based_connector_label - .split_once(':') - .ok_or(errors::ApiErrorResponse::InternalServerError) - .attach_printable( - "unable to split connector_name and mca_id from the first connector obtained from dynamic routing service", - )?; - - let outcome = get_success_based_metrics_outcome_for_payment( - &payment_status_attribute, - payment_connector.to_string(), - first_success_based_connector.to_string(), - ); - - core_metrics::DYNAMIC_SUCCESS_BASED_ROUTING.add( - &metrics::CONTEXT, - 1, - &add_attributes([ - ("tenant", state.tenant.name.clone()), - ( - "merchant_id", - payment_attempt.merchant_id.get_string_repr().to_string(), - ), - ( - "profile_id", - payment_attempt.profile_id.get_string_repr().to_string(), - ), - ("merchant_connector_id", merchant_connector_id.to_string()), - ( - "payment_id", - payment_attempt.payment_id.get_string_repr().to_string(), - ), - ( - "success_based_routing_connector", - first_success_based_connector.to_string(), - ), - ("payment_connector", payment_connector.to_string()), - ( - "currency", - payment_attempt - .currency - .map_or_else(|| "None".to_string(), |currency| currency.to_string()), - ), - ( - "payment_method", - payment_attempt.payment_method.map_or_else( - || "None".to_string(), - |payment_method| payment_method.to_string(), + .attach_printable("unable to retrieve success_rate based dynamic routing configs")?; + + let tenant_business_profile_id = generate_tenant_business_profile_id( + &state.tenant.redis_key_prefix, + business_profile.get_id().get_string_repr(), + ); + + let success_based_connectors = client + .calculate_success_rate( + tenant_business_profile_id.clone(), + success_based_routing_configs.clone(), + routable_connectors.clone(), + ) + .await + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable( + "unable to calculate/fetch success rate from dynamic routing service", + )?; + + let payment_status_attribute = + get_desired_payment_status_for_success_routing_metrics(&payment_attempt.status); + + let first_success_based_connector_label = &success_based_connectors + .labels_with_score + .first() + .ok_or(errors::ApiErrorResponse::InternalServerError) + .attach_printable( + "unable to fetch the first connector from list of connectors obtained from dynamic routing service", + )? + .label + .to_string(); + + let (first_success_based_connector, merchant_connector_id) = first_success_based_connector_label + .split_once(':') + .ok_or(errors::ApiErrorResponse::InternalServerError) + .attach_printable( + "unable to split connector_name and mca_id from the first connector obtained from dynamic routing service", + )?; + + let outcome = get_success_based_metrics_outcome_for_payment( + &payment_status_attribute, + payment_connector.to_string(), + first_success_based_connector.to_string(), + ); + + core_metrics::DYNAMIC_SUCCESS_BASED_ROUTING.add( + &metrics::CONTEXT, + 1, + &add_attributes([ + ("tenant", state.tenant.name.clone()), + ( + "merchant_id", + payment_attempt.merchant_id.get_string_repr().to_string(), ), - ), - ( - "payment_method_type", - payment_attempt.payment_method_type.map_or_else( - || "None".to_string(), - |payment_method_type| payment_method_type.to_string(), + ( + "profile_id", + payment_attempt.profile_id.get_string_repr().to_string(), ), - ), - ( - "capture_method", - payment_attempt.capture_method.map_or_else( - || "None".to_string(), - |capture_method| capture_method.to_string(), + ("merchant_connector_id", merchant_connector_id.to_string()), + ( + "payment_id", + payment_attempt.payment_id.get_string_repr().to_string(), ), - ), - ( - "authentication_type", - payment_attempt.authentication_type.map_or_else( - || "None".to_string(), - |authentication_type| authentication_type.to_string(), + ( + "success_based_routing_connector", + first_success_based_connector.to_string(), ), - ), - ("payment_status", payment_attempt.status.to_string()), - ("conclusive_classification", outcome.to_string()), - ]), - ); - - client - .update_success_rate( - tenant_business_profile_id, - success_based_routing_configs, - vec![routing_types::RoutableConnectorChoiceWithStatus::new( - routing_types::RoutableConnectorChoice { - choice_kind: api_models::routing::RoutableChoiceKind::FullStruct, - connector: common_enums::RoutableConnectors::from_str( - payment_connector.as_str(), - ) - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("unable to infer routable_connector from connector")?, - merchant_connector_id: payment_attempt.merchant_connector_id.clone(), - }, - payment_status_attribute == common_enums::AttemptStatus::Charged, - )], - ) - .await - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable( - "unable to update success based routing window in dynamic routing service", - )?; - Ok(()) + ("payment_connector", payment_connector.to_string()), + ( + "currency", + payment_attempt + .currency + .map_or_else(|| "None".to_string(), |currency| currency.to_string()), + ), + ( + "payment_method", + payment_attempt.payment_method.map_or_else( + || "None".to_string(), + |payment_method| payment_method.to_string(), + ), + ), + ( + "payment_method_type", + payment_attempt.payment_method_type.map_or_else( + || "None".to_string(), + |payment_method_type| payment_method_type.to_string(), + ), + ), + ( + "capture_method", + payment_attempt.capture_method.map_or_else( + || "None".to_string(), + |capture_method| capture_method.to_string(), + ), + ), + ( + "authentication_type", + payment_attempt.authentication_type.map_or_else( + || "None".to_string(), + |authentication_type| authentication_type.to_string(), + ), + ), + ("payment_status", payment_attempt.status.to_string()), + ("conclusive_classification", outcome.to_string()), + ]), + ); + logger::debug!("successfully pushed success_based_routing metrics"); + + client + .update_success_rate( + tenant_business_profile_id, + success_based_routing_configs, + vec![routing_types::RoutableConnectorChoiceWithStatus::new( + routing_types::RoutableConnectorChoice { + choice_kind: api_models::routing::RoutableChoiceKind::FullStruct, + connector: common_enums::RoutableConnectors::from_str( + payment_connector.as_str(), + ) + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("unable to infer routable_connector from connector")?, + merchant_connector_id: payment_attempt.merchant_connector_id.clone(), + }, + payment_status_attribute == common_enums::AttemptStatus::Charged, + )], + ) + .await + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable( + "unable to update success based routing window in dynamic routing service", + )?; + Ok(()) + } else { + Ok(()) + } } #[cfg(all(feature = "v1", feature = "dynamic_routing"))] @@ -875,3 +892,67 @@ fn get_success_based_metrics_outcome_for_payment( _ => common_enums::SuccessBasedRoutingConclusiveState::NonDeterministic, } } + +/// generates cache key with tenant's redis key prefix and profile_id +pub fn generate_tenant_business_profile_id( + redis_key_prefix: &str, + business_profile_id: &str, +) -> String { + format!("{}:{}", redis_key_prefix, business_profile_id) +} + +/// default config setup for success_based_routing +#[cfg(feature = "v1")] +#[instrument(skip_all)] +pub async fn default_success_based_routing_setup( + state: &SessionState, + key_store: domain::MerchantKeyStore, + business_profile: domain::Profile, + feature_to_enable: routing_types::SuccessBasedRoutingFeatures, + merchant_id: id_type::MerchantId, + mut success_based_dynamic_routing_algo: routing_types::DynamicRoutingAlgorithmRef, +) -> RouterResult> { + let db = state.store.as_ref(); + let key_manager_state = &state.into(); + let profile_id = business_profile.get_id().to_owned(); + let default_success_based_routing_config = routing_types::SuccessBasedRoutingConfig::default(); + let algorithm_id = common_utils::generate_routing_id_of_default_length(); + let timestamp = common_utils::date_time::now(); + let algo = routing_algorithm::RoutingAlgorithm { + algorithm_id: algorithm_id.clone(), + profile_id: profile_id.clone(), + merchant_id, + name: SUCCESS_BASED_DYNAMIC_ROUTING_ALGORITHM.to_string(), + description: None, + kind: diesel_models::enums::RoutingAlgorithmKind::Dynamic, + algorithm_data: serde_json::json!(default_success_based_routing_config), + created_at: timestamp, + modified_at: timestamp, + algorithm_for: common_enums::TransactionType::Payment, + }; + + let record = db + .insert_routing_algorithm(algo) + .await + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Unable to insert record in routing algorithm table")?; + + success_based_dynamic_routing_algo.update_algorithm_id(algorithm_id, feature_to_enable); + update_business_profile_active_dynamic_algorithm_ref( + db, + key_manager_state, + &key_store, + business_profile, + success_based_dynamic_routing_algo, + ) + .await?; + + let new_record = record.foreign_into(); + + core_metrics::ROUTING_CREATE_SUCCESS_RESPONSE.add( + &metrics::CONTEXT, + 1, + &add_attributes([("profile_id", profile_id.get_string_repr().to_string())]), + ); + Ok(ApplicationResponse::Json(new_record)) +} diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs index 3e0355a884a9..f3a589524a16 100644 --- a/crates/router/src/routes/routing.rs +++ b/crates/router/src/routes/routing.rs @@ -942,7 +942,7 @@ pub async fn toggle_success_based_routing( ) -> impl Responder { let flow = Flow::ToggleDynamicRouting; let wrapper = routing_types::ToggleSuccessBasedRoutingWrapper { - status: query.into_inner().status, + feature_to_enable: query.into_inner().enable, profile_id: path.into_inner().profile_id, }; Box::pin(oss_api::server_wrap( @@ -958,7 +958,7 @@ pub async fn toggle_success_based_routing( state, auth.merchant_account, auth.key_store, - wrapper.status, + wrapper.feature_to_enable, wrapper.profile_id, ) }, From 4647a2f6aece6b9479395fa3622b51b50d3091ee Mon Sep 17 00:00:00 2001 From: chikke srujan <121822803+srujanchikke@users.noreply.github.com> Date: Fri, 25 Oct 2024 18:24:22 +0530 Subject: [PATCH 21/46] feat(connector): [Fiuu] Add support for cards recurring payments (#6361) Co-authored-by: Chikke Srujan Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- config/deployments/integration_test.toml | 3 + config/deployments/production.toml | 4 + config/deployments/sandbox.toml | 4 + config/development.toml | 7 +- .../src/connectors/fiuu.rs | 48 ++- .../src/connectors/fiuu/transformers.rs | 276 ++++++++++++- crates/hyperswitch_connectors/src/utils.rs | 7 + crates/router/src/configs/defaults.rs | 36 ++ .../payments/operations/payment_create.rs | 6 +- .../cypress/e2e/PaymentUtils/Fiuu.js | 375 ++++++++++++++++++ cypress-tests/cypress/support/commands.js | 102 ++--- 11 files changed, 798 insertions(+), 70 deletions(-) diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index dafc6048154e..651e2c25b648 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -341,6 +341,9 @@ red_pagos = { country = "UY", currency = "UYU" } [pm_filters.zsl] local_bank_transfer = { country = "CN", currency = "CNY" } +[pm_filters.fiuu] +duit_now = { country ="MY", currency = "MYR" } + [payout_method_filters.adyenplatform] sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT,CZ,DE,HU,NO,PL,SE,GB,CH" , currency = "EUR,CZK,DKK,HUF,NOK,PLN,SEK,GBP,CHF" } diff --git a/config/deployments/production.toml b/config/deployments/production.toml index caf8c0305683..525033f06f2b 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -354,6 +354,10 @@ red_pagos = { country = "UY", currency = "UYU" } [pm_filters.zsl] local_bank_transfer = { country = "CN", currency = "CNY" } + +[pm_filters.fiuu] +duit_now = { country ="MY", currency = "MYR" } + [payout_method_filters.adyenplatform] sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT,CZ,DE,HU,NO,PL,SE,GB,CH" , currency = "EUR,CZK,DKK,HUF,NOK,PLN,SEK,GBP,CHF" } diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 3346c4a27252..422095c65fb6 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -358,6 +358,10 @@ red_pagos = { country = "UY", currency = "UYU" } [pm_filters.zsl] local_bank_transfer = { country = "CN", currency = "CNY" } + +[pm_filters.fiuu] +duit_now = { country ="MY", currency = "MYR" } + [payout_method_filters.adyenplatform] sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT,CZ,DE,HU,NO,PL,SE,GB,CH" , currency = "EUR,CZK,DKK,HUF,NOK,PLN,SEK,GBP,CHF" } diff --git a/config/development.toml b/config/development.toml index 8e5d9582e2f7..d32c36101323 100644 --- a/config/development.toml +++ b/config/development.toml @@ -531,6 +531,9 @@ region = "" credit = { currency = "USD" } debit = { currency = "USD" } +[pm_filters.fiuu] +duit_now = { country ="MY", currency = "MYR" } + [tokenization] stripe = { long_lived_token = false, payment_method = "wallet", payment_method_type = { type = "disable_only", list = "google_pay" } } checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization" } @@ -590,8 +593,8 @@ pay_later.klarna = { connector_list = "adyen" } wallet.google_pay = { connector_list = "stripe,adyen,cybersource,bankofamerica" } wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica" } wallet.paypal = { connector_list = "adyen" } -card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" } -card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" } +card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,fiuu" } +card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,fiuu" } bank_debit.ach = { connector_list = "gocardless,adyen" } bank_debit.becs = { connector_list = "gocardless" } bank_debit.bacs = { connector_list = "adyen" } diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs index 31d87ceedc93..6bb65622a7b4 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs @@ -1,6 +1,6 @@ pub mod transformers; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use common_enums::{CaptureMethod, PaymentMethodType}; use common_utils::{ @@ -12,6 +12,7 @@ use common_utils::{ }; use error_stack::ResultExt; use hyperswitch_domain_models::{ + payment_method_data::PaymentMethodData, router_data::{AccessToken, ErrorResponse, RouterData}, router_flow_types::{ access_token_auth::AccessTokenAuth, @@ -43,7 +44,11 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use transformers::{self as fiuu, FiuuWebhooksResponse}; -use crate::{constants::headers, types::ResponseRouterData, utils}; +use crate::{ + constants::headers, + types::ResponseRouterData, + utils::{self, PaymentMethodDataType}, +}; fn parse_response(data: &[u8]) -> Result where @@ -210,6 +215,15 @@ impl ConnectorValidation for Fiuu { ), } } + fn validate_mandate_payment( + &self, + pm_type: Option, + pm_data: PaymentMethodData, + ) -> CustomResult<(), errors::ConnectorError> { + let mandate_supported_pmd: HashSet = + HashSet::from([PaymentMethodDataType::Card]); + utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) + } } impl ConnectorIntegration for Fiuu { @@ -231,13 +245,21 @@ impl ConnectorIntegration CustomResult { - Ok(format!( - "{}RMS/API/Direct/1.4.0/index.php", - self.base_url(connectors) - )) + let url = if req.request.off_session == Some(true) { + format!( + "{}/RMS/API/Recurring/input_v7.php", + self.base_url(connectors) + ) + } else { + format!( + "{}RMS/API/Direct/1.4.0/index.php", + self.base_url(connectors) + ) + }; + Ok(url) } fn get_request_body( @@ -252,9 +274,15 @@ impl ConnectorIntegration for FPXTxnChannel { } } +#[derive(Serialize, Debug, Clone)] +pub struct FiuuMandateRequest { + #[serde(rename = "0")] + mandate_request: Secret, +} + +#[derive(Serialize, Debug, Clone)] +pub struct FiuuRecurringRequest { + record_type: FiuuRecordType, + merchant_id: Secret, + token: Secret, + order_id: String, + currency: Currency, + amount: StringMajorUnit, + billing_name: Secret, + email: Email, + verify_key: Secret, +} + +#[derive(Serialize, Debug, Clone, strum::Display)] +pub enum FiuuRecordType { + T, +} + +impl TryFrom<&FiuuRouterData<&PaymentsAuthorizeRouterData>> for FiuuMandateRequest { + type Error = Report; + fn try_from(item: &FiuuRouterData<&PaymentsAuthorizeRouterData>) -> Result { + let auth: FiuuAuthType = FiuuAuthType::try_from(&item.router_data.connector_auth_type)?; + let record_type = FiuuRecordType::T; + let merchant_id = auth.merchant_id; + let order_id = item.router_data.connector_request_reference_id.clone(); + let currency = item.router_data.request.currency; + let amount = item.amount.clone(); + let billing_name = item.router_data.get_billing_full_name()?; + let email = item.router_data.request.get_email()?; + let token = Secret::new(item.router_data.request.get_connector_mandate_id()?); + let verify_key = auth.verify_key; + let recurring_request = FiuuRecurringRequest { + record_type: record_type.clone(), + merchant_id: merchant_id.clone(), + token: token.clone(), + order_id: order_id.clone(), + currency, + amount: amount.clone(), + billing_name: billing_name.clone(), + email: email.clone(), + verify_key: verify_key.clone(), + }; + let check_sum = calculate_check_sum(recurring_request)?; + let mandate_request = format!( + "{}|{}||{}|{}|{}|{}|{}|{}|||{}", + record_type, + merchant_id.peek(), + token.peek(), + order_id, + currency, + amount.get_amount_as_string(), + billing_name.peek(), + email.peek(), + check_sum.peek() + ); + Ok(Self { + mandate_request: mandate_request.into(), + }) + } +} + +pub fn calculate_check_sum( + req: FiuuRecurringRequest, +) -> CustomResult, errors::ConnectorError> { + let formatted_string = format!( + "{}{}{}{}{}{}{}", + req.record_type, + req.merchant_id.peek(), + req.token.peek(), + req.order_id, + req.currency, + req.amount.get_amount_as_string(), + req.verify_key.peek() + ); + Ok(Secret::new(hex::encode( + crypto::Md5 + .generate_digest(formatted_string.as_bytes()) + .change_context(errors::ConnectorError::RequestEncodingFailed)?, + ))) +} + #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "PascalCase")] pub struct FiuuPaymentRequest { @@ -181,6 +271,8 @@ pub struct FiuuPaymentRequest { signature: Secret, #[serde(rename = "ReturnURL")] return_url: Option, + #[serde(rename = "NotificationURL")] + notification_url: Option, #[serde(flatten)] payment_method_data: FiuuPaymentMethodData, } @@ -219,6 +311,12 @@ pub struct FiuuCardData { cc_cvv2: Secret, cc_month: Secret, cc_year: Secret, + #[serde(rename = "mpstokenstatus")] + mps_token_status: Option, + #[serde(rename = "CustName")] + customer_name: Option>, + #[serde(rename = "CustEmail")] + customer_email: Option, } #[derive(Serialize, Debug, Clone)] @@ -278,7 +376,7 @@ pub fn calculate_signature( ) -> Result, Report> { let message = signature_data.as_bytes(); let encoded_data = hex::encode( - common_utils::crypto::Md5 + crypto::Md5 .generate_digest(message) .change_context(errors::ConnectorError::RequestEncodingFailed)?, ); @@ -307,8 +405,14 @@ impl TryFrom<&FiuuRouterData<&PaymentsAuthorizeRouterData>> for FiuuPaymentReque false => 1, true => 0, }; + let notification_url = Some( + Url::parse(&item.router_data.request.get_webhook_url()?) + .change_context(errors::ConnectorError::RequestEncodingFailed)?, + ); let payment_method_data = match item.router_data.request.payment_method_data { - PaymentMethodData::Card(ref card) => FiuuPaymentMethodData::try_from((card, &non_3ds)), + PaymentMethodData::Card(ref card) => { + FiuuPaymentMethodData::try_from((card, item.router_data)) + } PaymentMethodData::RealTimePayment(ref real_time_payment_data) => { match *real_time_payment_data.clone() { RealTimePaymentData::DuitNow {} => { @@ -434,20 +538,40 @@ impl TryFrom<&FiuuRouterData<&PaymentsAuthorizeRouterData>> for FiuuPaymentReque return_url, payment_method_data, signature, + notification_url, }) } } -impl TryFrom<(&Card, &i32)> for FiuuPaymentMethodData { +impl TryFrom<(&Card, &PaymentsAuthorizeRouterData)> for FiuuPaymentMethodData { type Error = Report; - fn try_from((req_card, non_3ds): (&Card, &i32)) -> Result { + fn try_from( + (req_card, item): (&Card, &PaymentsAuthorizeRouterData), + ) -> Result { + let (mps_token_status, customer_name, customer_email) = + if item.request.is_customer_initiated_mandate_payment() { + ( + Some(1), + Some(item.request.get_customer_name()?), + Some(item.request.get_email()?), + ) + } else { + (None, None, None) + }; + let non_3ds = match item.is_three_ds() { + false => 1, + true => 0, + }; Ok(Self::FiuuCardData(Box::new(FiuuCardData { txn_channel: TxnChannel::Creditan, - non_3ds: *non_3ds, + non_3ds, cc_pan: req_card.card_number.clone(), cc_cvv2: req_card.card_cvc.clone(), cc_month: req_card.card_exp_month.clone(), cc_year: req_card.card_exp_year.clone(), + mps_token_status, + customer_name, + customer_email, }))) } } @@ -543,6 +667,23 @@ pub enum FiuuPaymentsResponse { PaymentResponse(Box), QRPaymentResponse(Box), Error(FiuuErrorResponse), + RecurringResponse(Vec>), +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct FiuuRecurringResponse { + status: FiuuRecurringStautus, + #[serde(rename = "orderid")] + order_id: String, + #[serde(rename = "tranID")] + tran_id: Option, + reason: Option, +} +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "snake_case")] +pub enum FiuuRecurringStautus { + Accepted, + Failed, } #[derive(Debug, Serialize, Deserialize)] @@ -581,10 +722,17 @@ pub struct NonThreeDSResponseData { #[serde(rename = "tranID")] pub tran_id: String, pub status: String, + #[serde(rename = "extraP")] + pub extra_parameters: Option, pub error_code: Option, pub error_desc: Option, } +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct ExtraParameters { + token: Option>, +} + impl TryFrom< ResponseRouterData, @@ -652,6 +800,17 @@ impl }) } RequestData::NonThreeDS(non_threeds_data) => { + let mandate_reference = + non_threeds_data + .extra_parameters + .as_ref() + .and_then(|extra_p| { + extra_p.token.as_ref().map(|token| MandateReference { + connector_mandate_id: Some(token.clone().expose()), + payment_method_id: None, + mandate_metadata: None, + }) + }); let status = match non_threeds_data.status.as_str() { "00" => { if item.data.request.is_auto_capture()? { @@ -685,7 +844,7 @@ impl Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(data.txn_id), redirection_data: Box::new(None), - mandate_reference: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -700,6 +859,80 @@ impl }) } }, + FiuuPaymentsResponse::RecurringResponse(ref recurring_response_vec) => { + let recurring_response_item = recurring_response_vec.first(); + let router_data_response = match recurring_response_item { + Some(recurring_response) => { + let status = + common_enums::AttemptStatus::from(recurring_response.status.clone()); + let connector_transaction_id = recurring_response + .tran_id + .as_ref() + .map_or(ResponseId::NoResponseId, |tran_id| { + ResponseId::ConnectorTransactionId(tran_id.clone()) + }); + let response = if status == common_enums::AttemptStatus::Failure { + Err(ErrorResponse { + code: recurring_response + .reason + .clone() + .unwrap_or_else(|| "NO_ERROR_CODE".to_string()), + message: recurring_response + .reason + .clone() + .unwrap_or_else(|| "NO_ERROR_MESSAGE".to_string()), + reason: recurring_response.reason.clone(), + status_code: item.http_code, + attempt_status: None, + connector_transaction_id: recurring_response.tran_id.clone(), + }) + } else { + Ok(PaymentsResponseData::TransactionResponse { + resource_id: connector_transaction_id, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: None, + incremental_authorization_allowed: None, + charge_id: None, + }) + }; + Self { + status, + response, + ..item.data + } + } + None => { + // It is not expected to get empty response from the connnector, if we get we are not updating the payment response since we don't have any info in the authorize response. + let response = Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::NoResponseId, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: None, + incremental_authorization_allowed: None, + charge_id: None, + }); + Self { + response, + ..item.data + } + } + }; + Ok(router_data_response) + } + } + } +} + +impl From for common_enums::AttemptStatus { + fn from(status: FiuuRecurringStautus) -> Self { + match status { + FiuuRecurringStautus::Accepted => Self::Charged, + FiuuRecurringStautus::Failed => Self::Failure, } } } @@ -943,6 +1176,27 @@ impl TryFrom> for PaymentsSy capture_method: item.data.request.capture_method, status: response.status, })?; + let mandate_reference = response.extra_parameters.as_ref().and_then(|extra_p| { + let mandate_token: Result = serde_json::from_str(extra_p); + match mandate_token { + Ok(token) => { + token.token.as_ref().map(|token| MandateReference { + connector_mandate_id: Some(token.clone().expose()), + payment_method_id: None, + mandate_metadata: None, + }) + } + Err(err) => { + router_env::logger::warn!( + "Failed to convert 'extraP' from fiuu webhook response to fiuu::ExtraParameters. \ + Input: '{}', Error: {}", + extra_p, + err + ); + None + } + } + }); let error_response = if status == enums::AttemptStatus::Failure { Some(ErrorResponse { status_code: item.http_code, @@ -964,7 +1218,7 @@ impl TryFrom> for PaymentsSy let payments_response_data = PaymentsResponseData::TransactionResponse { resource_id: item.data.request.connector_transaction_id.clone(), redirection_data: Box::new(None), - mandate_reference: Box::new(None), + mandate_reference: Box::new(mandate_reference), connector_metadata: None, network_txn_id: None, connector_response_reference_id: None, @@ -1417,6 +1671,8 @@ pub struct FiuuWebhooksPaymentResponse { pub channel: String, pub error_desc: Option, pub error_code: Option, + #[serde(rename = "extraP")] + pub extra_parameters: Option, } #[derive(Debug, Deserialize, Serialize, Clone)] diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs index 652ec82c5ed8..fb2e1cce44ce 100644 --- a/crates/hyperswitch_connectors/src/utils.rs +++ b/crates/hyperswitch_connectors/src/utils.rs @@ -1117,6 +1117,7 @@ pub trait PaymentsAuthorizeRequestData { fn get_total_surcharge_amount(&self) -> Option; fn get_metadata_as_object(&self) -> Option; fn get_authentication_data(&self) -> Result; + fn get_customer_name(&self) -> Result, Error>; } impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData { @@ -1271,6 +1272,12 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData { .clone() .ok_or_else(missing_field_err("authentication_data")) } + + fn get_customer_name(&self) -> Result, Error> { + self.customer_name + .clone() + .ok_or_else(missing_field_err("customer_name")) + } } pub trait PaymentsCaptureRequestData { diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index e94ad375776e..c48d2fe54caa 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -423,6 +423,24 @@ impl Default for super::settings::RequiredFields { common: HashMap::new(), } ), + ( + enums::Connector::Fiuu, + RequiredFieldFinal { + mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), ( enums::Connector::Authorizedotnet, RequiredFieldFinal { @@ -3502,6 +3520,24 @@ impl Default for super::settings::RequiredFields { common: HashMap::new(), } ), + ( + enums::Connector::Fiuu, + RequiredFieldFinal { + mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), ( enums::Connector::Authorizedotnet, RequiredFieldFinal { diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 46799c3c196c..3bccce2783af 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -955,7 +955,11 @@ impl ValidateRequest> f helpers::validate_customer_id_mandatory_cases( request.setup_future_usage.is_some(), - request.customer_id.as_ref(), + request.customer_id.as_ref().or(request + .customer + .as_ref() + .map(|customer| customer.id.clone()) + .as_ref()), )?; } diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Fiuu.js b/cypress-tests/cypress/e2e/PaymentUtils/Fiuu.js index 86e2314c9279..24a445dd3c25 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Fiuu.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Fiuu.js @@ -13,6 +13,40 @@ const successfulThreeDSTestCardDetails = { card_holder_name: "joseph Doe", card_cvc: "123", }; + +const singleUseMandateData = { + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "125.0.0.1", + user_agent: "amet irure esse", + }, + }, + mandate_type: { + single_use: { + amount: 8000, + currency: "USD", + }, + }, +}; + +const multiUseMandateData = { + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "125.0.0.1", + user_agent: "amet irure esse", + }, + }, + mandate_type: { + multi_use: { + amount: 8000, + currency: "USD", + }, + }, +}; export const connectorDetails = { card_pm: { PaymentIntent: { @@ -184,5 +218,346 @@ export const connectorDetails = { }, }, }, + MandateSingleUse3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + currency: "USD", + mandate_data: singleUseMandateData, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + MandateSingleUse3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + currency: "USD", + mandate_data: singleUseMandateData, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + MandateSingleUseNo3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + mandate_data: singleUseMandateData, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + MandateSingleUseNo3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + mandate_data: singleUseMandateData, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + MandateMultiUseNo3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + mandate_data: multiUseMandateData, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + MandateMultiUseNo3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + mandate_data: multiUseMandateData, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + MandateMultiUse3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + currency: "USD", + mandate_data: multiUseMandateData, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + MandateMultiUse3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + currency: "USD", + mandate_data: multiUseMandateData, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + PaymentMethodIdMandateNo3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + mandate_data: null, + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "125.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + SaveCardUseNo3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + setup_future_usage: "on_session", + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "127.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + SaveCardUseNo3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + setup_future_usage: "on_session", + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "127.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + SaveCardUseNo3DSAutoCaptureOffSession: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + setup_future_usage: "off_session", + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "127.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + SaveCardUseNo3DSManualCaptureOffSession: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + setup_future_usage: "off_session", + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "127.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + SaveCardConfirmAutoCaptureOffSession: { + Request: { + setup_future_usage: "off_session", + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + SaveCardConfirmManualCaptureOffSession: { + Request: { + setup_future_usage: "off_session", + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + PaymentMethodIdMandateNo3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + mandate_data: null, + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "125.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + }, + }, + }, + PaymentMethodIdMandate3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + currency: "USD", + mandate_data: null, + authentication_type: "three_ds", + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "125.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + PaymentMethodIdMandate3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + mandate_data: null, + authentication_type: "three_ds", + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "125.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, }, }; diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index a6436e7f67c2..9b938e673d77 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -1843,7 +1843,11 @@ Cypress.Commands.add( const nextActionUrl = response.body.next_action.redirect_to_url; cy.log(nextActionUrl); } else if (response.body.authentication_type === "no_three_ds") { - expect(response.body.status).to.equal("succeeded"); + if (response.body.connector === "fiuu") { + expect(response.body.status).to.equal("failed"); + } else { + expect(response.body.status).to.equal("succeeded"); + } } else { throw new Error( `Invalid authentication type ${response.body.authentication_type}` @@ -2446,51 +2450,55 @@ Cypress.Commands.add( } ); -Cypress.Commands.add("updateConfig", (configType, configData, globalState, value) => { - const base_url = globalState.get("baseUrl"); - const merchant_id = globalState.get("merchantId"); - const api_key = globalState.get("adminApiKey"); - - let key; - let url; - let body; - - switch (configType) { - case 'autoRetry': - key = `should_call_gsm_${merchant_id}`; - url = `${base_url}/configs/${key}`; - body = { key: key, value: value }; - break; - case 'maxRetries': - key = `max_auto_retries_enabled_${merchant_id}`; - url = `${base_url}/configs/${key}`; - body = { key: key, value: value }; - break; - case 'stepUp': - key = `step_up_enabled_${merchant_id}`; - url = `${base_url}/configs/${key}`; - body = { key: key, value: value }; - break; - default: - throw new Error(`Invalid config type passed into the configs: "${api_key}: ${value}"`); - } - - cy.request({ - method: 'POST', - url: url, - headers: { - "Content-Type": "application/json", - "api-key": api_key, - }, - body: body, - failOnStatusCode: false, - }).then((response) => { - logRequestId(response.headers["x-request-id"]); - - if (response.status === 200) { - expect(response.body).to.have.property("key").to.equal(key); - expect(response.body).to.have.property("value").to.equal(value); +Cypress.Commands.add( + "updateConfig", + (configType, configData, globalState, value) => { + const base_url = globalState.get("baseUrl"); + const merchant_id = globalState.get("merchantId"); + const api_key = globalState.get("adminApiKey"); + + let key; + let url; + let body; + + switch (configType) { + case "autoRetry": + key = `should_call_gsm_${merchant_id}`; + url = `${base_url}/configs/${key}`; + body = { key: key, value: value }; + break; + case "maxRetries": + key = `max_auto_retries_enabled_${merchant_id}`; + url = `${base_url}/configs/${key}`; + body = { key: key, value: value }; + break; + case "stepUp": + key = `step_up_enabled_${merchant_id}`; + url = `${base_url}/configs/${key}`; + body = { key: key, value: value }; + break; + default: + throw new Error( + `Invalid config type passed into the configs: "${api_key}: ${value}"` + ); } - }); -}); + cy.request({ + method: "POST", + url: url, + headers: { + "Content-Type": "application/json", + "api-key": api_key, + }, + body: body, + failOnStatusCode: false, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + + if (response.status === 200) { + expect(response.body).to.have.property("key").to.equal(key); + expect(response.body).to.have.property("value").to.equal(value); + } + }); + } +); From b0d5c96b9918549663125681259a598698ec705c Mon Sep 17 00:00:00 2001 From: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com> Date: Fri, 25 Oct 2024 18:28:57 +0530 Subject: [PATCH 22/46] refactor(connector): [Paypal] Add support for passing shipping_cost in Payment request (#6423) --- .../src/router_request_types.rs | 11 ++- crates/router/src/connector/paypal.rs | 46 ++++++++++--- .../src/connector/paypal/transformers.rs | 68 +++++++++++++++---- .../router/src/core/payments/transformers.rs | 11 ++- crates/router/src/types.rs | 1 + .../router/src/types/api/verify_connector.rs | 1 + crates/router/tests/connectors/utils.rs | 1 + 7 files changed, 115 insertions(+), 24 deletions(-) diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs index d29672058f88..f958b8475e84 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types.rs @@ -71,17 +71,22 @@ pub struct PaymentsAuthorizeData { /// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference. pub merchant_order_reference_id: Option, pub integrity_object: Option, + pub shipping_cost: Option, } #[derive(Debug, Clone)] pub struct PaymentsPostSessionTokensData { + // amount here would include amount, surcharge_amount and shipping_cost pub amount: MinorUnit, + /// original amount sent by the merchant + pub order_amount: MinorUnit, pub currency: storage_enums::Currency, pub capture_method: Option, /// Merchant's identifier for the payment/invoice. This will be sent to the connector /// if the connector provides support to accept multiple reference ids. /// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference. pub merchant_order_reference_id: Option, + pub shipping_cost: Option, } #[derive(Debug, Clone, PartialEq)] @@ -833,10 +838,13 @@ pub struct PaymentsTaxCalculationData { #[derive(Debug, Clone, Default)] pub struct SdkPaymentsSessionUpdateData { pub order_tax_amount: MinorUnit, - pub net_amount: MinorUnit, + // amount here would include amount, surcharge_amount, order_tax_amount and shipping_cost pub amount: MinorUnit, + /// original amount sent by the merchant + pub order_amount: MinorUnit, pub currency: storage_enums::Currency, pub session_id: Option, + pub shipping_cost: Option, } #[derive(Debug, Clone)] @@ -862,4 +870,5 @@ pub struct SetupMandateRequestData { // MinorUnit for amount framework pub minor_amount: Option, + pub shipping_cost: Option, } diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 7b866971b011..24899a2c7d77 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -5,7 +5,7 @@ use base64::Engine; use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, - types::{AmountConvertor, StringMajorUnit, StringMajorUnitForConnector}, + types::{AmountConvertor, MinorUnit, StringMajorUnit, StringMajorUnitForConnector}, }; use diesel_models::enums; use error_stack::ResultExt; @@ -484,7 +484,8 @@ impl ConnectorIntegration CustomResult { let order_amount = connector_utils::convert_amount( self.amount_converter, - req.request.amount, + req.request.order_amount, req.request.currency, )?; let amount = connector_utils::convert_amount( self.amount_converter, - req.request.net_amount, + req.request.amount, req.request.currency, )?; let order_tax_amount = connector_utils::convert_amount( @@ -823,8 +840,14 @@ impl req.request.order_tax_amount, req.request.currency, )?; + let shipping_cost = connector_utils::convert_amount( + self.amount_converter, + req.request.shipping_cost.unwrap_or(MinorUnit::zero()), + req.request.currency, + )?; let connector_router_data = paypal::PaypalRouterData::try_from(( amount, + Some(shipping_cost), Some(order_tax_amount), Some(order_amount), req, @@ -915,7 +938,13 @@ impl ConnectorIntegration { pub amount: StringMajorUnit, + pub shipping_cost: Option, pub order_tax_amount: Option, pub order_amount: Option, pub router_data: T, @@ -38,20 +39,23 @@ impl StringMajorUnit, Option, Option, + Option, T, )> for PaypalRouterData { type Error = error_stack::Report; fn try_from( - (amount, order_tax_amount, order_amount, item): ( + (amount, shipping_cost, order_tax_amount, order_amount, item): ( StringMajorUnit, Option, Option, + Option, T, ), ) -> Result { Ok(Self { amount, + shipping_cost, order_tax_amount, order_amount, router_data: item, @@ -107,24 +111,47 @@ impl From<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for OrderReque value: item.amount.clone(), }, tax_total: None, + shipping: Some(OrderAmount { + currency_code: item.router_data.request.currency, + value: item + .shipping_cost + .clone() + .unwrap_or(StringMajorUnit::zero()), + }), }, } } } -impl From<&PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>> for OrderRequestAmount { - fn from(item: &PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>) -> Self { - Self { +impl TryFrom<&PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>> + for OrderRequestAmount +{ + type Error = error_stack::Report; + fn try_from( + item: &PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>, + ) -> Result { + Ok(Self { currency_code: item.router_data.request.currency, value: item.amount.clone(), breakdown: AmountBreakdown { item_total: OrderAmount { currency_code: item.router_data.request.currency, - value: item.amount.clone(), + value: item.order_amount.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "order_amount", + }, + )?, }, tax_total: None, + shipping: Some(OrderAmount { + currency_code: item.router_data.request.currency, + value: item + .shipping_cost + .clone() + .unwrap_or(StringMajorUnit::zero()), + }), }, - } + }) } } @@ -153,6 +180,13 @@ impl TryFrom<&PaypalRouterData<&types::SdkSessionUpdateRouterData>> for OrderReq }, )?, }), + shipping: Some(OrderAmount { + currency_code: item.router_data.request.currency, + value: item + .shipping_cost + .clone() + .unwrap_or(StringMajorUnit::zero()), + }), }, }) } @@ -162,6 +196,7 @@ impl TryFrom<&PaypalRouterData<&types::SdkSessionUpdateRouterData>> for OrderReq pub struct AmountBreakdown { item_total: OrderAmount, tax_total: Option, + shipping: Option, } #[derive(Default, Debug, Serialize, Eq, PartialEq)] @@ -206,9 +241,12 @@ impl From<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for ItemDetail } } -impl From<&PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>> for ItemDetails { - fn from(item: &PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>) -> Self { - Self { +impl TryFrom<&PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>> for ItemDetails { + type Error = error_stack::Report; + fn try_from( + item: &PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>, + ) -> Result { + Ok(Self { name: format!( "Payment for invoice {}", item.router_data.connector_request_reference_id @@ -216,10 +254,14 @@ impl From<&PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>> for It quantity: ORDER_QUANTITY, unit_amount: OrderAmount { currency_code: item.router_data.request.currency, - value: item.amount.clone(), + value: item.order_amount.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "order_amount", + }, + )?, }, tax: None, - } + }) } } @@ -549,12 +591,12 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsPostSessionTokensRouterData>> PaypalAuthType::try_from(&item.router_data.connector_auth_type)?; let payee = get_payee(&paypal_auth); - let amount = OrderRequestAmount::from(item); + let amount = OrderRequestAmount::try_from(item)?; let connector_request_reference_id = item.router_data.connector_request_reference_id.clone(); let shipping_address = ShippingAddress::from(item); - let item_details = vec![ItemDetails::from(item)]; + let item_details = vec![ItemDetails::try_from(item)?]; let purchase_units = vec![PurchaseUnitRequest { reference_id: Some(connector_request_reference_id.clone()), diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 66e5c996d34b..0ba89053031e 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -278,6 +278,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>( charges: None, merchant_order_reference_id: None, integrity_object: None, + shipping_cost: payment_data.payment_intent.amount_details.shipping_cost, }; // TODO: evaluate the fields in router data, if they are required or not @@ -2150,6 +2151,7 @@ impl TryFrom> for types::PaymentsAuthoriz .payment_intent .merchant_order_reference_id .clone(); + let shipping_cost = payment_data.payment_intent.shipping_cost; Ok(Self { payment_method_data: (payment_method_data.get_required_value("payment_method_data")?), @@ -2196,6 +2198,7 @@ impl TryFrom> for types::PaymentsAuthoriz charges, merchant_order_reference_id, integrity_object: None, + shipping_cost, }) } } @@ -2534,11 +2537,12 @@ impl TryFrom> for types::SdkPaymentsSessi + shipping_cost + surcharge_amount; Ok(Self { - net_amount, + amount: net_amount, order_tax_amount, currency: payment_data.currency, - amount: payment_data.payment_intent.amount, + order_amount: payment_data.payment_intent.amount, session_id: payment_data.session_id, + shipping_cost: payment_data.payment_intent.shipping_cost, }) } } @@ -2575,9 +2579,11 @@ impl TryFrom> for types::PaymentsPostSess .clone(); Ok(Self { amount, //need to change after we move to connector module + order_amount: payment_data.payment_intent.amount, currency: payment_data.currency, merchant_order_reference_id, capture_method: payment_data.payment_attempt.capture_method, + shipping_cost: payment_data.payment_intent.shipping_cost, }) } } @@ -2770,6 +2776,7 @@ impl TryFrom> for types::SetupMandateRequ | Some(RequestIncrementalAuthorization::Default) ), metadata: payment_data.payment_intent.metadata.clone().map(Into::into), + shipping_cost: payment_data.payment_intent.shipping_cost, }) } } diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 072e067f2c24..1f7c635da004 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -879,6 +879,7 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData { charges: None, // TODO: allow charges on mandates? merchant_order_reference_id: None, integrity_object: None, + shipping_cost: data.request.shipping_cost, } } } diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs index 6c92b1b801a9..052bd5823175 100644 --- a/crates/router/src/types/api/verify_connector.rs +++ b/crates/router/src/types/api/verify_connector.rs @@ -57,6 +57,7 @@ impl VerifyConnectorData { charges: None, merchant_order_reference_id: None, integrity_object: None, + shipping_cost: None, } } diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index 5acfd67c5470..eccade536c42 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -947,6 +947,7 @@ impl Default for PaymentAuthorizeType { charges: None, integrity_object: None, merchant_order_reference_id: None, + shipping_cost: None, }; Self(data) } From d58f706dc3fdd5ea277eeef6de9c224fe6097b46 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar <83278309+tsdk02@users.noreply.github.com> Date: Fri, 25 Oct 2024 18:29:25 +0530 Subject: [PATCH 23/46] fix(analytics): fix refund status filter on dashboard (#6431) --- crates/api_models/src/analytics/refunds.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/api_models/src/analytics/refunds.rs b/crates/api_models/src/analytics/refunds.rs index 8acb51e764c0..ef17387d1ea4 100644 --- a/crates/api_models/src/analytics/refunds.rs +++ b/crates/api_models/src/analytics/refunds.rs @@ -5,7 +5,7 @@ use std::{ use common_utils::id_type; -use crate::{enums::Currency, refunds::RefundStatus}; +use crate::enums::{Currency, RefundStatus}; #[derive( Clone, From 2807622ba671f77892a0fde42febbcffcb6c2238 Mon Sep 17 00:00:00 2001 From: Kiran Kumar <60121719+KiranKBR@users.noreply.github.com> Date: Fri, 25 Oct 2024 18:29:44 +0530 Subject: [PATCH 24/46] refactor(connector): added amount conversion framework for klarna and change type of amount to MinorUnit for OrderDetailsWithAmount (#4979) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: swangi-kumari Co-authored-by: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com> --- api-reference-v2/openapi_spec.json | 4 +- api-reference/openapi_spec.json | 4 +- crates/api_models/src/payments.rs | 2 +- crates/common_utils/src/types.rs | 17 +++++- .../src/connectors/taxjar.rs | 15 ++++- .../src/connectors/taxjar/transformers.rs | 21 +++---- .../src/connectors/zen/transformers.rs | 7 ++- .../src/connector/adyen/transformers.rs | 4 +- crates/router/src/connector/klarna.rs | 60 +++++++++++-------- .../src/connector/klarna/transformers.rs | 37 +++++------- .../connector/riskified/transformers/api.rs | 2 +- .../connector/signifyd/transformers/api.rs | 4 +- crates/router/src/core/payment_link.rs | 4 +- crates/router/src/core/payments/helpers.rs | 6 +- .../payments/operations/payment_confirm.rs | 2 +- .../payments/operations/payment_create.rs | 2 +- .../payments/operations/payment_update.rs | 2 +- .../router/src/core/payments/transformers.rs | 2 +- crates/router/src/types/api.rs | 4 +- crates/router/tests/connectors/payme.rs | 10 ++-- crates/router/tests/connectors/zen.rs | 8 +-- 21 files changed, 122 insertions(+), 95 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 9a406e9c7330..8ee962b0bbad 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -10977,9 +10977,7 @@ "minimum": 0 }, "amount": { - "type": "integer", - "format": "int64", - "description": "the amount per quantity of product" + "$ref": "#/components/schemas/MinorUnit" }, "requires_shipping": { "type": "boolean", diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 4b0f33da3e76..2f6f4fdf0bc7 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -14219,9 +14219,7 @@ "minimum": 0 }, "amount": { - "type": "integer", - "format": "int64", - "description": "the amount per quantity of product" + "$ref": "#/components/schemas/MinorUnit" }, "requires_shipping": { "type": "boolean", diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 61c7911170a3..4ab0158d01b9 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -5080,7 +5080,7 @@ pub struct OrderDetailsWithAmount { #[schema(example = 1)] pub quantity: u16, /// the amount per quantity of product - pub amount: i64, + pub amount: MinorUnit, // Does the order includes shipping pub requires_shipping: Option, /// The image URL of the product diff --git a/crates/common_utils/src/types.rs b/crates/common_utils/src/types.rs index 6a048e53147a..ce2be525989e 100644 --- a/crates/common_utils/src/types.rs +++ b/crates/common_utils/src/types.rs @@ -7,7 +7,8 @@ pub mod authentication; use std::{ borrow::Cow, fmt::Display, - ops::{Add, Sub}, + iter::Sum, + ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; @@ -483,6 +484,20 @@ impl Sub for MinorUnit { } } +impl Mul for MinorUnit { + type Output = Self; + + fn mul(self, a2: u16) -> Self::Output { + Self(self.0 * i64::from(a2)) + } +} + +impl Sum for MinorUnit { + fn sum>(iter: I) -> Self { + iter.fold(Self(0), |a, b| a + b) + } +} + /// Connector specific types to send #[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq)] diff --git a/crates/hyperswitch_connectors/src/connectors/taxjar.rs b/crates/hyperswitch_connectors/src/connectors/taxjar.rs index 56559b75abc6..c2466799cdf9 100644 --- a/crates/hyperswitch_connectors/src/connectors/taxjar.rs +++ b/crates/hyperswitch_connectors/src/connectors/taxjar.rs @@ -190,11 +190,22 @@ impl ConnectorIntegration { pub amount: FloatMajorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc. + pub order_amount: FloatMajorUnit, pub shipping: FloatMajorUnit, pub router_data: T, } -impl From<(FloatMajorUnit, FloatMajorUnit, T)> for TaxjarRouterData { - fn from((amount, shipping, item): (FloatMajorUnit, FloatMajorUnit, T)) -> Self { +impl From<(FloatMajorUnit, FloatMajorUnit, FloatMajorUnit, T)> for TaxjarRouterData { + fn from( + (amount, order_amount, shipping, item): (FloatMajorUnit, FloatMajorUnit, FloatMajorUnit, T), + ) -> Self { Self { amount, + order_amount, shipping, router_data: item, } @@ -49,7 +53,7 @@ pub struct LineItem { id: Option, quantity: Option, product_tax_code: Option, - unit_price: Option, + unit_price: Option, } #[derive(Default, Debug, Serialize, Eq, PartialEq)] @@ -69,8 +73,6 @@ impl TryFrom<&TaxjarRouterData<&types::PaymentsTaxCalculationRouterData>> item: &TaxjarRouterData<&types::PaymentsTaxCalculationRouterData>, ) -> Result { let request = &item.router_data.request; - let currency = item.router_data.request.currency; - let currency_unit = &api::CurrencyUnit::Base; let shipping = &item .router_data .request @@ -87,16 +89,11 @@ impl TryFrom<&TaxjarRouterData<&types::PaymentsTaxCalculationRouterData>> order_details .iter() .map(|line_item| { - let unit_price = utils::get_amount_as_f64( - currency_unit, - line_item.amount, - currency, - )?; Ok(LineItem { id: line_item.product_id.clone(), quantity: Some(line_item.quantity), product_tax_code: line_item.product_tax_code.clone(), - unit_price: Some(unit_price), + unit_price: Some(item.order_amount), }) }) .collect(); diff --git a/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs index d4a18a15182c..166e71304835 100644 --- a/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs @@ -624,11 +624,14 @@ fn get_item_object( name: data.product_name.clone(), quantity: data.quantity, price: utils::to_currency_base_unit_with_zero_decimal_check( - data.amount, + data.amount.get_amount_as_i64(), // This should be changed to MinorUnit when we implement amount conversion for this connector. Additionally, the function get_amount_as_i64() should be avoided in the future. item.request.currency, )?, line_amount_total: (f64::from(data.quantity) - * utils::to_currency_base_unit_asf64(data.amount, item.request.currency)?) + * utils::to_currency_base_unit_asf64( + data.amount.get_amount_as_i64(), // This should be changed to MinorUnit when we implement amount conversion for this connector. Additionally, the function get_amount_as_i64() should be avoided in the future. + item.request.currency, + )?) .to_string(), }) }) diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index 21c9c34409a7..bc75fd29c02c 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -1770,8 +1770,8 @@ fn get_line_items(item: &AdyenRouterData<&types::PaymentsAuthorizeRouterData>) - .iter() .enumerate() .map(|(i, data)| LineItem { - amount_including_tax: Some(MinorUnit::new(data.amount)), - amount_excluding_tax: Some(MinorUnit::new(data.amount)), + amount_including_tax: Some(data.amount), + amount_excluding_tax: Some(data.amount), description: Some(data.product_name.clone()), id: Some(format!("Items #{i}")), tax_amount: None, diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 0c362d26edfe..07bc6bd014c9 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -1,9 +1,11 @@ pub mod transformers; -use std::fmt::Debug; use api_models::enums; use base64::Engine; -use common_utils::request::RequestContent; +use common_utils::{ + request::RequestContent, + types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, +}; use error_stack::{report, ResultExt}; use masking::PeekInterface; use router_env::logger; @@ -29,8 +31,18 @@ use crate::{ utils::BytesExt, }; -#[derive(Debug, Clone)] -pub struct Klarna; +#[derive(Clone)] +pub struct Klarna { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Klarna { + pub fn new() -> &'static Self { + &Self { + amount_converter: &MinorUnitForConnector, + } + } +} impl ConnectorCommon for Klarna { fn id(&self) -> &'static str { @@ -215,12 +227,12 @@ impl req: &types::PaymentsSessionRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = klarna::KlarnaRouterData::try_from(( - &self.get_currency_unit(), + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_amount, req.request.currency, - req.request.amount, - req, - ))?; + )?; + let connector_router_data = klarna::KlarnaRouterData::from((amount, req)); let connector_req = klarna::KlarnaSessionRequest::try_from(&connector_router_data)?; // encode only for for urlencoded things. @@ -342,12 +354,12 @@ impl req: &types::PaymentsCaptureRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = klarna::KlarnaRouterData::try_from(( - &self.get_currency_unit(), + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_amount_to_capture, req.request.currency, - req.request.amount_to_capture, - req, - ))?; + )?; + let connector_router_data = klarna::KlarnaRouterData::from((amount, req)); let connector_req = klarna::KlarnaCaptureRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -670,12 +682,12 @@ impl req: &types::PaymentsAuthorizeRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = klarna::KlarnaRouterData::try_from(( - &self.get_currency_unit(), + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_amount, req.request.currency, - req.request.amount, - req, - ))?; + )?; + let connector_router_data = klarna::KlarnaRouterData::from((amount, req)); let connector_req = klarna::KlarnaPaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -847,12 +859,12 @@ impl services::ConnectorIntegration, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = klarna::KlarnaRouterData::try_from(( - &self.get_currency_unit(), + let amount = connector_utils::convert_amount( + self.amount_converter, + req.request.minor_refund_amount, req.request.currency, - req.request.refund_amount, - req, - ))?; + )?; + let connector_router_data = klarna::KlarnaRouterData::from((amount, req)); let connector_req = klarna::KlarnaRefundRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } diff --git a/crates/router/src/connector/klarna/transformers.rs b/crates/router/src/connector/klarna/transformers.rs index ea83e20d99d8..62a5cef0bcae 100644 --- a/crates/router/src/connector/klarna/transformers.rs +++ b/crates/router/src/connector/klarna/transformers.rs @@ -1,5 +1,5 @@ use api_models::payments; -use common_utils::pii; +use common_utils::{pii, types::MinorUnit}; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::router_data::KlarnaSdkResponse; use masking::{ExposeInterface, Secret}; @@ -15,25 +15,16 @@ use crate::{ #[derive(Debug, Serialize)] pub struct KlarnaRouterData { - amount: i64, + amount: MinorUnit, router_data: T, } -impl TryFrom<(&api::CurrencyUnit, enums::Currency, i64, T)> for KlarnaRouterData { - type Error = error_stack::Report; - - fn try_from( - (_currency_unit, _currency, amount, router_data): ( - &api::CurrencyUnit, - enums::Currency, - i64, - T, - ), - ) -> Result { - Ok(Self { +impl From<(MinorUnit, T)> for KlarnaRouterData { + fn from((amount, router_data): (MinorUnit, T)) -> Self { + Self { amount, router_data, - }) + } } } @@ -74,7 +65,7 @@ impl TryFrom<&Option> for KlarnaConnectorMetadataObject { pub struct KlarnaPaymentsRequest { auto_capture: bool, order_lines: Vec, - order_amount: i64, + order_amount: MinorUnit, purchase_country: enums::CountryAlpha2, purchase_currency: enums::Currency, merchant_reference1: Option, @@ -110,7 +101,7 @@ pub struct KlarnaSessionRequest { intent: KlarnaSessionIntent, purchase_country: enums::CountryAlpha2, purchase_currency: enums::Currency, - order_amount: i64, + order_amount: MinorUnit, order_lines: Vec, shipping_address: Option, } @@ -157,7 +148,7 @@ impl TryFrom<&KlarnaRouterData<&types::PaymentsSessionRouterData>> for KlarnaSes name: data.product_name.clone(), quantity: data.quantity, unit_price: data.amount, - total_amount: i64::from(data.quantity) * (data.amount), + total_amount: data.amount * data.quantity, }) .collect(), shipping_address: get_address_info(item.router_data.get_optional_shipping()) @@ -210,7 +201,7 @@ impl TryFrom<&KlarnaRouterData<&types::PaymentsAuthorizeRouterData>> for KlarnaP name: data.product_name.clone(), quantity: data.quantity, unit_price: data.amount, - total_amount: i64::from(data.quantity) * (data.amount), + total_amount: data.amount * data.quantity, }) .collect(), merchant_reference1: Some(item.router_data.connector_request_reference_id.clone()), @@ -294,8 +285,8 @@ impl TryFrom> pub struct OrderLines { name: String, quantity: u16, - unit_price: i64, - total_amount: i64, + unit_price: MinorUnit, + total_amount: MinorUnit, } #[derive(Debug, Serialize)] @@ -412,7 +403,7 @@ impl #[derive(Debug, Serialize)] pub struct KlarnaCaptureRequest { - captured_amount: i64, + captured_amount: MinorUnit, reference: Option, } @@ -490,7 +481,7 @@ impl #[derive(Default, Debug, Serialize)] pub struct KlarnaRefundRequest { - refunded_amount: i64, + refunded_amount: MinorUnit, reference: Option, } diff --git a/crates/router/src/connector/riskified/transformers/api.rs b/crates/router/src/connector/riskified/transformers/api.rs index 2e0ac3b00473..d2d38855dafc 100644 --- a/crates/router/src/connector/riskified/transformers/api.rs +++ b/crates/router/src/connector/riskified/transformers/api.rs @@ -163,7 +163,7 @@ impl TryFrom<&frm_types::FrmCheckoutRouterData> for RiskifiedPaymentsCheckoutReq .get_order_details()? .iter() .map(|order_detail| LineItem { - price: order_detail.amount, + price: order_detail.amount.get_amount_as_i64(), // This should be changed to MinorUnit when we implement amount conversion for this connector. Additionally, the function get_amount_as_i64() should be avoided in the future. quantity: i32::from(order_detail.quantity), title: order_detail.product_name.clone(), product_type: order_detail.product_type.clone(), diff --git a/crates/router/src/connector/signifyd/transformers/api.rs b/crates/router/src/connector/signifyd/transformers/api.rs index 6aeda8f8d470..eed0e9937b25 100644 --- a/crates/router/src/connector/signifyd/transformers/api.rs +++ b/crates/router/src/connector/signifyd/transformers/api.rs @@ -145,7 +145,7 @@ impl TryFrom<&frm_types::FrmSaleRouterData> for SignifydPaymentsSaleRequest { .iter() .map(|order_detail| Products { item_name: order_detail.product_name.clone(), - item_price: order_detail.amount, + item_price: order_detail.amount.get_amount_as_i64(), // This should be changed to MinorUnit when we implement amount conversion for this connector. Additionally, the function get_amount_as_i64() should be avoided in the future. item_quantity: i32::from(order_detail.quantity), item_id: order_detail.product_id.clone(), item_category: order_detail.category.clone(), @@ -382,7 +382,7 @@ impl TryFrom<&frm_types::FrmCheckoutRouterData> for SignifydPaymentsCheckoutRequ .iter() .map(|order_detail| Products { item_name: order_detail.product_name.clone(), - item_price: order_detail.amount, + item_price: order_detail.amount.get_amount_as_i64(), // This should be changed to MinorUnit when we implement amount conversion for this connector. Additionally, the function get_amount_as_i64() should be avoided in the future. item_quantity: i32::from(order_detail.quantity), item_id: order_detail.product_id.clone(), item_category: order_detail.category.clone(), diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs index ebc522b30ad9..09a2457197cb 100644 --- a/crates/router/src/core/payment_link.rs +++ b/crates/router/src/core/payment_link.rs @@ -11,7 +11,7 @@ use common_utils::{ DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SESSION_EXPIRY, }, ext_traits::{AsyncExt, OptionExt, ValueExt}, - types::{AmountConvertor, MinorUnit, StringMajorUnitForCore}, + types::{AmountConvertor, StringMajorUnitForCore}, }; use error_stack::{report, ResultExt}; use futures::future; @@ -547,7 +547,7 @@ fn validate_order_details( .clone_from(&order.product_img_link) }; order_details_amount_string.amount = required_conversion_type - .convert(MinorUnit::new(order.amount), currency) + .convert(order.amount, currency) .change_context(errors::ApiErrorResponse::AmountConversionFailed { amount_type: "StringMajorUnit", })?; diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 0de7683097b1..1f67e8066c9e 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -5445,13 +5445,13 @@ pub async fn get_unified_translation( } pub fn validate_order_details_amount( order_details: Vec, - amount: i64, + amount: MinorUnit, should_validate: bool, ) -> Result<(), errors::ApiErrorResponse> { if should_validate { - let total_order_details_amount: i64 = order_details + let total_order_details_amount: MinorUnit = order_details .iter() - .map(|order| order.amount * i64::from(order.quantity)) + .map(|order| order.amount * order.quantity) .sum(); if total_order_details_amount != amount { diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index 69cf19b09bbe..3a66094081ef 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -98,7 +98,7 @@ impl GetTracker, api::PaymentsRequest> for Pa if let Some(order_details) = &request.order_details { helpers::validate_order_details_amount( order_details.to_owned(), - payment_intent.amount.get_amount_as_i64(), + payment_intent.amount, false, )?; } diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 3bccce2783af..696bd1468e4b 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -338,7 +338,7 @@ impl GetTracker, api::PaymentsRequest> for Pa if let Some(order_details) = &request.order_details { helpers::validate_order_details_amount( order_details.to_owned(), - payment_intent.amount.get_amount_as_i64(), + payment_intent.amount, false, )?; } diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index 757370f0c95c..0b530d4d0541 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -82,7 +82,7 @@ impl GetTracker, api::PaymentsRequest> for Pa if let Some(order_details) = &request.order_details { helpers::validate_order_details_amount( order_details.to_owned(), - payment_intent.amount.get_amount_as_i64(), + payment_intent.amount, false, )?; } diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 0ba89053031e..fe217445eea3 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1974,7 +1974,7 @@ pub fn voucher_next_steps_check( } pub fn change_order_details_to_new_type( - order_amount: i64, + order_amount: MinorUnit, order_details: api_models::payments::OrderDetails, ) -> Option> { Some(vec![api_models::payments::OrderDetailsWithAmount { diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 198d400b8542..b85ae5bfab20 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -430,7 +430,9 @@ impl ConnectorData { enums::Connector::Itaubank => { Ok(ConnectorEnum::Old(Box::new(connector::Itaubank::new()))) } - enums::Connector::Klarna => Ok(ConnectorEnum::Old(Box::new(&connector::Klarna))), + enums::Connector::Klarna => { + Ok(ConnectorEnum::Old(Box::new(connector::Klarna::new()))) + } enums::Connector::Mollie => { Ok(ConnectorEnum::Old(Box::new(connector::Mollie::new()))) } diff --git a/crates/router/tests/connectors/payme.rs b/crates/router/tests/connectors/payme.rs index e85c57df622f..3b4cf5195f5e 100644 --- a/crates/router/tests/connectors/payme.rs +++ b/crates/router/tests/connectors/payme.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use api_models::payments::{Address, AddressDetails, OrderDetailsWithAmount}; -use common_utils::pii::Email; +use common_utils::{pii::Email, types::MinorUnit}; use masking::Secret; use router::types::{self, domain, storage::enums, PaymentAddress}; @@ -80,7 +80,7 @@ fn payment_method_details() -> Option { order_details: Some(vec![OrderDetailsWithAmount { product_name: "iphone 13".to_string(), quantity: 1, - amount: 1000, + amount: MinorUnit::new(1000), product_img_link: None, requires_shipping: None, product_id: None, @@ -381,7 +381,7 @@ async fn should_fail_payment_for_incorrect_cvc() { order_details: Some(vec![OrderDetailsWithAmount { product_name: "iphone 13".to_string(), quantity: 1, - amount: 100, + amount: MinorUnit::new(100), product_img_link: None, requires_shipping: None, product_id: None, @@ -421,7 +421,7 @@ async fn should_fail_payment_for_invalid_exp_month() { order_details: Some(vec![OrderDetailsWithAmount { product_name: "iphone 13".to_string(), quantity: 1, - amount: 100, + amount: MinorUnit::new(100), product_img_link: None, requires_shipping: None, product_id: None, @@ -461,7 +461,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { order_details: Some(vec![OrderDetailsWithAmount { product_name: "iphone 13".to_string(), quantity: 1, - amount: 100, + amount: MinorUnit::new(100), product_img_link: None, requires_shipping: None, product_id: None, diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rs index 20948a90c6d3..da83bdc7d415 100644 --- a/crates/router/tests/connectors/zen.rs +++ b/crates/router/tests/connectors/zen.rs @@ -325,7 +325,7 @@ async fn should_fail_payment_for_incorrect_card_number() { order_details: Some(vec![OrderDetailsWithAmount { product_name: "test".to_string(), quantity: 1, - amount: 1000, + amount: MinorUnit::new(1000), product_img_link: None, requires_shipping: None, product_id: None, @@ -368,7 +368,7 @@ async fn should_fail_payment_for_incorrect_cvc() { order_details: Some(vec![OrderDetailsWithAmount { product_name: "test".to_string(), quantity: 1, - amount: 1000, + amount: MinorUnit::new(1000), product_img_link: None, requires_shipping: None, product_id: None, @@ -411,7 +411,7 @@ async fn should_fail_payment_for_invalid_exp_month() { order_details: Some(vec![OrderDetailsWithAmount { product_name: "test".to_string(), quantity: 1, - amount: 1000, + amount: MinorUnit::new(1000), product_img_link: None, requires_shipping: None, product_id: None, @@ -454,7 +454,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { order_details: Some(vec![OrderDetailsWithAmount { product_name: "test".to_string(), quantity: 1, - amount: 1000, + amount: MinorUnit::new(1000), product_img_link: None, requires_shipping: None, product_id: None, From 53075792b372a7ca574b94058c7d72033c014bc8 Mon Sep 17 00:00:00 2001 From: Prasunna Soppa <70575890+prasunna09@users.noreply.github.com> Date: Fri, 25 Oct 2024 18:30:50 +0530 Subject: [PATCH 25/46] fix(router): Update request body for migrate-batch api (#6429) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/payment_methods.rs | 78 ++++++++++++------- .../src/core/payment_methods/migration.rs | 58 +++++++++----- crates/router/src/routes/payment_methods.rs | 15 ++-- 3 files changed, 100 insertions(+), 51 deletions(-) diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index d5255b5e8c5d..47460e73b713 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -6,6 +6,8 @@ use cards::CardNumber; use common_utils::{ consts::SURCHARGE_PERCENTAGE_PRECISION_LENGTH, crypto::OptionalEncryptableName, + errors, + ext_traits::OptionExt, id_type, link_utils, pii, types::{MinorUnit, Percentage, Surcharge}, }; @@ -2065,16 +2067,16 @@ pub struct PaymentMethodRecord { pub email: Option, pub phone: Option>, pub phone_country_code: Option, - pub merchant_id: id_type::MerchantId, + pub merchant_id: Option, pub payment_method: Option, pub payment_method_type: Option, pub nick_name: masking::Secret, - pub payment_instrument_id: masking::Secret, + pub payment_instrument_id: Option>, pub card_number_masked: masking::Secret, pub card_expiry_month: masking::Secret, pub card_expiry_year: masking::Secret, pub card_scheme: Option, - pub original_transaction_id: String, + pub original_transaction_id: Option, pub billing_address_zip: masking::Secret, pub billing_address_state: masking::Secret, pub billing_address_first_name: masking::Secret, @@ -2085,7 +2087,7 @@ pub struct PaymentMethodRecord { pub billing_address_line2: Option>, pub billing_address_line3: Option>, pub raw_card_number: Option>, - pub merchant_connector_id: id_type::MerchantConnectorAccountId, + pub merchant_connector_id: Option, pub original_transaction_amount: Option, pub original_transaction_currency: Option, pub line_number: Option, @@ -2171,31 +2173,54 @@ impl From for PaymentMethodMigrationResponse } } -impl From for PaymentMethodMigrate { - fn from(record: PaymentMethodRecord) -> Self { - let mut mandate_reference = HashMap::new(); - mandate_reference.insert( - record.merchant_connector_id, - PaymentsMandateReferenceRecord { - connector_mandate_id: record.payment_instrument_id.peek().to_string(), - payment_method_type: record.payment_method_type, - original_payment_authorized_amount: record.original_transaction_amount, - original_payment_authorized_currency: record.original_transaction_currency, - }, - ); - Self { - merchant_id: record.merchant_id, +impl + TryFrom<( + PaymentMethodRecord, + id_type::MerchantId, + Option, + )> for PaymentMethodMigrate +{ + type Error = error_stack::Report; + fn try_from( + item: ( + PaymentMethodRecord, + id_type::MerchantId, + Option, + ), + ) -> Result { + let (record, merchant_id, mca_id) = item; + + // if payment instrument id is present then only construct this + let connector_mandate_details = if record.payment_instrument_id.is_some() { + Some(PaymentsMandateReference(HashMap::from([( + mca_id.get_required_value("merchant_connector_id")?, + PaymentsMandateReferenceRecord { + connector_mandate_id: record + .payment_instrument_id + .get_required_value("payment_instrument_id")? + .peek() + .to_string(), + payment_method_type: record.payment_method_type, + original_payment_authorized_amount: record.original_transaction_amount, + original_payment_authorized_currency: record.original_transaction_currency, + }, + )]))) + } else { + None + }; + Ok(Self { + merchant_id, customer_id: Some(record.customer_id), card: Some(MigrateCardDetail { card_number: record.raw_card_number.unwrap_or(record.card_number_masked), card_exp_month: record.card_expiry_month, card_exp_year: record.card_expiry_year, - card_holder_name: record.name, + card_holder_name: record.name.clone(), card_network: None, card_type: None, card_issuer: None, card_issuing_country: None, - nick_name: Some(record.nick_name), + nick_name: Some(record.nick_name.clone()), }), payment_method: record.payment_method, payment_method_type: record.payment_method_type, @@ -2218,7 +2243,7 @@ impl From for PaymentMethodMigrate { }), email: record.email, }), - connector_mandate_details: Some(PaymentsMandateReference(mandate_reference)), + connector_mandate_details, metadata: None, payment_method_issuer_code: None, card_network: None, @@ -2227,17 +2252,18 @@ impl From for PaymentMethodMigrate { #[cfg(feature = "payouts")] wallet: None, payment_method_data: None, - network_transaction_id: record.original_transaction_id.into(), - } + network_transaction_id: record.original_transaction_id, + }) } } #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] -impl From for customers::CustomerRequest { - fn from(record: PaymentMethodRecord) -> Self { +impl From<(PaymentMethodRecord, id_type::MerchantId)> for customers::CustomerRequest { + fn from(value: (PaymentMethodRecord, id_type::MerchantId)) -> Self { + let (record, merchant_id) = value; Self { customer_id: Some(record.customer_id), - merchant_id: record.merchant_id, + merchant_id, name: record.name, email: record.email, phone: record.phone, diff --git a/crates/router/src/core/payment_methods/migration.rs b/crates/router/src/core/payment_methods/migration.rs index d548d03ab47c..af9e01d253c8 100644 --- a/crates/router/src/core/payment_methods/migration.rs +++ b/crates/router/src/core/payment_methods/migration.rs @@ -1,6 +1,7 @@ -use actix_multipart::form::{bytes::Bytes, MultipartForm}; +use actix_multipart::form::{bytes::Bytes, text::Text, MultipartForm}; use api_models::payment_methods::{PaymentMethodMigrationResponse, PaymentMethodRecord}; use csv::Reader; +use error_stack::ResultExt; use rdkafka::message::ToBytes; use crate::{ @@ -15,12 +16,32 @@ pub async fn migrate_payment_methods( merchant_id: &common_utils::id_type::MerchantId, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, + mca_id: Option, ) -> errors::RouterResponse> { let mut result = Vec::new(); for record in payment_methods { + let req = api::PaymentMethodMigrate::try_from(( + record.clone(), + merchant_id.clone(), + mca_id.clone(), + )) + .map_err(|err| errors::ApiErrorResponse::InvalidRequestData { + message: format!("error: {:?}", err), + }) + .attach_printable("record deserialization failed"); + match req { + Ok(_) => (), + Err(e) => { + result.push(PaymentMethodMigrationResponse::from(( + Err(e.to_string()), + record, + ))); + continue; + } + }; let res = migrate_payment_method( state.clone(), - api::PaymentMethodMigrate::from(record.clone()), + req?, merchant_id, merchant_account, key_store, @@ -42,6 +63,10 @@ pub async fn migrate_payment_methods( pub struct PaymentMethodsMigrateForm { #[multipart(limit = "1MB")] pub file: Bytes, + + pub merchant_id: Text, + + pub merchant_connector_id: Text>, } fn parse_csv(data: &[u8]) -> csv::Result> { @@ -58,26 +83,19 @@ fn parse_csv(data: &[u8]) -> csv::Result> { } pub fn get_payment_method_records( form: PaymentMethodsMigrateForm, -) -> Result<(common_utils::id_type::MerchantId, Vec), errors::ApiErrorResponse> -{ +) -> Result< + ( + common_utils::id_type::MerchantId, + Vec, + Option, + ), + errors::ApiErrorResponse, +> { match parse_csv(form.file.data.to_bytes()) { Ok(records) => { - if let Some(first_record) = records.first() { - if records - .iter() - .all(|merchant_id| merchant_id.merchant_id == first_record.merchant_id) - { - Ok((first_record.merchant_id.clone(), records)) - } else { - Err(errors::ApiErrorResponse::PreconditionFailed { - message: "Only one merchant id can be updated at a time".to_string(), - }) - } - } else { - Err(errors::ApiErrorResponse::PreconditionFailed { - message: "No records found".to_string(), - }) - } + let merchant_id = form.merchant_id.clone(); + let mca_id = form.merchant_connector_id.clone(); + Ok((merchant_id.clone(), records, mca_id)) } Err(e) => Err(errors::ApiErrorResponse::PreconditionFailed { message: e.to_string(), diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs index 0dbddbef77bf..3b47a06cf7c6 100644 --- a/crates/router/src/routes/payment_methods.rs +++ b/crates/router/src/routes/payment_methods.rs @@ -331,10 +331,13 @@ pub async fn migrate_payment_methods( MultipartForm(form): MultipartForm, ) -> HttpResponse { let flow = Flow::PaymentMethodsMigrate; - let (merchant_id, records) = match migration::get_payment_method_records(form) { - Ok((merchant_id, records)) => (merchant_id, records), - Err(e) => return api::log_and_return_error_response(e.into()), - }; + let (merchant_id, records, merchant_connector_id) = + match migration::get_payment_method_records(form) { + Ok((merchant_id, records, merchant_connector_id)) => { + (merchant_id, records, merchant_connector_id) + } + Err(e) => return api::log_and_return_error_response(e.into()), + }; Box::pin(api::server_wrap( flow, state, @@ -342,6 +345,7 @@ pub async fn migrate_payment_methods( records, |state, _, req, _| { let merchant_id = merchant_id.clone(); + let merchant_connector_id = merchant_connector_id.clone(); async move { let (key_store, merchant_account) = get_merchant_account(&state, &merchant_id).await?; @@ -349,7 +353,7 @@ pub async fn migrate_payment_methods( customers::migrate_customers( state.clone(), req.iter() - .map(|e| CustomerRequest::from(e.clone())) + .map(|e| CustomerRequest::from((e.clone(), merchant_id.clone()))) .collect(), merchant_account.clone(), key_store.clone(), @@ -362,6 +366,7 @@ pub async fn migrate_payment_methods( &merchant_id, &merchant_account, &key_store, + merchant_connector_id, )) .await } From a3ea62f88524a360b666cacfbc1cf239f6be8797 Mon Sep 17 00:00:00 2001 From: DEEPANSHU BANSAL <41580413+deepanshu-iiitu@users.noreply.github.com> Date: Fri, 25 Oct 2024 18:31:31 +0530 Subject: [PATCH 26/46] feat: Add amount, currency and email to paze session response (#6412) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- api-reference-v2/openapi_spec.json | 19 ++++++++++++++++++- api-reference/openapi_spec.json | 19 ++++++++++++++++++- crates/api_models/src/payments.rs | 9 +++++++++ .../src/router_request_types.rs | 2 +- .../src/core/payments/flows/session_flow.rs | 11 ++++++++++- .../router/src/core/payments/transformers.rs | 2 ++ 6 files changed, 58 insertions(+), 4 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 8ee962b0bbad..aa6c45d10aa7 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -16200,7 +16200,9 @@ "required": [ "client_id", "client_name", - "client_profile_id" + "client_profile_id", + "transaction_currency_code", + "transaction_amount" ], "properties": { "client_id": { @@ -16214,6 +16216,21 @@ "client_profile_id": { "type": "string", "description": "Paze Client Profile ID" + }, + "transaction_currency_code": { + "$ref": "#/components/schemas/Currency" + }, + "transaction_amount": { + "type": "string", + "description": "The transaction amount", + "example": "38.02" + }, + "email_address": { + "type": "string", + "description": "Email Address", + "example": "johntest@test.com", + "nullable": true, + "maxLength": 255 } } }, diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 2f6f4fdf0bc7..7e7df8ce1d5b 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -20986,7 +20986,9 @@ "required": [ "client_id", "client_name", - "client_profile_id" + "client_profile_id", + "transaction_currency_code", + "transaction_amount" ], "properties": { "client_id": { @@ -21000,6 +21002,21 @@ "client_profile_id": { "type": "string", "description": "Paze Client Profile ID" + }, + "transaction_currency_code": { + "$ref": "#/components/schemas/Currency" + }, + "transaction_amount": { + "type": "string", + "description": "The transaction amount", + "example": "38.02" + }, + "email_address": { + "type": "string", + "description": "Email Address", + "example": "johntest@test.com", + "nullable": true, + "maxLength": 255 } } }, diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 4ab0158d01b9..2e31c0ba258c 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -5578,6 +5578,15 @@ pub struct PazeSessionTokenResponse { pub client_name: String, /// Paze Client Profile ID pub client_profile_id: String, + /// The transaction currency code + #[schema(value_type = Currency, example = "USD")] + pub transaction_currency_code: api_enums::Currency, + /// The transaction amount + #[schema(value_type = String, example = "38.02")] + pub transaction_amount: StringMajorUnit, + /// Email Address + #[schema(max_length = 255, value_type = Option, example = "johntest@test.com")] + pub email_address: Option, } #[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)] diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs index f958b8475e84..5878a28f40d7 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types.rs @@ -821,7 +821,7 @@ pub struct PaymentsSessionData { pub country: Option, pub surcharge_details: Option, pub order_details: Option>, - + pub email: Option, // Minor Unit amount for amount frame work pub minor_amount: MinorUnit, } diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs index 736ffdd7b8b4..ba8054696a11 100644 --- a/crates/router/src/core/payments/flows/session_flow.rs +++ b/crates/router/src/core/payments/flows/session_flow.rs @@ -511,7 +511,13 @@ fn create_paze_session_token( field_name: "connector_wallets_details".to_string(), expected_format: "paze_metadata_format".to_string(), })?; - + let required_amount_type = StringMajorUnitForConnector; + let transaction_currency_code = router_data.request.currency; + let transaction_amount = required_amount_type + .convert(router_data.request.minor_amount, transaction_currency_code) + .change_context(errors::ApiErrorResponse::PreconditionFailed { + message: "Failed to convert amount to string major unit for paze".to_string(), + })?; Ok(types::PaymentsSessionRouterData { response: Ok(types::PaymentsResponseData::SessionResponse { session_token: payment_types::SessionToken::Paze(Box::new( @@ -519,6 +525,9 @@ fn create_paze_session_token( client_id: paze_wallet_details.data.client_id, client_name: paze_wallet_details.data.client_name, client_profile_id: paze_wallet_details.data.client_profile_id, + transaction_currency_code, + transaction_amount, + email_address: router_data.request.email.clone(), }, )), }), diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index fe217445eea3..c623ad86e647 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -2650,6 +2650,7 @@ impl TryFrom> for types::PaymentsSessionD ), order_details, surcharge_details: payment_data.surcharge_details, + email: payment_data.email, }) } } @@ -2709,6 +2710,7 @@ impl TryFrom> for types::PaymentsSessionD }, ), order_details, + email: payment_data.email, surcharge_details: payment_data.surcharge_details, }) } From 04c969866816be286720377e73982e21a3302ba9 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 00:26:27 +0000 Subject: [PATCH 27/46] chore(version): 2024.10.28.0 --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38907d9add97..ca6cf85f42b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,37 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.10.28.0 + +### Features + +- **connector:** + - [Rapyd] Use connector_response_reference_id ([#6302](https://github.com/juspay/hyperswitch/pull/6302)) ([`a845d46`](https://github.com/juspay/hyperswitch/commit/a845d46899d87ba7f3ca4386719c1934ce3da90e)) + - [Rapyd] Use connector_request_reference_id ([#6296](https://github.com/juspay/hyperswitch/pull/6296)) ([`4105d98`](https://github.com/juspay/hyperswitch/commit/4105d98d7aca885f9c622d5b56c6dbacb85a688b)) + - [Novalnet] Integrate Applepay wallet token flow ([#6409](https://github.com/juspay/hyperswitch/pull/6409)) ([`1d24b04`](https://github.com/juspay/hyperswitch/commit/1d24b04596e6d2f7c44b93501d56fc4fb950bd3b)) + - [PayU] Use connector_request_reference_id ([#6360](https://github.com/juspay/hyperswitch/pull/6360)) ([`acd1530`](https://github.com/juspay/hyperswitch/commit/acd153042062dd14d5e6e266fdc73d82b78213fe)) + - [Fiuu] Add support for cards recurring payments ([#6361](https://github.com/juspay/hyperswitch/pull/6361)) ([`4647a2f`](https://github.com/juspay/hyperswitch/commit/4647a2f6aece6b9479395fa3622b51b50d3091ee)) +- **euclid:** Add dynamic routing in core flows ([#6333](https://github.com/juspay/hyperswitch/pull/6333)) ([`ce732db`](https://github.com/juspay/hyperswitch/commit/ce732db9b2f98924a2b1d44ea5eb1000b6cbb498)) +- **router:** Move organization_id to request header from request body for v2 ([#6277](https://github.com/juspay/hyperswitch/pull/6277)) ([`aaac9aa`](https://github.com/juspay/hyperswitch/commit/aaac9aa97d1b00d50bec4e02efb0658956463398)) +- **sample_data:** Generate random disputes for sample data ([#6341](https://github.com/juspay/hyperswitch/pull/6341)) ([`e36ea18`](https://github.com/juspay/hyperswitch/commit/e36ea184ae6d1363fb1af55c790162df9f8b451c)) +- Add amount, currency and email to paze session response ([#6412](https://github.com/juspay/hyperswitch/pull/6412)) ([`a3ea62f`](https://github.com/juspay/hyperswitch/commit/a3ea62f88524a360b666cacfbc1cf239f6be8797)) + +### Bug Fixes + +- **analytics:** Fix refund status filter on dashboard ([#6431](https://github.com/juspay/hyperswitch/pull/6431)) ([`d58f706`](https://github.com/juspay/hyperswitch/commit/d58f706dc3fdd5ea277eeef6de9c224fe6097b46)) +- **router:** Update request body for migrate-batch api ([#6429](https://github.com/juspay/hyperswitch/pull/6429)) ([`5307579`](https://github.com/juspay/hyperswitch/commit/53075792b372a7ca574b94058c7d72033c014bc8)) + +### Refactors + +- **connector:** + - Add amount conversion framework to tsys ([#6282](https://github.com/juspay/hyperswitch/pull/6282)) ([`90765be`](https://github.com/juspay/hyperswitch/commit/90765bece1b12b208192e7ae4d54f4c70a301cea)) + - [Paypal] Add support for passing shipping_cost in Payment request ([#6423](https://github.com/juspay/hyperswitch/pull/6423)) ([`b0d5c96`](https://github.com/juspay/hyperswitch/commit/b0d5c96b9918549663125681259a598698ec705c)) + - Added amount conversion framework for klarna and change type of amount to MinorUnit for OrderDetailsWithAmount ([#4979](https://github.com/juspay/hyperswitch/pull/4979)) ([`2807622`](https://github.com/juspay/hyperswitch/commit/2807622ba671f77892a0fde42febbcffcb6c2238)) + +**Full Changelog:** [`2024.10.25.0...2024.10.28.0`](https://github.com/juspay/hyperswitch/compare/2024.10.25.0...2024.10.28.0) + +- - - + ## 2024.10.25.0 ### Features From cee84cdcfd6c323e8db80163f462d8e286aae600 Mon Sep 17 00:00:00 2001 From: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:06:20 +0530 Subject: [PATCH 28/46] fix(core): fix setup mandate payments to store connector mandate details (#6446) --- .../payments/operations/payment_response.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index a18996ccc3b7..2c09ffd8ff20 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -1085,6 +1085,34 @@ impl PostUpdateTracker, types::SetupMandateRequestDa )) .await?; + payment_data.payment_method_info = if let Some(payment_method_id) = &payment_method_id { + match state + .store + .find_payment_method( + &(state.into()), + key_store, + payment_method_id, + merchant_account.storage_scheme, + ) + .await + { + Ok(payment_method) => Some(payment_method), + Err(error) => { + if error.current_context().is_db_not_found() { + logger::info!("Payment Method not found in db {:?}", error); + None + } else { + Err(error) + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Error retrieving payment method from db") + .map_err(|err| logger::error!(payment_method_retrieve=?err)) + .ok() + } + } + } + } else { + None + }; let mandate_id = mandate::mandate_procedure( state, resp, From cd6265887adf7c17136e9fb608e97e6dd535e360 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:14:36 +0000 Subject: [PATCH 29/46] chore(version): 2024.10.28.1 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6cf85f42b5..e6f92b8cf864 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.10.28.1 + +### Bug Fixes + +- **core:** Fix setup mandate payments to store connector mandate details ([#6446](https://github.com/juspay/hyperswitch/pull/6446)) ([`cee84cd`](https://github.com/juspay/hyperswitch/commit/cee84cdcfd6c323e8db80163f462d8e286aae600)) + +**Full Changelog:** [`2024.10.28.0...2024.10.28.1`](https://github.com/juspay/hyperswitch/compare/2024.10.28.0...2024.10.28.1) + +- - - + ## 2024.10.28.0 ### Features From e33340e70b59e9e4f18e92fc27d8c90b3df5768b Mon Sep 17 00:00:00 2001 From: Debarati Ghatak <88573135+cookieg13@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:39:29 +0530 Subject: [PATCH 30/46] fix(connector): [Novalnet] Remove webhook placeholder connector config (#6451) --- crates/connector_configs/toml/development.toml | 1 - crates/connector_configs/toml/production.toml | 1 - crates/connector_configs/toml/sandbox.toml | 1 - 3 files changed, 3 deletions(-) diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index 8cb42f33a26d..886b2dd7ee7c 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -2301,7 +2301,6 @@ key1="Payment Access Key" api_secret="Tariff ID" [novalnet.connector_webhook_details] merchant_secret="Source verification key" -placeholder="Enter Payment Access Key" [[novalnet.metadata.google_pay]] name="merchant_name" label="Google Pay Merchant Name" diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml index b4b12318a6f2..cc501a4c101e 100644 --- a/crates/connector_configs/toml/production.toml +++ b/crates/connector_configs/toml/production.toml @@ -1794,7 +1794,6 @@ key1="Payment Access Key" api_secret="Tariff ID" [novalnet.connector_webhook_details] merchant_secret="Source verification key" -placeholder="Enter Payment Access Key" [[novalnet.metadata.google_pay]] name="merchant_name" label="Google Pay Merchant Name" diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml index 7e83effb7a8b..d767417a043c 100644 --- a/crates/connector_configs/toml/sandbox.toml +++ b/crates/connector_configs/toml/sandbox.toml @@ -2268,7 +2268,6 @@ key1="Payment Access Key" api_secret="Tariff ID" [novalnet.connector_webhook_details] merchant_secret="Source verification key" -placeholder="Enter Payment Access Key" [[novalnet.metadata.google_pay]] name="merchant_name" label="Google Pay Merchant Name" From 925e4240e4ad6da1d243769b184842c0d8251a7d Mon Sep 17 00:00:00 2001 From: chikke srujan <121822803+srujanchikke@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:46:48 +0530 Subject: [PATCH 31/46] fix(connector): [Adyen] Add MYR currency config (#6442) Co-authored-by: Chikke Srujan --- config/deployments/integration_test.toml | 2 +- config/deployments/production.toml | 2 +- config/deployments/sandbox.toml | 2 +- config/development.toml | 2 +- config/docker_compose.toml | 66 ++++++++++++++++++------ crates/router/src/consts.rs | 2 +- 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 651e2c25b648..780af87383f9 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -196,7 +196,7 @@ alfamart = { country = "ID", currency = "IDR" } ali_pay = { country = "AU,JP,HK,SG,MY,TH,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,FI,RO,MT,SI,GR,PT,IE,IT,CA,US", currency = "USD,EUR,GBP,JPY,AUD,SGD,CHF,SEK,NOK,NZD,THB,HKD,CAD" } ali_pay_hk = { country = "HK", currency = "HKD" } alma = { country = "FR", currency = "EUR" } -apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD" } +apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD,MYR" } atome = { country = "MY,SG", currency = "MYR,SGD" } bacs = { country = "GB", currency = "GBP" } bancontact_card = { country = "BE", currency = "EUR" } diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 525033f06f2b..430475b9e5c1 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -209,7 +209,7 @@ alfamart = { country = "ID", currency = "IDR" } ali_pay = { country = "AU,JP,HK,SG,MY,TH,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,FI,RO,MT,SI,GR,PT,IE,IT,CA,US", currency = "USD,EUR,GBP,JPY,AUD,SGD,CHF,SEK,NOK,NZD,THB,HKD,CAD" } ali_pay_hk = { country = "HK", currency = "HKD" } alma = { country = "FR", currency = "EUR" } -apple_pay = { country = "AE,AM,AR,AT,AU,AZ,BE,BG,BH,BR,BY,CA,CH,CN,CO,CR,CY,CZ,DE,DK,EE,ES,FI,FO,FR,GB,GE,GG,GL,GR,HK,HR,HU,IE,IL,IM,IS,IT,JE,JO,JP,KW,KZ,LI,LT,LU,LV,MC,MD,ME,MO,MT,MX,MY,NL,NO,NZ,PE,PL,PS,PT,QA,RO,RS,SA,SE,SG,SI,SK,SM,TW,UA,GB,UM,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD" } +apple_pay = { country = "AE,AM,AR,AT,AU,AZ,BE,BG,BH,BR,BY,CA,CH,CN,CO,CR,CY,CZ,DE,DK,EE,ES,FI,FO,FR,GB,GE,GG,GL,GR,HK,HR,HU,IE,IL,IM,IS,IT,JE,JO,JP,KW,KZ,LI,LT,LU,LV,MC,MD,ME,MO,MT,MX,MY,NL,NO,NZ,PE,PL,PS,PT,QA,RO,RS,SA,SE,SG,SI,SK,SM,TW,UA,GB,UM,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD,MYR" } atome = { country = "MY,SG", currency = "MYR,SGD" } bacs = { country = "GB", currency = "GBP" } bancontact_card = { country = "BE", currency = "EUR" } diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 422095c65fb6..99d4253aea3d 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -212,7 +212,7 @@ alfamart = { country = "ID", currency = "IDR" } ali_pay = { country = "AU,JP,HK,SG,MY,TH,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,FI,RO,MT,SI,GR,PT,IE,IT,CA,US", currency = "USD,EUR,GBP,JPY,AUD,SGD,CHF,SEK,NOK,NZD,THB,HKD,CAD" } ali_pay_hk = { country = "HK", currency = "HKD" } alma = { country = "FR", currency = "EUR" } -apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD" } +apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD,MYR" } atome = { country = "MY,SG", currency = "MYR,SGD" } bacs = { country = "GB", currency = "GBP" } bancontact_card = { country = "BE", currency = "EUR" } diff --git a/config/development.toml b/config/development.toml index d32c36101323..43fff373fb4d 100644 --- a/config/development.toml +++ b/config/development.toml @@ -383,7 +383,7 @@ open_banking_pis = {currency = "EUR,GBP"} [pm_filters.adyen] google_pay = { country = "AU,NZ,JP,HK,SG,MY,TH,VN,BH,AE,KW,BR,ES,GB,SE,NO,SK,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,RO,HR,LI,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,TR,IS,CA,US", currency = "AED,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BMD,BND,BOB,BRL,BSD,BWP,BYN,BZD,CAD,CHF,CLP,CNY,COP,CRC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HTG,HUF,IDR,ILS,INR,IQD,JMD,JOD,JPY,KES,KGS,KHR,KMF,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LYD,MAD,MDL,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SEK,SGD,SHP,SLE,SOS,SRD,STN,SVC,SZL,THB,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW" } -apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD" } +apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD,MYR" } paypal = { country = "AU,NZ,CN,JP,HK,MY,TH,KR,PH,ID,AE,KW,BR,ES,GB,SE,NO,SK,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,UA,MT,SI,GI,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,BRL,CAD,CZK,DKK,EUR,HKD,HUF,INR,JPY,MYR,MXN,NZD,NOK,PHP,PLN,RUB,GBP,SGD,SEK,CHF,THB,USD" } mobile_pay = { country = "DK,FI", currency = "DKK,SEK,NOK,EUR" } ali_pay = { country = "AU,JP,HK,SG,MY,TH,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,FI,RO,MT,SI,GR,PT,IE,IT,CA,US", currency = "USD,EUR,GBP,JPY,AUD,SGD,CHF,SEK,NOK,NZD,THB,HKD,CAD" } diff --git a/config/docker_compose.toml b/config/docker_compose.toml index dde0902af912..38176875c319 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -348,34 +348,68 @@ discord_invite_url = "https://discord.gg/wJZ7DVW8mm" payout_eligibility = true [pm_filters.adyen] -online_banking_fpx = { country = "MY", currency = "MYR" } -online_banking_thailand = { country = "TH", currency = "THB" } -touch_n_go = { country = "MY", currency = "MYR" } +ach = { country = "US", currency = "USD" } +affirm = { country = "US", currency = "USD" } +afterpay_clearpay = { country = "US,CA,GB,AU,NZ", currency = "GBP,AUD,NZD,CAD,USD" } +alfamart = { country = "ID", currency = "IDR" } +ali_pay = { country = "AU,JP,HK,SG,MY,TH,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,FI,RO,MT,SI,GR,PT,IE,IT,CA,US", currency = "USD,EUR,GBP,JPY,AUD,SGD,CHF,SEK,NOK,NZD,THB,HKD,CAD" } +ali_pay_hk = { country = "HK", currency = "HKD" } +alma = { country = "FR", currency = "EUR" } +apple_pay = { country = "AU,NZ,CN,JP,HK,SG,MY,BH,AE,KW,BR,ES,GB,SE,NO,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,LI,UA,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,CHF,CAD,EUR,GBP,HKD,SGD,USD,MYR" } atome = { country = "MY,SG", currency = "MYR,SGD" } -swish = { country = "SE", currency = "SEK" } -permata_bank_transfer = { country = "ID", currency = "IDR" } +bacs = { country = "GB", currency = "GBP" } +bancontact_card = { country = "BE", currency = "EUR" } bca_bank_transfer = { country = "ID", currency = "IDR" } +bizum = { country = "ES", currency = "EUR" } +blik = { country = "PL", currency = "PLN" } bni_va = { country = "ID", currency = "IDR" } +boleto = { country = "BR", currency = "BRL" } bri_va = { country = "ID", currency = "IDR" } cimb_va = { country = "ID", currency = "IDR" } +dana = { country = "ID", currency = "IDR" } danamon_va = { country = "ID", currency = "IDR" } -mandiri_va = { country = "ID", currency = "IDR" } -alfamart = { country = "ID", currency = "IDR" } +eps = { country = "AT", currency = "EUR" } +family_mart = { country = "JP", currency = "JPY" } +gcash = { country = "PH", currency = "PHP" } +giropay = { country = "DE", currency = "EUR" } +go_pay = { country = "ID", currency = "IDR" } +google_pay = { country = "AU,NZ,JP,HK,SG,MY,TH,VN,BH,AE,KW,BR,ES,GB,SE,NO,SK,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,RO,HR,LI,MT,SI,GR,PT,IE,CZ,EE,LT,LV,IT,PL,TR,IS,CA,US", currency = "AED,ALL,AMD,ANG,AOA,ARS,AUD,AWG,AZN,BAM,BBD,BDT,BGN,BHD,BMD,BND,BOB,BRL,BSD,BWP,BYN,BZD,CAD,CHF,CLP,CNY,COP,CRC,CUP,CVE,CZK,DJF,DKK,DOP,DZD,EGP,ETB,EUR,FJD,FKP,GBP,GEL,GHS,GIP,GMD,GNF,GTQ,GYD,HKD,HNL,HTG,HUF,IDR,ILS,INR,IQD,JMD,JOD,JPY,KES,KGS,KHR,KMF,KRW,KWD,KYD,KZT,LAK,LBP,LKR,LYD,MAD,MDL,MKD,MMK,MNT,MOP,MRU,MUR,MVR,MWK,MXN,MYR,MZN,NAD,NGN,NIO,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PKR,PLN,PYG,QAR,RON,RSD,RUB,RWF,SAR,SBD,SCR,SEK,SGD,SHP,SLE,SOS,SRD,STN,SVC,SZL,THB,TND,TOP,TRY,TTD,TWD,TZS,UAH,UGX,USD,UYU,UZS,VES,VND,VUV,WST,XAF,XCD,XOF,XPF,YER,ZAR,ZMW" } +ideal = { country = "NL", currency = "EUR" } indomaret = { country = "ID", currency = "IDR" } +kakao_pay = { country = "KR", currency = "KRW" } +klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NO,PL,PT,RO,ES,SE,CH,NL,GB,US", currency = "AUD,EUR,CAD,CZK,DKK,NOK,PLN,RON,SEK,CHF,GBP,USD"} +lawson = { country = "JP", currency = "JPY" } +mandiri_va = { country = "ID", currency = "IDR" } +mb_way = { country = "PT", currency = "EUR" } +mini_stop = { country = "JP", currency = "JPY" } +mobile_pay = { country = "DK,FI", currency = "DKK,SEK,NOK,EUR" } +momo = { country = "VN", currency = "VND" } +momo_atm = { country = "VN", currency = "VND" } +online_banking_czech_republic = { country = "CZ", currency = "EUR,CZK" } +online_banking_finland = { country = "FI", currency = "EUR" } +online_banking_fpx = { country = "MY", currency = "MYR" } +online_banking_poland = { country = "PL", currency = "PLN" } +online_banking_slovakia = { country = "SK", currency = "EUR,CZK" } +online_banking_thailand = { country = "TH", currency = "THB" } open_banking_uk = { country = "GB", currency = "GBP" } oxxo = { country = "MX", currency = "MXN" } +pay_bright = { country = "CA", currency = "CAD" } +pay_easy = { country = "JP", currency = "JPY" } pay_safe_card = { country = "AT,AU,BE,BR,BE,CA,HR,CY,CZ,DK,FI,FR,GE,DE,GI,HU,IS,IE,KW,LV,IE,LI,LT,LU,MT,MX,MD,ME,NL,NZ,NO,PY,PE,PL,PT,RO,SA,RS,SK,SI,ES,SE,CH,TR,AE,GB,US,UY", currency = "EUR,AUD,BRL,CAD,CZK,DKK,GEL,GIP,HUF,KWD,CHF,MXN,MDL,NZD,NOK,PYG,PEN,PLN,RON,SAR,RSD,SEK,TRY,AED,GBP,USD,UYU" } -seven_eleven = { country = "JP", currency = "JPY" } -lawson = { country = "JP", currency = "JPY" } -mini_stop = { country = "JP", currency = "JPY" } -family_mart = { country = "JP", currency = "JPY" } +permata_bank_transfer = { country = "ID", currency = "IDR" } seicomart = { country = "JP", currency = "JPY" } -pay_easy = { country = "JP", currency = "JPY" } -boleto = { country = "BR", currency = "BRL" } -ideal = { country = "NL", currency = "EUR" } -klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NO,PL,PT,RO,ES,SE,CH,NL,GB,US", currency = "AUD,EUR,CAD,CZK,DKK,NOK,PLN,RON,SEK,CHF,GBP,USD" } +sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT", currency = "EUR" } +seven_eleven = { country = "JP", currency = "JPY" } +sofort = { country = "AT,BE,DE,ES,CH,NL", currency = "CHF,EUR"} paypal = { country = "AU,NZ,CN,JP,HK,MY,TH,KR,PH,ID,AE,KW,BR,ES,GB,SE,NO,SK,AT,NL,DE,HU,CY,LU,CH,BE,FR,DK,FI,RO,HR,UA,MT,SI,GI,PT,IE,CZ,EE,LT,LV,IT,PL,IS,CA,US", currency = "AUD,BRL,CAD,CZK,DKK,EUR,HKD,HUF,INR,JPY,MYR,MXN,NZD,NOK,PHP,PLN,RUB,GBP,SGD,SEK,CHF,THB,USD" } -sofort = { country = "AT,BE,DE,ES,CH,NL", currency = "CHF,EUR" } + +swish = { country = "SE", currency = "SEK" } +touch_n_go = { country = "MY", currency = "MYR" } +trustly = { country = "ES,GB,SE,NO,AT,NL,DE,DK,FI,EE,LT,LV", currency = "CZK,DKK,EUR,GBP,NOK,SEK" } +twint = { country = "CH", currency = "CHF" } +vipps = { country = "NO", currency = "NOK" } +walley = { country = "SE,NO,DK,FI", currency = "DKK,EUR,NOK,SEK" } +we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,LI,MT,SI,GR,PT,IT,CA,US", currency = "AUD,CAD,CNY,EUR,GBP,HKD,JPY,NZD,SGD,USD,CNY" } [pm_filters.volt] diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs index 2bcf5baa1ec7..6a5f5b88f45c 100644 --- a/crates/router/src/consts.rs +++ b/crates/router/src/consts.rs @@ -136,7 +136,7 @@ pub const CONNECTOR_CREDS_TOKEN_TTL: i64 = 900; pub const MAX_ALLOWED_AMOUNT: i64 = 999999999; //payment attempt default unified error code and unified error message -pub const DEFAULT_UNIFIED_ERROR_CODE: &str = "UE_000"; +pub const DEFAULT_UNIFIED_ERROR_CODE: &str = "UE_9000"; pub const DEFAULT_UNIFIED_ERROR_MESSAGE: &str = "Something went wrong"; // Recon's feature tag From 0e497811adaad118163f783b225eedf5cc10dcc1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:18:52 +0000 Subject: [PATCH 32/46] chore(version): 2024.10.28.2 --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6f92b8cf864..416b6cb7f08b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.10.28.2 + +### Bug Fixes + +- **connector:** + - [Novalnet] Remove webhook placeholder connector config ([#6451](https://github.com/juspay/hyperswitch/pull/6451)) ([`e33340e`](https://github.com/juspay/hyperswitch/commit/e33340e70b59e9e4f18e92fc27d8c90b3df5768b)) + - [Adyen] Add MYR currency config ([#6442](https://github.com/juspay/hyperswitch/pull/6442)) ([`925e424`](https://github.com/juspay/hyperswitch/commit/925e4240e4ad6da1d243769b184842c0d8251a7d)) + +**Full Changelog:** [`2024.10.28.1...2024.10.28.2`](https://github.com/juspay/hyperswitch/compare/2024.10.28.1...2024.10.28.2) + +- - - + ## 2024.10.28.1 ### Bug Fixes From 7fe22e09a956f8851d3ad9102af23ef00a205f28 Mon Sep 17 00:00:00 2001 From: Pa1NarK <69745008+pixincreate@users.noreply.github.com> Date: Mon, 28 Oct 2024 20:03:58 +0530 Subject: [PATCH 33/46] ci(cypress): reduce cargo build jobs to 3 (#6453) --- .github/workflows/cypress-tests-runner.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.yml index 0c9ac7caa5ed..055aacdcf4f2 100644 --- a/.github/workflows/cypress-tests-runner.yml +++ b/.github/workflows/cypress-tests-runner.yml @@ -159,7 +159,7 @@ jobs: - name: Build project if: ${{ env.RUN_TESTS == 'true' }} - run: cargo build --package router --bin router --jobs 4 + run: cargo build --package router --bin router --jobs 3 - name: Setup Local Server if: ${{ env.RUN_TESTS == 'true' }} From aecd5eea3d2dce3ccdd4784f60d076b641104b67 Mon Sep 17 00:00:00 2001 From: Kartikeya Hegde Date: Mon, 28 Oct 2024 20:37:59 +0530 Subject: [PATCH 34/46] fix(multitenancy): consistently use tenant nomenclature everywhere (#6389) --- config/config.example.toml | 2 +- config/deployments/env_specific.toml | 2 +- config/development.toml | 2 +- config/docker_compose.toml | 2 +- crates/drainer/src/settings.rs | 45 ++++++++++++++++-- crates/router/src/configs/settings.rs | 47 ++++++++++++++++--- .../router/src/core/payment_methods/cards.rs | 8 ++-- crates/router/src/core/routing/helpers.rs | 2 +- crates/router/src/middleware.rs | 7 +-- crates/router/src/routes/app.rs | 2 +- crates/router/src/services/api.rs | 32 ++++++------- .../src/types/storage/payment_attempt.rs | 6 +-- loadtest/config/development.toml | 2 +- 13 files changed, 113 insertions(+), 46 deletions(-) diff --git a/config/config.example.toml b/config/config.example.toml index 8f04ba498314..b0d3c7436734 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -741,7 +741,7 @@ enabled = false global_tenant = { schema = "public", redis_key_prefix = "", clickhouse_database = "default"} [multitenancy.tenants] -public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default" } # schema -> Postgres db schema, redis_key_prefix -> redis key distinguisher, base_url -> url of the tenant +public = { base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default" } # schema -> Postgres db schema, redis_key_prefix -> redis key distinguisher, base_url -> url of the tenant [user_auth_methods] encryption_key = "" # Encryption key used for encrypting data in user_authentication_methods table diff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.toml index cfefe9a130f3..0eab330652a8 100644 --- a/config/deployments/env_specific.toml +++ b/config/deployments/env_specific.toml @@ -305,7 +305,7 @@ enabled = false global_tenant = { schema = "public", redis_key_prefix = "", clickhouse_database = "default"} [multitenancy.tenants] -public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default" } +public = { base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default" } [user_auth_methods] encryption_key = "user_auth_table_encryption_key" # Encryption key used for encrypting data in user_authentication_methods table diff --git a/config/development.toml b/config/development.toml index 43fff373fb4d..cbc4573e5552 100644 --- a/config/development.toml +++ b/config/development.toml @@ -750,7 +750,7 @@ enabled = false global_tenant = { schema = "public", redis_key_prefix = "", clickhouse_database = "default"} [multitenancy.tenants] -public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default"} +public = { base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default"} [user_auth_methods] encryption_key = "A8EF32E029BC3342E54BF2E172A4D7AA43E8EF9D2C3A624A9F04E2EF79DC698F" diff --git a/config/docker_compose.toml b/config/docker_compose.toml index 38176875c319..cf07a1bf9bed 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -609,7 +609,7 @@ enabled = false global_tenant = { schema = "public", redis_key_prefix = "", clickhouse_database = "default" } [multitenancy.tenants] -public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default" } +public = { base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default" } [user_auth_methods] encryption_key = "A8EF32E029BC3342E54BF2E172A4D7AA43E8EF9D2C3A624A9F04E2EF79DC698F" diff --git a/crates/drainer/src/settings.rs b/crates/drainer/src/settings.rs index 052267395041..5b391b492e09 100644 --- a/crates/drainer/src/settings.rs +++ b/crates/drainer/src/settings.rs @@ -125,21 +125,56 @@ impl Multitenancy { pub fn get_tenants(&self) -> &HashMap { &self.tenants.0 } - pub fn get_tenant_names(&self) -> Vec { - self.tenants.0.keys().cloned().collect() + pub fn get_tenant_ids(&self) -> Vec { + self.tenants + .0 + .values() + .map(|tenant| tenant.tenant_id.clone()) + .collect() } pub fn get_tenant(&self, tenant_id: &str) -> Option<&Tenant> { self.tenants.0.get(tenant_id) } } -#[derive(Debug, Deserialize, Clone, Default)] -#[serde(transparent)] +#[derive(Debug, Clone, Default)] pub struct TenantConfig(pub HashMap); +impl<'de> Deserialize<'de> for TenantConfig { + fn deserialize>(deserializer: D) -> Result { + #[derive(Deserialize)] + struct Inner { + base_url: String, + schema: String, + redis_key_prefix: String, + clickhouse_database: String, + } + + let hashmap = >::deserialize(deserializer)?; + + Ok(Self( + hashmap + .into_iter() + .map(|(key, value)| { + ( + key.clone(), + Tenant { + tenant_id: key, + base_url: value.base_url, + schema: value.schema, + redis_key_prefix: value.redis_key_prefix, + clickhouse_database: value.clickhouse_database, + }, + ) + }) + .collect(), + )) + } +} + #[derive(Debug, Deserialize, Clone, Default)] pub struct Tenant { - pub name: String, + pub tenant_id: String, pub base_url: String, pub schema: String, pub redis_key_prefix: String, diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs index 149ee2b84562..61e026ae2c57 100644 --- a/crates/router/src/configs/settings.rs +++ b/crates/router/src/configs/settings.rs @@ -141,8 +141,12 @@ impl Multitenancy { pub fn get_tenants(&self) -> &HashMap { &self.tenants.0 } - pub fn get_tenant_names(&self) -> Vec { - self.tenants.0.keys().cloned().collect() + pub fn get_tenant_ids(&self) -> Vec { + self.tenants + .0 + .values() + .map(|tenant| tenant.tenant_id.clone()) + .collect() } pub fn get_tenant(&self, tenant_id: &str) -> Option<&Tenant> { self.tenants.0.get(tenant_id) @@ -154,13 +158,12 @@ pub struct DecisionConfig { pub base_url: String, } -#[derive(Debug, Deserialize, Clone, Default)] -#[serde(transparent)] +#[derive(Debug, Clone, Default)] pub struct TenantConfig(pub HashMap); -#[derive(Debug, Deserialize, Clone, Default)] +#[derive(Debug, Clone, Default)] pub struct Tenant { - pub name: String, + pub tenant_id: String, pub base_url: String, pub schema: String, pub redis_key_prefix: String, @@ -1102,6 +1105,38 @@ where })? } +impl<'de> Deserialize<'de> for TenantConfig { + fn deserialize>(deserializer: D) -> Result { + #[derive(Deserialize)] + struct Inner { + base_url: String, + schema: String, + redis_key_prefix: String, + clickhouse_database: String, + } + + let hashmap = >::deserialize(deserializer)?; + + Ok(Self( + hashmap + .into_iter() + .map(|(key, value)| { + ( + key.clone(), + Tenant { + tenant_id: key, + base_url: value.base_url, + schema: value.schema, + redis_key_prefix: value.redis_key_prefix, + clickhouse_database: value.clickhouse_database, + }, + ) + }) + .collect(), + )) + } +} + #[cfg(test)] mod hashmap_deserialization_test { #![allow(clippy::unwrap_used)] diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 067b35e1e5ea..990a0f0e9ad5 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -2058,7 +2058,7 @@ pub async fn get_payment_method_from_hs_locker<'a>( merchant_id, payment_method_reference, locker_choice, - state.tenant.name.clone(), + state.tenant.tenant_id.clone(), state.request_id, ) .await @@ -2112,7 +2112,7 @@ pub async fn add_card_to_hs_locker( locker, payload, locker_choice, - state.tenant.name.clone(), + state.tenant.tenant_id.clone(), state.request_id, ) .await?; @@ -2309,7 +2309,7 @@ pub async fn get_card_from_hs_locker<'a>( merchant_id, card_reference, Some(locker_choice), - state.tenant.name.clone(), + state.tenant.tenant_id.clone(), state.request_id, ) .await @@ -2355,7 +2355,7 @@ pub async fn delete_card_from_hs_locker<'a>( customer_id, merchant_id, card_reference, - state.tenant.name.clone(), + state.tenant.tenant_id.clone(), state.request_id, ) .await diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs index 6b5845831745..31cd4234714e 100644 --- a/crates/router/src/core/routing/helpers.rs +++ b/crates/router/src/core/routing/helpers.rs @@ -739,7 +739,7 @@ pub async fn push_metrics_for_success_based_routing( &metrics::CONTEXT, 1, &add_attributes([ - ("tenant", state.tenant.name.clone()), + ("tenant", state.tenant.tenant_id.clone()), ( "merchant_id", payment_attempt.merchant_id.get_string_repr().to_string(), diff --git a/crates/router/src/middleware.rs b/crates/router/src/middleware.rs index c80d14b9e253..0185d8a0768a 100644 --- a/crates/router/src/middleware.rs +++ b/crates/router/src/middleware.rs @@ -147,10 +147,11 @@ where .and_then(|i| i.to_str().ok()) .map(|s| s.to_owned()); let response_fut = self.service.call(req); + let tenant_id_clone = tenant_id.clone(); Box::pin( async move { - if let Some(tenant_id) = tenant_id { - router_env::tracing::Span::current().record("tenant_id", &tenant_id); + if let Some(tenant) = tenant_id_clone { + router_env::tracing::Span::current().record("tenant_id", tenant); } let response = response_fut.await; router_env::tracing::Span::current().record("golden_log_line", true); @@ -166,7 +167,7 @@ where status_code = Empty, flow = "UNKNOWN", golden_log_line = Empty, - tenant_id = "ta" + tenant_id = &tenant_id ) .or_current(), ), diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 33699ed266a4..f11840edf630 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -207,7 +207,7 @@ pub struct AppState { } impl scheduler::SchedulerAppState for AppState { fn get_tenants(&self) -> Vec { - self.conf.multitenancy.get_tenant_names() + self.conf.multitenancy.get_tenant_ids() } } pub trait AppStateInfo { diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 6f6eb381669f..02d4950a47d8 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -721,31 +721,27 @@ where .change_context(errors::ApiErrorResponse::InternalServerError.switch())?; let mut event_type = payload.get_api_event_type(); - let tenants: HashSet<_> = state - .conf - .multitenancy - .get_tenant_names() - .into_iter() - .collect(); let tenant_id = if !state.conf.multitenancy.enabled { DEFAULT_TENANT.to_string() } else { - incoming_request_header + let request_tenant_id = incoming_request_header .get(TENANT_HEADER) .and_then(|value| value.to_str().ok()) - .ok_or_else(|| errors::ApiErrorResponse::MissingTenantId.switch()) - .map(|req_tenant_id| { - if !tenants.contains(req_tenant_id) { - Err(errors::ApiErrorResponse::InvalidTenant { - tenant_id: req_tenant_id.to_string(), - } - .switch()) - } else { - Ok(req_tenant_id.to_string()) + .ok_or_else(|| errors::ApiErrorResponse::MissingTenantId.switch())?; + + state + .conf + .multitenancy + .get_tenant(request_tenant_id) + .map(|tenant| tenant.tenant_id.clone()) + .ok_or( + errors::ApiErrorResponse::InvalidTenant { + tenant_id: request_tenant_id.to_string(), } - })?? + .switch(), + )? }; - // let tenant_id = "public".to_string(); + let mut session_state = Arc::new(app_state.clone()).get_session_state(tenant_id.as_str(), || { errors::ApiErrorResponse::InvalidTenant { diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rs index 98f51725bbe3..0291374d54f6 100644 --- a/crates/router/src/types/storage/payment_attempt.rs +++ b/crates/router/src/types/storage/payment_attempt.rs @@ -221,7 +221,7 @@ mod tests { let store = state .stores - .get(state.conf.multitenancy.get_tenant_names().first().unwrap()) + .get(state.conf.multitenancy.get_tenant_ids().first().unwrap()) .unwrap(); let response = store .insert_payment_attempt(payment_attempt, enums::MerchantStorageScheme::PostgresOnly) @@ -304,7 +304,7 @@ mod tests { }; let store = state .stores - .get(state.conf.multitenancy.get_tenant_names().first().unwrap()) + .get(state.conf.multitenancy.get_tenant_ids().first().unwrap()) .unwrap(); store .insert_payment_attempt(payment_attempt, enums::MerchantStorageScheme::PostgresOnly) @@ -401,7 +401,7 @@ mod tests { }; let store = state .stores - .get(state.conf.multitenancy.get_tenant_names().first().unwrap()) + .get(state.conf.multitenancy.get_tenant_ids().first().unwrap()) .unwrap(); store .insert_payment_attempt(payment_attempt, enums::MerchantStorageScheme::PostgresOnly) diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index c8a5ccf9228d..11268e15e543 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -369,7 +369,7 @@ enabled = false global_tenant = { schema = "public", redis_key_prefix = "" } [multitenancy.tenants] -public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default"} +public = { base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default"} [email] sender_email = "example@example.com" From 98567569c1c61648eebf0ad7a1ab58bba967b427 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:22:02 +0000 Subject: [PATCH 35/46] chore(version): 2024.10.29.0 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 416b6cb7f08b..cb6fcc8f40b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.10.29.0 + +### Bug Fixes + +- **multitenancy:** Consistently use tenant nomenclature everywhere ([#6389](https://github.com/juspay/hyperswitch/pull/6389)) ([`aecd5ee`](https://github.com/juspay/hyperswitch/commit/aecd5eea3d2dce3ccdd4784f60d076b641104b67)) + +**Full Changelog:** [`2024.10.28.2...2024.10.29.0`](https://github.com/juspay/hyperswitch/compare/2024.10.28.2...2024.10.29.0) + +- - - + ## 2024.10.28.2 ### Bug Fixes From 55a81eb4692979036d0bfd43e445d3e1db6601e7 Mon Sep 17 00:00:00 2001 From: GORAKHNATH YADAV Date: Tue, 29 Oct 2024 12:53:21 +0530 Subject: [PATCH 36/46] docs: Added desc. for wallets other than AP, GP (#6452) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- api-reference-v2/openapi_spec.json | 3 ++- api-reference/openapi_spec.json | 3 ++- crates/api_models/src/payments.rs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index aa6c45d10aa7..06bbf125dfbf 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -19980,7 +19980,8 @@ } } } - ] + ], + "description": "Hyperswitch supports SDK integration with Apple Pay and Google Pay wallets. For other wallets, we integrate with their respective connectors, redirecting the customer to the connector for wallet payments. As a result, we don’t receive any payment method data in the confirm call for payments made through other wallets." }, "WeChatPay": { "type": "object" diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 7e7df8ce1d5b..9d92c28d55f8 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -24731,7 +24731,8 @@ } } } - ] + ], + "description": "Hyperswitch supports SDK integration with Apple Pay and Google Pay wallets. For other wallets, we integrate with their respective connectors, redirecting the customer to the connector for wallet payments. As a result, we don’t receive any payment method data in the confirm call for payments made through other wallets." }, "WeChatPay": { "type": "object" diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 2e31c0ba258c..2f90db83c551 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -3567,6 +3567,7 @@ pub struct WalletResponse { details: Option, } +/// Hyperswitch supports SDK integration with Apple Pay and Google Pay wallets. For other wallets, we integrate with their respective connectors, redirecting the customer to the connector for wallet payments. As a result, we don’t receive any payment method data in the confirm call for payments made through other wallets. #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub enum WalletResponseData { From 11ce389000bf53c7f740d069f7ad2262bf5b70d6 Mon Sep 17 00:00:00 2001 From: Rahul Singh Patwal <66076661+rahulpatwal0922@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:04:09 +0530 Subject: [PATCH 37/46] refactor(connector): add amount conversion framework to payu (#6199) Co-authored-by: rahulsinghpatwal Co-authored-by: patwalrahul092@gmail.com Co-authored-by: DEEPANSHU BANSAL <41580413+deepanshu-iiitu@users.noreply.github.com> --- .../src/connectors/payu.rs | 35 +++++++++++-- .../src/connectors/payu/transformers.rs | 51 +++++++++++++------ crates/router/src/types/api.rs | 2 +- crates/router/tests/connectors/payu.rs | 2 +- 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs index 05f983b8fbbd..ad2479f19e4c 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu.rs @@ -6,6 +6,7 @@ use common_utils::{ errors::CustomResult, ext_traits::ByteSliceExt, request::{Method, Request, RequestBuilder, RequestContent}, + types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, }; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ @@ -43,11 +44,22 @@ use transformers as payu; use crate::{ constants::headers, types::{RefreshTokenRouterData, ResponseRouterData}, + utils, utils::construct_not_supported_error_report, }; -#[derive(Debug, Clone)] -pub struct Payu; +#[derive(Clone)] +pub struct Payu { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Payu { + pub fn new() -> &'static Self { + &Self { + amount_converter: &MinorUnitForConnector, + } + } +} impl ConnectorCommonExt for Payu where @@ -538,7 +550,15 @@ impl ConnectorIntegration CustomResult { - let connector_req = payu::PayuPaymentsRequest::try_from(req)?; + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + + let connector_router_data = payu::PayuRouterData::try_from((amount, req))?; + + let connector_req = payu::PayuPaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -625,7 +645,14 @@ impl ConnectorIntegration for Payu { req: &RefundsRouterData, _connectors: &Connectors, ) -> CustomResult { - let connector_req = payu::PayuRefundRequest::try_from(req)?; + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_refund_amount, + req.request.currency, + )?; + + let connector_router_data = payu::PayuRouterData::try_from((amount, req))?; + let connector_req = payu::PayuRefundRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } diff --git a/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs index 4ebc09a0023b..9bdb52de4f0d 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs @@ -3,6 +3,7 @@ use common_enums::enums; use common_utils::{ consts::BASE64_ENGINE, pii::{Email, IpAddress}, + types::MinorUnit, }; use error_stack::ResultExt; use hyperswitch_domain_models::{ @@ -24,12 +25,28 @@ use crate::{ const WALLET_IDENTIFIER: &str = "PBL"; -#[derive(Debug, Serialize, Eq, PartialEq)] +#[derive(Debug, Serialize)] +pub struct PayuRouterData { + pub amount: MinorUnit, + pub router_data: T, +} + +impl TryFrom<(MinorUnit, T)> for PayuRouterData { + type Error = error_stack::Report; + fn try_from((amount, item): (MinorUnit, T)) -> Result { + Ok(Self { + amount, + router_data: item, + }) + } +} + +#[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct PayuPaymentsRequest { customer_ip: Secret, merchant_pos_id: Secret, - total_amount: i64, + total_amount: MinorUnit, currency_code: enums::Currency, description: String, pay_methods: PayuPaymentMethod, @@ -77,11 +94,13 @@ pub enum PayuWalletCode { Jp, } -impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest { +impl TryFrom<&PayuRouterData<&types::PaymentsAuthorizeRouterData>> for PayuPaymentsRequest { type Error = error_stack::Report; - fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { - let auth_type = PayuAuthType::try_from(&item.connector_auth_type)?; - let payment_method = match item.request.payment_method_data.clone() { + fn try_from( + item: &PayuRouterData<&types::PaymentsAuthorizeRouterData>, + ) -> Result { + let auth_type = PayuAuthType::try_from(&item.router_data.connector_auth_type)?; + let payment_method = match item.router_data.request.payment_method_data.clone() { PaymentMethodData::Card(ccard) => Ok(PayuPaymentMethod { pay_method: PayuPaymentMethodData::Card(PayuCard::Card { number: ccard.card_number, @@ -119,7 +138,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest { "Unknown payment method".to_string(), )), }?; - let browser_info = item.request.browser_info.clone().ok_or( + let browser_info = item.router_data.request.browser_info.clone().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "browser_info", }, @@ -134,10 +153,10 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest { .to_string(), ), merchant_pos_id: auth_type.merchant_pos_id, - ext_order_id: Some(item.connector_request_reference_id.clone()), - total_amount: item.request.amount, - currency_code: item.request.currency, - description: item.description.clone().ok_or( + ext_order_id: Some(item.router_data.connector_request_reference_id.clone()), + total_amount: item.amount.to_owned(), + currency_code: item.router_data.request.currency, + description: item.router_data.description.clone().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "item.description", }, @@ -488,10 +507,10 @@ impl TryFrom, + amount: Option, } #[derive(Default, Debug, Serialize)] @@ -499,12 +518,12 @@ pub struct PayuRefundRequest { refund: PayuRefundRequestData, } -impl TryFrom<&types::RefundsRouterData> for PayuRefundRequest { +impl TryFrom<&PayuRouterData<&types::RefundsRouterData>> for PayuRefundRequest { type Error = error_stack::Report; - fn try_from(item: &types::RefundsRouterData) -> Result { + fn try_from(item: &PayuRouterData<&types::RefundsRouterData>) -> Result { Ok(Self { refund: PayuRefundRequestData { - description: item.request.reason.clone().ok_or( + description: item.router_data.request.reason.clone().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "item.request.reason", }, diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index b85ae5bfab20..a30462132726 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -458,7 +458,7 @@ impl ConnectorData { enums::Connector::Payone => { Ok(ConnectorEnum::Old(Box::new(connector::Payone::new()))) } - enums::Connector::Payu => Ok(ConnectorEnum::Old(Box::new(&connector::Payu))), + enums::Connector::Payu => Ok(ConnectorEnum::Old(Box::new(connector::Payu::new()))), enums::Connector::Placetopay => { Ok(ConnectorEnum::Old(Box::new(connector::Placetopay::new()))) } diff --git a/crates/router/tests/connectors/payu.rs b/crates/router/tests/connectors/payu.rs index b0e5e9ec6a1d..9bb3785bbd6a 100644 --- a/crates/router/tests/connectors/payu.rs +++ b/crates/router/tests/connectors/payu.rs @@ -11,7 +11,7 @@ impl Connector for Payu { fn get_data(&self) -> types::api::ConnectorData { use router::connector::Payu; utils::construct_connector_data_old( - Box::new(&Payu), + Box::new(Payu::new()), types::Connector::Payu, types::api::GetToken::Connector, None, From cae75314c4ed99b77eab0702b5d507f3d714cd19 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 00:25:27 +0000 Subject: [PATCH 38/46] chore(version): 2024.10.30.0 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb6fcc8f40b6..3d5ba93dca1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.10.30.0 + +### Refactors + +- **connector:** Add amount conversion framework to payu ([#6199](https://github.com/juspay/hyperswitch/pull/6199)) ([`11ce389`](https://github.com/juspay/hyperswitch/commit/11ce389000bf53c7f740d069f7ad2262bf5b70d6)) + +### Documentation + +- Added desc. for wallets other than AP, GP ([#6452](https://github.com/juspay/hyperswitch/pull/6452)) ([`55a81eb`](https://github.com/juspay/hyperswitch/commit/55a81eb4692979036d0bfd43e445d3e1db6601e7)) + +**Full Changelog:** [`2024.10.29.0...2024.10.30.0`](https://github.com/juspay/hyperswitch/compare/2024.10.29.0...2024.10.30.0) + +- - - + ## 2024.10.29.0 ### Bug Fixes From d697def0b7cad3743db9fd70d09a45921dcbea61 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar <83278309+tsdk02@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:56:26 +0530 Subject: [PATCH 39/46] feat(analytics): add `customer_id` as filter for payment intents (#6344) --- crates/analytics/src/payment_intents/core.rs | 3 +- .../analytics/src/payment_intents/filters.rs | 1 + .../analytics/src/payment_intents/metrics.rs | 7 + .../metrics/payment_processed_amount.rs | 161 ++++++++++++++++++ crates/analytics/src/payment_intents/types.rs | 5 + crates/analytics/src/query.rs | 6 + crates/analytics/src/sqlx.rs | 5 + .../src/analytics/payment_intents.rs | 3 + 8 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs diff --git a/crates/analytics/src/payment_intents/core.rs b/crates/analytics/src/payment_intents/core.rs index af46baed23ee..3e8915c60a2a 100644 --- a/crates/analytics/src/payment_intents/core.rs +++ b/crates/analytics/src/payment_intents/core.rs @@ -205,7 +205,8 @@ pub async fn get_metrics( | PaymentIntentMetrics::SessionizedPaymentsSuccessRate => metrics_builder .payments_success_rate .add_metrics_bucket(&value), - PaymentIntentMetrics::SessionizedPaymentProcessedAmount => metrics_builder + PaymentIntentMetrics::SessionizedPaymentProcessedAmount + | PaymentIntentMetrics::PaymentProcessedAmount => metrics_builder .payment_processed_amount .add_metrics_bucket(&value), PaymentIntentMetrics::SessionizedPaymentsDistribution => metrics_builder diff --git a/crates/analytics/src/payment_intents/filters.rs b/crates/analytics/src/payment_intents/filters.rs index e81b050214c5..d03d6c2a15f9 100644 --- a/crates/analytics/src/payment_intents/filters.rs +++ b/crates/analytics/src/payment_intents/filters.rs @@ -54,4 +54,5 @@ pub struct PaymentIntentFilterRow { pub status: Option>, pub currency: Option>, pub profile_id: Option, + pub customer_id: Option, } diff --git a/crates/analytics/src/payment_intents/metrics.rs b/crates/analytics/src/payment_intents/metrics.rs index e9d7f2443068..9aa7d3e97719 100644 --- a/crates/analytics/src/payment_intents/metrics.rs +++ b/crates/analytics/src/payment_intents/metrics.rs @@ -17,6 +17,7 @@ use crate::{ }; mod payment_intent_count; +mod payment_processed_amount; mod payments_success_rate; mod sessionized_metrics; mod smart_retried_amount; @@ -24,6 +25,7 @@ mod successful_smart_retries; mod total_smart_retries; use payment_intent_count::PaymentIntentCount; +use payment_processed_amount::PaymentProcessedAmount; use payments_success_rate::PaymentsSuccessRate; use smart_retried_amount::SmartRetriedAmount; use successful_smart_retries::SuccessfulSmartRetries; @@ -107,6 +109,11 @@ where .load_metrics(dimensions, auth, filters, granularity, time_range, pool) .await } + Self::PaymentProcessedAmount => { + PaymentProcessedAmount + .load_metrics(dimensions, auth, filters, granularity, time_range, pool) + .await + } Self::SessionizedSuccessfulSmartRetries => { sessionized_metrics::SuccessfulSmartRetries .load_metrics(dimensions, auth, filters, granularity, time_range, pool) diff --git a/crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs b/crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs new file mode 100644 index 000000000000..51b574f4ad38 --- /dev/null +++ b/crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs @@ -0,0 +1,161 @@ +use std::collections::HashSet; + +use api_models::analytics::{ + payment_intents::{ + PaymentIntentDimensions, PaymentIntentFilters, PaymentIntentMetricsBucketIdentifier, + }, + Granularity, TimeRange, +}; +use common_utils::errors::ReportSwitchExt; +use diesel_models::enums as storage_enums; +use error_stack::ResultExt; +use time::PrimitiveDateTime; + +use super::PaymentIntentMetricRow; +use crate::{ + enums::AuthInfo, + query::{Aggregate, GroupByClause, QueryBuilder, QueryFilter, SeriesBucket, ToSql, Window}, + types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, +}; + +#[derive(Default)] +pub(super) struct PaymentProcessedAmount; + +#[async_trait::async_trait] +impl super::PaymentIntentMetric for PaymentProcessedAmount +where + T: AnalyticsDataSource + super::PaymentIntentMetricAnalytics, + PrimitiveDateTime: ToSql, + AnalyticsCollection: ToSql, + Granularity: GroupByClause, + Aggregate<&'static str>: ToSql, + Window<&'static str>: ToSql, +{ + async fn load_metrics( + &self, + dimensions: &[PaymentIntentDimensions], + auth: &AuthInfo, + filters: &PaymentIntentFilters, + granularity: &Option, + time_range: &TimeRange, + pool: &T, + ) -> MetricsResult> + { + let mut query_builder: QueryBuilder = + QueryBuilder::new(AnalyticsCollection::PaymentIntent); + + let mut dimensions = dimensions.to_vec(); + + dimensions.push(PaymentIntentDimensions::PaymentIntentStatus); + + for dim in dimensions.iter() { + query_builder.add_select_column(dim).switch()?; + } + + query_builder + .add_select_column(Aggregate::Count { + field: None, + alias: Some("count"), + }) + .switch()?; + + query_builder + .add_select_column("attempt_count == 1 as first_attempt") + .switch()?; + + query_builder.add_select_column("currency").switch()?; + + query_builder + .add_select_column(Aggregate::Sum { + field: "amount", + alias: Some("total"), + }) + .switch()?; + + query_builder + .add_select_column(Aggregate::Min { + field: "created_at", + alias: Some("start_bucket"), + }) + .switch()?; + + query_builder + .add_select_column(Aggregate::Max { + field: "created_at", + alias: Some("end_bucket"), + }) + .switch()?; + + filters.set_filter_clause(&mut query_builder).switch()?; + + auth.set_filter_clause(&mut query_builder).switch()?; + + time_range + .set_filter_clause(&mut query_builder) + .attach_printable("Error filtering time range") + .switch()?; + + for dim in dimensions.iter() { + query_builder + .add_group_by_clause(dim) + .attach_printable("Error grouping by dimensions") + .switch()?; + } + + query_builder + .add_group_by_clause("attempt_count") + .attach_printable("Error grouping by attempt_count") + .switch()?; + + query_builder + .add_group_by_clause("currency") + .attach_printable("Error grouping by currency") + .switch()?; + + if let Some(granularity) = granularity.as_ref() { + granularity + .set_group_by_clause(&mut query_builder) + .attach_printable("Error adding granularity") + .switch()?; + } + + query_builder + .add_filter_clause( + PaymentIntentDimensions::PaymentIntentStatus, + storage_enums::IntentStatus::Succeeded, + ) + .switch()?; + + query_builder + .execute_query::(pool) + .await + .change_context(MetricsError::QueryBuildingError)? + .change_context(MetricsError::QueryExecutionFailure)? + .into_iter() + .map(|i| { + Ok(( + PaymentIntentMetricsBucketIdentifier::new( + None, + i.currency.as_ref().map(|i| i.0), + i.profile_id.clone(), + TimeRange { + start_time: match (granularity, i.start_bucket) { + (Some(g), Some(st)) => g.clip_to_start(st)?, + _ => time_range.start_time, + }, + end_time: granularity.as_ref().map_or_else( + || Ok(time_range.end_time), + |g| i.end_bucket.map(|et| g.clip_to_end(et)).transpose(), + )?, + }, + ), + i, + )) + }) + .collect::, + crate::query::PostProcessingError, + >>() + .change_context(MetricsError::PostProcessingFailure) + } +} diff --git a/crates/analytics/src/payment_intents/types.rs b/crates/analytics/src/payment_intents/types.rs index 03f2a196c20e..bb5141297c56 100644 --- a/crates/analytics/src/payment_intents/types.rs +++ b/crates/analytics/src/payment_intents/types.rs @@ -30,6 +30,11 @@ where .add_filter_in_range_clause(PaymentIntentDimensions::ProfileId, &self.profile_id) .attach_printable("Error adding profile id filter")?; } + if !self.customer_id.is_empty() { + builder + .add_filter_in_range_clause("customer_id", &self.customer_id) + .attach_printable("Error adding customer id filter")?; + } Ok(()) } } diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rs index 7ce338f7db30..d746594e36ee 100644 --- a/crates/analytics/src/query.rs +++ b/crates/analytics/src/query.rs @@ -451,6 +451,12 @@ impl ToSql for &common_utils::id_type::PaymentId { } } +impl ToSql for common_utils::id_type::CustomerId { + fn to_sql(&self, _table_engine: &TableEngine) -> error_stack::Result { + Ok(self.get_string_repr().to_owned()) + } +} + /// Implement `ToSql` on arrays of types that impl `ToString`. macro_rules! impl_to_sql_for_to_string { ($($type:ty),+) => { diff --git a/crates/analytics/src/sqlx.rs b/crates/analytics/src/sqlx.rs index 89eb2ee0bde1..7c90e37c55fb 100644 --- a/crates/analytics/src/sqlx.rs +++ b/crates/analytics/src/sqlx.rs @@ -652,10 +652,15 @@ impl<'a> FromRow<'a, PgRow> for super::payment_intents::filters::PaymentIntentFi ColumnNotFound(_) => Ok(Default::default()), e => Err(e), })?; + let customer_id: Option = row.try_get("customer_id").or_else(|e| match e { + ColumnNotFound(_) => Ok(Default::default()), + e => Err(e), + })?; Ok(Self { status, currency, profile_id, + customer_id, }) } } diff --git a/crates/api_models/src/analytics/payment_intents.rs b/crates/api_models/src/analytics/payment_intents.rs index d018437ae8c1..60662f2e90af 100644 --- a/crates/api_models/src/analytics/payment_intents.rs +++ b/crates/api_models/src/analytics/payment_intents.rs @@ -16,6 +16,8 @@ pub struct PaymentIntentFilters { pub currency: Vec, #[serde(default)] pub profile_id: Vec, + #[serde(default)] + pub customer_id: Vec, } #[derive( @@ -62,6 +64,7 @@ pub enum PaymentIntentMetrics { SmartRetriedAmount, PaymentIntentCount, PaymentsSuccessRate, + PaymentProcessedAmount, SessionizedSuccessfulSmartRetries, SessionizedTotalSmartRetries, SessionizedSmartRetriedAmount, From 8372389671c4aefeb625365d198390df5d8f35a5 Mon Sep 17 00:00:00 2001 From: Kashif Date: Wed, 30 Oct 2024 12:57:22 +0530 Subject: [PATCH 40/46] feat(cypress-test): include worldpay's request / response structure for test suite (#6420) --- .../e2e/PaymentTest/00006-VoidPayment.cy.js | 4 +- .../e2e/PaymentTest/00013-SaveCardFlow.cy.js | 9 +- .../e2e/PaymentTest/00020-Variations.cy.js | 22 +- .../cypress/e2e/PaymentUtils/Commons.js | 21 + .../cypress/e2e/PaymentUtils/Paybox.js | 23 - .../cypress/e2e/PaymentUtils/Utils.js | 7 + .../cypress/e2e/PaymentUtils/WorldPay.js | 436 ++++++++++++++++++ .../fixtures/create-connector-body.json | 3 +- .../cypress/support/redirectionHandler.js | 14 +- 9 files changed, 499 insertions(+), 40 deletions(-) create mode 100644 cypress-tests/cypress/e2e/PaymentUtils/WorldPay.js diff --git a/cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js index 9735a74adfd1..c783f5e3d721 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00006-VoidPayment.cy.js @@ -67,7 +67,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("void-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ - "Void" + "VoidAfterConfirm" ]; let req_data = data["Request"]; let res_data = data["Response"]; @@ -178,7 +178,7 @@ describe("Card - NoThreeDS Manual payment flow test", () => { it("void-call-test", () => { let data = getConnectorDetails(globalState.get("connectorId"))[ "card_pm" - ]["Void"]; + ]["VoidAfterConfirm"]; let req_data = data["Request"]; let res_data = data["Response"]; cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState); diff --git a/cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js index 6e9289d4d0b0..e74c8fc9dd47 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00013-SaveCardFlow.cy.js @@ -46,8 +46,13 @@ describe("Card - SaveCard payment flow test", () => { "automatic", globalState ); - if (should_continue) - should_continue = utils.should_continue_further(res_data); + if (should_continue) { + // Don't continue if payment status is processing during auto capture + // Payment data is tokenized only after payment is successful + let notProcessing = res_data?.body?.status != "processing"; + should_continue = + notProcessing && utils.should_continue_further(res_data); + } }); it("retrieve-payment-call-test", () => { diff --git a/cypress-tests/cypress/e2e/PaymentTest/00020-Variations.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00020-Variations.cy.js index a00a2e39f959..b24b9f10f791 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00020-Variations.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00020-Variations.cy.js @@ -331,7 +331,7 @@ describe("Corner cases", () => { }); it("Capture call", () => { - let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ "CaptureCapturedAmount" ]; @@ -396,7 +396,7 @@ describe("Corner cases", () => { }); it("Confirm call", () => { - let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ "ConfirmSuccessfulPayment" ]; let req_data = data["Request"]; @@ -460,12 +460,12 @@ describe("Corner cases", () => { }); it("Void call", () => { - // `commons` here is intentionally used as we need to pass `ResponseCustom` - let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ "Void" ]; + let commonData = getConnectorDetails(globalState.get("commons"))["card_pm"]["Void"]; let req_data = data["Request"]; - let res_data = data["ResponseCustom"]; + let res_data = utils.getConnectorFlowDetails(data, commonData, "ResponseCustom"); cy.voidCallTest(fixtures.voidBody, req_data, res_data, globalState); if (should_continue) @@ -592,12 +592,12 @@ describe("Corner cases", () => { }); it("Refund call", () => { - // `commons` here is intentionally used as we need to pass `ResponseCustom` - let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ "Refund" ]; + let commonData = getConnectorDetails(globalState.get("commons"))["card_pm"]["Refund"]; let req_data = data["Request"]; - let res_data = data["ResponseCustom"]; + let res_data = utils.getConnectorFlowDetails(data, commonData, "ResponseCustom"); cy.refundCallTest( fixtures.refundBody, req_data, @@ -655,12 +655,12 @@ describe("Corner cases", () => { }); it("Refund call", () => { - // `commons` here is intentionally used as we need to pass `ResponseCustom` - let data = getConnectorDetails(globalState.get("commons"))["card_pm"][ + let data = getConnectorDetails(globalState.get("connectorId"))["card_pm"][ "Refund" ]; + let commonData = getConnectorDetails(globalState.get("commons"))["card_pm"]["Refund"]; let req_data = data["Request"]; - let res_data = data["ResponseCustom"]; + let res_data = utils.getConnectorFlowDetails(data, commonData, "ResponseCustom"); cy.refundCallTest( fixtures.refundBody, req_data, diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js index 73e54fee916f..01905ee05320 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js @@ -666,6 +666,27 @@ export const connectorDetails = { }, }, }), + VoidAfterConfirm: getCustomExchange({ + Request: {}, + Response: { + status: 200, + body: { + status: "cancelled", + capture_method: "manual", + }, + }, + ResponseCustom: { + status: 400, + body: { + error: { + type: "invalid_request", + message: + "You cannot cancel this payment because it has status succeeded", + code: "IR_16", + }, + }, + }, + }), Refund: getCustomExchange({ Request: { payment_method: "card", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Paybox.js b/cypress-tests/cypress/e2e/PaymentUtils/Paybox.js index 8fbb8c0b07b7..b0550854ef87 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Paybox.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Paybox.js @@ -401,29 +401,6 @@ export const connectorDetails = { }, }, }, - CaptureCapturedAmount: { - Request: { - Request: { - payment_method: "card", - payment_method_data: { - card: successfulNo3DSCardDetails, - }, - currency: "EUR", - customer_acceptance: null, - }, - }, - Response: { - status: 400, - body: { - error: { - type: "invalid_request", - message: - "This Payment could not be captured because it has a payment.status of succeeded. The expected state is requires_capture, partially_captured_and_capturable, processing", - code: "IR_14", - }, - }, - }, - }, ConfirmSuccessfulPayment: { Request: { payment_method: "card", diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js b/cypress-tests/cypress/e2e/PaymentUtils/Utils.js index 18f4df3eb577..8848450bc61e 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Utils.js @@ -19,6 +19,7 @@ import { connectorDetails as stripeConnectorDetails } from "./Stripe.js"; import { connectorDetails as trustpayConnectorDetails } from "./Trustpay.js"; import { connectorDetails as wellsfargoConnectorDetails } from "./WellsFargo.js"; import { connectorDetails as fiuuConnectorDetails } from "./Fiuu.js"; +import { connectorDetails as worldpayConnectorDetails } from "./WorldPay.js"; const connectorDetails = { adyen: adyenConnectorDetails, @@ -39,6 +40,7 @@ const connectorDetails = { datatrans: datatransConnectorDetails, wellsfargo: wellsfargoConnectorDetails, fiuu: fiuuConnectorDetails, + worldpay: worldpayConnectorDetails, }; export default function getConnectorDetails(connectorId) { @@ -46,6 +48,11 @@ export default function getConnectorDetails(connectorId) { return x; } +export function getConnectorFlowDetails(connectorData, commonData, key) { + let data = connectorData[key] === undefined ? commonData[key] : connectorData[key]; + return data; +} + function mergeDetails(connectorId) { const connectorData = getValueByKey(connectorDetails, connectorId); const fallbackData = getValueByKey(connectorDetails, "commons"); diff --git a/cypress-tests/cypress/e2e/PaymentUtils/WorldPay.js b/cypress-tests/cypress/e2e/PaymentUtils/WorldPay.js new file mode 100644 index 000000000000..70ed4fefa6c2 --- /dev/null +++ b/cypress-tests/cypress/e2e/PaymentUtils/WorldPay.js @@ -0,0 +1,436 @@ + +const billing = { + address: { + line1: "1467", + line2: "Harrison Street", + line3: "Harrison Street", + city: "San Fransico", + state: "CA", + zip: "94122", + country: "US", + first_name: "John", + last_name: "Doe" + } +}; + +const browser_info = { + "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36", + "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", + "language": "nl-NL", + "color_depth": 24, + "screen_height": 723, + "screen_width": 1536, + "time_zone": 0, + "java_enabled": true, + "java_script_enabled": true, + "ip_address": "127.0.0.1" +}; + +const successfulNo3DSCardDetails = { + card_number: "4242424242424242", + card_exp_month: "10", + card_exp_year: "2030", + card_holder_name: "morino", + card_cvc: "737", +}; + +const successfulThreeDSTestCardDetails = { + card_number: "4000000000001091", + card_exp_month: "10", + card_exp_year: "2030", + card_holder_name: "morino", + card_cvc: "737", +}; + +const payment_method_data_no3ds = { + card: { + last4: "4242", + card_type: "CREDIT", + card_network: "Visa", + card_issuer: "STRIPE PAYMENTS UK LIMITED", + card_issuing_country: "UNITEDKINGDOM", + card_isin: "424242", + card_extended_bin: null, + card_exp_month: "10", + card_exp_year: "2030", + card_holder_name: null, + payment_checks: null, + authentication_data: null + }, + billing: null +}; + +const payment_method_data_3ds = { + card: { + last4: "1091", + card_type: "CREDIT", + card_network: "Visa", + card_issuer: "INTL HDQTRS-CENTER OWNED", + card_issuing_country: "UNITEDSTATES", + card_isin: "400000", + card_extended_bin: null, + card_exp_month: "10", + card_exp_year: "2030", + card_holder_name: null, + payment_checks: null, + authentication_data: null + }, + billing: null +}; + +const singleUseMandateData = { + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "125.0.0.1", + user_agent: "amet irure esse", + }, + }, + mandate_type: { + single_use: { + amount: 8000, + currency: "USD", + }, + }, +}; + +export const connectorDetails = { + card_pm: { + PaymentIntent: { + Request: { + currency: "USD", + customer_acceptance: null, + setup_future_usage: "on_session", + }, Response: { + status: 200, + body: { + status: "requires_payment_method", + setup_future_usage: "on_session", + }, + }, + }, + No3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_type: "debit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + setup_future_usage: "on_session", + billing: billing, + }, + Response: { + status: 200, + body: { + status: "requires_capture", + payment_method: "card", + payment_method_type: "debit", + attempt_count: 1, + payment_method_data: payment_method_data_no3ds, + }, + }, + }, + No3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_type: "debit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + setup_future_usage: "on_session", + }, + Response: { + status: 200, + body: { + status: "processing", + payment_method: "card", + payment_method_type: "debit", + attempt_count: 1, + payment_method_data: payment_method_data_no3ds, + }, + }, + }, + Capture: { + Request: { + payment_method: "card", + payment_method_type: "debit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "processing", + amount: 6500, + amount_capturable: 6500, + }, + }, + }, + PartialCapture: { + Request: { + payment_method: "card", + payment_method_type: "debit", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "processing", + amount: 6500, + amount_capturable: 6500, + }, + }, + }, + Void: { + Request: {}, + Response: { + status: 200, + body: { + status: "cancelled", + }, + }, + ResponseCustom: { + body: { + type: "invalid_request", + message: "You cannot cancel this payment because it has status processing", + code: "IR_16", + } + } + }, + VoidAfterConfirm: { + Request: {}, + Response: { + status: 200, + body: { + status: "processing", + }, + }, + }, + SaveCardUseNo3DSManualCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + setup_future_usage: "on_session", + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "127.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: "Missing required param: payment_method_data", + code: "IR_04" + } + }, + }, + }, + SaveCardUseNo3DSAutoCapture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + setup_future_usage: "on_session", + browser_info, + customer_acceptance: { + acceptance_type: "offline", + accepted_at: "1963-05-03T04:07:52.723Z", + online: { + ip_address: "127.0.0.1", + user_agent: "amet irure esse", + }, + }, + }, + Response: { + status: 200, + body: { + status: "processing" + }, + } + }, + "3DSManualCapture": { + Request: { + payment_method: "card", + payment_method_type: "debit", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + currency: "USD", + customer_acceptance: null, + setup_future_usage: "on_session", + browser_info, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + setup_future_usage: "on_session", + payment_method_data: payment_method_data_3ds, + }, + }, + }, + "3DSAutoCapture": { + Request: { + payment_method: "card", + payment_method_type: "debit", + payment_method_data: { + card: successfulThreeDSTestCardDetails, + }, + currency: "USD", + customer_acceptance: null, + setup_future_usage: "on_session", + browser_info, + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + setup_future_usage: "on_session", + payment_method_data: payment_method_data_3ds, + }, + }, + }, + + /** + * Variation cases + */ + CaptureCapturedAmount: { + Request: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "EUR", + customer_acceptance: null, + }, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: + "This Payment could not be captured because it has a capture_method of automatic. The expected state is manual_multiple", + code: "IR_14", + }, + }, + }, + }, + ConfirmSuccessfulPayment: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: + "You cannot confirm this payment because it has status processing", + code: "IR_16", + }, + }, + }, + }, + + /** + * Not implemented or not ready for running test cases + * - Refunds + * - Mandates + */ + Refund: { + Request: {}, + Response: { + body: { + error: { + type: "invalid_request", + message: "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + code: "IR_14" + } + } + }, + ResponseCustom: { + status: 400, + body: { + error: { + type: "invalid_request", + message: "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + code: "IR_14", + }, + }, + }, + }, + PartialRefund: { + Request: {}, + Response: { + body: { + error: { + type: "invalid_request", + message: "This Payment could not be refund because it has a status of processing. The expected state is succeeded, partially_captured", + code: "IR_14" + } + } + } + }, + SyncRefund: { + Request: {}, + Response: { + body: { + error: { + type: "invalid_request", + message: "Refund does not exist in our records.", + code: "HE_02" + } + } + } + }, + ZeroAuthMandate: { + Request: { + payment_method: "card", + payment_method_data: { + card: successfulNo3DSCardDetails, + }, + currency: "USD", + mandate_data: singleUseMandateData, + }, + Response: { + body: { + error: { + type: "invalid_request", + message: "Setup Mandate flow for Worldpay is not implemented", + code: "IR_00" + } + }, + }, + }, + }, +} \ No newline at end of file diff --git a/cypress-tests/cypress/fixtures/create-connector-body.json b/cypress-tests/cypress/fixtures/create-connector-body.json index 5e0ce73aedc8..54a96d8f6ee2 100644 --- a/cypress-tests/cypress/fixtures/create-connector-body.json +++ b/cypress-tests/cypress/fixtures/create-connector-body.json @@ -13,6 +13,7 @@ "metadata": { "city": "NY", "unit": "245", - "endpoint_prefix": "AD" + "endpoint_prefix": "AD", + "merchant_name": "Cypress Test" } } diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js index b493d11fee83..aa6db7d50747 100644 --- a/cypress-tests/cypress/support/redirectionHandler.js +++ b/cypress-tests/cypress/support/redirectionHandler.js @@ -343,7 +343,19 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) { cy.get("#outcomeSelect").select("Approve").should("have.value", "Y"); cy.get('button[type="submit"]').click(); }); - } else { + } else if (connectorId === "worldpay") { + cy.get("iframe", { timeout: WAIT_TIME }) + .its("0.contentDocument.body") + .within(() => { + cy.get('form[name="cardholderInput"]', { timeout: WAIT_TIME }) + .should("exist") + .then(() => { + cy.get('input[name="challengeDataEntry"]').click().type("1234"); + cy.get('input[value="SUBMIT"]').click(); + }) + }); + } + else { // If connectorId is neither of adyen, trustpay, nmi, stripe, bankofamerica or cybersource, wait for 10 seconds cy.wait(WAIT_TIME); } From 7dcffccf3f16de5e40f61a302beb318035c3e88b Mon Sep 17 00:00:00 2001 From: Mani Chandra <84711804+ThisIsMani@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:58:41 +0530 Subject: [PATCH 41/46] feat(authz): Make info APIs support `ParentGroup` (#6440) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/events/user_role.rs | 9 ++- crates/api_models/src/user_role/role.rs | 26 +++++- crates/common_enums/src/enums.rs | 20 +++-- crates/router/src/core/user_role.rs | 45 ++++++++++- crates/router/src/core/user_role/role.rs | 80 ++++++++++++++++++- crates/router/src/routes/app.rs | 12 +++ crates/router/src/routes/lock_utils.rs | 3 + crates/router/src/routes/user_role.rs | 67 ++++++++++++++++ .../router/src/services/authorization/info.rs | 26 +----- .../authorization/permission_groups.rs | 70 +++++++++++++--- .../src/services/authorization/permissions.rs | 31 +++++++ .../authorization/roles/predefined_roles.rs | 21 +++++ crates/router_env/src/logger/types.rs | 6 ++ 13 files changed, 364 insertions(+), 52 deletions(-) diff --git a/crates/api_models/src/events/user_role.rs b/crates/api_models/src/events/user_role.rs index a2c76ecc3944..e0df36a3349c 100644 --- a/crates/api_models/src/events/user_role.rs +++ b/crates/api_models/src/events/user_role.rs @@ -2,8 +2,9 @@ use common_utils::events::{ApiEventMetric, ApiEventsType}; use crate::user_role::{ role::{ - CreateRoleRequest, GetRoleRequest, ListRolesAtEntityLevelRequest, ListRolesRequest, - RoleInfoResponseNew, RoleInfoWithGroupsResponse, UpdateRoleRequest, + CreateRoleRequest, GetRoleRequest, GroupsAndResources, ListRolesAtEntityLevelRequest, + ListRolesRequest, RoleInfoResponseNew, RoleInfoWithGroupsResponse, RoleInfoWithParents, + UpdateRoleRequest, }, AuthorizationInfoResponse, DeleteUserRoleRequest, ListUsersInEntityRequest, UpdateUserRoleRequest, @@ -22,6 +23,8 @@ common_utils::impl_api_event_type!( RoleInfoResponseNew, RoleInfoWithGroupsResponse, ListUsersInEntityRequest, - ListRolesRequest + ListRolesRequest, + GroupsAndResources, + RoleInfoWithParents ) ); diff --git a/crates/api_models/src/user_role/role.rs b/crates/api_models/src/user_role/role.rs index 885ec455e4cf..7c877cd74777 100644 --- a/crates/api_models/src/user_role/role.rs +++ b/crates/api_models/src/user_role/role.rs @@ -1,5 +1,6 @@ -pub use common_enums::PermissionGroup; -use common_enums::{EntityType, RoleScope}; +use common_enums::{ + EntityType, ParentGroup, PermissionGroup, PermissionScope, Resource, RoleScope, +}; #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct CreateRoleRequest { @@ -22,6 +23,21 @@ pub struct RoleInfoWithGroupsResponse { pub role_scope: RoleScope, } +#[derive(Debug, serde::Serialize)] +pub struct RoleInfoWithParents { + pub role_id: String, + pub parent_groups: Vec, + pub role_name: String, + pub role_scope: RoleScope, +} + +#[derive(Debug, serde::Serialize)] +pub struct ParentGroupInfo { + pub name: ParentGroup, + pub description: String, + pub scopes: Vec, +} + #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct ListRolesRequest { pub entity_type: Option, @@ -57,3 +73,9 @@ pub struct MinimalRoleInfo { pub role_id: String, pub role_name: String, } + +#[derive(Debug, serde::Serialize)] +pub struct GroupsAndResources { + pub groups: Vec, + pub resources: Vec, +} diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index c103153eec80..faae71eda223 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -2884,10 +2884,15 @@ pub enum PermissionGroup { AnalyticsView, UsersView, UsersManage, + // TODO: To be deprecated, make sure DB is migrated before removing MerchantDetailsView, + // TODO: To be deprecated, make sure DB is migrated before removing MerchantDetailsManage, + // TODO: To be deprecated, make sure DB is migrated before removing OrganizationManage, ReconOps, + AccountView, + AccountManage, } #[derive(Clone, Debug, serde::Serialize, PartialEq, Eq, Hash, strum::EnumIter)] @@ -2897,14 +2902,12 @@ pub enum ParentGroup { Workflows, Analytics, Users, - #[serde(rename = "MerchantAccess")] - Merchant, - #[serde(rename = "OrganizationAccess")] - Organization, Recon, + Account, } -#[derive(Clone, Copy, Eq, PartialEq, Hash)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, serde::Serialize)] +#[serde(rename_all = "snake_case")] pub enum Resource { Payment, Refund, @@ -2925,10 +2928,11 @@ pub enum Resource { Recon, } -#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, serde::Serialize, Hash)] +#[serde(rename_all = "snake_case")] pub enum PermissionScope { - Read, - Write, + Read = 0, + Write = 1, } /// Name of banks supported by Hyperswitch diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rs index 284be4ab4baa..27c1e2ae4945 100644 --- a/crates/router/src/core/user_role.rs +++ b/crates/router/src/core/user_role.rs @@ -1,6 +1,9 @@ use std::collections::{HashMap, HashSet}; -use api_models::{user as user_api, user_role as user_role_api}; +use api_models::{ + user as user_api, + user_role::{self as user_role_api, role as role_api}, +}; use diesel_models::{ enums::{UserRoleVersion, UserStatus}, organization::OrganizationBridge, @@ -16,7 +19,11 @@ use crate::{ routes::{app::ReqState, SessionState}, services::{ authentication as auth, - authorization::{info, permission_groups::PermissionGroupExt, roles}, + authorization::{ + info, + permission_groups::{ParentGroupExt, PermissionGroupExt}, + roles, + }, ApplicationResponse, }, types::domain, @@ -72,6 +79,40 @@ pub async fn get_authorization_info_with_group_tag( )) } +pub async fn get_parent_group_info( + state: SessionState, + user_from_token: auth::UserFromToken, +) -> UserResponse> { + let role_info = roles::RoleInfo::from_role_id_in_merchant_scope( + &state, + &user_from_token.role_id, + &user_from_token.merchant_id, + &user_from_token.org_id, + ) + .await + .to_not_found_response(UserErrors::InvalidRoleId)?; + + let parent_groups = ParentGroup::get_descriptions_for_groups( + role_info.get_entity_type(), + PermissionGroup::iter().collect(), + ) + .into_iter() + .map(|(parent_group, description)| role_api::ParentGroupInfo { + name: parent_group.clone(), + description, + scopes: PermissionGroup::iter() + .filter_map(|group| (group.parent() == parent_group).then_some(group.scope())) + // TODO: Remove this hashset conversion when merhant access + // and organization access groups are removed + .collect::>() + .into_iter() + .collect(), + }) + .collect::>(); + + Ok(ApplicationResponse::Json(parent_groups)) +} + pub async fn update_user_role( state: SessionState, user_from_token: auth::UserFromToken, diff --git a/crates/router/src/core/user_role/role.rs b/crates/router/src/core/user_role/role.rs index b5b5cab421f1..1d37f7ac8d16 100644 --- a/crates/router/src/core/user_role/role.rs +++ b/crates/router/src/core/user_role/role.rs @@ -1,5 +1,7 @@ +use std::collections::HashSet; + use api_models::user_role::role::{self as role_api}; -use common_enums::{EntityType, RoleScope}; +use common_enums::{EntityType, ParentGroup, PermissionGroup, RoleScope}; use common_utils::generate_id_with_default_len; use diesel_models::role::{RoleNew, RoleUpdate}; use error_stack::{report, ResultExt}; @@ -9,7 +11,10 @@ use crate::{ routes::{app::ReqState, SessionState}, services::{ authentication::{blacklist, UserFromToken}, - authorization::roles::{self, predefined_roles::PREDEFINED_ROLES}, + authorization::{ + permission_groups::{ParentGroupExt, PermissionGroupExt}, + roles::{self, predefined_roles::PREDEFINED_ROLES}, + }, ApplicationResponse, }, types::domain::user::RoleName, @@ -19,7 +24,7 @@ use crate::{ pub async fn get_role_from_token_with_groups( state: SessionState, user_from_token: UserFromToken, -) -> UserResponse> { +) -> UserResponse> { let role_info = user_from_token .get_role_info_from_db(&state) .await @@ -30,6 +35,29 @@ pub async fn get_role_from_token_with_groups( Ok(ApplicationResponse::Json(permissions)) } +pub async fn get_groups_and_resources_for_role_from_token( + state: SessionState, + user_from_token: UserFromToken, +) -> UserResponse { + let role_info = user_from_token.get_role_info_from_db(&state).await?; + + let groups = role_info + .get_permission_groups() + .into_iter() + .collect::>(); + let resources = groups + .iter() + .flat_map(|group| group.resources()) + .collect::>() + .into_iter() + .collect(); + + Ok(ApplicationResponse::Json(role_api::GroupsAndResources { + groups, + resources, + })) +} + pub async fn create_role( state: SessionState, user_from_token: UserFromToken, @@ -111,6 +139,52 @@ pub async fn get_role_with_groups( )) } +pub async fn get_parent_info_for_role( + state: SessionState, + user_from_token: UserFromToken, + role: role_api::GetRoleRequest, +) -> UserResponse { + let role_info = roles::RoleInfo::from_role_id_in_merchant_scope( + &state, + &role.role_id, + &user_from_token.merchant_id, + &user_from_token.org_id, + ) + .await + .to_not_found_response(UserErrors::InvalidRoleId)?; + + if role_info.is_internal() { + return Err(UserErrors::InvalidRoleId.into()); + } + + let parent_groups = ParentGroup::get_descriptions_for_groups( + role_info.get_entity_type(), + role_info.get_permission_groups().to_vec(), + ) + .into_iter() + .map(|(parent_group, description)| role_api::ParentGroupInfo { + name: parent_group.clone(), + description, + scopes: role_info + .get_permission_groups() + .iter() + .filter_map(|group| (group.parent() == parent_group).then_some(group.scope())) + // TODO: Remove this hashset conversion when merhant access + // and organization access groups are removed + .collect::>() + .into_iter() + .collect(), + }) + .collect(); + + Ok(ApplicationResponse::Json(role_api::RoleInfoWithParents { + role_id: role.role_id, + parent_groups, + role_name: role_info.get_role_name().to_string(), + role_scope: role_info.get_scope(), + })) +} + pub async fn update_role( state: SessionState, user_from_token: UserFromToken, diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index f11840edf630..f54895ce7da3 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -1819,9 +1819,14 @@ impl User { web::resource("/permission_info") .route(web::get().to(user_role::get_authorization_info)), ) + // TODO: To be deprecated .service( web::resource("/module/list").route(web::get().to(user_role::get_role_information)), ) + .service( + web::resource("/parent/list") + .route(web::get().to(user_role::get_parent_group_info)), + ) .service( web::resource("/update").route(web::post().to(user::update_user_account_details)), ) @@ -2017,6 +2022,9 @@ impl User { .route(web::get().to(user_role::get_role_from_token)) .route(web::post().to(user_role::create_role)), ) + .service(web::resource("/v2").route( + web::get().to(user_role::get_groups_and_resources_for_role_from_token), + )) // TODO: To be deprecated .service( web::resource("/v2/list") @@ -2039,6 +2047,10 @@ impl User { web::resource("/{role_id}") .route(web::get().to(user_role::get_role)) .route(web::put().to(user_role::update_role)), + ) + .service( + web::resource("/{role_id}/v2") + .route(web::get().to(user_role::get_parent_info_for_role)), ), ); diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs index a0c5c0f99026..ac17cf802107 100644 --- a/crates/router/src/routes/lock_utils.rs +++ b/crates/router/src/routes/lock_utils.rs @@ -263,10 +263,13 @@ impl From for ApiIdentifier { | Flow::ListInvitableRolesAtEntityLevel | Flow::ListUpdatableRolesAtEntityLevel | Flow::GetRole + | Flow::GetRoleV2 | Flow::GetRoleFromToken + | Flow::GetRoleFromTokenV2 | Flow::UpdateUserRole | Flow::GetAuthorizationInfo | Flow::GetRolesInfo + | Flow::GetParentGroupInfo | Flow::AcceptInvitationsV2 | Flow::AcceptInvitationsPreAuth | Flow::DeleteUserRole diff --git a/crates/router/src/routes/user_role.rs b/crates/router/src/routes/user_role.rs index 74847f064747..9910cef3950a 100644 --- a/crates/router/src/routes/user_role.rs +++ b/crates/router/src/routes/user_role.rs @@ -55,6 +55,26 @@ pub async fn get_role_from_token(state: web::Data, req: HttpRequest) - .await } +pub async fn get_groups_and_resources_for_role_from_token( + state: web::Data, + req: HttpRequest, +) -> HttpResponse { + let flow = Flow::GetRoleFromTokenV2; + + Box::pin(api::server_wrap( + flow, + state.clone(), + &req, + (), + |state, user, _, _| async move { + role_core::get_groups_and_resources_for_role_from_token(state, user).await + }, + &auth::DashboardNoPermissionAuth, + api_locking::LockAction::NotApplicable, + )) + .await +} + pub async fn create_role( state: web::Data, req: HttpRequest, @@ -100,6 +120,31 @@ pub async fn get_role( .await } +pub async fn get_parent_info_for_role( + state: web::Data, + req: HttpRequest, + path: web::Path, +) -> HttpResponse { + let flow = Flow::GetRoleV2; + let request_payload = user_role_api::role::GetRoleRequest { + role_id: path.into_inner(), + }; + Box::pin(api::server_wrap( + flow, + state.clone(), + &req, + request_payload, + |state, user, payload, _| async move { + role_core::get_parent_info_for_role(state, user, payload).await + }, + &auth::JWTAuth { + permission: Permission::ProfileUserRead, + }, + api_locking::LockAction::NotApplicable, + )) + .await +} + pub async fn update_role( state: web::Data, req: HttpRequest, @@ -226,6 +271,28 @@ pub async fn get_role_information( .await } +pub async fn get_parent_group_info( + state: web::Data, + http_req: HttpRequest, +) -> HttpResponse { + let flow = Flow::GetParentGroupInfo; + + Box::pin(api::server_wrap( + flow, + state.clone(), + &http_req, + (), + |state, user_from_token, _, _| async move { + user_role_core::get_parent_group_info(state, user_from_token).await + }, + &auth::JWTAuth { + permission: Permission::ProfileUserRead, + }, + api_locking::LockAction::NotApplicable, + )) + .await +} + pub async fn list_users_in_lineage( state: web::Data, req: HttpRequest, diff --git a/crates/router/src/services/authorization/info.rs b/crates/router/src/services/authorization/info.rs index dba96dac1888..bd987e2fe9ae 100644 --- a/crates/router/src/services/authorization/info.rs +++ b/crates/router/src/services/authorization/info.rs @@ -37,32 +37,13 @@ fn get_group_description(group: PermissionGroup) -> &'static str { PermissionGroup::AnalyticsView => "View Analytics", PermissionGroup::UsersView => "View Users", PermissionGroup::UsersManage => "Manage and invite Users to the Team", - PermissionGroup::MerchantDetailsView => "View Merchant Details", - PermissionGroup::MerchantDetailsManage => "Create, modify and delete Merchant Details like api keys, webhooks, etc", + PermissionGroup::MerchantDetailsView | PermissionGroup::AccountView => "View Merchant Details", + PermissionGroup::MerchantDetailsManage | PermissionGroup::AccountManage => "Create, modify and delete Merchant Details like api keys, webhooks, etc", PermissionGroup::OrganizationManage => "Manage organization level tasks like create new Merchant accounts, Organization level roles, etc", PermissionGroup::ReconOps => "View and manage reconciliation reports", } } -pub fn get_parent_name(group: PermissionGroup) -> ParentGroup { - match group { - PermissionGroup::OperationsView | PermissionGroup::OperationsManage => { - ParentGroup::Operations - } - PermissionGroup::ConnectorsView | PermissionGroup::ConnectorsManage => { - ParentGroup::Connectors - } - PermissionGroup::WorkflowsView | PermissionGroup::WorkflowsManage => ParentGroup::Workflows, - PermissionGroup::AnalyticsView => ParentGroup::Analytics, - PermissionGroup::UsersView | PermissionGroup::UsersManage => ParentGroup::Users, - PermissionGroup::MerchantDetailsView | PermissionGroup::MerchantDetailsManage => { - ParentGroup::Merchant - } - PermissionGroup::OrganizationManage => ParentGroup::Organization, - PermissionGroup::ReconOps => ParentGroup::Recon, - } -} - pub fn get_parent_group_description(group: ParentGroup) -> &'static str { match group { ParentGroup::Operations => "Payments, Refunds, Payouts, Mandates, Disputes and Customers", @@ -70,8 +51,7 @@ pub fn get_parent_group_description(group: ParentGroup) -> &'static str { ParentGroup::Workflows => "Create, modify and delete Routing, 3DS Decision Manager, Surcharge Decision Manager", ParentGroup::Analytics => "View Analytics", ParentGroup::Users => "Manage and invite Users to the Team", - ParentGroup::Merchant => "Create, modify and delete Merchant Details like api keys, webhooks, etc", - ParentGroup::Organization =>"Manage organization level tasks like create new Merchant accounts, Organization level roles, etc", + ParentGroup::Account => "Create, modify and delete Merchant Details like api keys, webhooks, etc", ParentGroup::Recon => "View and manage reconciliation reports", } } diff --git a/crates/router/src/services/authorization/permission_groups.rs b/crates/router/src/services/authorization/permission_groups.rs index 3d1a0c8ea5b1..57c385565a86 100644 --- a/crates/router/src/services/authorization/permission_groups.rs +++ b/crates/router/src/services/authorization/permission_groups.rs @@ -1,4 +1,9 @@ -use common_enums::{ParentGroup, PermissionGroup, PermissionScope, Resource}; +use std::collections::HashMap; + +use common_enums::{EntityType, ParentGroup, PermissionGroup, PermissionScope, Resource}; +use strum::IntoEnumIterator; + +use super::permissions::{self, ResourceExt}; pub trait PermissionGroupExt { fn scope(&self) -> PermissionScope; @@ -15,7 +20,8 @@ impl PermissionGroupExt for PermissionGroup { | Self::WorkflowsView | Self::AnalyticsView | Self::UsersView - | Self::MerchantDetailsView => PermissionScope::Read, + | Self::MerchantDetailsView + | Self::AccountView => PermissionScope::Read, Self::OperationsManage | Self::ConnectorsManage @@ -23,7 +29,8 @@ impl PermissionGroupExt for PermissionGroup { | Self::UsersManage | Self::MerchantDetailsManage | Self::OrganizationManage - | Self::ReconOps => PermissionScope::Write, + | Self::ReconOps + | Self::AccountManage => PermissionScope::Write, } } @@ -34,9 +41,12 @@ impl PermissionGroupExt for PermissionGroup { Self::WorkflowsView | Self::WorkflowsManage => ParentGroup::Workflows, Self::AnalyticsView => ParentGroup::Analytics, Self::UsersView | Self::UsersManage => ParentGroup::Users, - Self::MerchantDetailsView | Self::MerchantDetailsManage => ParentGroup::Merchant, - Self::OrganizationManage => ParentGroup::Organization, Self::ReconOps => ParentGroup::Recon, + Self::MerchantDetailsView + | Self::OrganizationManage + | Self::MerchantDetailsManage + | Self::AccountView + | Self::AccountManage => ParentGroup::Account, } } @@ -52,10 +62,14 @@ impl PermissionGroupExt for PermissionGroup { Self::ConnectorsView => vec![Self::ConnectorsView], Self::ConnectorsManage => vec![Self::ConnectorsView, Self::ConnectorsManage], - Self::WorkflowsView => vec![Self::WorkflowsView], - Self::WorkflowsManage => vec![Self::WorkflowsView, Self::WorkflowsManage], + Self::WorkflowsView => vec![Self::WorkflowsView, Self::ConnectorsView], + Self::WorkflowsManage => vec![ + Self::WorkflowsView, + Self::WorkflowsManage, + Self::ConnectorsView, + ], - Self::AnalyticsView => vec![Self::AnalyticsView], + Self::AnalyticsView => vec![Self::AnalyticsView, Self::OperationsView], Self::UsersView => vec![Self::UsersView], Self::UsersManage => { @@ -70,12 +84,19 @@ impl PermissionGroupExt for PermissionGroup { } Self::OrganizationManage => vec![Self::OrganizationManage], + + Self::AccountView => vec![Self::AccountView], + Self::AccountManage => vec![Self::AccountView, Self::AccountManage], } } } pub trait ParentGroupExt { fn resources(&self) -> Vec; + fn get_descriptions_for_groups( + entity_type: EntityType, + groups: Vec, + ) -> HashMap; } impl ParentGroupExt for ParentGroup { @@ -86,10 +107,38 @@ impl ParentGroupExt for ParentGroup { Self::Workflows => WORKFLOWS.to_vec(), Self::Analytics => ANALYTICS.to_vec(), Self::Users => USERS.to_vec(), - Self::Merchant | Self::Organization => ACCOUNT.to_vec(), + Self::Account => ACCOUNT.to_vec(), Self::Recon => RECON.to_vec(), } } + + fn get_descriptions_for_groups( + entity_type: EntityType, + groups: Vec, + ) -> HashMap { + Self::iter() + .filter_map(|parent| { + let scopes = groups + .iter() + .filter(|group| group.parent() == parent) + .map(|group| group.scope()) + .max()?; + + let resources = parent + .resources() + .iter() + .filter(|res| res.entities().iter().any(|entity| entity <= &entity_type)) + .map(|res| permissions::get_resource_name(res, &entity_type)) + .collect::>() + .join(", "); + + Some(( + parent, + format!("{} {}", permissions::get_scope_name(&scopes), resources), + )) + }) + .collect() + } } pub static OPERATIONS: [Resource; 8] = [ @@ -105,11 +154,10 @@ pub static OPERATIONS: [Resource; 8] = [ pub static CONNECTORS: [Resource; 2] = [Resource::Connector, Resource::Account]; -pub static WORKFLOWS: [Resource; 5] = [ +pub static WORKFLOWS: [Resource; 4] = [ Resource::Routing, Resource::ThreeDsDecisionManager, Resource::SurchargeDecisionManager, - Resource::Connector, Resource::Account, ]; diff --git a/crates/router/src/services/authorization/permissions.rs b/crates/router/src/services/authorization/permissions.rs index 0521db7acc15..6e472d55623b 100644 --- a/crates/router/src/services/authorization/permissions.rs +++ b/crates/router/src/services/authorization/permissions.rs @@ -73,3 +73,34 @@ generate_permissions! { }, ] } + +pub fn get_resource_name(resource: &Resource, entity_type: &EntityType) -> &'static str { + match (resource, entity_type) { + (Resource::Payment, _) => "Payments", + (Resource::Refund, _) => "Refunds", + (Resource::Dispute, _) => "Disputes", + (Resource::Mandate, _) => "Mandates", + (Resource::Customer, _) => "Customers", + (Resource::Payout, _) => "Payouts", + (Resource::ApiKey, _) => "Api Keys", + (Resource::Connector, _) => "Payment Processors, Payout Processors, Fraud & Risk Managers", + (Resource::Routing, _) => "Routing", + (Resource::ThreeDsDecisionManager, _) => "3DS Decision Manager", + (Resource::SurchargeDecisionManager, _) => "Surcharge Decision Manager", + (Resource::Analytics, _) => "Analytics", + (Resource::Report, _) => "Operation Reports", + (Resource::User, _) => "Users", + (Resource::WebhookEvent, _) => "Webhook Events", + (Resource::Recon, _) => "Reconciliation Reports", + (Resource::Account, EntityType::Profile) => "Business Profile Account", + (Resource::Account, EntityType::Merchant) => "Merchant Account", + (Resource::Account, EntityType::Organization) => "Organization Account", + } +} + +pub fn get_scope_name(scope: &PermissionScope) -> &'static str { + match scope { + PermissionScope::Read => "View", + PermissionScope::Write => "View and Manage", + } +} diff --git a/crates/router/src/services/authorization/roles/predefined_roles.rs b/crates/router/src/services/authorization/roles/predefined_roles.rs index 33a1d5f53ca7..39f6d47f824b 100644 --- a/crates/router/src/services/authorization/roles/predefined_roles.rs +++ b/crates/router/src/services/authorization/roles/predefined_roles.rs @@ -24,7 +24,9 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::UsersView, PermissionGroup::UsersManage, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, PermissionGroup::MerchantDetailsManage, + PermissionGroup::AccountManage, PermissionGroup::OrganizationManage, PermissionGroup::ReconOps, ], @@ -48,6 +50,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: common_utils::consts::ROLE_ID_INTERNAL_VIEW_ONLY_USER.to_string(), role_name: "internal_view_only".to_string(), @@ -75,7 +78,9 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::UsersView, PermissionGroup::UsersManage, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, PermissionGroup::MerchantDetailsManage, + PermissionGroup::AccountManage, PermissionGroup::OrganizationManage, PermissionGroup::ReconOps, ], @@ -105,7 +110,9 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::UsersView, PermissionGroup::UsersManage, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, PermissionGroup::MerchantDetailsManage, + PermissionGroup::AccountManage, PermissionGroup::ReconOps, ], role_id: consts::user_role::ROLE_ID_MERCHANT_ADMIN.to_string(), @@ -128,6 +135,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_MERCHANT_VIEW_ONLY.to_string(), role_name: "merchant_view_only".to_string(), @@ -148,6 +156,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::UsersView, PermissionGroup::UsersManage, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_MERCHANT_IAM_ADMIN.to_string(), role_name: "merchant_iam".to_string(), @@ -168,7 +177,9 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, PermissionGroup::MerchantDetailsManage, + PermissionGroup::AccountManage, ], role_id: consts::user_role::ROLE_ID_MERCHANT_DEVELOPER.to_string(), role_name: "merchant_developer".to_string(), @@ -191,6 +202,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_MERCHANT_OPERATOR.to_string(), role_name: "merchant_operator".to_string(), @@ -210,6 +222,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_MERCHANT_CUSTOMER_SUPPORT.to_string(), role_name: "customer_support".to_string(), @@ -237,7 +250,9 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::UsersView, PermissionGroup::UsersManage, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, PermissionGroup::MerchantDetailsManage, + PermissionGroup::AccountManage, ], role_id: consts::user_role::ROLE_ID_PROFILE_ADMIN.to_string(), role_name: "profile_admin".to_string(), @@ -259,6 +274,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_PROFILE_VIEW_ONLY.to_string(), role_name: "profile_view_only".to_string(), @@ -279,6 +295,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::UsersView, PermissionGroup::UsersManage, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_PROFILE_IAM_ADMIN.to_string(), role_name: "profile_iam".to_string(), @@ -299,7 +316,9 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, PermissionGroup::MerchantDetailsManage, + PermissionGroup::AccountManage, ], role_id: consts::user_role::ROLE_ID_PROFILE_DEVELOPER.to_string(), role_name: "profile_developer".to_string(), @@ -322,6 +341,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_PROFILE_OPERATOR.to_string(), role_name: "profile_operator".to_string(), @@ -341,6 +361,7 @@ pub static PREDEFINED_ROLES: Lazy> = Lazy::new(| PermissionGroup::AnalyticsView, PermissionGroup::UsersView, PermissionGroup::MerchantDetailsView, + PermissionGroup::AccountView, ], role_id: consts::user_role::ROLE_ID_PROFILE_CUSTOMER_SUPPORT.to_string(), role_name: "profile_customer_support".to_string(), diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs index 8d853ded338c..652ce2b81dbc 100644 --- a/crates/router_env/src/logger/types.rs +++ b/crates/router_env/src/logger/types.rs @@ -374,6 +374,8 @@ pub enum Flow { GetAuthorizationInfo, /// Get Roles info GetRolesInfo, + /// Get Parent Group Info + GetParentGroupInfo, /// List roles v2 ListRolesV2, /// List invitable roles at entity level @@ -382,8 +384,12 @@ pub enum Flow { ListUpdatableRolesAtEntityLevel, /// Get role GetRole, + /// Get parent info for role + GetRoleV2, /// Get role from token GetRoleFromToken, + /// Get resources and groups for role from token + GetRoleFromTokenV2, /// Update user role UpdateUserRole, /// Create merchant account for user in a org From bb246e27b72e9e4168c89b94e8d07d63a544b586 Mon Sep 17 00:00:00 2001 From: chikke srujan <121822803+srujanchikke@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:58:58 +0530 Subject: [PATCH 42/46] refactor(connnector): Structure connector enums in separate files for improved team ownership (#6459) Co-authored-by: Chikke Srujan Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com> --- .github/CODEOWNERS | 4 + crates/api_models/src/connector_enums.rs | 297 + crates/api_models/src/enums.rs | 298 +- crates/api_models/src/lib.rs | 1 + crates/common_enums/src/connector_enums.rs | 126 + crates/common_enums/src/enums.rs | 128 +- crates/common_enums/src/lib.rs | 1 + crates/router/src/configs/defaults.rs | 12562 +--------------- .../payment_connector_required_fields.rs | 12562 ++++++++++++++++ scripts/add_connector.sh | 10 +- 10 files changed, 13002 insertions(+), 12987 deletions(-) create mode 100644 crates/api_models/src/connector_enums.rs create mode 100644 crates/common_enums/src/connector_enums.rs create mode 100644 crates/router/src/configs/defaults/payment_connector_required_fields.rs diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3f7911188413..dc4010d0fd0c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -45,6 +45,10 @@ crates/test_utils/tests/connectors/ @juspay/hyperswitch-connector crates/test_utils/tests/sample_auth.toml @juspay/hyperswitch-connector crates/connector_configs/ @juspay/hyperswitch-connector crates/hyperswitch_connectors/ @juspay/hyperswitch-connector +crates/api_models/src/connector_enums.rs @juspay/hyperswitch-connector +crates/common_enums/src/connector_enums.rs @juspay/hyperswitch-connector +crates/router/src/configs/defaults/payment_connector_required_fields.rs @juspay/hyperswitch-connector +crates/hyperswitch_interfaces/src/configs.rs @juspay/hyperswitch-connector crates/router/src/compatibility/ @juspay/hyperswitch-compatibility diff --git a/crates/api_models/src/connector_enums.rs b/crates/api_models/src/connector_enums.rs new file mode 100644 index 000000000000..5803800f4df0 --- /dev/null +++ b/crates/api_models/src/connector_enums.rs @@ -0,0 +1,297 @@ +pub use common_enums::enums::{PaymentMethod, PayoutType}; +#[cfg(feature = "dummy_connector")] +use common_utils::errors; +use utoipa::ToSchema; + +/// A connector is an integration to fulfill payments +#[derive( + Clone, + Copy, + Debug, + Eq, + PartialEq, + ToSchema, + serde::Deserialize, + serde::Serialize, + strum::VariantNames, + strum::EnumIter, + strum::Display, + strum::EnumString, + Hash, +)] +#[serde(rename_all = "snake_case")] +#[strum(serialize_all = "snake_case")] +pub enum Connector { + Adyenplatform, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "phonypay")] + #[strum(serialize = "phonypay")] + DummyConnector1, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "fauxpay")] + #[strum(serialize = "fauxpay")] + DummyConnector2, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "pretendpay")] + #[strum(serialize = "pretendpay")] + DummyConnector3, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "stripe_test")] + #[strum(serialize = "stripe_test")] + DummyConnector4, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "adyen_test")] + #[strum(serialize = "adyen_test")] + DummyConnector5, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "checkout_test")] + #[strum(serialize = "checkout_test")] + DummyConnector6, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "paypal_test")] + #[strum(serialize = "paypal_test")] + DummyConnector7, + Aci, + Adyen, + Airwallex, + Authorizedotnet, + Bambora, + Bamboraapac, + Bankofamerica, + Billwerk, + Bitpay, + Bluesnap, + Boku, + Braintree, + Cashtocode, + Checkout, + Coinbase, + Cryptopay, + Cybersource, + Datatrans, + Deutschebank, + // Digitalvirgo, template code for future usage + Dlocal, + Ebanx, + Fiserv, + Fiservemea, + Fiuu, + Forte, + Globalpay, + Globepay, + Gocardless, + Gpayments, + Helcim, + Iatapay, + Itaubank, + Klarna, + Mifinity, + Mollie, + Multisafepay, + Netcetera, + Nexinets, + Nexixpay, + Nmi, + Noon, + Novalnet, + Nuvei, + // Opayo, added as template code for future usage + Opennode, + Paybox, + // Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage + Payme, + Payone, + Paypal, + Payu, + Placetopay, + Powertranz, + Prophetpay, + Rapyd, + Razorpay, + Shift4, + Square, + Stax, + Stripe, + Taxjar, + Threedsecureio, + //Thunes, + Trustpay, + Tsys, + Volt, + Wellsfargo, + // Wellsfargopayout, + Wise, + Worldline, + Worldpay, + Signifyd, + Plaid, + Riskified, + Zen, + Zsl, +} + +impl Connector { + #[cfg(feature = "payouts")] + pub fn supports_instant_payout(&self, payout_method: Option) -> bool { + matches!( + (self, payout_method), + (Self::Paypal, Some(PayoutType::Wallet)) + | (_, Some(PayoutType::Card)) + | (Self::Adyenplatform, _) + ) + } + #[cfg(feature = "payouts")] + pub fn supports_create_recipient(&self, payout_method: Option) -> bool { + matches!((self, payout_method), (_, Some(PayoutType::Bank))) + } + #[cfg(feature = "payouts")] + pub fn supports_payout_eligibility(&self, payout_method: Option) -> bool { + matches!((self, payout_method), (_, Some(PayoutType::Card))) + } + #[cfg(feature = "payouts")] + pub fn is_payout_quote_call_required(&self) -> bool { + matches!(self, Self::Wise) + } + #[cfg(feature = "payouts")] + pub fn supports_access_token_for_payout(&self, payout_method: Option) -> bool { + matches!((self, payout_method), (Self::Paypal, _)) + } + #[cfg(feature = "payouts")] + pub fn supports_vendor_disburse_account_create_for_payout(&self) -> bool { + matches!(self, Self::Stripe) + } + pub fn supports_access_token(&self, payment_method: PaymentMethod) -> bool { + matches!( + (self, payment_method), + (Self::Airwallex, _) + | (Self::Deutschebank, _) + | (Self::Globalpay, _) + | (Self::Paypal, _) + | (Self::Payu, _) + | (Self::Trustpay, PaymentMethod::BankRedirect) + | (Self::Iatapay, _) + | (Self::Volt, _) + | (Self::Itaubank, _) + ) + } + pub fn supports_file_storage_module(&self) -> bool { + matches!(self, Self::Stripe | Self::Checkout) + } + pub fn requires_defend_dispute(&self) -> bool { + matches!(self, Self::Checkout) + } + pub fn is_separate_authentication_supported(&self) -> bool { + match self { + #[cfg(feature = "dummy_connector")] + Self::DummyConnector1 + | Self::DummyConnector2 + | Self::DummyConnector3 + | Self::DummyConnector4 + | Self::DummyConnector5 + | Self::DummyConnector6 + | Self::DummyConnector7 => false, + Self::Aci + // Add Separate authentication support for connectors + | Self::Adyen + | Self::Adyenplatform + | Self::Airwallex + | Self::Authorizedotnet + | Self::Bambora + | Self::Bamboraapac + | Self::Bankofamerica + | Self::Billwerk + | Self::Bitpay + | Self::Bluesnap + | Self::Boku + | Self::Braintree + | Self::Cashtocode + | Self::Coinbase + | Self::Cryptopay + | Self::Deutschebank + | Self::Dlocal + | Self::Ebanx + | Self::Fiserv + | Self::Fiservemea + | Self::Fiuu + | Self::Forte + | Self::Globalpay + | Self::Globepay + | Self::Gocardless + | Self::Gpayments + | Self::Helcim + | Self::Iatapay + | Self::Itaubank + | Self::Klarna + | Self::Mifinity + | Self::Mollie + | Self::Multisafepay + | Self::Nexinets + | Self::Nexixpay + | Self::Novalnet + | Self::Nuvei + | Self::Opennode + | Self::Paybox + | Self::Payme + | Self::Payone + | Self::Paypal + | Self::Payu + | Self::Placetopay + | Self::Powertranz + | Self::Prophetpay + | Self::Rapyd + | Self::Shift4 + | Self::Square + | Self::Stax + | Self::Taxjar + // | Self::Thunes + | Self::Trustpay + | Self::Tsys + | Self::Volt + | Self::Wellsfargo + // | Self::Wellsfargopayout + | Self::Wise + | Self::Worldline + | Self::Worldpay + | Self::Zen + | Self::Zsl + | Self::Signifyd + | Self::Plaid + | Self::Razorpay + | Self::Riskified + | Self::Threedsecureio + | Self::Datatrans + | Self::Netcetera + | Self::Noon + | Self::Stripe => false, + Self::Checkout | Self::Nmi | Self::Cybersource => true, + } + } + pub fn is_pre_processing_required_before_authorize(&self) -> bool { + matches!(self, Self::Airwallex) + } + #[cfg(feature = "dummy_connector")] + pub fn validate_dummy_connector_enabled( + &self, + is_dummy_connector_enabled: bool, + ) -> errors::CustomResult<(), errors::ValidationError> { + if !is_dummy_connector_enabled + && matches!( + self, + Self::DummyConnector1 + | Self::DummyConnector2 + | Self::DummyConnector3 + | Self::DummyConnector4 + | Self::DummyConnector5 + | Self::DummyConnector6 + | Self::DummyConnector7 + ) + { + Err(errors::ValidationError::InvalidValue { + message: "Invalid connector name".to_string(), + } + .into()) + } else { + Ok(()) + } + } +} diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs index 48939e430595..e2b2b7fde46f 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -1,10 +1,10 @@ use std::str::FromStr; pub use common_enums::*; -#[cfg(feature = "dummy_connector")] -use common_utils::errors; use utoipa::ToSchema; +pub use super::connector_enums::Connector; + #[derive( Clone, Copy, @@ -27,300 +27,6 @@ pub enum RoutingAlgorithm { Custom, } -/// A connector is an integration to fulfill payments -#[derive( - Clone, - Copy, - Debug, - Eq, - PartialEq, - ToSchema, - serde::Deserialize, - serde::Serialize, - strum::VariantNames, - strum::EnumIter, - strum::Display, - strum::EnumString, - Hash, -)] -#[serde(rename_all = "snake_case")] -#[strum(serialize_all = "snake_case")] -pub enum Connector { - Adyenplatform, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "phonypay")] - #[strum(serialize = "phonypay")] - DummyConnector1, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "fauxpay")] - #[strum(serialize = "fauxpay")] - DummyConnector2, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "pretendpay")] - #[strum(serialize = "pretendpay")] - DummyConnector3, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "stripe_test")] - #[strum(serialize = "stripe_test")] - DummyConnector4, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "adyen_test")] - #[strum(serialize = "adyen_test")] - DummyConnector5, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "checkout_test")] - #[strum(serialize = "checkout_test")] - DummyConnector6, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "paypal_test")] - #[strum(serialize = "paypal_test")] - DummyConnector7, - Aci, - Adyen, - Airwallex, - Authorizedotnet, - Bambora, - Bamboraapac, - Bankofamerica, - Billwerk, - Bitpay, - Bluesnap, - Boku, - Braintree, - Cashtocode, - Checkout, - Coinbase, - Cryptopay, - Cybersource, - Datatrans, - Deutschebank, - // Digitalvirgo, template code for future usage - Dlocal, - Ebanx, - Fiserv, - Fiservemea, - Fiuu, - Forte, - Globalpay, - Globepay, - Gocardless, - Gpayments, - Helcim, - Iatapay, - Itaubank, - Klarna, - Mifinity, - Mollie, - Multisafepay, - Netcetera, - Nexinets, - Nexixpay, - Nmi, - Noon, - Novalnet, - Nuvei, - // Opayo, added as template code for future usage - Opennode, - Paybox, - // Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage - Payme, - Payone, - Paypal, - Payu, - Placetopay, - Powertranz, - Prophetpay, - Rapyd, - Razorpay, - Shift4, - Square, - Stax, - Stripe, - Taxjar, - Threedsecureio, - //Thunes, - Trustpay, - Tsys, - Volt, - Wellsfargo, - // Wellsfargopayout, - Wise, - Worldline, - Worldpay, - Signifyd, - Plaid, - Riskified, - Zen, - Zsl, -} - -impl Connector { - #[cfg(feature = "payouts")] - pub fn supports_instant_payout(&self, payout_method: Option) -> bool { - matches!( - (self, payout_method), - (Self::Paypal, Some(PayoutType::Wallet)) - | (_, Some(PayoutType::Card)) - | (Self::Adyenplatform, _) - ) - } - #[cfg(feature = "payouts")] - pub fn supports_create_recipient(&self, payout_method: Option) -> bool { - matches!((self, payout_method), (_, Some(PayoutType::Bank))) - } - #[cfg(feature = "payouts")] - pub fn supports_payout_eligibility(&self, payout_method: Option) -> bool { - matches!((self, payout_method), (_, Some(PayoutType::Card))) - } - #[cfg(feature = "payouts")] - pub fn is_payout_quote_call_required(&self) -> bool { - matches!(self, Self::Wise) - } - #[cfg(feature = "payouts")] - pub fn supports_access_token_for_payout(&self, payout_method: Option) -> bool { - matches!((self, payout_method), (Self::Paypal, _)) - } - #[cfg(feature = "payouts")] - pub fn supports_vendor_disburse_account_create_for_payout(&self) -> bool { - matches!(self, Self::Stripe) - } - pub fn supports_access_token(&self, payment_method: PaymentMethod) -> bool { - matches!( - (self, payment_method), - (Self::Airwallex, _) - | (Self::Deutschebank, _) - | (Self::Globalpay, _) - | (Self::Paypal, _) - | (Self::Payu, _) - | (Self::Trustpay, PaymentMethod::BankRedirect) - | (Self::Iatapay, _) - | (Self::Volt, _) - | (Self::Itaubank, _) - ) - } - pub fn supports_file_storage_module(&self) -> bool { - matches!(self, Self::Stripe | Self::Checkout) - } - pub fn requires_defend_dispute(&self) -> bool { - matches!(self, Self::Checkout) - } - pub fn is_separate_authentication_supported(&self) -> bool { - match self { - #[cfg(feature = "dummy_connector")] - Self::DummyConnector1 - | Self::DummyConnector2 - | Self::DummyConnector3 - | Self::DummyConnector4 - | Self::DummyConnector5 - | Self::DummyConnector6 - | Self::DummyConnector7 => false, - Self::Aci - // Add Separate authentication support for connectors - // | Self::Fiuu - | Self::Adyen - | Self::Adyenplatform - | Self::Airwallex - | Self::Authorizedotnet - | Self::Bambora - | Self::Bamboraapac - | Self::Bankofamerica - | Self::Billwerk - | Self::Bitpay - | Self::Bluesnap - | Self::Boku - | Self::Braintree - | Self::Cashtocode - | Self::Coinbase - | Self::Cryptopay - | Self::Deutschebank - | Self::Dlocal - | Self::Ebanx - | Self::Fiserv - | Self::Fiservemea - | Self::Fiuu - | Self::Forte - | Self::Globalpay - | Self::Globepay - | Self::Gocardless - | Self::Gpayments - | Self::Helcim - | Self::Iatapay - | Self::Itaubank - | Self::Klarna - | Self::Mifinity - | Self::Mollie - | Self::Multisafepay - | Self::Nexinets - | Self::Nexixpay - | Self::Novalnet - | Self::Nuvei - | Self::Opennode - | Self::Paybox - | Self::Payme - | Self::Payone - | Self::Paypal - | Self::Payu - | Self::Placetopay - | Self::Powertranz - | Self::Prophetpay - | Self::Rapyd - | Self::Shift4 - | Self::Square - | Self::Stax - | Self::Taxjar - //| Self::Thunes - | Self::Trustpay - | Self::Tsys - | Self::Volt - | Self::Wellsfargo - // | Self::Wellsfargopayout - | Self::Wise - | Self::Worldline - | Self::Worldpay - | Self::Zen - | Self::Zsl - | Self::Signifyd - | Self::Plaid - | Self::Razorpay - | Self::Riskified - | Self::Threedsecureio - | Self::Datatrans - | Self::Netcetera - | Self::Noon - | Self::Stripe => false, - Self::Checkout | Self::Nmi | Self::Cybersource => true, - } - } - pub fn is_pre_processing_required_before_authorize(&self) -> bool { - matches!(self, Self::Airwallex) - } - #[cfg(feature = "dummy_connector")] - pub fn validate_dummy_connector_enabled( - &self, - is_dummy_connector_enabled: bool, - ) -> errors::CustomResult<(), errors::ValidationError> { - if !is_dummy_connector_enabled - && matches!( - self, - Self::DummyConnector1 - | Self::DummyConnector2 - | Self::DummyConnector3 - | Self::DummyConnector4 - | Self::DummyConnector5 - | Self::DummyConnector6 - | Self::DummyConnector7 - ) - { - Err(errors::ValidationError::InvalidValue { - message: "Invalid connector name".to_string(), - } - .into()) - } else { - Ok(()) - } - } -} - #[cfg(feature = "payouts")] #[derive( Clone, diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs index daa329a76317..a28332e7fea0 100644 --- a/crates/api_models/src/lib.rs +++ b/crates/api_models/src/lib.rs @@ -5,6 +5,7 @@ pub mod apple_pay_certificates_migration; pub mod blocklist; pub mod cards_info; pub mod conditional_configs; +pub mod connector_enums; pub mod connector_onboarding; pub mod consts; pub mod currency; diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs new file mode 100644 index 000000000000..a5f6d0fe356c --- /dev/null +++ b/crates/common_enums/src/connector_enums.rs @@ -0,0 +1,126 @@ +use utoipa::ToSchema; +#[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + PartialEq, + serde::Serialize, + serde::Deserialize, + strum::Display, + strum::EnumString, + strum::EnumIter, + strum::VariantNames, + ToSchema, +)] +#[router_derive::diesel_enum(storage_type = "db_enum")] +#[serde(rename_all = "snake_case")] +#[strum(serialize_all = "snake_case")] +/// Connectors eligible for payments routing +pub enum RoutableConnectors { + Adyenplatform, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "phonypay")] + #[strum(serialize = "phonypay")] + DummyConnector1, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "fauxpay")] + #[strum(serialize = "fauxpay")] + DummyConnector2, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "pretendpay")] + #[strum(serialize = "pretendpay")] + DummyConnector3, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "stripe_test")] + #[strum(serialize = "stripe_test")] + DummyConnector4, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "adyen_test")] + #[strum(serialize = "adyen_test")] + DummyConnector5, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "checkout_test")] + #[strum(serialize = "checkout_test")] + DummyConnector6, + #[cfg(feature = "dummy_connector")] + #[serde(rename = "paypal_test")] + #[strum(serialize = "paypal_test")] + DummyConnector7, + Aci, + Adyen, + Airwallex, + Authorizedotnet, + Bankofamerica, + Billwerk, + Bitpay, + Bambora, + Bamboraapac, + Bluesnap, + Boku, + Braintree, + Cashtocode, + Checkout, + Coinbase, + Cryptopay, + Cybersource, + Datatrans, + Deutschebank, + // Digitalvirgo, template code for future usage + Dlocal, + Ebanx, + Fiserv, + Fiservemea, + Fiuu, + Forte, + Globalpay, + Globepay, + Gocardless, + Helcim, + Iatapay, + Itaubank, + Klarna, + Mifinity, + Mollie, + Multisafepay, + Nexinets, + Nexixpay, + Nmi, + Noon, + Novalnet, + Nuvei, + // Opayo, added as template code for future usage + Opennode, + // Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage + Paybox, + Payme, + Payone, + Paypal, + Payu, + Placetopay, + Powertranz, + Prophetpay, + Rapyd, + Razorpay, + Riskified, + Shift4, + Signifyd, + Square, + Stax, + Stripe, + // Taxjar, + Trustpay, + // Thunes + // Tsys, + Tsys, + Volt, + Wellsfargo, + // Wellsfargopayout, + Wise, + Worldline, + Worldpay, + Zen, + Plaid, + Zsl, +} diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index faae71eda223..917030c1e80e 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3,6 +3,8 @@ use std::num::{ParseFloatError, TryFromIntError}; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; +pub use super::connector_enums::RoutableConnectors; + #[doc(hidden)] pub mod diesel_exports { pub use super::{ @@ -140,132 +142,6 @@ pub enum AttemptStatus { DeviceDataCollectionPending, } -#[derive( - Clone, - Copy, - Debug, - Eq, - Hash, - PartialEq, - serde::Serialize, - serde::Deserialize, - strum::Display, - strum::EnumString, - strum::EnumIter, - strum::VariantNames, - ToSchema, -)] -#[router_derive::diesel_enum(storage_type = "db_enum")] -#[serde(rename_all = "snake_case")] -#[strum(serialize_all = "snake_case")] -/// Connectors eligible for payments routing -pub enum RoutableConnectors { - Adyenplatform, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "phonypay")] - #[strum(serialize = "phonypay")] - DummyConnector1, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "fauxpay")] - #[strum(serialize = "fauxpay")] - DummyConnector2, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "pretendpay")] - #[strum(serialize = "pretendpay")] - DummyConnector3, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "stripe_test")] - #[strum(serialize = "stripe_test")] - DummyConnector4, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "adyen_test")] - #[strum(serialize = "adyen_test")] - DummyConnector5, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "checkout_test")] - #[strum(serialize = "checkout_test")] - DummyConnector6, - #[cfg(feature = "dummy_connector")] - #[serde(rename = "paypal_test")] - #[strum(serialize = "paypal_test")] - DummyConnector7, - Aci, - Adyen, - Airwallex, - Authorizedotnet, - Bankofamerica, - Billwerk, - Bitpay, - Bambora, - Bamboraapac, - Bluesnap, - Boku, - Braintree, - Cashtocode, - Checkout, - Coinbase, - Cryptopay, - Cybersource, - Datatrans, - Deutschebank, - // Digitalvirgo, template code for future usage - Dlocal, - Ebanx, - Fiserv, - Fiservemea, - Fiuu, - Forte, - Globalpay, - Globepay, - Gocardless, - Helcim, - Iatapay, - Itaubank, - Klarna, - Mifinity, - Mollie, - Multisafepay, - Nexinets, - Nexixpay, - Nmi, - Noon, - Novalnet, - Nuvei, - // Opayo, added as template code for future usage - Opennode, - // Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage - Paybox, - Payme, - Payone, - Paypal, - Payu, - Placetopay, - Powertranz, - Prophetpay, - Rapyd, - Razorpay, - Riskified, - Shift4, - Signifyd, - Square, - Stax, - Stripe, - // Taxjar, - Trustpay, - // Thunes - // Tsys, - Tsys, - Volt, - Wellsfargo, - // Wellsfargopayout, - Wise, - Worldline, - Worldpay, - Zen, - Plaid, - Zsl, -} - impl AttemptStatus { pub fn is_terminal_status(self) -> bool { match self { diff --git a/crates/common_enums/src/lib.rs b/crates/common_enums/src/lib.rs index 14966d15b5f5..ec5b78d4a508 100644 --- a/crates/common_enums/src/lib.rs +++ b/crates/common_enums/src/lib.rs @@ -1,3 +1,4 @@ +pub mod connector_enums; pub mod enums; pub mod transformers; diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs index c48d2fe54caa..74f6502159da 100644 --- a/crates/router/src/configs/defaults.rs +++ b/crates/router/src/configs/defaults.rs @@ -2,11 +2,11 @@ use std::collections::{HashMap, HashSet}; use api_models::{enums, payment_methods::RequiredFieldInfo}; -use super::settings::{ConnectorFields, PaymentMethodType, RequiredFieldFinal}; - #[cfg(feature = "payouts")] pub mod payout_required_fields; +pub mod payment_connector_required_fields; + impl Default for super::settings::Server { fn default() -> Self { Self { @@ -138,12564 +138,6 @@ impl Default for super::settings::KvConfig { } } -use super::settings::{ - Mandates, SupportedConnectorsForMandate, SupportedPaymentMethodTypesForMandate, - SupportedPaymentMethodsForMandate, -}; - -impl Default for Mandates { - fn default() -> Self { - Self { - supported_payment_methods: SupportedPaymentMethodsForMandate(HashMap::from([ - ( - enums::PaymentMethod::PayLater, - SupportedPaymentMethodTypesForMandate(HashMap::from([( - enums::PaymentMethodType::Klarna, - SupportedConnectorsForMandate { - connector_list: HashSet::from([enums::Connector::Adyen]), - }, - )])), - ), - ( - enums::PaymentMethod::Wallet, - SupportedPaymentMethodTypesForMandate(HashMap::from([ - ( - enums::PaymentMethodType::GooglePay, - SupportedConnectorsForMandate { - connector_list: HashSet::from([ - enums::Connector::Stripe, - enums::Connector::Adyen, - enums::Connector::Globalpay, - enums::Connector::Multisafepay, - enums::Connector::Bankofamerica, - enums::Connector::Noon, - enums::Connector::Cybersource, - enums::Connector::Wellsfargo, - ]), - }, - ), - ( - enums::PaymentMethodType::ApplePay, - SupportedConnectorsForMandate { - connector_list: HashSet::from([ - enums::Connector::Stripe, - enums::Connector::Adyen, - enums::Connector::Bankofamerica, - enums::Connector::Cybersource, - enums::Connector::Wellsfargo, - ]), - }, - ), - ])), - ), - ( - enums::PaymentMethod::Card, - SupportedPaymentMethodTypesForMandate(HashMap::from([ - ( - enums::PaymentMethodType::Credit, - SupportedConnectorsForMandate { - connector_list: HashSet::from([ - enums::Connector::Aci, - enums::Connector::Adyen, - enums::Connector::Authorizedotnet, - enums::Connector::Globalpay, - enums::Connector::Worldpay, - enums::Connector::Multisafepay, - enums::Connector::Nexinets, - enums::Connector::Noon, - enums::Connector::Payme, - enums::Connector::Stripe, - enums::Connector::Bankofamerica, - enums::Connector::Cybersource, - enums::Connector::Wellsfargo, - ]), - }, - ), - ( - enums::PaymentMethodType::Debit, - SupportedConnectorsForMandate { - connector_list: HashSet::from([ - enums::Connector::Aci, - enums::Connector::Adyen, - enums::Connector::Authorizedotnet, - enums::Connector::Globalpay, - enums::Connector::Worldpay, - enums::Connector::Multisafepay, - enums::Connector::Nexinets, - enums::Connector::Noon, - enums::Connector::Payme, - enums::Connector::Stripe, - ]), - }, - ), - ])), - ), - ])), - update_mandate_supported: SupportedPaymentMethodsForMandate(HashMap::default()), - } - } -} - -impl Default for super::settings::RequiredFields { - fn default() -> Self { - Self(HashMap::from([ - ( - enums::PaymentMethod::Card, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::Debit, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Aci, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Airwallex, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Fiuu, - RequiredFieldFinal { - mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Authorizedotnet, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Bambora, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Bankofamerica, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Billwerk, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Bluesnap, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Boku, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Braintree, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Checkout, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Coinbase, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Cybersource, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common:HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Dlocal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - common:HashMap::new(), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector1, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector2, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector3, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector5, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector6, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector7, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Fiserv, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Fiuu, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Forte, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common:HashMap::new(), - } - ), - ( - enums::Connector::Globalpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Helcim, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Iatapay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Mollie, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Multisafepay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Nexinets, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Nmi, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "billing_zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Noon, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Novalnet, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "browser_info.language".to_string(), - RequiredFieldInfo { - required_field: "browser_info.language".to_string(), - display_name: "browser_info_language".to_string(), - field_type: enums::FieldType::BrowserLanguage, - value: None, - } - ), - ( - "browser_info.ip_address".to_string(), - RequiredFieldInfo { - required_field: "browser_info.ip_address".to_string(), - display_name: "browser_info_ip_address".to_string(), - field_type: enums::FieldType::BrowserIp, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "first_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "last_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email_address".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Nuvei, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Paybox, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - - ] - ), - } - ), - ( - enums::Connector::Payme, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Paypal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Payu, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Powertranz, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Rapyd, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Shift4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Square, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Stax, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common:HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ] - ), - common: HashMap::new() - } - ), - ( - enums::Connector::Tsys, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new() - } - ), - ( - enums::Connector::Wellsfargo, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common:HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Worldline, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Worldpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Zen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Credit, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Aci, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Airwallex, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Fiuu, - RequiredFieldFinal { - mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Authorizedotnet, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Bambora, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Bankofamerica, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Billwerk, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Bluesnap, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Boku, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Braintree, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Checkout, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Coinbase, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Cybersource, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Dlocal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - common:HashMap::new(), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector1, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector2, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector3, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector5, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector6, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - #[cfg(feature = "dummy_connector")] - ( - enums::Connector::DummyConnector7, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Fiserv, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Fiuu, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Forte, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common:HashMap::new(), - } - ), - ( - enums::Connector::Globalpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Helcim, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Iatapay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Mollie, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Multisafepay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Nexinets, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Nexixpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "first_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "last_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Nmi, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "billing_zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Noon, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Novalnet, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "browser_info.language".to_string(), - RequiredFieldInfo { - required_field: "browser_info.language".to_string(), - display_name: "browser_info_language".to_string(), - field_type: enums::FieldType::BrowserLanguage, - value: None, - } - ), - ( - "browser_info.ip_address".to_string(), - RequiredFieldInfo { - required_field: "browser_info.ip_address".to_string(), - display_name: "browser_info_ip_address".to_string(), - field_type: enums::FieldType::BrowserIp, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "first_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "last_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email_address".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Nuvei, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ),( - enums::Connector::Paybox, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - - ] - ), - } - ), - ( - enums::Connector::Payme, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Paypal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Payu, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Powertranz, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Rapyd, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Shift4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Square, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Stax, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common:HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ] - ), - common: HashMap::new() - } - ), - ( - enums::Connector::Tsys, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ) - ] - ), - common: HashMap::new() - } - ), - ( - enums::Connector::Wellsfargo, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ] - ), - } - ), - ( - enums::Connector::Worldline, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "payment_method_data.card.card_cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_cvc".to_string(), - display_name: "card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Worldpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Zen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ]), - }, - ), - - ])), - ), - ( - enums::PaymentMethod::BankRedirect, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::OpenBankingUk, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Volt, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap:: from([ - ( - "payment_method_data.bank_redirect.open_banking_uk.issuer".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.open_banking_uk.issuer".to_string(), - display_name: "issuer".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Trustly, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::OnlineBankingCzechRepublic, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.bank_redirect.open_banking_czech_republic.issuer".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.open_banking_czech_republic.issuer".to_string(), - display_name: "issuer".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::OnlineBankingFinland, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::OnlineBankingPoland, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.bank_redirect.open_banking_poland.issuer".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.open_banking_poland.issuer".to_string(), - display_name: "issuer".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ), - - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::OnlineBankingSlovakia, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.bank_redirect.open_banking_slovakia.issuer".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.open_banking_slovakia.issuer".to_string(), - display_name: "issuer".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::OnlineBankingFpx, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.bank_redirect.open_banking_fpx.issuer".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.open_banking_fpx.issuer".to_string(), - display_name: "issuer".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::OnlineBankingThailand, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.bank_redirect.open_banking_thailand.issuer".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.open_banking_thailand.issuer".to_string(), - display_name: "issuer".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Bizum, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Przelewy24, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - common: HashMap::new(), - } - )]), - }, - ), - ( - enums::PaymentMethodType::BancontactCard, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Mollie, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ]), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.bank_redirect.bancontact_card.card_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.bancontact_card.card_number".to_string(), - display_name: "card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.bank_redirect.bancontact_card.card_exp_month".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.bancontact_card.card_exp_month".to_string(), - display_name: "card_exp_month".to_string(), - field_type: enums::FieldType::UserCardExpiryMonth, - value: None, - } - ), - ( - "payment_method_data.bank_redirect.bancontact_card.card_exp_year".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.bancontact_card.card_exp_year".to_string(), - display_name: "card_exp_year".to_string(), - field_type: enums::FieldType::UserCardExpiryYear, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ]), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Giropay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Aci, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "DE".to_string(), - ]}, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Globalpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ("billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry { - options: vec![ - "DE".to_string(), - ] - }, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Mollie, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Nuvei, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::from([ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "DE".to_string(), - ] - }, - value: None, - } - )] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Paypal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "DE".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Shift4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry { - options: vec![ - "DE".to_string(), - ] - }, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Ideal, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Aci, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.bank_redirect.ideal.bank_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.ideal.bank_name".to_string(), - display_name: "bank_name".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "NL".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.bank_redirect.ideal.bank_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.ideal.bank_name".to_string(), - display_name: "bank_name".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ), - - ]), - } - ), - ( - enums::Connector::Globalpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Mollie, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Nexinets, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Nuvei, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "NL".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Shift4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry{ - options: vec![ - "NL".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Paypal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry{ - options: vec![ - "NL".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "billing_email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "NL".to_string(), - ] - }, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Sofort, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Aci, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ("billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "ES".to_string(), - "GB".to_string(), - "SE".to_string(), - "AT".to_string(), - "NL".to_string(), - "DE".to_string(), - "CH".to_string(), - "BE".to_string(), - "FR".to_string(), - "FI".to_string(), - "IT".to_string(), - "PL".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Globalpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ("billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry { - options: vec![ - "AT".to_string(), - "BE".to_string(), - "DE".to_string(), - "ES".to_string(), - "IT".to_string(), - "NL".to_string(), - ] - }, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Mollie, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Nexinets, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Nuvei, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::from([ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ES".to_string(), - "GB".to_string(), - "IT".to_string(), - "DE".to_string(), - "FR".to_string(), - "AT".to_string(), - "BE".to_string(), - "NL".to_string(), - "BE".to_string(), - "SK".to_string(), - ] - }, - value: None, - } - )] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Paypal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "ES".to_string(), - "GB".to_string(), - "AT".to_string(), - "NL".to_string(), - "DE".to_string(), - "BE".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Shift4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - non_mandate : HashMap::new(), - common: HashMap::from([ - ("billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "ES".to_string(), - "AT".to_string(), - "NL".to_string(), - "DE".to_string(), - "BE".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "account_holder_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "account_holder_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - )]), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry { - options: vec![ - "ES".to_string(), - "GB".to_string(), - "SE".to_string(), - "AT".to_string(), - "NL".to_string(), - "DE".to_string(), - "CH".to_string(), - "BE".to_string(), - "FR".to_string(), - "FI".to_string(), - "IT".to_string(), - "PL".to_string(), - ] - }, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Eps, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.bank_redirect.eps.bank_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.eps.bank_name".to_string(), - display_name: "bank_name".to_string(), - field_type: enums::FieldType::UserBank, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Aci, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "bank_account_country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "AT".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Globalpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry { - options: vec![ - "AT".to_string(), - ] - }, - value: None, - } - ) - ]) - } - ), - ( - enums::Connector::Mollie, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Paypal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "bank_account_country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "AT".to_string(), - ] - }, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "AT".to_string(), - ] - }, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Shift4, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate:HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Nuvei, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "AT".to_string(), - ] - }, - value: None, - } - )] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Blik, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.bank_redirect.blik.blik_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.blik.blik_code".to_string(), - display_name: "blik_code".to_string(), - field_type: enums::FieldType::UserBlikCode, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.bank_redirect.blik.blik_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_redirect.blik.blik_code".to_string(), - display_name: "blik_code".to_string(), - field_type: enums::FieldType::UserBlikCode, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ]), - } - ) - ]), - }, - ), - ])), - ), - ( - enums::PaymentMethod::Wallet, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::ApplePay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Bankofamerica, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Cybersource, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Wellsfargo, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "shipping.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.first_name".to_string(), - display_name: "shipping_first_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.last_name".to_string(), - display_name: "shipping_last_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.city".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserShippingAddressCity, - value: None, - } - ), - ( - "shipping.address.state".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserShippingAddressState, - value: None, - } - ), - ( - "shipping.address.zip".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserShippingAddressPincode, - value: None, - } - ), - ( - "shipping.address.country".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserShippingAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "shipping.address.line1".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserShippingAddressLine1, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - - ]), - }, - ), - ( - enums::PaymentMethodType::GooglePay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Bankofamerica, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Bluesnap, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Noon, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Nuvei, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Airwallex, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Authorizedotnet, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Checkout, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Globalpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Multisafepay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - )]), - common: HashMap::new(), - } - ), - ( - enums::Connector::Cybersource, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ( - enums::Connector::Payu, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Rapyd, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Trustpay, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Wellsfargo, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "email".to_string(), - RequiredFieldInfo { - required_field: "email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "shipping.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.first_name".to_string(), - display_name: "shipping_first_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.last_name".to_string(), - display_name: "shipping_last_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.city".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserShippingAddressCity, - value: None, - } - ), - ( - "shipping.address.state".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserShippingAddressState, - value: None, - } - ), - ( - "shipping.address.zip".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserShippingAddressPincode, - value: None, - } - ), - ( - "shipping.address.country".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserShippingAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "shipping.address.line1".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserShippingAddressLine1, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::WeChatPay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::AliPay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::AliPayHk, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Cashapp, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::MbWay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - common: HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), - display_name: "phone_number".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ] - ), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::KakaoPay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Twint, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Gcash, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Vipps, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Dana, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Momo, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Swish, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::TouchNGo, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - // Added shipping fields for the SDK flow to accept it from wallet directly, - // this won't show up in SDK in payment's sheet but will be used in the background - enums::PaymentMethodType::Paypal, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - )] - ), - } - ), - ( - enums::Connector::Braintree, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Paypal, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new( - ), - common: HashMap::from( - [ - ( - "shipping.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.first_name".to_string(), - display_name: "shipping_first_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.last_name".to_string(), - display_name: "shipping_last_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.city".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserShippingAddressCity, - value: None, - } - ), - ( - "shipping.address.state".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserShippingAddressState, - value: None, - } - ), - ( - "shipping.address.zip".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserShippingAddressPincode, - value: None, - } - ), - ( - "shipping.address.country".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserShippingAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "shipping.address.line1".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserShippingAddressLine1, - value: None, - } - ), - ] - ), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Mifinity, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Mifinity, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "payment_method_data.wallet.mifinity.date_of_birth".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.wallet.mifinity.date_of_birth".to_string(), - display_name: "date_of_birth".to_string(), - field_type: enums::FieldType::UserDateOfBirth, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "first_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "last_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "nationality".to_string(), - field_type: enums::FieldType::UserCountry{ - options: vec![ - "BR".to_string(), - "CN".to_string(), - "SG".to_string(), - "MY".to_string(), - "DE".to_string(), - "CH".to_string(), - "DK".to_string(), - "GB".to_string(), - "ES".to_string(), - "AD".to_string(), - "GI".to_string(), - "FI".to_string(), - "FR".to_string(), - "GR".to_string(), - "HR".to_string(), - "IT".to_string(), - "JP".to_string(), - "MX".to_string(), - "AR".to_string(), - "CO".to_string(), - "CL".to_string(), - "PE".to_string(), - "VE".to_string(), - "UY".to_string(), - "PY".to_string(), - "BO".to_string(), - "EC".to_string(), - "GT".to_string(), - "HN".to_string(), - "SV".to_string(), - "NI".to_string(), - "CR".to_string(), - "PA".to_string(), - "DO".to_string(), - "CU".to_string(), - "PR".to_string(), - "NL".to_string(), - "NO".to_string(), - "PL".to_string(), - "PT".to_string(), - "SE".to_string(), - "RU".to_string(), - "TR".to_string(), - "TW".to_string(), - "HK".to_string(), - "MO".to_string(), - "AX".to_string(), - "AL".to_string(), - "DZ".to_string(), - "AS".to_string(), - "AO".to_string(), - "AI".to_string(), - "AG".to_string(), - "AM".to_string(), - "AW".to_string(), - "AU".to_string(), - "AT".to_string(), - "AZ".to_string(), - "BS".to_string(), - "BH".to_string(), - "BD".to_string(), - "BB".to_string(), - "BE".to_string(), - "BZ".to_string(), - "BJ".to_string(), - "BM".to_string(), - "BT".to_string(), - "BQ".to_string(), - "BA".to_string(), - "BW".to_string(), - "IO".to_string(), - "BN".to_string(), - "BG".to_string(), - "BF".to_string(), - "BI".to_string(), - "KH".to_string(), - "CM".to_string(), - "CA".to_string(), - "CV".to_string(), - "KY".to_string(), - "CF".to_string(), - "TD".to_string(), - "CX".to_string(), - "CC".to_string(), - "KM".to_string(), - "CG".to_string(), - "CK".to_string(), - "CI".to_string(), - "CW".to_string(), - "CY".to_string(), - "CZ".to_string(), - "DJ".to_string(), - "DM".to_string(), - "EG".to_string(), - "GQ".to_string(), - "ER".to_string(), - "EE".to_string(), - "ET".to_string(), - "FK".to_string(), - "FO".to_string(), - "FJ".to_string(), - "GF".to_string(), - "PF".to_string(), - "TF".to_string(), - "GA".to_string(), - "GM".to_string(), - "GE".to_string(), - "GH".to_string(), - "GL".to_string(), - "GD".to_string(), - "GP".to_string(), - "GU".to_string(), - "GG".to_string(), - "GN".to_string(), - "GW".to_string(), - "GY".to_string(), - "HT".to_string(), - "HM".to_string(), - "VA".to_string(), - "IS".to_string(), - "IN".to_string(), - "ID".to_string(), - "IE".to_string(), - "IM".to_string(), - "IL".to_string(), - "JE".to_string(), - "JO".to_string(), - "KZ".to_string(), - "KE".to_string(), - "KI".to_string(), - "KW".to_string(), - "KG".to_string(), - "LA".to_string(), - "LV".to_string(), - "LB".to_string(), - "LS".to_string(), - "LI".to_string(), - "LT".to_string(), - "LU".to_string(), - "MK".to_string(), - "MG".to_string(), - "MW".to_string(), - "MV".to_string(), - "ML".to_string(), - "MT".to_string(), - "MH".to_string(), - "MQ".to_string(), - "MR".to_string(), - "MU".to_string(), - "YT".to_string(), - "FM".to_string(), - "MD".to_string(), - "MC".to_string(), - "MN".to_string(), - "ME".to_string(), - "MS".to_string(), - "MA".to_string(), - "MZ".to_string(), - "NA".to_string(), - "NR".to_string(), - "NP".to_string(), - "NC".to_string(), - "NZ".to_string(), - "NE".to_string(), - "NG".to_string(), - "NU".to_string(), - "NF".to_string(), - "MP".to_string(), - "OM".to_string(), - "PK".to_string(), - "PW".to_string(), - "PS".to_string(), - "PG".to_string(), - "PH".to_string(), - "PN".to_string(), - "QA".to_string(), - "RE".to_string(), - "RO".to_string(), - "RW".to_string(), - "BL".to_string(), - "SH".to_string(), - "KN".to_string(), - "LC".to_string(), - "MF".to_string(), - "PM".to_string(), - "VC".to_string(), - "WS".to_string(), - "SM".to_string(), - "ST".to_string(), - "SA".to_string(), - "SN".to_string(), - "RS".to_string(), - "SC".to_string(), - "SL".to_string(), - "SX".to_string(), - "SK".to_string(), - "SI".to_string(), - "SB".to_string(), - "SO".to_string(), - "ZA".to_string(), - "GS".to_string(), - "KR".to_string(), - "LK".to_string(), - "SR".to_string(), - "SJ".to_string(), - "SZ".to_string(), - "TH".to_string(), - "TL".to_string(), - "TG".to_string(), - "TK".to_string(), - "TO".to_string(), - "TT".to_string(), - "TN".to_string(), - "TM".to_string(), - "TC".to_string(), - "TV".to_string(), - "UG".to_string(), - "UA".to_string(), - "AE".to_string(), - "UZ".to_string(), - "VU".to_string(), - "VN".to_string(), - "VG".to_string(), - "VI".to_string(), - "WF".to_string(), - "EH".to_string(), - "ZM".to_string(), - ] - }, - value: None, - } - - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email_address".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "payment_method_data.wallet.mifinity.language_preference".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.wallet.mifinity.language_preference".to_string(), - display_name: "language_preference".to_string(), - field_type: enums::FieldType::LanguagePreference{ - options: vec![ - "BR".to_string(), - "PT_BR".to_string(), - "CN".to_string(), - "ZH_CN".to_string(), - "DE".to_string(), - "DK".to_string(), - "DA".to_string(), - "DA_DK".to_string(), - "EN".to_string(), - "ES".to_string(), - "FI".to_string(), - "FR".to_string(), - "GR".to_string(), - "EL".to_string(), - "EL_GR".to_string(), - "HR".to_string(), - "IT".to_string(), - "JP".to_string(), - "JA".to_string(), - "JA_JP".to_string(), - "LA".to_string(), - "ES_LA".to_string(), - "NL".to_string(), - "NO".to_string(), - "PL".to_string(), - "PT".to_string(), - "RU".to_string(), - "SV".to_string(), - "SE".to_string(), - "SV_SE".to_string(), - "ZH".to_string(), - "TW".to_string(), - "ZH_TW".to_string(), - ] - }, - value: None, - } - ), - ]), - } - ), - ]), - } - ), - ])), - ), - ( - enums::PaymentMethod::PayLater, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::AfterpayClearpay, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "GB".to_string(), - "AU".to_string(), - "CA".to_string(), - "US".to_string(), - "NZ".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "shipping.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.first_name".to_string(), - display_name: "shipping_first_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.last_name".to_string(), - display_name: "shipping_last_name".to_string(), - field_type: enums::FieldType::UserShippingName, - value: None, - } - ), - ( - "shipping.address.city".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserShippingAddressCity, - value: None, - } - ), - ( - "shipping.address.state".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserShippingAddressState, - value: None, - } - ), - ( - "shipping.address.zip".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserShippingAddressPincode, - value: None, - } - ), - ( - "shipping.address.country".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserShippingAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "shipping.address.line1".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserShippingAddressLine1, - value: None, - } - ), - ]), - common : HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "billing_last_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "GB".to_string(), - "AU".to_string(), - "CA".to_string(), - "US".to_string(), - "NZ".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "shipping.address.city".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserShippingAddressCity, - value: None, - } - ), - ( - "shipping.address.zip".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserShippingAddressPincode, - value: None, - } - ), - ( - "shipping.address.country".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserShippingAddressCountry{ - options: vec![ - "GB".to_string(), - "AU".to_string(), - "CA".to_string(), - "US".to_string(), - "NZ".to_string(), - ] - }, - value: None, - } - ), - ( - "shipping.address.line1".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserShippingAddressLine1, - value: None, - } - ), - ( - "shipping.address.line2".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserShippingAddressLine2, - value: None, - } - ), - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Klarna, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate: HashMap::from([ - ( "payment_method_data.pay_later.klarna.billing_country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(), - display_name: "billing_country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "AU".to_string(), - "AT".to_string(), - "BE".to_string(), - "CA".to_string(), - "CZ".to_string(), - "DK".to_string(), - "FI".to_string(), - "FR".to_string(), - "GR".to_string(), - "DE".to_string(), - "IE".to_string(), - "IT".to_string(), - "NL".to_string(), - "NZ".to_string(), - "NO".to_string(), - "PL".to_string(), - "PT".to_string(), - "RO".to_string(), - "ES".to_string(), - "SE".to_string(), - "CH".to_string(), - "GB".to_string(), - "US".to_string(), - ] - }, - value: None, - }), - ("billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - }) - ]), - common : HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate: HashMap::new(), - common : HashMap::from([ - ( "payment_method_data.pay_later.klarna.billing_country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(), - display_name: "billing_country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - }), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ]), - } - ), - ( - enums::Connector::Klarna, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "AU".to_string(), - "AT".to_string(), - "BE".to_string(), - "CA".to_string(), - "CZ".to_string(), - "DK".to_string(), - "FI".to_string(), - "FR".to_string(), - "DE".to_string(), - "GR".to_string(), - "IE".to_string(), - "IT".to_string(), - "NL".to_string(), - "NZ".to_string(), - "NO".to_string(), - "PL".to_string(), - "PT".to_string(), - "ES".to_string(), - "SE".to_string(), - "CH".to_string(), - "GB".to_string(), - "US".to_string(), - ] - }, - value: None, - } - ) - ]), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Affirm, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "US".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone_number".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "shipping.address.line1".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "shipping.address.line2".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "shipping.address.zip".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserShippingAddressPincode, - value: None, - } - ), - ( - "shipping.address.city".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserShippingAddressCity, - value: None, - } - ), - ( - "shipping.address.country".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserCountry { - options: vec![ - "US".to_string(), - ]}, - value: None, - } - ), - - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::PayBright, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "CA".to_string(), - ] - }, - value: None, - } - ), - ( - "payment_method_data.billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone_number".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ( - "shipping.address.city".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserShippingAddressCity, - value: None, - } - ), - ( - "shipping.address.zip".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserShippingAddressPincode, - value: None, - } - ), - ( - "shipping.address.country".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserShippingAddressCountry{ - options: vec![ - "ALL".to_string(), - ] - }, - value: None, - } - ), - ( - "shipping.address.line1".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserShippingAddressLine1, - value: None, - } - ), - ( - "shipping.address.line2".to_string(), - RequiredFieldInfo { - required_field: "shipping.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserShippingAddressLine2, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Walley, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "DK".to_string(), - "FI".to_string(), - "NO".to_string(), - "SE".to_string(), - ]}, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Alma, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "FR".to_string(), - ] - }, - value: None, - } - ), - ( - "payment_method_data.billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), - display_name: "phone_number".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Atome, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "MY".to_string(), - "SG".to_string() - ] - }, - value: None, - } - ), - ( - "payment_method_data.billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "billing.phone.number".to_string(), - display_name: "phone_number".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ])), - ), - ( - enums::PaymentMethod::Crypto, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::CryptoCurrency, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Cryptopay, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate: HashMap::from([ - ( - "payment_method_data.crypto.pay_currency".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.crypto.pay_currency".to_string(), - display_name: "currency".to_string(), - field_type: enums::FieldType::UserCurrency{ - options: vec![ - "BTC".to_string(), - "LTC".to_string(), - "ETH".to_string(), - "XRP".to_string(), - "XLM".to_string(), - "BCH".to_string(), - "ADA".to_string(), - "SOL".to_string(), - "SHIB".to_string(), - "TRX".to_string(), - "DOGE".to_string(), - "BNB".to_string(), - "USDT".to_string(), - "USDC".to_string(), - "DAI".to_string(), - ] - }, - value: None, - } - ), - ( - "payment_method_data.crypto.network".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.crypto.network".to_string(), - display_name: "network".to_string(), - field_type: enums::FieldType::UserCryptoCurrencyNetwork, - value: None, - } - ), - ]), - common : HashMap::new(), - } - ), - ]), - }, - ), - ])), - ), - ( - enums::PaymentMethod::Voucher, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::Boleto, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "payment_method_data.voucher.boleto.social_security_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.voucher.boleto.social_security_number".to_string(), - display_name: "social_security_number".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - } - ), - ( - "billing.address.state".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.state".to_string(), - display_name: "state".to_string(), - field_type: enums::FieldType::UserAddressState, - value: None, - } - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "BR".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - } - ), - ( - "billing.address.line2".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line2".to_string(), - display_name: "line2".to_string(), - field_type: enums::FieldType::UserAddressLine2, - value: None, - } - ), - ]), - common : HashMap::new(), - } - ), - ( - enums::Connector::Zen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Alfamart, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Indomaret, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Oxxo, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::new(), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::SevenEleven, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ) - ] - ), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Lawson, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ] - ), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::MiniStop, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ] - ), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::FamilyMart, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ] - ), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Seicomart, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ] - ), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::PayEasy, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ] - ), - common : HashMap::new(), - } - ) - ]), - }, - ), - ])), - ), - ( - enums::PaymentMethod::Upi, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::UpiCollect, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Razorpay, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::new(), - common : HashMap::from([ - ( - "payment_method_data.upi.upi_collect.vpa_id".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.upi.upi_collect.vpa_id".to_string(), - display_name: "vpa_id".to_string(), - field_type: enums::FieldType::UserVpaId, - value: None, - } - ), - ]), - } - ), - ]), - }, - ), - ])), - ), - ( - enums::PaymentMethod::BankDebit, - PaymentMethodType(HashMap::from([( - enums::PaymentMethodType::Ach, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.ach.account_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.ach.account_number".to_string(), - display_name: "bank_account_number".to_string(), - field_type: enums::FieldType::UserBankAccountNumber, - value: None, - } - ), - ( - "payment_method_data.bank_debit.ach.routing_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.ach.routing_number".to_string(), - display_name: "bank_routing_number".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ) - ]), - }), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - }), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.ach.account_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.ach.account_number".to_string(), - display_name: "bank_account_number".to_string(), - field_type: enums::FieldType::UserBankAccountNumber, - value: None, - } - ), - ( - "payment_method_data.bank_debit.ach.routing_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.ach.routing_number".to_string(), - display_name: "bank_routing_number".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ) - ]), - }) - ] - )} - ), - ( - enums::PaymentMethodType::Sepa, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), - display_name: "iban".to_string(), - field_type: enums::FieldType::UserIban, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - }), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), - display_name: "iban".to_string(), - field_type: enums::FieldType::UserIban, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Deutschebank, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - }), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), - display_name: "iban".to_string(), - field_type: enums::FieldType::UserIban, - value: None, - } - ) - ]), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Bacs, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.bacs.account_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(), - display_name: "bank_account_number".to_string(), - field_type: enums::FieldType::UserBankAccountNumber, - value: None, - } - ), - ( - "payment_method_data.bank_debit.bacs.sort_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(), - display_name: "bank_sort_code".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry { - options: vec!["UK".to_string()], - }, - value: None, - }, - ), - ( - "billing.address.zip".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.zip".to_string(), - display_name: "zip".to_string(), - field_type: enums::FieldType::UserAddressPincode, - value: None, - }, - ), - ( - "billing.address.line1".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.line1".to_string(), - display_name: "line1".to_string(), - field_type: enums::FieldType::UserAddressLine1, - value: None, - }, - ) - ]), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - }), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.bacs.account_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(), - display_name: "bank_account_number".to_string(), - field_type: enums::FieldType::UserBankAccountNumber, - value: None, - } - ), - ( - "payment_method_data.bank_debit.bacs.sort_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(), - display_name: "bank_sort_code".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ) - ]), - }) - ]), - }, - ), - ( - enums::PaymentMethodType::Becs, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "billing_first_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.becs.account_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.becs.account_number".to_string(), - display_name: "bank_account_number".to_string(), - field_type: enums::FieldType::UserBankAccountNumber, - value: None, - } - ), - ( - "payment_method_data.bank_debit.becs.bsb_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.becs.bsb_number".to_string(), - display_name: "bsb_number".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - }), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "owner_name".to_string(), - field_type: enums::FieldType::UserBillingName, - value: None, - } - ), - ( - "payment_method_data.bank_debit.bacs.account_number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(), - display_name: "bank_account_number".to_string(), - field_type: enums::FieldType::UserBankAccountNumber, - value: None, - } - ), - ( - "payment_method_data.bank_debit.bacs.sort_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(), - display_name: "bank_sort_code".to_string(), - field_type: enums::FieldType::Text, - value: None, - } - ) - ]), - }) - ]), - }, - ), - ]))), - ( - enums::PaymentMethod::BankTransfer, - PaymentMethodType(HashMap::from([( - enums::PaymentMethodType::Multibanco, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]), - common: HashMap::new(), - } - ), - ])}), - (enums::PaymentMethodType::LocalBankTransfer, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Zsl, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry{ - options: vec![ - "CN".to_string(), - ] - }, - value: None, - } - ), - ( - "billing.address.city".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.city".to_string(), - display_name: "city".to_string(), - field_type: enums::FieldType::UserAddressCity, - value: None, - }, - ), - ]), - common: HashMap::new(), - } - ), - ])}), - (enums::PaymentMethodType::Ach, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ]) - } - ), - ])}), - (enums::PaymentMethodType::Pix, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Itaubank, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::from( - [ - ( - "payment_method_data.bank_transfer.pix.pix_key".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_transfer.pix.pix_key".to_string(), - display_name: "pix_key".to_string(), - field_type: enums::FieldType::UserPixKey, - value: None, - } - ), - ( - "payment_method_data.bank_transfer.pix.cnpj".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_transfer.pix.cnpj".to_string(), - display_name: "cnpj".to_string(), - field_type: enums::FieldType::UserCnpj, - value: None, - } - ), - ( - "payment_method_data.bank_transfer.pix.cpf".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.bank_transfer.pix.cpf".to_string(), - display_name: "cpf".to_string(), - field_type: enums::FieldType::UserCpf, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ] - ), - } - ), - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ])}), - ( - enums::PaymentMethodType::PermataBankTransfer, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::BcaBankTransfer, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::BniVa, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::BriVa, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::CimbVa, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::DanamonVa, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::MandiriVa, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - common : HashMap::new(), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Sepa, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::new(), - common : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.country".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.country".to_string(), - display_name: "country".to_string(), - field_type: enums::FieldType::UserAddressCountry { - options: vec![ - "BE".to_string(), - "DE".to_string(), - "ES".to_string(), - "FR".to_string(), - "IE".to_string(), - "NL".to_string(), - ], - }, - value: None, - }, - ), - ]), - } - ) - ]), - }, - ), - ( - enums::PaymentMethodType::Bacs, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Stripe, - RequiredFieldFinal { - mandate : HashMap::new(), - non_mandate : HashMap::new(), - common : HashMap::from([ - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ), - ( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "card_holder_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ) - ]), - } - ) - ]), - }, - ), - ]))), - ( - enums::PaymentMethod::GiftCard, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::PaySafeCard, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Givex, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from([ - - ( - "payment_method_data.gift_card.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.gift_card.number".to_string(), - display_name: "gift_card_number".to_string(), - field_type: enums::FieldType::UserCardNumber, - value: None, - } - ), - ( - "payment_method_data.gift_card.cvc".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.gift_card.cvc".to_string(), - display_name: "gift_card_cvc".to_string(), - field_type: enums::FieldType::UserCardCvc, - value: None, - } - ), - ]), - common: HashMap::new(), - } - ), - ]), - }, - ), - ])) - ), - ( - enums::PaymentMethod::CardRedirect, - PaymentMethodType(HashMap::from([ - ( - enums::PaymentMethodType::Benefit, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "first_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "last_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::Knet, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::from( - [( - "billing.address.first_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.first_name".to_string(), - display_name: "first_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.address.last_name".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.address.last_name".to_string(), - display_name: "last_name".to_string(), - field_type: enums::FieldType::UserFullName, - value: None, - } - ), - ( - "billing.phone.number".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.number".to_string(), - display_name: "phone".to_string(), - field_type: enums::FieldType::UserPhoneNumber, - value: None, - } - ), - ( - "billing.phone.country_code".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.phone.country_code".to_string(), - display_name: "dialing_code".to_string(), - field_type: enums::FieldType::UserPhoneNumberCountryCode, - value: None, - } - ), - ( - "billing.email".to_string(), - RequiredFieldInfo { - required_field: "payment_method_data.billing.email".to_string(), - display_name: "email".to_string(), - field_type: enums::FieldType::UserEmailAddress, - value: None, - } - ) - ] - ), - common: HashMap::new(), - } - ), - ]), - }, - ), - ( - enums::PaymentMethodType::MomoAtm, - ConnectorFields { - fields: HashMap::from([ - ( - enums::Connector::Adyen, - RequiredFieldFinal { - mandate: HashMap::new(), - non_mandate: HashMap::new(), - common: HashMap::new(), - } - ), - ]), - }, - ) - ])) - ) - ])) - } -} - #[allow(clippy::derivable_impls)] impl Default for super::settings::ApiKeys { fn default() -> Self { diff --git a/crates/router/src/configs/defaults/payment_connector_required_fields.rs b/crates/router/src/configs/defaults/payment_connector_required_fields.rs new file mode 100644 index 000000000000..28ddeec1fcd3 --- /dev/null +++ b/crates/router/src/configs/defaults/payment_connector_required_fields.rs @@ -0,0 +1,12562 @@ +use std::collections::{HashMap, HashSet}; + +use api_models::{enums, payment_methods::RequiredFieldInfo}; + +use crate::settings::{ + self, ConnectorFields, Mandates, PaymentMethodType, RequiredFieldFinal, + SupportedConnectorsForMandate, SupportedPaymentMethodTypesForMandate, + SupportedPaymentMethodsForMandate, +}; + +impl Default for Mandates { + fn default() -> Self { + Self { + supported_payment_methods: SupportedPaymentMethodsForMandate(HashMap::from([ + ( + enums::PaymentMethod::PayLater, + SupportedPaymentMethodTypesForMandate(HashMap::from([( + enums::PaymentMethodType::Klarna, + SupportedConnectorsForMandate { + connector_list: HashSet::from([enums::Connector::Adyen]), + }, + )])), + ), + ( + enums::PaymentMethod::Wallet, + SupportedPaymentMethodTypesForMandate(HashMap::from([ + ( + enums::PaymentMethodType::GooglePay, + SupportedConnectorsForMandate { + connector_list: HashSet::from([ + enums::Connector::Stripe, + enums::Connector::Adyen, + enums::Connector::Globalpay, + enums::Connector::Multisafepay, + enums::Connector::Bankofamerica, + enums::Connector::Noon, + enums::Connector::Cybersource, + enums::Connector::Wellsfargo, + ]), + }, + ), + ( + enums::PaymentMethodType::ApplePay, + SupportedConnectorsForMandate { + connector_list: HashSet::from([ + enums::Connector::Stripe, + enums::Connector::Adyen, + enums::Connector::Bankofamerica, + enums::Connector::Cybersource, + enums::Connector::Wellsfargo, + ]), + }, + ), + ])), + ), + ( + enums::PaymentMethod::Card, + SupportedPaymentMethodTypesForMandate(HashMap::from([ + ( + enums::PaymentMethodType::Credit, + SupportedConnectorsForMandate { + connector_list: HashSet::from([ + enums::Connector::Aci, + enums::Connector::Adyen, + enums::Connector::Authorizedotnet, + enums::Connector::Globalpay, + enums::Connector::Worldpay, + enums::Connector::Multisafepay, + enums::Connector::Nexinets, + enums::Connector::Noon, + enums::Connector::Payme, + enums::Connector::Stripe, + enums::Connector::Bankofamerica, + enums::Connector::Cybersource, + enums::Connector::Wellsfargo, + ]), + }, + ), + ( + enums::PaymentMethodType::Debit, + SupportedConnectorsForMandate { + connector_list: HashSet::from([ + enums::Connector::Aci, + enums::Connector::Adyen, + enums::Connector::Authorizedotnet, + enums::Connector::Globalpay, + enums::Connector::Worldpay, + enums::Connector::Multisafepay, + enums::Connector::Nexinets, + enums::Connector::Noon, + enums::Connector::Payme, + enums::Connector::Stripe, + ]), + }, + ), + ])), + ), + ])), + update_mandate_supported: SupportedPaymentMethodsForMandate(HashMap::default()), + } + } +} + +impl Default for settings::RequiredFields { + fn default() -> Self { + Self(HashMap::from([ + ( + enums::PaymentMethod::Card, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::Debit, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Aci, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Airwallex, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Fiuu, + RequiredFieldFinal { + mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Authorizedotnet, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Bambora, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Bankofamerica, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Billwerk, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Bluesnap, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Boku, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Braintree, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Checkout, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Coinbase, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Cybersource, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common:HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Dlocal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + common:HashMap::new(), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector1, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector2, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector3, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector5, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector6, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector7, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Fiserv, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Fiuu, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Forte, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common:HashMap::new(), + } + ), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Helcim, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Iatapay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Multisafepay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Nexinets, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Nmi, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "billing_zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Noon, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Novalnet, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "browser_info.language".to_string(), + RequiredFieldInfo { + required_field: "browser_info.language".to_string(), + display_name: "browser_info_language".to_string(), + field_type: enums::FieldType::BrowserLanguage, + value: None, + } + ), + ( + "browser_info.ip_address".to_string(), + RequiredFieldInfo { + required_field: "browser_info.ip_address".to_string(), + display_name: "browser_info_ip_address".to_string(), + field_type: enums::FieldType::BrowserIp, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "first_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "last_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email_address".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Paybox, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + + ] + ), + } + ), + ( + enums::Connector::Payme, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Payu, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Powertranz, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Rapyd, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Shift4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Square, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Stax, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common:HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ] + ), + common: HashMap::new() + } + ), + ( + enums::Connector::Tsys, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new() + } + ), + ( + enums::Connector::Wellsfargo, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common:HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Worldline, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Worldpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Zen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Credit, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Aci, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Airwallex, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Fiuu, + RequiredFieldFinal { + mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Authorizedotnet, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Bambora, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Bankofamerica, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Billwerk, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Bluesnap, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Boku, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Braintree, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Checkout, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Coinbase, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Cybersource, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Dlocal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + common:HashMap::new(), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector1, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector2, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector3, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector5, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector6, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + #[cfg(feature = "dummy_connector")] + ( + enums::Connector::DummyConnector7, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Fiserv, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Fiuu, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Forte, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common:HashMap::new(), + } + ), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Helcim, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Iatapay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Multisafepay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Nexinets, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Nexixpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "first_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "last_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Nmi, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "billing_zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Noon, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Novalnet, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "browser_info.language".to_string(), + RequiredFieldInfo { + required_field: "browser_info.language".to_string(), + display_name: "browser_info_language".to_string(), + field_type: enums::FieldType::BrowserLanguage, + value: None, + } + ), + ( + "browser_info.ip_address".to_string(), + RequiredFieldInfo { + required_field: "browser_info.ip_address".to_string(), + display_name: "browser_info_ip_address".to_string(), + field_type: enums::FieldType::BrowserIp, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "first_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "last_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email_address".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ),( + enums::Connector::Paybox, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + + ] + ), + } + ), + ( + enums::Connector::Payme, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Payu, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Powertranz, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Rapyd, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Shift4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Square, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Stax, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common:HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ] + ), + common: HashMap::new() + } + ), + ( + enums::Connector::Tsys, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ) + ] + ), + common: HashMap::new() + } + ), + ( + enums::Connector::Wellsfargo, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ] + ), + } + ), + ( + enums::Connector::Worldline, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "payment_method_data.card.card_cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_cvc".to_string(), + display_name: "card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Worldpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Zen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ]), + }, + ), + + ])), + ), + ( + enums::PaymentMethod::BankRedirect, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::OpenBankingUk, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Volt, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap:: from([ + ( + "payment_method_data.bank_redirect.open_banking_uk.issuer".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.open_banking_uk.issuer".to_string(), + display_name: "issuer".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Trustly, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::OnlineBankingCzechRepublic, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.bank_redirect.open_banking_czech_republic.issuer".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.open_banking_czech_republic.issuer".to_string(), + display_name: "issuer".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::OnlineBankingFinland, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::OnlineBankingPoland, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.bank_redirect.open_banking_poland.issuer".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.open_banking_poland.issuer".to_string(), + display_name: "issuer".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ), + + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::OnlineBankingSlovakia, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.bank_redirect.open_banking_slovakia.issuer".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.open_banking_slovakia.issuer".to_string(), + display_name: "issuer".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::OnlineBankingFpx, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.bank_redirect.open_banking_fpx.issuer".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.open_banking_fpx.issuer".to_string(), + display_name: "issuer".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::OnlineBankingThailand, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.bank_redirect.open_banking_thailand.issuer".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.open_banking_thailand.issuer".to_string(), + display_name: "issuer".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Bizum, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Przelewy24, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + common: HashMap::new(), + } + )]), + }, + ), + ( + enums::PaymentMethodType::BancontactCard, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ]), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.bancontact_card.card_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.bancontact_card.card_number".to_string(), + display_name: "card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.bank_redirect.bancontact_card.card_exp_month".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.bancontact_card.card_exp_month".to_string(), + display_name: "card_exp_month".to_string(), + field_type: enums::FieldType::UserCardExpiryMonth, + value: None, + } + ), + ( + "payment_method_data.bank_redirect.bancontact_card.card_exp_year".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.bancontact_card.card_exp_year".to_string(), + display_name: "card_exp_year".to_string(), + field_type: enums::FieldType::UserCardExpiryYear, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ]), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Giropay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Aci, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "DE".to_string(), + ]}, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ("billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "DE".to_string(), + ] + }, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::from([ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "DE".to_string(), + ] + }, + value: None, + } + )] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "DE".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Shift4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "DE".to_string(), + ] + }, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Ideal, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Aci, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.bank_redirect.ideal.bank_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.ideal.bank_name".to_string(), + display_name: "bank_name".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "NL".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.ideal.bank_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.ideal.bank_name".to_string(), + display_name: "bank_name".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ), + + ]), + } + ), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nexinets, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "NL".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Shift4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry{ + options: vec![ + "NL".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry{ + options: vec![ + "NL".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "billing_email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "NL".to_string(), + ] + }, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Sofort, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Aci, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ("billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "ES".to_string(), + "GB".to_string(), + "SE".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "CH".to_string(), + "BE".to_string(), + "FR".to_string(), + "FI".to_string(), + "IT".to_string(), + "PL".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ("billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "AT".to_string(), + "BE".to_string(), + "DE".to_string(), + "ES".to_string(), + "IT".to_string(), + "NL".to_string(), + ] + }, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nexinets, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::from([ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ES".to_string(), + "GB".to_string(), + "IT".to_string(), + "DE".to_string(), + "FR".to_string(), + "AT".to_string(), + "BE".to_string(), + "NL".to_string(), + "BE".to_string(), + "SK".to_string(), + ] + }, + value: None, + } + )] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "ES".to_string(), + "GB".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "BE".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Shift4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + non_mandate : HashMap::new(), + common: HashMap::from([ + ("billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "ES".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "BE".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "account_holder_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "account_holder_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + )]), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "ES".to_string(), + "GB".to_string(), + "SE".to_string(), + "AT".to_string(), + "NL".to_string(), + "DE".to_string(), + "CH".to_string(), + "BE".to_string(), + "FR".to_string(), + "FI".to_string(), + "IT".to_string(), + "PL".to_string(), + ] + }, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Eps, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.eps.bank_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.eps.bank_name".to_string(), + display_name: "bank_name".to_string(), + field_type: enums::FieldType::UserBank, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Aci, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "bank_account_country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "AT".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "AT".to_string(), + ] + }, + value: None, + } + ) + ]) + } + ), + ( + enums::Connector::Mollie, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "bank_account_country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "AT".to_string(), + ] + }, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "AT".to_string(), + ] + }, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Shift4, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate:HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "AT".to_string(), + ] + }, + value: None, + } + )] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Blik, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.blik.blik_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.blik.blik_code".to_string(), + display_name: "blik_code".to_string(), + field_type: enums::FieldType::UserBlikCode, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.bank_redirect.blik.blik_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_redirect.blik.blik_code".to_string(), + display_name: "blik_code".to_string(), + field_type: enums::FieldType::UserBlikCode, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ]), + } + ) + ]), + }, + ), + ])), + ), + ( + enums::PaymentMethod::Wallet, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::ApplePay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Bankofamerica, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Cybersource, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Wellsfargo, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "shipping.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.first_name".to_string(), + display_name: "shipping_first_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.last_name".to_string(), + display_name: "shipping_last_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.city".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserShippingAddressCity, + value: None, + } + ), + ( + "shipping.address.state".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserShippingAddressState, + value: None, + } + ), + ( + "shipping.address.zip".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserShippingAddressPincode, + value: None, + } + ), + ( + "shipping.address.country".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserShippingAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "shipping.address.line1".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserShippingAddressLine1, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + + ]), + }, + ), + ( + enums::PaymentMethodType::GooglePay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Bankofamerica, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Bluesnap, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Noon, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Nuvei, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Airwallex, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Authorizedotnet, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Checkout, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Globalpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Multisafepay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + )]), + common: HashMap::new(), + } + ), + ( + enums::Connector::Cybersource, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ( + enums::Connector::Payu, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Rapyd, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Trustpay, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Wellsfargo, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "email".to_string(), + RequiredFieldInfo { + required_field: "email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "shipping.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.first_name".to_string(), + display_name: "shipping_first_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.last_name".to_string(), + display_name: "shipping_last_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.city".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserShippingAddressCity, + value: None, + } + ), + ( + "shipping.address.state".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserShippingAddressState, + value: None, + } + ), + ( + "shipping.address.zip".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserShippingAddressPincode, + value: None, + } + ), + ( + "shipping.address.country".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserShippingAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "shipping.address.line1".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserShippingAddressLine1, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::WeChatPay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::AliPay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::AliPayHk, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Cashapp, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::MbWay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + common: HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "billing.phone.number".to_string(), + display_name: "phone_number".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ] + ), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::KakaoPay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Twint, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Gcash, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Vipps, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Dana, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Momo, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Swish, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::TouchNGo, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + // Added shipping fields for the SDK flow to accept it from wallet directly, + // this won't show up in SDK in payment's sheet but will be used in the background + enums::PaymentMethodType::Paypal, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + )] + ), + } + ), + ( + enums::Connector::Braintree, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Paypal, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new( + ), + common: HashMap::from( + [ + ( + "shipping.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.first_name".to_string(), + display_name: "shipping_first_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.last_name".to_string(), + display_name: "shipping_last_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.city".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserShippingAddressCity, + value: None, + } + ), + ( + "shipping.address.state".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserShippingAddressState, + value: None, + } + ), + ( + "shipping.address.zip".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserShippingAddressPincode, + value: None, + } + ), + ( + "shipping.address.country".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserShippingAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "shipping.address.line1".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserShippingAddressLine1, + value: None, + } + ), + ] + ), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Mifinity, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Mifinity, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "payment_method_data.wallet.mifinity.date_of_birth".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.wallet.mifinity.date_of_birth".to_string(), + display_name: "date_of_birth".to_string(), + field_type: enums::FieldType::UserDateOfBirth, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "first_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "last_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "nationality".to_string(), + field_type: enums::FieldType::UserCountry{ + options: vec![ + "BR".to_string(), + "CN".to_string(), + "SG".to_string(), + "MY".to_string(), + "DE".to_string(), + "CH".to_string(), + "DK".to_string(), + "GB".to_string(), + "ES".to_string(), + "AD".to_string(), + "GI".to_string(), + "FI".to_string(), + "FR".to_string(), + "GR".to_string(), + "HR".to_string(), + "IT".to_string(), + "JP".to_string(), + "MX".to_string(), + "AR".to_string(), + "CO".to_string(), + "CL".to_string(), + "PE".to_string(), + "VE".to_string(), + "UY".to_string(), + "PY".to_string(), + "BO".to_string(), + "EC".to_string(), + "GT".to_string(), + "HN".to_string(), + "SV".to_string(), + "NI".to_string(), + "CR".to_string(), + "PA".to_string(), + "DO".to_string(), + "CU".to_string(), + "PR".to_string(), + "NL".to_string(), + "NO".to_string(), + "PL".to_string(), + "PT".to_string(), + "SE".to_string(), + "RU".to_string(), + "TR".to_string(), + "TW".to_string(), + "HK".to_string(), + "MO".to_string(), + "AX".to_string(), + "AL".to_string(), + "DZ".to_string(), + "AS".to_string(), + "AO".to_string(), + "AI".to_string(), + "AG".to_string(), + "AM".to_string(), + "AW".to_string(), + "AU".to_string(), + "AT".to_string(), + "AZ".to_string(), + "BS".to_string(), + "BH".to_string(), + "BD".to_string(), + "BB".to_string(), + "BE".to_string(), + "BZ".to_string(), + "BJ".to_string(), + "BM".to_string(), + "BT".to_string(), + "BQ".to_string(), + "BA".to_string(), + "BW".to_string(), + "IO".to_string(), + "BN".to_string(), + "BG".to_string(), + "BF".to_string(), + "BI".to_string(), + "KH".to_string(), + "CM".to_string(), + "CA".to_string(), + "CV".to_string(), + "KY".to_string(), + "CF".to_string(), + "TD".to_string(), + "CX".to_string(), + "CC".to_string(), + "KM".to_string(), + "CG".to_string(), + "CK".to_string(), + "CI".to_string(), + "CW".to_string(), + "CY".to_string(), + "CZ".to_string(), + "DJ".to_string(), + "DM".to_string(), + "EG".to_string(), + "GQ".to_string(), + "ER".to_string(), + "EE".to_string(), + "ET".to_string(), + "FK".to_string(), + "FO".to_string(), + "FJ".to_string(), + "GF".to_string(), + "PF".to_string(), + "TF".to_string(), + "GA".to_string(), + "GM".to_string(), + "GE".to_string(), + "GH".to_string(), + "GL".to_string(), + "GD".to_string(), + "GP".to_string(), + "GU".to_string(), + "GG".to_string(), + "GN".to_string(), + "GW".to_string(), + "GY".to_string(), + "HT".to_string(), + "HM".to_string(), + "VA".to_string(), + "IS".to_string(), + "IN".to_string(), + "ID".to_string(), + "IE".to_string(), + "IM".to_string(), + "IL".to_string(), + "JE".to_string(), + "JO".to_string(), + "KZ".to_string(), + "KE".to_string(), + "KI".to_string(), + "KW".to_string(), + "KG".to_string(), + "LA".to_string(), + "LV".to_string(), + "LB".to_string(), + "LS".to_string(), + "LI".to_string(), + "LT".to_string(), + "LU".to_string(), + "MK".to_string(), + "MG".to_string(), + "MW".to_string(), + "MV".to_string(), + "ML".to_string(), + "MT".to_string(), + "MH".to_string(), + "MQ".to_string(), + "MR".to_string(), + "MU".to_string(), + "YT".to_string(), + "FM".to_string(), + "MD".to_string(), + "MC".to_string(), + "MN".to_string(), + "ME".to_string(), + "MS".to_string(), + "MA".to_string(), + "MZ".to_string(), + "NA".to_string(), + "NR".to_string(), + "NP".to_string(), + "NC".to_string(), + "NZ".to_string(), + "NE".to_string(), + "NG".to_string(), + "NU".to_string(), + "NF".to_string(), + "MP".to_string(), + "OM".to_string(), + "PK".to_string(), + "PW".to_string(), + "PS".to_string(), + "PG".to_string(), + "PH".to_string(), + "PN".to_string(), + "QA".to_string(), + "RE".to_string(), + "RO".to_string(), + "RW".to_string(), + "BL".to_string(), + "SH".to_string(), + "KN".to_string(), + "LC".to_string(), + "MF".to_string(), + "PM".to_string(), + "VC".to_string(), + "WS".to_string(), + "SM".to_string(), + "ST".to_string(), + "SA".to_string(), + "SN".to_string(), + "RS".to_string(), + "SC".to_string(), + "SL".to_string(), + "SX".to_string(), + "SK".to_string(), + "SI".to_string(), + "SB".to_string(), + "SO".to_string(), + "ZA".to_string(), + "GS".to_string(), + "KR".to_string(), + "LK".to_string(), + "SR".to_string(), + "SJ".to_string(), + "SZ".to_string(), + "TH".to_string(), + "TL".to_string(), + "TG".to_string(), + "TK".to_string(), + "TO".to_string(), + "TT".to_string(), + "TN".to_string(), + "TM".to_string(), + "TC".to_string(), + "TV".to_string(), + "UG".to_string(), + "UA".to_string(), + "AE".to_string(), + "UZ".to_string(), + "VU".to_string(), + "VN".to_string(), + "VG".to_string(), + "VI".to_string(), + "WF".to_string(), + "EH".to_string(), + "ZM".to_string(), + ] + }, + value: None, + } + + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email_address".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "payment_method_data.wallet.mifinity.language_preference".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.wallet.mifinity.language_preference".to_string(), + display_name: "language_preference".to_string(), + field_type: enums::FieldType::LanguagePreference{ + options: vec![ + "BR".to_string(), + "PT_BR".to_string(), + "CN".to_string(), + "ZH_CN".to_string(), + "DE".to_string(), + "DK".to_string(), + "DA".to_string(), + "DA_DK".to_string(), + "EN".to_string(), + "ES".to_string(), + "FI".to_string(), + "FR".to_string(), + "GR".to_string(), + "EL".to_string(), + "EL_GR".to_string(), + "HR".to_string(), + "IT".to_string(), + "JP".to_string(), + "JA".to_string(), + "JA_JP".to_string(), + "LA".to_string(), + "ES_LA".to_string(), + "NL".to_string(), + "NO".to_string(), + "PL".to_string(), + "PT".to_string(), + "RU".to_string(), + "SV".to_string(), + "SE".to_string(), + "SV_SE".to_string(), + "ZH".to_string(), + "TW".to_string(), + "ZH_TW".to_string(), + ] + }, + value: None, + } + ), + ]), + } + ), + ]), + } + ), + ])), + ), + ( + enums::PaymentMethod::PayLater, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::AfterpayClearpay, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "GB".to_string(), + "AU".to_string(), + "CA".to_string(), + "US".to_string(), + "NZ".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "shipping.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.first_name".to_string(), + display_name: "shipping_first_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.last_name".to_string(), + display_name: "shipping_last_name".to_string(), + field_type: enums::FieldType::UserShippingName, + value: None, + } + ), + ( + "shipping.address.city".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserShippingAddressCity, + value: None, + } + ), + ( + "shipping.address.state".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserShippingAddressState, + value: None, + } + ), + ( + "shipping.address.zip".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserShippingAddressPincode, + value: None, + } + ), + ( + "shipping.address.country".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserShippingAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "shipping.address.line1".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserShippingAddressLine1, + value: None, + } + ), + ]), + common : HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "billing_last_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "GB".to_string(), + "AU".to_string(), + "CA".to_string(), + "US".to_string(), + "NZ".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "shipping.address.city".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserShippingAddressCity, + value: None, + } + ), + ( + "shipping.address.zip".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserShippingAddressPincode, + value: None, + } + ), + ( + "shipping.address.country".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserShippingAddressCountry{ + options: vec![ + "GB".to_string(), + "AU".to_string(), + "CA".to_string(), + "US".to_string(), + "NZ".to_string(), + ] + }, + value: None, + } + ), + ( + "shipping.address.line1".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserShippingAddressLine1, + value: None, + } + ), + ( + "shipping.address.line2".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserShippingAddressLine2, + value: None, + } + ), + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Klarna, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate: HashMap::from([ + ( "payment_method_data.pay_later.klarna.billing_country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(), + display_name: "billing_country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "AU".to_string(), + "AT".to_string(), + "BE".to_string(), + "CA".to_string(), + "CZ".to_string(), + "DK".to_string(), + "FI".to_string(), + "FR".to_string(), + "GR".to_string(), + "DE".to_string(), + "IE".to_string(), + "IT".to_string(), + "NL".to_string(), + "NZ".to_string(), + "NO".to_string(), + "PL".to_string(), + "PT".to_string(), + "RO".to_string(), + "ES".to_string(), + "SE".to_string(), + "CH".to_string(), + "GB".to_string(), + "US".to_string(), + ] + }, + value: None, + }), + ("billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + }) + ]), + common : HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate: HashMap::new(), + common : HashMap::from([ + ( "payment_method_data.pay_later.klarna.billing_country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.pay_later.klarna.billing_country".to_string(), + display_name: "billing_country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + }), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ]), + } + ), + ( + enums::Connector::Klarna, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "AU".to_string(), + "AT".to_string(), + "BE".to_string(), + "CA".to_string(), + "CZ".to_string(), + "DK".to_string(), + "FI".to_string(), + "FR".to_string(), + "DE".to_string(), + "GR".to_string(), + "IE".to_string(), + "IT".to_string(), + "NL".to_string(), + "NZ".to_string(), + "NO".to_string(), + "PL".to_string(), + "PT".to_string(), + "ES".to_string(), + "SE".to_string(), + "CH".to_string(), + "GB".to_string(), + "US".to_string(), + ] + }, + value: None, + } + ) + ]), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Affirm, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "US".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone_number".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "shipping.address.line1".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "shipping.address.line2".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "shipping.address.zip".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserShippingAddressPincode, + value: None, + } + ), + ( + "shipping.address.city".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserShippingAddressCity, + value: None, + } + ), + ( + "shipping.address.country".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserCountry { + options: vec![ + "US".to_string(), + ]}, + value: None, + } + ), + + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::PayBright, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "CA".to_string(), + ] + }, + value: None, + } + ), + ( + "payment_method_data.billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone_number".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ( + "shipping.address.city".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserShippingAddressCity, + value: None, + } + ), + ( + "shipping.address.zip".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserShippingAddressPincode, + value: None, + } + ), + ( + "shipping.address.country".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserShippingAddressCountry{ + options: vec![ + "ALL".to_string(), + ] + }, + value: None, + } + ), + ( + "shipping.address.line1".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserShippingAddressLine1, + value: None, + } + ), + ( + "shipping.address.line2".to_string(), + RequiredFieldInfo { + required_field: "shipping.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserShippingAddressLine2, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Walley, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "DK".to_string(), + "FI".to_string(), + "NO".to_string(), + "SE".to_string(), + ]}, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Alma, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "FR".to_string(), + ] + }, + value: None, + } + ), + ( + "payment_method_data.billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "billing.phone.number".to_string(), + display_name: "phone_number".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Atome, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "MY".to_string(), + "SG".to_string() + ] + }, + value: None, + } + ), + ( + "payment_method_data.billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "billing.phone.number".to_string(), + display_name: "phone_number".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ])), + ), + ( + enums::PaymentMethod::Crypto, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::CryptoCurrency, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Cryptopay, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate: HashMap::from([ + ( + "payment_method_data.crypto.pay_currency".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.crypto.pay_currency".to_string(), + display_name: "currency".to_string(), + field_type: enums::FieldType::UserCurrency{ + options: vec![ + "BTC".to_string(), + "LTC".to_string(), + "ETH".to_string(), + "XRP".to_string(), + "XLM".to_string(), + "BCH".to_string(), + "ADA".to_string(), + "SOL".to_string(), + "SHIB".to_string(), + "TRX".to_string(), + "DOGE".to_string(), + "BNB".to_string(), + "USDT".to_string(), + "USDC".to_string(), + "DAI".to_string(), + ] + }, + value: None, + } + ), + ( + "payment_method_data.crypto.network".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.crypto.network".to_string(), + display_name: "network".to_string(), + field_type: enums::FieldType::UserCryptoCurrencyNetwork, + value: None, + } + ), + ]), + common : HashMap::new(), + } + ), + ]), + }, + ), + ])), + ), + ( + enums::PaymentMethod::Voucher, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::Boleto, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "payment_method_data.voucher.boleto.social_security_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.voucher.boleto.social_security_number".to_string(), + display_name: "social_security_number".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + } + ), + ( + "billing.address.state".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.state".to_string(), + display_name: "state".to_string(), + field_type: enums::FieldType::UserAddressState, + value: None, + } + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "BR".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + } + ), + ( + "billing.address.line2".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line2".to_string(), + display_name: "line2".to_string(), + field_type: enums::FieldType::UserAddressLine2, + value: None, + } + ), + ]), + common : HashMap::new(), + } + ), + ( + enums::Connector::Zen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Alfamart, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Indomaret, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Oxxo, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::new(), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::SevenEleven, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ) + ] + ), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Lawson, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ] + ), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::MiniStop, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ] + ), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::FamilyMart, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ] + ), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Seicomart, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ] + ), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::PayEasy, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ] + ), + common : HashMap::new(), + } + ) + ]), + }, + ), + ])), + ), + ( + enums::PaymentMethod::Upi, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::UpiCollect, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Razorpay, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::new(), + common : HashMap::from([ + ( + "payment_method_data.upi.upi_collect.vpa_id".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.upi.upi_collect.vpa_id".to_string(), + display_name: "vpa_id".to_string(), + field_type: enums::FieldType::UserVpaId, + value: None, + } + ), + ]), + } + ), + ]), + }, + ), + ])), + ), + ( + enums::PaymentMethod::BankDebit, + PaymentMethodType(HashMap::from([( + enums::PaymentMethodType::Ach, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.ach.account_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.ach.account_number".to_string(), + display_name: "bank_account_number".to_string(), + field_type: enums::FieldType::UserBankAccountNumber, + value: None, + } + ), + ( + "payment_method_data.bank_debit.ach.routing_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.ach.routing_number".to_string(), + display_name: "bank_routing_number".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ) + ]), + }), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + }), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.ach.account_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.ach.account_number".to_string(), + display_name: "bank_account_number".to_string(), + field_type: enums::FieldType::UserBankAccountNumber, + value: None, + } + ), + ( + "payment_method_data.bank_debit.ach.routing_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.ach.routing_number".to_string(), + display_name: "bank_routing_number".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ) + ]), + }) + ] + )} + ), + ( + enums::PaymentMethodType::Sepa, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), + display_name: "iban".to_string(), + field_type: enums::FieldType::UserIban, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + }), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), + display_name: "iban".to_string(), + field_type: enums::FieldType::UserIban, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Deutschebank, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + }), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.sepa_bank_debit.iban".to_string(), + display_name: "iban".to_string(), + field_type: enums::FieldType::UserIban, + value: None, + } + ) + ]), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Bacs, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.bacs.account_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(), + display_name: "bank_account_number".to_string(), + field_type: enums::FieldType::UserBankAccountNumber, + value: None, + } + ), + ( + "payment_method_data.bank_debit.bacs.sort_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(), + display_name: "bank_sort_code".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec!["UK".to_string()], + }, + value: None, + }, + ), + ( + "billing.address.zip".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.zip".to_string(), + display_name: "zip".to_string(), + field_type: enums::FieldType::UserAddressPincode, + value: None, + }, + ), + ( + "billing.address.line1".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.line1".to_string(), + display_name: "line1".to_string(), + field_type: enums::FieldType::UserAddressLine1, + value: None, + }, + ) + ]), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + }), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.bacs.account_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(), + display_name: "bank_account_number".to_string(), + field_type: enums::FieldType::UserBankAccountNumber, + value: None, + } + ), + ( + "payment_method_data.bank_debit.bacs.sort_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(), + display_name: "bank_sort_code".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ) + ]), + }) + ]), + }, + ), + ( + enums::PaymentMethodType::Becs, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "billing_first_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.becs.account_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.becs.account_number".to_string(), + display_name: "bank_account_number".to_string(), + field_type: enums::FieldType::UserBankAccountNumber, + value: None, + } + ), + ( + "payment_method_data.bank_debit.becs.bsb_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.becs.bsb_number".to_string(), + display_name: "bsb_number".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + }), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "owner_name".to_string(), + field_type: enums::FieldType::UserBillingName, + value: None, + } + ), + ( + "payment_method_data.bank_debit.bacs.account_number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.bacs.account_number".to_string(), + display_name: "bank_account_number".to_string(), + field_type: enums::FieldType::UserBankAccountNumber, + value: None, + } + ), + ( + "payment_method_data.bank_debit.bacs.sort_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_debit.bacs.sort_code".to_string(), + display_name: "bank_sort_code".to_string(), + field_type: enums::FieldType::Text, + value: None, + } + ) + ]), + }) + ]), + }, + ), + ]))), + ( + enums::PaymentMethod::BankTransfer, + PaymentMethodType(HashMap::from([( + enums::PaymentMethodType::Multibanco, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]), + common: HashMap::new(), + } + ), + ])}), + (enums::PaymentMethodType::LocalBankTransfer, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Zsl, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry{ + options: vec![ + "CN".to_string(), + ] + }, + value: None, + } + ), + ( + "billing.address.city".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.city".to_string(), + display_name: "city".to_string(), + field_type: enums::FieldType::UserAddressCity, + value: None, + }, + ), + ]), + common: HashMap::new(), + } + ), + ])}), + (enums::PaymentMethodType::Ach, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ]) + } + ), + ])}), + (enums::PaymentMethodType::Pix, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Itaubank, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::from( + [ + ( + "payment_method_data.bank_transfer.pix.pix_key".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_transfer.pix.pix_key".to_string(), + display_name: "pix_key".to_string(), + field_type: enums::FieldType::UserPixKey, + value: None, + } + ), + ( + "payment_method_data.bank_transfer.pix.cnpj".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_transfer.pix.cnpj".to_string(), + display_name: "cnpj".to_string(), + field_type: enums::FieldType::UserCnpj, + value: None, + } + ), + ( + "payment_method_data.bank_transfer.pix.cpf".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.bank_transfer.pix.cpf".to_string(), + display_name: "cpf".to_string(), + field_type: enums::FieldType::UserCpf, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ] + ), + } + ), + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ])}), + ( + enums::PaymentMethodType::PermataBankTransfer, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::BcaBankTransfer, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::BniVa, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::BriVa, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::CimbVa, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::DanamonVa, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::MandiriVa, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + common : HashMap::new(), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Sepa, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::new(), + common : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.country".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.country".to_string(), + display_name: "country".to_string(), + field_type: enums::FieldType::UserAddressCountry { + options: vec![ + "BE".to_string(), + "DE".to_string(), + "ES".to_string(), + "FR".to_string(), + "IE".to_string(), + "NL".to_string(), + ], + }, + value: None, + }, + ), + ]), + } + ) + ]), + }, + ), + ( + enums::PaymentMethodType::Bacs, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Stripe, + RequiredFieldFinal { + mandate : HashMap::new(), + non_mandate : HashMap::new(), + common : HashMap::from([ + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ), + ( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "card_holder_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ) + ]), + } + ) + ]), + }, + ), + ]))), + ( + enums::PaymentMethod::GiftCard, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::PaySafeCard, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Givex, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from([ + + ( + "payment_method_data.gift_card.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.gift_card.number".to_string(), + display_name: "gift_card_number".to_string(), + field_type: enums::FieldType::UserCardNumber, + value: None, + } + ), + ( + "payment_method_data.gift_card.cvc".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.gift_card.cvc".to_string(), + display_name: "gift_card_cvc".to_string(), + field_type: enums::FieldType::UserCardCvc, + value: None, + } + ), + ]), + common: HashMap::new(), + } + ), + ]), + }, + ), + ])) + ), + ( + enums::PaymentMethod::CardRedirect, + PaymentMethodType(HashMap::from([ + ( + enums::PaymentMethodType::Benefit, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "first_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "last_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::Knet, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::from( + [( + "billing.address.first_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.first_name".to_string(), + display_name: "first_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.address.last_name".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.address.last_name".to_string(), + display_name: "last_name".to_string(), + field_type: enums::FieldType::UserFullName, + value: None, + } + ), + ( + "billing.phone.number".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.number".to_string(), + display_name: "phone".to_string(), + field_type: enums::FieldType::UserPhoneNumber, + value: None, + } + ), + ( + "billing.phone.country_code".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.phone.country_code".to_string(), + display_name: "dialing_code".to_string(), + field_type: enums::FieldType::UserPhoneNumberCountryCode, + value: None, + } + ), + ( + "billing.email".to_string(), + RequiredFieldInfo { + required_field: "payment_method_data.billing.email".to_string(), + display_name: "email".to_string(), + field_type: enums::FieldType::UserEmailAddress, + value: None, + } + ) + ] + ), + common: HashMap::new(), + } + ), + ]), + }, + ), + ( + enums::PaymentMethodType::MomoAtm, + ConnectorFields { + fields: HashMap::from([ + ( + enums::Connector::Adyen, + RequiredFieldFinal { + mandate: HashMap::new(), + non_mandate: HashMap::new(), + common: HashMap::new(), + } + ), + ]), + }, + ) + ])) + ) + ])) + } +} diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh index 2e12d8290508..0405f8b110f8 100755 --- a/scripts/add_connector.sh +++ b/scripts/add_connector.sh @@ -45,7 +45,7 @@ cd $SCRIPT/.. # Remove template files if already created for this connector rm -rf $conn/$payment_gateway $conn/$payment_gateway.rs -git checkout $conn.rs $src/types/api.rs $src/configs/settings.rs config/development.toml config/docker_compose.toml config/config.example.toml loadtest/config/development.toml crates/api_models/src/enums.rs crates/euclid/src/enums.rs crates/api_models/src/routing.rs $src/core/payments/flows.rs crates/common_enums/src/enums.rs $src/types/transformers.rs $src/core/admin.rs +git checkout $conn.rs $src/types/api.rs $src/configs/settings.rs config/development.toml config/docker_compose.toml config/config.example.toml loadtest/config/development.toml crates/api_models/src/connector_enums.rs crates/euclid/src/enums.rs crates/api_models/src/routing.rs $src/core/payments/flows.rs crates/common_enums/src/connector_enums.rs crates/common_enums/src/connector_enums.rs-e $src/types/transformers.rs $src/core/admin.rs # Add enum for this connector in required places previous_connector='' @@ -59,17 +59,17 @@ sed -i'' -e "s|$previous_connector_camelcase \(.*\)|$previous_connector_camelcas sed -i'' -e "s/pub $previous_connector: \(.*\)/pub $previous_connector: \1\n\tpub ${payment_gateway}: ConnectorParams,/" crates/hyperswitch_interfaces/src/configs.rs sed -i'' -e "s|$previous_connector.base_url \(.*\)|$previous_connector.base_url \1\n${payment_gateway}.base_url = \"$base_url\"|" config/development.toml config/docker_compose.toml config/config.example.toml loadtest/config/development.toml sed -r -i'' -e "s/\"$previous_connector\",/\"$previous_connector\",\n \"${payment_gateway}\",/" config/development.toml config/docker_compose.toml config/config.example.toml loadtest/config/development.toml -sed -i '' -e "s/\(pub enum Connector {\)/\1\n\t${payment_gateway_camelcase},/" crates/api_models/src/enums.rs -sed -i '' -e "/\/\/ Add Separate authentication support for connectors/{N;s/\(.*\)\n/\1\n\t\t\t| Self::${payment_gateway_camelcase}\n/;}" crates/api_models/src/enums.rs +sed -i '' -e "s/\(pub enum Connector {\)/\1\n\t${payment_gateway_camelcase},/" crates/api_models/src/connector_enums.rs +sed -i '' -e "/\/\/ Add Separate authentication support for connectors/{N;s/\(.*\)\n/\1\n\t\t\t| Self::${payment_gateway_camelcase}\n/;}" crates/api_models/src/connector_enums.rs sed -i '' -e "s/\(match connector_name {\)/\1\n\t\tapi_enums::Connector::${payment_gateway_camelcase} => {${payment_gateway}::transformers::${payment_gateway_camelcase}AuthType::try_from(val)?;Ok(())}/" $src/core/admin.rs -sed -i'' -e "s/\(pub enum RoutableConnectors {\)/\1\n\t${payment_gateway_camelcase},/" crates/common_enums/src/enums.rs +sed -i'' -e "s/\(pub enum RoutableConnectors {\)/\1\n\t${payment_gateway_camelcase},/" crates/common_enums/src/connector_enums.rs sed -i '' -e "s/\(pub enum Connector {\)/\1\n\t${payment_gateway_camelcase},/" crates/euclid/src/enums.rs sed -i'' -e "s|$previous_connector_camelcase \(.*\)|$previous_connector_camelcase \1\n\t\t\tapi_enums::Connector::${payment_gateway_camelcase} => Self::${payment_gateway_camelcase},|" $src/types/transformers.rs sed -i'' -e "s/^default_imp_for_\(.*\)/default_imp_for_\1\n\tconnectors::${payment_gateway_camelcase},/" crates/hyperswitch_connectors/src/default_implementations.rs sed -i'' -e "s/^default_imp_for_\(.*\)/default_imp_for_\1\n\tconnectors::${payment_gateway_camelcase},/" crates/hyperswitch_connectors/src/default_implementations_v2.rs # Remove temporary files created in above step -rm $conn.rs-e $src/types/api.rs-e $src/configs/settings.rs-e config/development.toml-e config/docker_compose.toml-e config/config.example.toml-e loadtest/config/development.toml-e crates/api_models/src/enums.rs-e crates/euclid/src/enums.rs-e crates/api_models/src/routing.rs-e $src/core/payments/flows.rs-e crates/common_enums/src/enums.rs-e $src/types/transformers.rs-e $src/core/admin.rs-e +rm $conn.rs-e $src/types/api.rs-e $src/configs/settings.rs-e config/development.toml-e config/docker_compose.toml-e config/config.example.toml-e loadtest/config/development.toml-e crates/api_models/src/connector_enums.rs-e crates/euclid/src/enums.rs-e crates/api_models/src/routing.rs-e $src/core/payments/flows.rs-e crates/common_enums/src/connector_enums.rs-e $src/types/transformers.rs-e $src/core/admin.rs-e crates/hyperswitch_connectors/src/default_implementations.rs-e crates/hyperswitch_connectors/src/default_implementations_v2.rs-e crates/hyperswitch_interfaces/src/configs.rs-e $src/connector.rs-e cd $conn/ # Generate template files for the connector From 62067e406a01d3a17ef94a04b0ef0304ebd05a70 Mon Sep 17 00:00:00 2001 From: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:02:15 +0530 Subject: [PATCH 43/46] chore(users): change entity_type column of roles to non-optional (#6435) --- crates/diesel_models/src/role.rs | 4 ++-- crates/diesel_models/src/schema.rs | 2 +- crates/diesel_models/src/schema_v2.rs | 2 +- crates/router/src/core/user_role/role.rs | 2 +- crates/router/src/db/role.rs | 2 +- crates/router/src/services/authorization/roles.rs | 2 +- .../down.sql | 4 ++++ .../up.sql | 6 ++++++ 8 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 migrations/2024-10-24-123318_update-entity-type-column-in-roles/down.sql create mode 100644 migrations/2024-10-24-123318_update-entity-type-column-in-roles/up.sql diff --git a/crates/diesel_models/src/role.rs b/crates/diesel_models/src/role.rs index 3fb64e645d60..8199bd3979ce 100644 --- a/crates/diesel_models/src/role.rs +++ b/crates/diesel_models/src/role.rs @@ -18,7 +18,7 @@ pub struct Role { pub created_by: String, pub last_modified_at: PrimitiveDateTime, pub last_modified_by: String, - pub entity_type: Option, + pub entity_type: enums::EntityType, } #[derive(router_derive::Setter, Clone, Debug, Insertable, router_derive::DebugAsDisplay)] @@ -35,7 +35,7 @@ pub struct RoleNew { pub created_by: String, pub last_modified_at: PrimitiveDateTime, pub last_modified_by: String, - pub entity_type: Option, + pub entity_type: enums::EntityType, } #[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)] diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index 8d2dfc47b623..e2ab676b2d30 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -1235,7 +1235,7 @@ diesel::table! { #[max_length = 64] last_modified_by -> Varchar, #[max_length = 64] - entity_type -> Nullable, + entity_type -> Varchar, } } diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs index b5e895cde790..5651bf95dd9d 100644 --- a/crates/diesel_models/src/schema_v2.rs +++ b/crates/diesel_models/src/schema_v2.rs @@ -1181,7 +1181,7 @@ diesel::table! { #[max_length = 64] last_modified_by -> Varchar, #[max_length = 64] - entity_type -> Nullable, + entity_type -> Varchar, } } diff --git a/crates/router/src/core/user_role/role.rs b/crates/router/src/core/user_role/role.rs index 1d37f7ac8d16..0250415d4fda 100644 --- a/crates/router/src/core/user_role/role.rs +++ b/crates/router/src/core/user_role/role.rs @@ -92,7 +92,7 @@ pub async fn create_role( org_id: user_from_token.org_id, groups: req.groups, scope: req.role_scope, - entity_type: Some(EntityType::Merchant), + entity_type: EntityType::Merchant, created_by: user_from_token.user_id.clone(), last_modified_by: user_from_token.user_id, created_at: now, diff --git a/crates/router/src/db/role.rs b/crates/router/src/db/role.rs index ce009d38a9ec..d13508356e5a 100644 --- a/crates/router/src/db/role.rs +++ b/crates/router/src/db/role.rs @@ -354,7 +354,7 @@ impl RoleInterface for MockDb { None => true, }; - matches_merchant && role.org_id == *org_id && role.entity_type == entity_type + matches_merchant && role.org_id == *org_id && Some(role.entity_type) == entity_type }) .take(limit_usize) .cloned() diff --git a/crates/router/src/services/authorization/roles.rs b/crates/router/src/services/authorization/roles.rs index 63d547bfa67e..bf66eb924669 100644 --- a/crates/router/src/services/authorization/roles.rs +++ b/crates/router/src/services/authorization/roles.rs @@ -119,7 +119,7 @@ impl From for RoleInfo { role_name: role.role_name, groups: role.groups.into_iter().map(Into::into).collect(), scope: role.scope, - entity_type: role.entity_type.unwrap_or(EntityType::Merchant), + entity_type: role.entity_type, is_invitable: true, is_deletable: true, is_updatable: true, diff --git a/migrations/2024-10-24-123318_update-entity-type-column-in-roles/down.sql b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/down.sql new file mode 100644 index 000000000000..60dfa892e602 --- /dev/null +++ b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/down.sql @@ -0,0 +1,4 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE roles ALTER COLUMN entity_type DROP DEFAULT; + +ALTER TABLE roles ALTER COLUMN entity_type DROP NOT NULL; \ No newline at end of file diff --git a/migrations/2024-10-24-123318_update-entity-type-column-in-roles/up.sql b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/up.sql new file mode 100644 index 000000000000..564a026184ef --- /dev/null +++ b/migrations/2024-10-24-123318_update-entity-type-column-in-roles/up.sql @@ -0,0 +1,6 @@ +-- Your SQL goes here +UPDATE roles SET entity_type = 'merchant' WHERE entity_type IS NULL; + +ALTER TABLE roles ALTER COLUMN entity_type SET DEFAULT 'merchant'; + +ALTER TABLE roles ALTER COLUMN entity_type SET NOT NULL; \ No newline at end of file From 33bc83fce47c579457f1b9be0a91bb4fa13585ff Mon Sep 17 00:00:00 2001 From: Gaurav Ghodinde <65962770+gauravghodinde@users.noreply.github.com> Date: Wed, 30 Oct 2024 19:44:44 +0530 Subject: [PATCH 44/46] refactor(connector): add amount conversion framework to rapyd (#6414) --- crates/router/src/connector/rapyd.rs | 47 +++++++++++-------- .../src/connector/rapyd/transformers.rs | 22 ++++----- crates/router/src/types/api.rs | 4 +- crates/router/tests/connectors/rapyd.rs | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index da10513b3d3b..196eb4ce73dd 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -1,11 +1,11 @@ pub mod transformers; -use std::fmt::Debug; use base64::Engine; use common_utils::{ date_time, ext_traits::{Encode, StringExt}, request::RequestContent, + types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, }; use diesel_models::enums; use error_stack::{Report, ResultExt}; @@ -17,6 +17,7 @@ use transformers as rapyd; use super::utils as connector_utils; use crate::{ configs::settings, + connector::utils::convert_amount, consts, core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, @@ -34,9 +35,17 @@ use crate::{ utils::{self, crypto, ByteSliceExt, BytesExt}, }; -#[derive(Debug, Clone)] -pub struct Rapyd; - +#[derive(Clone)] +pub struct Rapyd { + amount_converter: &'static (dyn AmountConvertor + Sync), +} +impl Rapyd { + pub fn new() -> &'static Self { + &Self { + amount_converter: &MinorUnitForConnector, + } + } +} impl Rapyd { pub fn generate_signature( &self, @@ -198,12 +207,12 @@ impl req: &types::PaymentsAuthorizeRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = rapyd::RapydRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + req.request.minor_amount, req.request.currency, - req.request.amount, - req, - ))?; + )?; + let connector_router_data = rapyd::RapydRouterData::from((amount, req)); let connector_req = rapyd::RapydPaymentsRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -528,12 +537,12 @@ impl req: &types::PaymentsCaptureRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = rapyd::RapydRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + req.request.minor_amount_to_capture, req.request.currency, - req.request.amount_to_capture, - req, - ))?; + )?; + let connector_router_data = rapyd::RapydRouterData::from((amount, req)); let connector_req = rapyd::CaptureRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) } @@ -668,12 +677,12 @@ impl services::ConnectorIntegration, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = rapyd::RapydRouterData::try_from(( - &self.get_currency_unit(), + let amount = convert_amount( + self.amount_converter, + req.request.minor_refund_amount, req.request.currency, - req.request.refund_amount, - req, - ))?; + )?; + let connector_router_data = rapyd::RapydRouterData::from((amount, req)); let connector_req = rapyd::RapydRefundRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(connector_req))) diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index 1246444ff313..b83ffcec4124 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -1,3 +1,4 @@ +use common_utils::types::MinorUnit; use error_stack::ResultExt; use serde::{Deserialize, Serialize}; use time::PrimitiveDateTime; @@ -15,25 +16,22 @@ use crate::{ #[derive(Debug, Serialize)] pub struct RapydRouterData { - pub amount: i64, + pub amount: MinorUnit, pub router_data: T, } -impl TryFrom<(&api::CurrencyUnit, enums::Currency, i64, T)> for RapydRouterData { - type Error = error_stack::Report; - fn try_from( - (_currency_unit, _currency, amount, item): (&api::CurrencyUnit, enums::Currency, i64, T), - ) -> Result { - Ok(Self { +impl From<(MinorUnit, T)> for RapydRouterData { + fn from((amount, router_data): (MinorUnit, T)) -> Self { + Self { amount, - router_data: item, - }) + router_data, + } } } #[derive(Default, Debug, Serialize)] pub struct RapydPaymentsRequest { - pub amount: i64, + pub amount: MinorUnit, pub currency: enums::Currency, pub payment_method: PaymentMethod, pub payment_method_options: Option, @@ -302,7 +300,7 @@ pub struct DisputeResponseData { #[derive(Default, Debug, Serialize)] pub struct RapydRefundRequest { pub payment: String, - pub amount: Option, + pub amount: Option, pub currency: Option, } @@ -409,7 +407,7 @@ impl TryFrom> #[derive(Debug, Serialize, Clone)] pub struct CaptureRequest { - amount: Option, + amount: Option, receipt_email: Option>, statement_descriptor: Option, } diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index a30462132726..ee25cb5fcb15 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -471,7 +471,9 @@ impl ConnectorData { enums::Connector::Razorpay => { Ok(ConnectorEnum::Old(Box::new(connector::Razorpay::new()))) } - enums::Connector::Rapyd => Ok(ConnectorEnum::Old(Box::new(&connector::Rapyd))), + enums::Connector::Rapyd => { + Ok(ConnectorEnum::Old(Box::new(connector::Rapyd::new()))) + } enums::Connector::Shift4 => { Ok(ConnectorEnum::Old(Box::new(connector::Shift4::new()))) } diff --git a/crates/router/tests/connectors/rapyd.rs b/crates/router/tests/connectors/rapyd.rs index fe6bc34cf18f..ff083a37e595 100644 --- a/crates/router/tests/connectors/rapyd.rs +++ b/crates/router/tests/connectors/rapyd.rs @@ -16,7 +16,7 @@ impl utils::Connector for Rapyd { fn get_data(&self) -> types::api::ConnectorData { use router::connector::Rapyd; utils::construct_connector_data_old( - Box::new(&Rapyd), + Box::new(Rapyd::new()), types::Connector::Rapyd, types::api::GetToken::Connector, None, From c514608594ebbe9894de47747b0d9fb573ab2503 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Wed, 30 Oct 2024 21:26:23 +0530 Subject: [PATCH 45/46] feat(router): Add payments get-intent API for v2 (#6396) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- .../payments/payments--get-intent.mdx | 3 + api-reference-v2/mint.json | 1 + api-reference-v2/openapi_spec.json | 389 ++++++++++-------- crates/api_models/src/events/payment.rs | 14 +- crates/api_models/src/payments.rs | 9 +- .../src/router_flow_types/payments.rs | 5 +- crates/openapi/src/openapi_v2.rs | 3 +- crates/openapi/src/routes/payments.rs | 21 +- crates/router/src/core/payments.rs | 4 +- crates/router/src/core/payments/operations.rs | 7 +- .../payments/operations/payment_get_intent.rs | 231 +++++++++++ .../router/src/core/payments/transformers.rs | 2 +- crates/router/src/routes/app.rs | 4 + crates/router/src/routes/lock_utils.rs | 1 + crates/router/src/routes/payments.rs | 57 ++- crates/router/src/services/api.rs | 4 +- crates/router/src/types/api/payments.rs | 8 +- crates/router_env/src/logger/types.rs | 2 + 18 files changed, 570 insertions(+), 195 deletions(-) create mode 100644 api-reference-v2/api-reference/payments/payments--get-intent.mdx create mode 100644 crates/router/src/core/payments/operations/payment_get_intent.rs diff --git a/api-reference-v2/api-reference/payments/payments--get-intent.mdx b/api-reference-v2/api-reference/payments/payments--get-intent.mdx new file mode 100644 index 000000000000..cd1321be217e --- /dev/null +++ b/api-reference-v2/api-reference/payments/payments--get-intent.mdx @@ -0,0 +1,3 @@ +--- +openapi: get /v2/payments/{id}/get-intent +--- \ No newline at end of file diff --git a/api-reference-v2/mint.json b/api-reference-v2/mint.json index 974e530f3111..17dd6dfb7ffa 100644 --- a/api-reference-v2/mint.json +++ b/api-reference-v2/mint.json @@ -38,6 +38,7 @@ "group": "Payments", "pages": [ "api-reference/payments/payments--create-intent", + "api-reference/payments/payments--get-intent", "api-reference/payments/payments--session-token", "api-reference/payments/payments--confirm-intent" ] diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 06bbf125dfbf..0c4679026031 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -1843,7 +1843,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PaymentsCreateIntentResponse" + "$ref": "#/components/schemas/PaymentsIntentResponse" } } } @@ -1859,6 +1859,47 @@ ] } }, + "/v2/payments/{id}/get-intent": { + "get": { + "tags": [ + "Payments" + ], + "summary": "Payments - Get Intent", + "description": "**Get a payment intent object when id is passed in path**\n\nYou will require the 'API - Key' from the Hyperswitch dashboard to make the call.", + "operationId": "Get the Payment Intent details", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The unique identifier for the Payment Intent", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Payment Intent", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentsIntentResponse" + } + } + } + }, + "404": { + "description": "Payment Intent not found" + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, "/v2/payments/{id}/confirm-intent": { "post": { "tags": [ @@ -13568,179 +13609,6 @@ }, "additionalProperties": false }, - "PaymentsCreateIntentResponse": { - "type": "object", - "required": [ - "id", - "amount_details", - "client_secret", - "capture_method", - "authentication_type", - "customer_present", - "setup_future_usage", - "apply_mit_exemption", - "payment_link_enabled", - "request_incremental_authorization", - "expires_on", - "request_external_three_ds_authentication" - ], - "properties": { - "id": { - "type": "string", - "description": "Global Payment Id for the payment" - }, - "amount_details": { - "$ref": "#/components/schemas/AmountDetailsResponse" - }, - "client_secret": { - "type": "string", - "description": "It's a token used for client side verification.", - "example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo" - }, - "merchant_reference_id": { - "type": "string", - "description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant.", - "example": "pay_mbabizu24mvu3mela5njyhpit4", - "nullable": true, - "maxLength": 30, - "minLength": 30 - }, - "routing_algorithm_id": { - "type": "string", - "description": "The routing algorithm id to be used for the payment", - "nullable": true - }, - "capture_method": { - "$ref": "#/components/schemas/CaptureMethod" - }, - "authentication_type": { - "allOf": [ - { - "$ref": "#/components/schemas/AuthenticationType" - } - ], - "default": "no_three_ds" - }, - "billing": { - "allOf": [ - { - "$ref": "#/components/schemas/Address" - } - ], - "nullable": true - }, - "shipping": { - "allOf": [ - { - "$ref": "#/components/schemas/Address" - } - ], - "nullable": true - }, - "customer_id": { - "type": "string", - "description": "The identifier for the customer", - "example": "cus_y3oqhf46pyzuxjbcn2giaqnb44", - "nullable": true, - "maxLength": 64, - "minLength": 1 - }, - "customer_present": { - "$ref": "#/components/schemas/PresenceOfCustomerDuringPayment" - }, - "description": { - "type": "string", - "description": "A description for the payment", - "example": "It's my first payment request", - "nullable": true - }, - "return_url": { - "type": "string", - "description": "The URL to which you want the user to be redirected after the completion of the payment operation", - "example": "https://hyperswitch.io", - "nullable": true - }, - "setup_future_usage": { - "$ref": "#/components/schemas/FutureUsage" - }, - "apply_mit_exemption": { - "$ref": "#/components/schemas/MitExemptionRequest" - }, - "statement_descriptor": { - "type": "string", - "description": "For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.", - "example": "Hyperswitch Router", - "nullable": true, - "maxLength": 22 - }, - "order_details": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OrderDetailsWithAmount" - }, - "description": "Use this object to capture the details about the different products for which the payment is being made. The sum of amount across different products here should be equal to the overall payment amount", - "example": "[{\n \"product_name\": \"Apple iPhone 16\",\n \"quantity\": 1,\n \"amount\" : 69000\n \"product_img_link\" : \"https://dummy-img-link.com\"\n }]", - "nullable": true - }, - "allowed_payment_method_types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PaymentMethodType" - }, - "description": "Use this parameter to restrict the Payment Method Types to show for a given PaymentIntent", - "nullable": true - }, - "metadata": { - "type": "object", - "description": "Metadata is useful for storing additional, unstructured information on an object.", - "nullable": true - }, - "connector_metadata": { - "allOf": [ - { - "$ref": "#/components/schemas/ConnectorMetadata" - } - ], - "nullable": true - }, - "feature_metadata": { - "allOf": [ - { - "$ref": "#/components/schemas/FeatureMetadata" - } - ], - "nullable": true - }, - "payment_link_enabled": { - "$ref": "#/components/schemas/EnablePaymentLinkRequest" - }, - "payment_link_config": { - "allOf": [ - { - "$ref": "#/components/schemas/PaymentLinkConfigRequest" - } - ], - "nullable": true - }, - "request_incremental_authorization": { - "$ref": "#/components/schemas/RequestIncrementalAuthorization" - }, - "expires_on": { - "type": "string", - "format": "date-time", - "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds" - }, - "frm_metadata": { - "type": "object", - "description": "Additional data related to some frm(Fraud Risk Management) connectors", - "nullable": true - }, - "request_external_three_ds_authentication": { - "$ref": "#/components/schemas/External3dsAuthenticationRequest" - } - }, - "additionalProperties": false - }, "PaymentsCreateResponseOpenApi": { "type": "object", "required": [ @@ -14434,6 +14302,179 @@ } } }, + "PaymentsIntentResponse": { + "type": "object", + "required": [ + "id", + "amount_details", + "client_secret", + "capture_method", + "authentication_type", + "customer_present", + "setup_future_usage", + "apply_mit_exemption", + "payment_link_enabled", + "request_incremental_authorization", + "expires_on", + "request_external_three_ds_authentication" + ], + "properties": { + "id": { + "type": "string", + "description": "Global Payment Id for the payment" + }, + "amount_details": { + "$ref": "#/components/schemas/AmountDetailsResponse" + }, + "client_secret": { + "type": "string", + "description": "It's a token used for client side verification.", + "example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo" + }, + "merchant_reference_id": { + "type": "string", + "description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant.", + "example": "pay_mbabizu24mvu3mela5njyhpit4", + "nullable": true, + "maxLength": 30, + "minLength": 30 + }, + "routing_algorithm_id": { + "type": "string", + "description": "The routing algorithm id to be used for the payment", + "nullable": true + }, + "capture_method": { + "$ref": "#/components/schemas/CaptureMethod" + }, + "authentication_type": { + "allOf": [ + { + "$ref": "#/components/schemas/AuthenticationType" + } + ], + "default": "no_three_ds" + }, + "billing": { + "allOf": [ + { + "$ref": "#/components/schemas/Address" + } + ], + "nullable": true + }, + "shipping": { + "allOf": [ + { + "$ref": "#/components/schemas/Address" + } + ], + "nullable": true + }, + "customer_id": { + "type": "string", + "description": "The identifier for the customer", + "example": "cus_y3oqhf46pyzuxjbcn2giaqnb44", + "nullable": true, + "maxLength": 64, + "minLength": 1 + }, + "customer_present": { + "$ref": "#/components/schemas/PresenceOfCustomerDuringPayment" + }, + "description": { + "type": "string", + "description": "A description for the payment", + "example": "It's my first payment request", + "nullable": true + }, + "return_url": { + "type": "string", + "description": "The URL to which you want the user to be redirected after the completion of the payment operation", + "example": "https://hyperswitch.io", + "nullable": true + }, + "setup_future_usage": { + "$ref": "#/components/schemas/FutureUsage" + }, + "apply_mit_exemption": { + "$ref": "#/components/schemas/MitExemptionRequest" + }, + "statement_descriptor": { + "type": "string", + "description": "For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.", + "example": "Hyperswitch Router", + "nullable": true, + "maxLength": 22 + }, + "order_details": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OrderDetailsWithAmount" + }, + "description": "Use this object to capture the details about the different products for which the payment is being made. The sum of amount across different products here should be equal to the overall payment amount", + "example": "[{\n \"product_name\": \"Apple iPhone 16\",\n \"quantity\": 1,\n \"amount\" : 69000\n \"product_img_link\" : \"https://dummy-img-link.com\"\n }]", + "nullable": true + }, + "allowed_payment_method_types": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PaymentMethodType" + }, + "description": "Use this parameter to restrict the Payment Method Types to show for a given PaymentIntent", + "nullable": true + }, + "metadata": { + "type": "object", + "description": "Metadata is useful for storing additional, unstructured information on an object.", + "nullable": true + }, + "connector_metadata": { + "allOf": [ + { + "$ref": "#/components/schemas/ConnectorMetadata" + } + ], + "nullable": true + }, + "feature_metadata": { + "allOf": [ + { + "$ref": "#/components/schemas/FeatureMetadata" + } + ], + "nullable": true + }, + "payment_link_enabled": { + "$ref": "#/components/schemas/EnablePaymentLinkRequest" + }, + "payment_link_config": { + "allOf": [ + { + "$ref": "#/components/schemas/PaymentLinkConfigRequest" + } + ], + "nullable": true + }, + "request_incremental_authorization": { + "$ref": "#/components/schemas/RequestIncrementalAuthorization" + }, + "expires_on": { + "type": "string", + "format": "date-time", + "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds" + }, + "frm_metadata": { + "type": "object", + "description": "Additional data related to some frm(Fraud Risk Management) connectors", + "nullable": true + }, + "request_external_three_ds_authentication": { + "$ref": "#/components/schemas/External3dsAuthenticationRequest" + } + }, + "additionalProperties": false + }, "PaymentsResponse": { "type": "object", "required": [ diff --git a/crates/api_models/src/events/payment.rs b/crates/api_models/src/events/payment.rs index 000343864b20..b9dc1476fdb8 100644 --- a/crates/api_models/src/events/payment.rs +++ b/crates/api_models/src/events/payment.rs @@ -2,7 +2,8 @@ use common_utils::events::{ApiEventMetric, ApiEventsType}; #[cfg(feature = "v2")] use super::{ - PaymentsConfirmIntentResponse, PaymentsCreateIntentRequest, PaymentsCreateIntentResponse, + PaymentsConfirmIntentResponse, PaymentsCreateIntentRequest, PaymentsGetIntentRequest, + PaymentsIntentResponse, }; #[cfg(all( any(feature = "v2", feature = "v1"), @@ -150,7 +151,16 @@ impl ApiEventMetric for PaymentsCreateIntentRequest { } #[cfg(feature = "v2")] -impl ApiEventMetric for PaymentsCreateIntentResponse { +impl ApiEventMetric for PaymentsGetIntentRequest { + fn get_api_event_type(&self) -> Option { + Some(ApiEventsType::Payment { + payment_id: self.id.clone(), + }) + } +} + +#[cfg(feature = "v2")] +impl ApiEventMetric for PaymentsIntentResponse { fn get_api_event_type(&self) -> Option { Some(ApiEventsType::Payment { payment_id: self.id.clone(), diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 2f90db83c551..ceb2b654871c 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -287,10 +287,17 @@ impl PaymentsCreateIntentRequest { } } +// This struct is only used internally, not visible in API Reference +#[derive(Debug, Clone, serde::Serialize)] +#[cfg(feature = "v2")] +pub struct PaymentsGetIntentRequest { + pub id: id_type::GlobalPaymentId, +} + #[derive(Debug, serde::Serialize, Clone, ToSchema)] #[serde(deny_unknown_fields)] #[cfg(feature = "v2")] -pub struct PaymentsCreateIntentResponse { +pub struct PaymentsIntentResponse { /// Global Payment Id for the payment #[schema(value_type = String)] pub id: id_type::GlobalPaymentId, diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs index 602c184139f9..c43d72ce8def 100644 --- a/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs +++ b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs @@ -57,7 +57,10 @@ pub struct CalculateTax; pub struct SdkSessionUpdate; #[derive(Debug, Clone)] -pub struct CreateIntent; +pub struct PaymentCreateIntent; + +#[derive(Debug, Clone)] +pub struct PaymentGetIntent; #[derive(Debug, Clone)] pub struct PostSessionTokens; diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 7bbe019dcbae..dacaedd97631 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -123,6 +123,7 @@ Never share your secret api keys. Keep them guarded and secure. //Routes for payments routes::payments::payments_create_intent, + routes::payments::payments_get_intent, routes::payments::payments_confirm_intent, //Routes for refunds @@ -325,7 +326,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::PaymentsSessionRequest, api_models::payments::PaymentsSessionResponse, api_models::payments::PaymentsCreateIntentRequest, - api_models::payments::PaymentsCreateIntentResponse, + api_models::payments::PaymentsIntentResponse, api_models::payments::PazeWalletData, api_models::payments::AmountDetails, api_models::payments::SessionToken, diff --git a/crates/openapi/src/routes/payments.rs b/crates/openapi/src/routes/payments.rs index 3429de60ba7b..e245c5af68a4 100644 --- a/crates/openapi/src/routes/payments.rs +++ b/crates/openapi/src/routes/payments.rs @@ -620,7 +620,7 @@ pub fn payments_post_session_tokens() {} ), ), responses( - (status = 200, description = "Payment created", body = PaymentsCreateIntentResponse), + (status = 200, description = "Payment created", body = PaymentsIntentResponse), (status = 400, description = "Missing Mandatory fields") ), tag = "Payments", @@ -630,6 +630,25 @@ pub fn payments_post_session_tokens() {} #[cfg(feature = "v2")] pub fn payments_create_intent() {} +/// Payments - Get Intent +/// +/// **Get a payment intent object when id is passed in path** +/// +/// You will require the 'API - Key' from the Hyperswitch dashboard to make the call. +#[utoipa::path( + get, + path = "/v2/payments/{id}/get-intent", + params (("id" = String, Path, description = "The unique identifier for the Payment Intent")), + responses( + (status = 200, description = "Payment Intent", body = PaymentsIntentResponse), + (status = 404, description = "Payment Intent not found") + ), + tag = "Payments", + operation_id = "Get the Payment Intent details", + security(("api_key" = [])), +)] +#[cfg(feature = "v2")] +pub fn payments_get_intent() {} /// Payments - Confirm Intent /// /// **Confirms a payment intent object with the payment method data** diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index de58eeed1008..860394f7c493 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -1021,7 +1021,7 @@ pub async fn payments_intent_operation_core( ) -> RouterResult<(D, Req, Option)> where F: Send + Clone + Sync, - Req: Authenticate + Clone, + Req: Clone, Op: Operation + Send + Sync, D: OperationSessionGetters + OperationSessionSetters + Send + Sync + Clone, { @@ -1454,7 +1454,7 @@ pub async fn payments_intent_core( where F: Send + Clone + Sync, Op: Operation + Send + Sync + Clone, - Req: Debug + Authenticate + Clone, + Req: Debug + Clone, D: OperationSessionGetters + OperationSessionSetters + Send + Sync + Clone, Res: transformers::ToResponse, { diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs index 6546638a62ed..b03f41ac0fd1 100644 --- a/crates/router/src/core/payments/operations.rs +++ b/crates/router/src/core/payments/operations.rs @@ -28,11 +28,12 @@ pub mod payments_incremental_authorization; #[cfg(feature = "v1")] pub mod tax_calculation; +#[cfg(feature = "v2")] +pub mod payment_confirm_intent; #[cfg(feature = "v2")] pub mod payment_create_intent; - #[cfg(feature = "v2")] -pub mod payment_confirm_intent; +pub mod payment_get_intent; use api_models::enums::FrmSuggestion; #[cfg(all(feature = "v1", feature = "dynamic_routing"))] @@ -45,6 +46,8 @@ use router_env::{instrument, tracing}; pub use self::payment_confirm_intent::PaymentIntentConfirm; #[cfg(feature = "v2")] pub use self::payment_create_intent::PaymentIntentCreate; +#[cfg(feature = "v2")] +pub use self::payment_get_intent::PaymentGetIntent; pub use self::payment_response::PaymentResponse; #[cfg(feature = "v1")] pub use self::{ diff --git a/crates/router/src/core/payments/operations/payment_get_intent.rs b/crates/router/src/core/payments/operations/payment_get_intent.rs new file mode 100644 index 000000000000..55ddc3b482a6 --- /dev/null +++ b/crates/router/src/core/payments/operations/payment_get_intent.rs @@ -0,0 +1,231 @@ +use std::marker::PhantomData; + +use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest}; +use async_trait::async_trait; +use common_utils::errors::CustomResult; +use router_env::{instrument, tracing}; + +use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; +use crate::{ + core::{ + errors::{self, RouterResult}, + payments::{self, helpers, operations}, + }, + db::errors::StorageErrorExt, + routes::{app::ReqState, SessionState}, + types::{ + api, domain, + storage::{self, enums}, + }, +}; + +#[derive(Debug, Clone, Copy)] +pub struct PaymentGetIntent; + +impl Operation for &PaymentGetIntent { + type Data = payments::PaymentIntentData; + fn to_validate_request( + &self, + ) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> + { + Ok(*self) + } + fn to_get_tracker( + &self, + ) -> RouterResult<&(dyn GetTracker + Send + Sync)> + { + Ok(*self) + } + fn to_domain(&self) -> RouterResult<&(dyn Domain)> { + Ok(*self) + } + fn to_update_tracker( + &self, + ) -> RouterResult<&(dyn UpdateTracker + Send + Sync)> + { + Ok(*self) + } +} + +impl Operation for PaymentGetIntent { + type Data = payments::PaymentIntentData; + fn to_validate_request( + &self, + ) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> + { + Ok(self) + } + fn to_get_tracker( + &self, + ) -> RouterResult<&(dyn GetTracker + Send + Sync)> + { + Ok(self) + } + fn to_domain(&self) -> RouterResult<&dyn Domain> { + Ok(self) + } + fn to_update_tracker( + &self, + ) -> RouterResult<&(dyn UpdateTracker + Send + Sync)> + { + Ok(self) + } +} + +type PaymentsGetIntentOperation<'b, F> = + BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData>; + +#[async_trait] +impl GetTracker, PaymentsGetIntentRequest> + for PaymentGetIntent +{ + #[instrument(skip_all)] + async fn get_trackers<'a>( + &'a self, + state: &'a SessionState, + _payment_id: &common_utils::id_type::GlobalPaymentId, + request: &PaymentsGetIntentRequest, + merchant_account: &domain::MerchantAccount, + _profile: &domain::Profile, + key_store: &domain::MerchantKeyStore, + _header_payload: &hyperswitch_domain_models::payments::HeaderPayload, + ) -> RouterResult< + operations::GetTrackerResponse< + 'a, + F, + PaymentsGetIntentRequest, + payments::PaymentIntentData, + >, + > { + let db = &*state.store; + let key_manager_state = &state.into(); + let storage_scheme = merchant_account.storage_scheme; + let payment_intent = db + .find_payment_intent_by_id(key_manager_state, &request.id, key_store, storage_scheme) + .await + .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; + + let payment_data = payments::PaymentIntentData { + flow: PhantomData, + payment_intent, + }; + + let get_trackers_response = operations::GetTrackerResponse { + operation: Box::new(self), + payment_data, + }; + + Ok(get_trackers_response) + } +} + +#[async_trait] +impl UpdateTracker, PaymentsGetIntentRequest> + for PaymentGetIntent +{ + #[instrument(skip_all)] + async fn update_trackers<'b>( + &'b self, + _state: &'b SessionState, + _req_state: ReqState, + payment_data: payments::PaymentIntentData, + _customer: Option, + _storage_scheme: enums::MerchantStorageScheme, + _updated_customer: Option, + _key_store: &domain::MerchantKeyStore, + _frm_suggestion: Option, + _header_payload: hyperswitch_domain_models::payments::HeaderPayload, + ) -> RouterResult<( + PaymentsGetIntentOperation<'b, F>, + payments::PaymentIntentData, + )> + where + F: 'b + Send, + { + Ok((Box::new(self), payment_data)) + } +} + +impl ValidateRequest> + for PaymentGetIntent +{ + #[instrument(skip_all)] + fn validate_request<'a, 'b>( + &'b self, + _request: &PaymentsGetIntentRequest, + merchant_account: &'a domain::MerchantAccount, + ) -> RouterResult<( + PaymentsGetIntentOperation<'b, F>, + operations::ValidateResult, + )> { + Ok(( + Box::new(self), + operations::ValidateResult { + merchant_id: merchant_account.get_id().to_owned(), + storage_scheme: merchant_account.storage_scheme, + requeue: false, + }, + )) + } +} + +#[async_trait] +impl Domain> + for PaymentGetIntent +{ + #[instrument(skip_all)] + async fn get_customer_details<'a>( + &'a self, + state: &SessionState, + payment_data: &mut payments::PaymentIntentData, + merchant_key_store: &domain::MerchantKeyStore, + storage_scheme: enums::MerchantStorageScheme, + ) -> CustomResult< + ( + BoxedOperation<'a, F, PaymentsGetIntentRequest, payments::PaymentIntentData>, + Option, + ), + errors::StorageError, + > { + Ok((Box::new(self), None)) + } + + #[instrument(skip_all)] + async fn make_pm_data<'a>( + &'a self, + _state: &'a SessionState, + _payment_data: &mut payments::PaymentIntentData, + _storage_scheme: enums::MerchantStorageScheme, + _merchant_key_store: &domain::MerchantKeyStore, + _customer: &Option, + _business_profile: &domain::Profile, + ) -> RouterResult<( + PaymentsGetIntentOperation<'a, F>, + Option, + Option, + )> { + Ok((Box::new(self), None, None)) + } + + async fn get_connector<'a>( + &'a self, + _merchant_account: &domain::MerchantAccount, + state: &SessionState, + _request: &PaymentsGetIntentRequest, + _payment_intent: &storage::PaymentIntent, + _merchant_key_store: &domain::MerchantKeyStore, + ) -> CustomResult { + helpers::get_connector_default(state, None).await + } + + #[instrument(skip_all)] + async fn guard_payment_against_blocklist<'a>( + &'a self, + _state: &SessionState, + _merchant_account: &domain::MerchantAccount, + _key_store: &domain::MerchantKeyStore, + _payment_data: &mut payments::PaymentIntentData, + ) -> CustomResult { + Ok(false) + } +} diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index c623ad86e647..e059ebdb8b52 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -755,7 +755,7 @@ where } #[cfg(feature = "v2")] -impl ToResponse for api::PaymentsCreateIntentResponse +impl ToResponse for api::PaymentsIntentResponse where F: Clone, Op: Debug, diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index f54895ce7da3..ae099a36e444 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -527,6 +527,10 @@ impl Payments { web::resource("/confirm-intent") .route(web::post().to(payments::payment_confirm_intent)), ) + .service( + web::resource("/get-intent") + .route(web::get().to(payments::payments_get_intent)), + ) .service( web::resource("/create-external-sdk-tokens") .route(web::post().to(payments::payments_connector_session)), diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs index ac17cf802107..43ddc35b8ae6 100644 --- a/crates/router/src/routes/lock_utils.rs +++ b/crates/router/src/routes/lock_utils.rs @@ -139,6 +139,7 @@ impl From for ApiIdentifier { | Flow::SessionUpdateTaxCalculation | Flow::PaymentsConfirmIntent | Flow::PaymentsCreateIntent + | Flow::PaymentsGetIntent | Flow::PaymentsPostSessionTokens => Self::Payments, Flow::PayoutsCreate diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs index bca7bd37cccb..62cb4a0b79b1 100644 --- a/crates/router/src/routes/payments.rs +++ b/crates/router/src/routes/payments.rs @@ -125,11 +125,11 @@ pub async fn payments_create_intent( json_payload.into_inner(), |state, auth: auth::AuthenticationDataV2, req, req_state| { payments::payments_intent_core::< - api_types::CreateIntent, - payment_types::PaymentsCreateIntentResponse, + api_types::PaymentCreateIntent, + payment_types::PaymentsIntentResponse, _, _, - PaymentIntentData, + PaymentIntentData, >( state, req_state, @@ -156,6 +156,57 @@ pub async fn payments_create_intent( .await } +#[cfg(feature = "v2")] +#[instrument(skip_all, fields(flow = ?Flow::PaymentsGetIntent, payment_id))] +pub async fn payments_get_intent( + state: web::Data, + req: actix_web::HttpRequest, + path: web::Path, +) -> impl Responder { + use api_models::payments::PaymentsGetIntentRequest; + use hyperswitch_domain_models::payments::PaymentIntentData; + + let flow = Flow::PaymentsGetIntent; + let header_payload = match HeaderPayload::foreign_try_from(req.headers()) { + Ok(headers) => headers, + Err(err) => { + return api::log_and_return_error_response(err); + } + }; + + let payload = PaymentsGetIntentRequest { + id: path.into_inner(), + }; + + Box::pin(api::server_wrap( + flow, + state, + &req, + payload, + |state, auth: auth::AuthenticationDataV2, req, req_state| { + payments::payments_intent_core::< + api_types::PaymentGetIntent, + payment_types::PaymentsIntentResponse, + _, + _, + PaymentIntentData, + >( + state, + req_state, + auth.merchant_account, + auth.profile, + auth.key_store, + payments::operations::PaymentGetIntent, + req, + header_payload.clone(), + ) + }, + &auth::HeaderAuth(auth::ApiKeyAuth), + api_locking::LockAction::NotApplicable, + )) + .await +} + #[cfg(feature = "v1")] #[instrument(skip(state, req), fields(flow = ?Flow::PaymentsStart, payment_id))] pub async fn payments_start( diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 02d4950a47d8..2cf8b721a057 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -1259,10 +1259,8 @@ impl Authenticate for api_models::payments::PaymentsIncrementalAuthorizationRequ impl Authenticate for api_models::payments::PaymentsStartRequest {} // impl Authenticate for api_models::payments::PaymentsApproveRequest {} impl Authenticate for api_models::payments::PaymentsRejectRequest {} -#[cfg(feature = "v2")] -impl Authenticate for api_models::payments::PaymentsCreateIntentRequest {} // #[cfg(feature = "v2")] -// impl Authenticate for api_models::payments::PaymentsCreateIntentResponse {} +// impl Authenticate for api_models::payments::PaymentsIntentResponse {} pub fn build_redirection_form( form: &RedirectForm, diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index fc13cc6a22b6..57ef1d3336f5 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -19,13 +19,13 @@ pub use api_models::payments::{ VerifyResponse, WalletData, }; #[cfg(feature = "v2")] -pub use api_models::payments::{PaymentsCreateIntentRequest, PaymentsCreateIntentResponse}; +pub use api_models::payments::{PaymentsCreateIntentRequest, PaymentsIntentResponse}; use error_stack::ResultExt; pub use hyperswitch_domain_models::router_flow_types::payments::{ Approve, Authorize, AuthorizeSessionToken, Balance, CalculateTax, Capture, CompleteAuthorize, - CreateConnectorCustomer, CreateIntent, IncrementalAuthorization, InitPayment, PSync, - PaymentMethodToken, PostProcessing, PostSessionTokens, PreProcessing, Reject, SdkSessionUpdate, - Session, SetupMandate, Void, + CreateConnectorCustomer, IncrementalAuthorization, InitPayment, PSync, PaymentCreateIntent, + PaymentGetIntent, PaymentMethodToken, PostProcessing, PostSessionTokens, PreProcessing, Reject, + SdkSessionUpdate, Session, SetupMandate, Void, }; pub use hyperswitch_interfaces::api::payments::{ ConnectorCustomer, MandateSetup, Payment, PaymentApprove, PaymentAuthorize, diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs index 652ce2b81dbc..2410be9750cb 100644 --- a/crates/router_env/src/logger/types.rs +++ b/crates/router_env/src/logger/types.rs @@ -171,6 +171,8 @@ pub enum Flow { PaymentsAggregate, /// Payments Create Intent flow PaymentsCreateIntent, + /// Payments Get Intent flow + PaymentsGetIntent, #[cfg(feature = "payouts")] /// Payouts create flow PayoutsCreate, From 37513e0f1e78f99da0accf0fee263c10ca4e03c6 Mon Sep 17 00:00:00 2001 From: awasthi21 <107559116+awasthi21@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:32:59 +0530 Subject: [PATCH 46/46] feat(connector): [Paybox] Add mandates Flow for Paybox (#6378) --- crates/api_models/src/payments.rs | 57 +++- crates/common_utils/src/lib.rs | 5 + crates/diesel_models/src/payment_attempt.rs | 12 +- .../connectors/deutschebank/transformers.rs | 3 +- .../src/connectors/fiuu/transformers.rs | 2 + .../src/connectors/nexinets/transformers.rs | 1 + .../src/connectors/novalnet/transformers.rs | 4 +- .../src/connectors/payeezy/transformers.rs | 3 +- crates/hyperswitch_connectors/src/utils.rs | 2 +- .../src/payments/payment_attempt.rs | 3 + .../src/router_data.rs | 2 + .../src/router_request_types.rs | 3 +- .../src/router_response_types.rs | 1 + .../router/src/connector/aci/transformers.rs | 1 + .../src/connector/adyen/transformers.rs | 7 +- .../connector/authorizedotnet/transformers.rs | 4 +- .../src/connector/bamboraapac/transformers.rs | 2 + .../connector/bankofamerica/transformers.rs | 2 + .../src/connector/braintree/transformers.rs | 4 + .../src/connector/cybersource/transformers.rs | 2 + .../src/connector/globalpay/transformers.rs | 3 +- .../src/connector/gocardless/transformers.rs | 2 + .../connector/multisafepay/transformers.rs | 5 +- .../router/src/connector/noon/transformers.rs | 1 + .../src/connector/nuvei/transformers.rs | 1 + crates/router/src/connector/paybox.rs | 17 +- .../src/connector/paybox/transformers.rs | 249 +++++++++++++++++- .../src/connector/payme/transformers.rs | 1 + .../src/connector/stripe/transformers.rs | 5 +- crates/router/src/connector/utils.rs | 38 ++- .../src/connector/wellsfargo/transformers.rs | 2 + crates/router/src/consts.rs | 3 + .../src/core/authentication/transformers.rs | 1 + .../core/fraud_check/flows/checkout_flow.rs | 1 + .../fraud_check/flows/fulfillment_flow.rs | 1 + .../core/fraud_check/flows/record_return.rs | 1 + .../src/core/fraud_check/flows/sale_flow.rs | 1 + .../fraud_check/flows/transaction_flow.rs | 1 + crates/router/src/core/mandate/utils.rs | 1 + crates/router/src/core/payments.rs | 27 +- crates/router/src/core/payments/helpers.rs | 1 + .../payments/operations/payment_confirm.rs | 100 ++++--- .../payments/operations/payment_create.rs | 84 ++++-- .../payments/operations/payment_response.rs | 64 ++++- .../payments/operations/payment_update.rs | 8 +- .../router/src/core/payments/tokenization.rs | 65 +++-- .../router/src/core/payments/transformers.rs | 57 +++- crates/router/src/core/utils.rs | 8 + crates/router/src/core/webhooks/utils.rs | 1 + .../router/src/services/conversion_impls.rs | 1 + crates/router/src/types.rs | 5 + .../router/src/types/api/verify_connector.rs | 2 + .../src/types/storage/payment_method.rs | 1 + crates/router/tests/connectors/aci.rs | 2 + crates/router/tests/connectors/utils.rs | 2 + 55 files changed, 729 insertions(+), 153 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index ceb2b654871c..777cabe30025 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1316,12 +1316,59 @@ pub struct NetworkTokenWithNTIRef { #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)] pub struct ConnectorMandateReferenceId { - pub connector_mandate_id: Option, - pub payment_method_id: Option, - pub update_history: Option>, - pub mandate_metadata: Option, -} + connector_mandate_id: Option, + payment_method_id: Option, + update_history: Option>, + mandate_metadata: Option, + connector_mandate_request_reference_id: Option, +} + +impl ConnectorMandateReferenceId { + pub fn new( + connector_mandate_id: Option, + payment_method_id: Option, + update_history: Option>, + mandate_metadata: Option, + connector_mandate_request_reference_id: Option, + ) -> Self { + Self { + connector_mandate_id, + payment_method_id, + update_history, + mandate_metadata, + connector_mandate_request_reference_id, + } + } + pub fn get_connector_mandate_id(&self) -> Option { + self.connector_mandate_id.clone() + } + pub fn get_payment_method_id(&self) -> Option { + self.payment_method_id.clone() + } + pub fn get_mandate_metadata(&self) -> Option { + self.mandate_metadata.clone() + } + pub fn get_connector_mandate_request_reference_id(&self) -> Option { + self.connector_mandate_request_reference_id.clone() + } + + pub fn update( + &mut self, + connector_mandate_id: Option, + payment_method_id: Option, + update_history: Option>, + mandate_metadata: Option, + connector_mandate_request_reference_id: Option, + ) { + 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, diff --git a/crates/common_utils/src/lib.rs b/crates/common_utils/src/lib.rs index 923bdf89c026..463ec3ee1b67 100644 --- a/crates/common_utils/src/lib.rs +++ b/crates/common_utils/src/lib.rs @@ -270,6 +270,11 @@ pub fn generate_time_ordered_id_without_prefix() -> String { uuid::Uuid::now_v7().as_simple().to_string() } +/// Generate a nanoid with the specified length +#[inline] +pub fn generate_id_with_len(length: usize) -> String { + nanoid::nanoid!(length, &consts::ALPHABETS) +} #[allow(missing_docs)] pub trait DbConnectionParams { fn get_username(&self) -> &str; diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rs index ae4722a6f37e..f8654d3cd963 100644 --- a/crates/diesel_models/src/payment_attempt.rs +++ b/crates/diesel_models/src/payment_attempt.rs @@ -21,7 +21,15 @@ pub struct ConnectorMandateReferenceId { pub connector_mandate_id: Option, pub payment_method_id: Option, pub mandate_metadata: Option, + pub connector_mandate_request_reference_id: Option, } + +impl ConnectorMandateReferenceId { + pub fn get_connector_mandate_request_reference_id(&self) -> Option { + self.connector_mandate_request_reference_id.clone() + } +} + #[cfg(feature = "v2")] #[derive( Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Selectable, @@ -414,6 +422,7 @@ pub enum PaymentAttemptUpdate { customer_acceptance: Option, shipping_cost: Option, order_tax_amount: Option, + connector_mandate_detail: Option, }, VoidUpdate { status: storage_enums::AttemptStatus, @@ -2158,6 +2167,7 @@ impl From for PaymentAttemptUpdateInternal { customer_acceptance, shipping_cost, order_tax_amount, + connector_mandate_detail, } => Self { amount: Some(amount), currency: Some(currency), @@ -2209,7 +2219,7 @@ impl From for PaymentAttemptUpdateInternal { shipping_cost, order_tax_amount, connector_transaction_data: None, - connector_mandate_detail: None, + connector_mandate_detail, }, PaymentAttemptUpdate::VoidUpdate { status, diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs index ccecdaa3d415..9dd842768f19 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs @@ -176,7 +176,7 @@ impl TryFrom<&DeutschebankRouterData<&PaymentsAuthorizeRouterData>> } Some(api_models::payments::MandateReferenceId::ConnectorMandateId(mandate_data)) => { let mandate_metadata: DeutschebankMandateMetadata = mandate_data - .mandate_metadata + .get_mandate_metadata() .ok_or(errors::ConnectorError::MissingConnectorMandateMetadata)? .clone() .parse_value("DeutschebankMandateMetadata") @@ -325,6 +325,7 @@ impl reference: Secret::from(reference.clone()), signed_on, })), + connector_mandate_request_reference_id: None, })) } else { Box::new(None) diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs index 7c346bd86cc5..3639a7db4c8d 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs @@ -809,6 +809,7 @@ impl connector_mandate_id: Some(token.clone().expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }) }); let status = match non_threeds_data.status.as_str() { @@ -1184,6 +1185,7 @@ impl TryFrom> for PaymentsSy connector_mandate_id: Some(token.clone().expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id:None }) } Err(err) => { diff --git a/crates/hyperswitch_connectors/src/connectors/nexinets/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nexinets/transformers.rs index 4761581401f0..4149f740e76d 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexinets/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexinets/transformers.rs @@ -360,6 +360,7 @@ impl TryFrom> for NovalnetPaym .into()), }, Some(api_models::payments::MandateReferenceId::ConnectorMandateId(mandate_data)) => { - let connector_mandate_id = mandate_data.connector_mandate_id.ok_or( + let connector_mandate_id = mandate_data.get_connector_mandate_id().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "connector_mandate_id", }, @@ -597,6 +597,7 @@ impl TryFrom connector_mandate_id: Some(id.clone()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, } })), connector_metadata: None, diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs index af29d54117a0..707e34a158c5 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs @@ -185,7 +185,7 @@ fn get_transaction_type_and_stored_creds( match mandate_ids.mandate_reference_id.clone() { Some(api_models::payments::MandateReferenceId::ConnectorMandateId( connector_mandate_ids, - )) => connector_mandate_ids.connector_mandate_id, + )) => connector_mandate_ids.get_connector_mandate_id(), _ => None, } }); @@ -420,6 +420,7 @@ impl TryFrom { - connector_mandate_ids.connector_mandate_id.clone() + connector_mandate_ids.get_connector_mandate_id() } Some(payments::MandateReferenceId::NetworkMandateId(_)) | None diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs index 4b3fd1f8cf9f..831e97b54a17 100644 --- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs +++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs @@ -787,6 +787,7 @@ pub enum PaymentAttemptUpdate { client_source: Option, client_version: Option, customer_acceptance: Option, + connector_mandate_detail: Option, }, RejectUpdate { status: storage_enums::AttemptStatus, @@ -1027,6 +1028,7 @@ impl PaymentAttemptUpdate { client_source, client_version, customer_acceptance, + connector_mandate_detail, } => DieselPaymentAttemptUpdate::ConfirmUpdate { amount: net_amount.get_order_amount(), currency, @@ -1060,6 +1062,7 @@ impl PaymentAttemptUpdate { customer_acceptance, shipping_cost: net_amount.get_shipping_cost(), order_tax_amount: net_amount.get_order_tax_amount(), + connector_mandate_detail, }, Self::VoidUpdate { status, diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs index ba76cc533ca4..186a4f012629 100644 --- a/crates/hyperswitch_domain_models/src/router_data.rs +++ b/crates/hyperswitch_domain_models/src/router_data.rs @@ -84,6 +84,8 @@ pub struct RouterData { pub additional_merchant_data: Option, pub header_payload: Option, + + pub connector_mandate_request_reference_id: Option, } // Different patterns of authentication. diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs index 5878a28f40d7..d20ac148b706 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types.rs @@ -1,6 +1,6 @@ pub mod authentication; pub mod fraud_check; -use api_models::payments::{Address, RequestSurchargeDetails}; +use api_models::payments::{AdditionalPaymentData, Address, RequestSurchargeDetails}; use common_utils::{ consts, errors, ext_traits::OptionExt, @@ -72,6 +72,7 @@ pub struct PaymentsAuthorizeData { pub merchant_order_reference_id: Option, pub integrity_object: Option, pub shipping_cost: Option, + pub additional_payment_method_data: Option, } #[derive(Debug, Clone)] diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 2ed77c8072d2..6356301c7264 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -83,6 +83,7 @@ pub struct MandateReference { pub connector_mandate_id: Option, pub payment_method_id: Option, pub mandate_metadata: Option, + pub connector_mandate_request_reference_id: Option, } #[derive(Debug, Clone)] diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index 7355617b53ae..77598f7be381 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -749,6 +749,7 @@ impl connector_mandate_id: Some(id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); Ok(Self { diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index bc75fd29c02c..95ac2a67a533 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -14,7 +14,7 @@ use time::{Duration, OffsetDateTime, PrimitiveDateTime}; use crate::{connector::utils::PayoutsData, types::api::payouts, utils::OptionExt}; use crate::{ connector::utils::{ - self, AddressDetailsData, BrowserInformationData, CardData, MandateReferenceData, + self, missing_field_err, AddressDetailsData, BrowserInformationData, CardData, PaymentsAuthorizeRequestData, PhoneDetailsData, RouterData, }, consts, @@ -2573,7 +2573,9 @@ impl<'a> None => PaymentType::Scheme, }, stored_payment_method_id: Secret::new( - connector_mandate_ids.get_connector_mandate_id()?, + connector_mandate_ids + .get_connector_mandate_id() + .ok_or_else(missing_field_err("mandate_id"))?, ), }; Ok::, Self::Error>(AdyenPaymentMethod::Mandate(Box::new( @@ -3365,6 +3367,7 @@ pub fn get_adyen_response( connector_mandate_id: Some(mandate_id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); let network_txn_id = response.additional_data.and_then(|additional_data| { additional_data diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs index 6961a87326b1..c9427683d883 100644 --- a/crates/router/src/connector/authorizedotnet/transformers.rs +++ b/crates/router/src/connector/authorizedotnet/transformers.rs @@ -399,6 +399,7 @@ impl ), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }, )), connector_metadata: None, @@ -647,7 +648,7 @@ impl ), ) -> Result { let mandate_id = connector_mandate_id - .connector_mandate_id + .get_connector_mandate_id() .ok_or(errors::ConnectorError::MissingConnectorMandateID)?; Ok(Self { transaction_type: TransactionType::try_from(item.router_data.request.capture_method)?, @@ -1113,6 +1114,7 @@ impl ), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, } }); diff --git a/crates/router/src/connector/bamboraapac/transformers.rs b/crates/router/src/connector/bamboraapac/transformers.rs index 8fcbcd98f090..1a254c052a49 100644 --- a/crates/router/src/connector/bamboraapac/transformers.rs +++ b/crates/router/src/connector/bamboraapac/transformers.rs @@ -281,6 +281,7 @@ impl connector_mandate_id, payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }) } else { None @@ -465,6 +466,7 @@ impl connector_mandate_id: Some(connector_mandate_id), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, })), connector_metadata: None, network_txn_id: None, diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index b5669decd867..c6490cd61398 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -362,6 +362,7 @@ impl .map(|payment_instrument| payment_instrument.id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, } }); let mut mandate_status = @@ -1512,6 +1513,7 @@ fn get_payment_response( .map(|payment_instrument| payment_instrument.id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); Ok(types::PaymentsResponseData::TransactionResponse { diff --git a/crates/router/src/connector/braintree/transformers.rs b/crates/router/src/connector/braintree/transformers.rs index 948d6f2cfd30..f606e671a8d9 100644 --- a/crates/router/src/connector/braintree/transformers.rs +++ b/crates/router/src/connector/braintree/transformers.rs @@ -445,6 +445,7 @@ impl connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }, )), connector_metadata: None, @@ -620,6 +621,7 @@ impl connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }, )), connector_metadata: None, @@ -702,6 +704,7 @@ impl connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }, )), connector_metadata: None, @@ -766,6 +769,7 @@ impl connector_mandate_id: Some(pm.id.clone().expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }, )), connector_metadata: None, diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index 4331b4d79832..c187dcb6dfc4 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -2555,6 +2555,7 @@ fn get_payment_response( .map(|payment_instrument| payment_instrument.id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); Ok(types::PaymentsResponseData::TransactionResponse { @@ -3283,6 +3284,7 @@ impl .map(|payment_instrument| payment_instrument.id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); let mut mandate_status = enums::AttemptStatus::foreign_from(( item.response diff --git a/crates/router/src/connector/globalpay/transformers.rs b/crates/router/src/connector/globalpay/transformers.rs index d17c8a8fdfdb..8008cc309c27 100644 --- a/crates/router/src/connector/globalpay/transformers.rs +++ b/crates/router/src/connector/globalpay/transformers.rs @@ -262,6 +262,7 @@ fn get_payment_response( connector_mandate_id: Some(id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }) }); match status { @@ -472,7 +473,7 @@ fn get_mandate_details(item: &types::PaymentsAuthorizeRouterData) -> Result connector_mandate_ids.connector_mandate_id, + )) => connector_mandate_ids.get_connector_mandate_id(), _ => None, } }); diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/router/src/connector/gocardless/transformers.rs index dac90b283664..6a8fe01eede5 100644 --- a/crates/router/src/connector/gocardless/transformers.rs +++ b/crates/router/src/connector/gocardless/transformers.rs @@ -516,6 +516,7 @@ impl connector_mandate_id: Some(item.response.mandates.id.clone().expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); Ok(Self { response: Ok(types::PaymentsResponseData::TransactionResponse { @@ -669,6 +670,7 @@ impl connector_mandate_id: Some(item.data.request.get_connector_mandate_id()?), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }; Ok(Self { status: enums::AttemptStatus::from(item.response.payments.status), diff --git a/crates/router/src/connector/multisafepay/transformers.rs b/crates/router/src/connector/multisafepay/transformers.rs index 2831b63fcbe0..6a227cffb37b 100644 --- a/crates/router/src/connector/multisafepay/transformers.rs +++ b/crates/router/src/connector/multisafepay/transformers.rs @@ -830,7 +830,9 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> .and_then(|mandate_ids| match mandate_ids.mandate_reference_id { Some(api_models::payments::MandateReferenceId::ConnectorMandateId( connector_mandate_ids, - )) => connector_mandate_ids.connector_mandate_id.map(Secret::new), + )) => connector_mandate_ids + .get_connector_mandate_id() + .map(Secret::new), _ => None, }), days_active: Some(30), @@ -989,6 +991,7 @@ impl connector_mandate_id: Some(id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }), ), connector_metadata: None, diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rs index 634a9feccf38..4556121db239 100644 --- a/crates/router/src/connector/noon/transformers.rs +++ b/crates/router/src/connector/noon/transformers.rs @@ -577,6 +577,7 @@ impl connector_mandate_id: Some(subscription_data.identifier.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); Ok(Self { status, diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs index 68c25f58acb9..209d1a7476f6 100644 --- a/crates/router/src/connector/nuvei/transformers.rs +++ b/crates/router/src/connector/nuvei/transformers.rs @@ -1607,6 +1607,7 @@ where connector_mandate_id: Some(id), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }), ), // we don't need to save session token for capture, void flow so ignoring if it is not present diff --git a/crates/router/src/connector/paybox.rs b/crates/router/src/connector/paybox.rs index a251679be85b..dd54e185dac3 100644 --- a/crates/router/src/connector/paybox.rs +++ b/crates/router/src/connector/paybox.rs @@ -11,7 +11,7 @@ use super::utils::{ }; use crate::{ configs::settings, - connector::utils, + connector::{utils, utils::PaymentMethodDataType}, core::{ errors::{self, CustomResult}, payments, @@ -60,6 +60,13 @@ impl api::PaymentsCompleteAuthorize for Paybox {} impl ConnectorIntegration for Paybox { + fn build_request( + &self, + _req: &types::PaymentsCancelRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Err(errors::ConnectorError::NotImplemented("Cancel/Void flow".to_string()).into()) + } } impl @@ -151,6 +158,14 @@ impl ConnectorValidation for Paybox { ), } } + fn validate_mandate_payment( + &self, + pm_type: Option, + pm_data: types::domain::payments::PaymentMethodData, + ) -> CustomResult<(), errors::ConnectorError> { + let mandate_supported_pmd = std::collections::HashSet::from([PaymentMethodDataType::Card]); + connector_utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) + } } impl ConnectorIntegration diff --git a/crates/router/src/connector/paybox/transformers.rs b/crates/router/src/connector/paybox/transformers.rs index b52a6e463f63..4b9c25f6dba6 100644 --- a/crates/router/src/connector/paybox/transformers.rs +++ b/crates/router/src/connector/paybox/transformers.rs @@ -1,3 +1,4 @@ +use api_models::payments::AdditionalPaymentData; use bytes::Bytes; use common_utils::{ date_time::DateFormat, errors::CustomResult, ext_traits::ValueExt, types::MinorUnit, @@ -8,7 +9,7 @@ use hyperswitch_domain_models::{ router_data::ConnectorAuthType, router_response_types::RedirectForm, }; use hyperswitch_interfaces::consts; -use masking::{PeekInterface, Secret}; +use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::{ @@ -16,7 +17,7 @@ use crate::{ self, PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData, RouterData, }, core::errors, - types::{self, api, domain, storage::enums}, + types::{self, api, domain, storage::enums, MandateReference}, }; pub struct PayboxRouterData { @@ -42,6 +43,10 @@ const SUCCESS_CODE: &str = "00000"; const VERSION_PAYBOX: &str = "00104"; const PAY_ORIGIN_INTERNET: &str = "024"; const THREE_DS_FAIL_CODE: &str = "00000000"; +const RECURRING_ORIGIN: &str = "027"; +const MANDATE_REQUEST: &str = "00056"; +const MANDATE_AUTH_ONLY: &str = "00051"; +const MANDATE_AUTH_AND_CAPTURE_ONLY: &str = "00053"; type Error = error_stack::Report; @@ -50,6 +55,13 @@ type Error = error_stack::Report; pub enum PayboxPaymentsRequest { Card(PaymentsRequest), CardThreeDs(ThreeDSPaymentsRequest), + Mandate(MandatePaymentRequest), +} + +#[derive(Debug, Serialize)] +pub struct CardMandateInfo { + pub card_exp_month: Secret, + pub card_exp_year: Secret, } #[derive(Debug, Serialize)] @@ -99,6 +111,10 @@ pub struct PaymentsRequest { #[serde(rename = "ID3D")] #[serde(skip_serializing_if = "Option::is_none")] pub three_ds_data: Option>, + + #[serde(rename = "REFABONNE")] + #[serde(skip_serializing_if = "Option::is_none")] + pub customer_id: Option>, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] @@ -367,8 +383,10 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsAuthorizeRouterData>> for PayboxP let auth_data: PayboxAuthType = PayboxAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; - let transaction_type = - get_transaction_type(item.router_data.request.capture_method)?; + let transaction_type = get_transaction_type( + item.router_data.request.capture_method, + item.router_data.request.is_mandate_payment(), + )?; let currency = diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) .to_string(); @@ -420,18 +438,80 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsAuthorizeRouterData>> for PayboxP rank: auth_data.rang, key: auth_data.cle, three_ds_data: None, + customer_id: match item.router_data.request.is_mandate_payment() { + true => { + let reference_id = item + .router_data + .connector_mandate_request_reference_id + .clone() + .ok_or_else(|| { + errors::ConnectorError::MissingRequiredField { + field_name: "connector_mandate_request_reference_id", + } + })?; + Some(Secret::new(reference_id)) + } + false => None, + }, })) } } + domain::PaymentMethodData::MandatePayment => { + let mandate_data = extract_card_mandate_info( + item.router_data + .request + .additional_payment_method_data + .clone(), + )?; + Ok(Self::Mandate(MandatePaymentRequest::try_from(( + item, + mandate_data, + ))?)) + } _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), } } } -fn get_transaction_type(capture_method: Option) -> Result { - match capture_method { - Some(enums::CaptureMethod::Automatic) | None => Ok(AUTH_AND_CAPTURE_REQUEST.to_string()), - Some(enums::CaptureMethod::Manual) => Ok(AUTH_REQUEST.to_string()), +fn extract_card_mandate_info( + additional_payment_method_data: Option, +) -> Result { + match additional_payment_method_data { + Some(AdditionalPaymentData::Card(card_data)) => Ok(CardMandateInfo { + card_exp_month: card_data.card_exp_month.clone().ok_or_else(|| { + errors::ConnectorError::MissingRequiredField { + field_name: "card_exp_month", + } + })?, + card_exp_year: card_data.card_exp_year.clone().ok_or_else(|| { + errors::ConnectorError::MissingRequiredField { + field_name: "card_exp_year", + } + })?, + }), + _ => Err(errors::ConnectorError::MissingRequiredFields { + field_names: vec!["card_exp_month", "card_exp_year"], + } + .into()), + } +} + +fn get_transaction_type( + capture_method: Option, + is_mandate_request: bool, +) -> Result { + match (capture_method, is_mandate_request) { + (Some(enums::CaptureMethod::Automatic), false) | (None, false) => { + Ok(AUTH_AND_CAPTURE_REQUEST.to_string()) + } + (Some(enums::CaptureMethod::Automatic), true) | (None, true) => { + Err(errors::ConnectorError::NotSupported { + message: "Capture Not allowed in case of Creating the Subscriber".to_string(), + connector: "Paybox", + })? + } + (Some(enums::CaptureMethod::Manual), false) => Ok(AUTH_REQUEST.to_string()), + (Some(enums::CaptureMethod::Manual), true) => Ok(MANDATE_REQUEST.to_string()), _ => Err(errors::ConnectorError::CaptureMethodNotSupported)?, } } @@ -499,6 +579,11 @@ pub struct TransactionResponse { #[serde(rename = "COMMENTAIRE")] pub response_message: String, + #[serde(rename = "PORTEUR")] + pub carrier_id: Option>, + + #[serde(rename = "REFABONNE")] + pub customer_id: Option>, } pub fn parse_url_encoded_to_struct( @@ -658,7 +743,15 @@ impl response.paybox_order_id, ), redirection_data: Box::new(None), - mandate_reference: Box::new(None), + mandate_reference: Box::new(response.carrier_id.as_ref().map( + |pm: &Secret| MandateReference { + connector_mandate_id: Some(pm.clone().expose()), + payment_method_id: None, + mandate_metadata: None, + connector_mandate_request_reference_id: + response.customer_id.map(|secret| secret.expose()), + }, + )), connector_metadata: Some(serde_json::json!(PayboxMeta { connector_request_id: response.transaction_number.clone() })), @@ -917,7 +1010,16 @@ impl response.paybox_order_id, ), redirection_data: Box::new(None), - mandate_reference: Box::new(None), + mandate_reference: Box::new(response.carrier_id.as_ref().map(|pm| { + MandateReference { + connector_mandate_id: Some(pm.clone().expose()), + payment_method_id: None, + mandate_metadata: None, + connector_mandate_request_reference_id: response + .customer_id + .map(|secret| secret.expose()), + } + })), connector_metadata: Some(serde_json::json!(PayboxMeta { connector_request_id: response.transaction_number.clone() })), @@ -973,8 +1075,10 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsCompleteAuthorizeRouterData>> for let auth_data: PayboxAuthType = PayboxAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; - let transaction_type = - get_transaction_type(item.router_data.request.capture_method)?; + let transaction_type = get_transaction_type( + item.router_data.request.capture_method, + item.router_data.request.is_mandate_payment(), + )?; let currency = diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) .to_string(); @@ -1004,9 +1108,130 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsCompleteAuthorizeRouterData>> for || Some(Secret::new(THREE_DS_FAIL_CODE.to_string())), |data| Some(data.clone()), ), + customer_id: match item.router_data.request.is_mandate_payment() { + true => Some(Secret::new(item.router_data.payment_id.clone())), + false => None, + }, }) } _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), } } } + +#[derive(Debug, Serialize)] +pub struct MandatePaymentRequest { + #[serde(rename = "DATEQ")] + pub date: String, + + #[serde(rename = "TYPE")] + pub transaction_type: String, + + #[serde(rename = "NUMQUESTION")] + pub paybox_request_number: String, + + #[serde(rename = "MONTANT")] + pub amount: MinorUnit, + + #[serde(rename = "REFERENCE")] + pub description_reference: String, + + #[serde(rename = "VERSION")] + pub version: String, + + #[serde(rename = "DEVISE")] + pub currency: String, + + #[serde(rename = "ACTIVITE")] + pub activity: String, + + #[serde(rename = "SITE")] + pub site: Secret, + + #[serde(rename = "RANG")] + pub rank: Secret, + + #[serde(rename = "CLE")] + pub key: Secret, + + #[serde(rename = "DATEVAL")] + pub cc_exp_date: Secret, + + #[serde(rename = "REFABONNE")] + pub customer_id: Secret, + + #[serde(rename = "PORTEUR")] + pub carrier_id: Secret, +} + +impl + TryFrom<( + &PayboxRouterData<&types::PaymentsAuthorizeRouterData>, + CardMandateInfo, + )> for MandatePaymentRequest +{ + type Error = error_stack::Report; + fn try_from( + (item, card_mandate_info): ( + &PayboxRouterData<&types::PaymentsAuthorizeRouterData>, + CardMandateInfo, + ), + ) -> Result { + let auth_data: PayboxAuthType = + PayboxAuthType::try_from(&item.router_data.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; + let transaction_type = match item.router_data.request.capture_method { + Some(enums::CaptureMethod::Automatic) | None => { + Ok(MANDATE_AUTH_AND_CAPTURE_ONLY.to_string()) + } + Some(enums::CaptureMethod::Manual) => Ok(MANDATE_AUTH_ONLY.to_string()), + _ => Err(errors::ConnectorError::CaptureMethodNotSupported), + }?; + let currency = diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) + .to_string(); + let format_time = common_utils::date_time::format_date( + common_utils::date_time::now(), + DateFormat::DDMMYYYYHHmmss, + ) + .change_context(errors::ConnectorError::RequestEncodingFailed)?; + Ok(Self { + date: format_time.clone(), + transaction_type, + paybox_request_number: get_paybox_request_number()?, + amount: item.router_data.request.minor_amount, + description_reference: item.router_data.connector_request_reference_id.clone(), + version: VERSION_PAYBOX.to_string(), + currency, + activity: RECURRING_ORIGIN.to_string(), + site: auth_data.site, + rank: auth_data.rang, + key: auth_data.cle, + customer_id: Secret::new( + item.router_data + .request + .get_connector_mandate_request_reference_id()?, + ), + carrier_id: Secret::new(item.router_data.request.get_connector_mandate_id()?), + cc_exp_date: get_card_expiry_month_year_2_digit( + card_mandate_info.card_exp_month.clone(), + card_mandate_info.card_exp_year.clone(), + )?, + }) + } +} + +fn get_card_expiry_month_year_2_digit( + card_exp_month: Secret, + card_exp_year: Secret, +) -> Result, errors::ConnectorError> { + let year_2_digit = card_exp_year + .peek() + .get(..2) + .ok_or(errors::ConnectorError::RequestEncodingFailed)? + .to_string(); + Ok(Secret::new(format!( + "{}{}", + card_exp_month.peek(), + year_2_digit + ))) +} diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rs index ceeafb50251f..2f8b78e281ad 100644 --- a/crates/router/src/connector/payme/transformers.rs +++ b/crates/router/src/connector/payme/transformers.rs @@ -252,6 +252,7 @@ impl TryFrom<&PaymePaySaleResponse> for types::PaymentsResponseData { connector_mandate_id: Some(buyer_key.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, } })), connector_metadata: None, diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index fe69f43777e5..af82bda3e6af 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1709,7 +1709,7 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent connector_mandate_ids, )) => ( None, - connector_mandate_ids.connector_mandate_id, + connector_mandate_ids.get_connector_mandate_id(), StripeBillingAddress::default(), get_payment_method_type_for_saved_payment_method_payment(item)?, ), @@ -2450,6 +2450,7 @@ impl connector_mandate_id, payment_method_id, mandate_metadata: None, + connector_mandate_request_reference_id: None, } }); @@ -2655,6 +2656,7 @@ impl connector_mandate_id, payment_method_id: Some(payment_method_id), mandate_metadata: None, + connector_mandate_request_reference_id: None, } }); @@ -2746,6 +2748,7 @@ impl connector_mandate_id, payment_method_id, mandate_metadata: None, + connector_mandate_request_reference_id: None, } }); let status = enums::AttemptStatus::from(item.response.status); diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index 9e9e43734dbb..76def480cffe 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -713,7 +713,7 @@ impl PaymentsPreProcessingData for types::PaymentsPreProcessingData { .as_ref() .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { - connector_mandate_ids.connector_mandate_id.clone() + connector_mandate_ids.get_connector_mandate_id() } Some(payments::MandateReferenceId::NetworkMandateId(_)) | None @@ -799,6 +799,7 @@ pub trait PaymentsAuthorizeRequestData { fn get_total_surcharge_amount(&self) -> Option; fn get_metadata_as_object(&self) -> Option; fn get_authentication_data(&self) -> Result; + fn get_connector_mandate_request_reference_id(&self) -> Result; } pub trait PaymentMethodTokenizationRequestData { @@ -861,7 +862,7 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData { .as_ref() .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { - connector_mandate_ids.connector_mandate_id.clone() + connector_mandate_ids.get_connector_mandate_id() } Some(payments::MandateReferenceId::NetworkMandateId(_)) | None @@ -979,6 +980,21 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData { .clone() .ok_or_else(missing_field_err("authentication_data")) } + + /// Attempts to retrieve the connector mandate reference ID as a `Result`. + fn get_connector_mandate_request_reference_id(&self) -> Result { + self.mandate_id + .as_ref() + .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { + Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { + connector_mandate_ids.get_connector_mandate_request_reference_id() + } + Some(payments::MandateReferenceId::NetworkMandateId(_)) + | None + | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None, + }) + .ok_or_else(missing_field_err("connector_mandate_request_reference_id")) + } } pub trait ConnectorCustomerData { @@ -1058,6 +1074,7 @@ pub trait PaymentsCompleteAuthorizeRequestData { fn get_redirect_response_payload(&self) -> Result; fn get_complete_authorize_url(&self) -> Result; fn is_mandate_payment(&self) -> bool; + fn get_connector_mandate_request_reference_id(&self) -> Result; } impl PaymentsCompleteAuthorizeRequestData for types::CompleteAuthorizeData { @@ -1098,6 +1115,20 @@ impl PaymentsCompleteAuthorizeRequestData for types::CompleteAuthorizeData { .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref()) .is_some() } + /// Attempts to retrieve the connector mandate reference ID as a `Result`. + fn get_connector_mandate_request_reference_id(&self) -> Result { + self.mandate_id + .as_ref() + .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { + Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { + connector_mandate_ids.get_connector_mandate_request_reference_id() + } + Some(payments::MandateReferenceId::NetworkMandateId(_)) + | None + | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None, + }) + .ok_or_else(missing_field_err("connector_mandate_request_reference_id")) + } } pub trait PaymentsSyncRequestData { @@ -1924,8 +1955,7 @@ pub trait MandateReferenceData { impl MandateReferenceData for payments::ConnectorMandateReferenceId { fn get_connector_mandate_id(&self) -> Result { - self.connector_mandate_id - .clone() + self.get_connector_mandate_id() .ok_or_else(missing_field_err("mandate_id")) } } diff --git a/crates/router/src/connector/wellsfargo/transformers.rs b/crates/router/src/connector/wellsfargo/transformers.rs index 4dd455d0da30..1ca6c7bd9683 100644 --- a/crates/router/src/connector/wellsfargo/transformers.rs +++ b/crates/router/src/connector/wellsfargo/transformers.rs @@ -1787,6 +1787,7 @@ fn get_payment_response( .map(|payment_instrument| payment_instrument.id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); Ok(types::PaymentsResponseData::TransactionResponse { @@ -1973,6 +1974,7 @@ impl .map(|payment_instrument| payment_instrument.id.expose()), payment_method_id: None, mandate_metadata: None, + connector_mandate_request_reference_id: None, }); let mut mandate_status = enums::AttemptStatus::foreign_from(( item.response diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs index 6a5f5b88f45c..090ddca961ba 100644 --- a/crates/router/src/consts.rs +++ b/crates/router/src/consts.rs @@ -142,6 +142,9 @@ pub const DEFAULT_UNIFIED_ERROR_MESSAGE: &str = "Something went wrong"; // Recon's feature tag pub const RECON_FEATURE_TAG: &str = "RECONCILIATION AND SETTLEMENT"; +// Length of the unique reference ID generated for connector mandate requests +pub const CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH: usize = 18; + /// Vault Add request url #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] pub const ADD_VAULT_REQUEST_URL: &str = "/vault/add"; diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rs index 6013cdbe97f7..6b8a378a0701 100644 --- a/crates/router/src/core/authentication/transformers.rs +++ b/crates/router/src/core/authentication/transformers.rs @@ -184,6 +184,7 @@ pub fn construct_router_data( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }) } diff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rs index 87e76b2c5fb8..4249559aab6b 100644 --- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs +++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs @@ -160,6 +160,7 @@ impl ConstructFlowSpecificData( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } diff --git a/crates/router/src/core/fraud_check/flows/record_return.rs b/crates/router/src/core/fraud_check/flows/record_return.rs index f80f604daa40..3ef2b9232082 100644 --- a/crates/router/src/core/fraud_check/flows/record_return.rs +++ b/crates/router/src/core/fraud_check/flows/record_return.rs @@ -128,6 +128,7 @@ impl ConstructFlowSpecificData( connector_wallets_details: router_data.connector_wallets_details, additional_merchant_data: router_data.additional_merchant_data, header_payload: router_data.header_payload, + connector_mandate_request_reference_id: router_data.connector_mandate_request_reference_id, } } diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index 3a66094081ef..1bd3ddce7351 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -1,16 +1,17 @@ use std::marker::PhantomData; +// use api_models::{admin::ExtendedCardInfoConfig, enums::FrmSuggestion, payments::ExtendedCardInfo}; +#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] +use api_models::payment_methods::PaymentMethodsData; use api_models::{ admin::ExtendedCardInfoConfig, enums::FrmSuggestion, // payment_methods::PaymentMethodsData, - payments::{ExtendedCardInfo, GetAddressFromPaymentMethodData}, + payments::{ConnectorMandateReferenceId, ExtendedCardInfo, GetAddressFromPaymentMethodData}, }; -// use api_models::{admin::ExtendedCardInfoConfig, enums::FrmSuggestion, payments::ExtendedCardInfo}; -#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] -use api_models::{payment_methods::PaymentMethodsData, payments::AdditionalPaymentData}; use async_trait::async_trait; use common_utils::ext_traits::{AsyncExt, Encode, StringExt, ValueExt}; +use diesel_models::payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId; use error_stack::{report, ResultExt}; use futures::FutureExt; #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] @@ -23,6 +24,7 @@ use tracing_futures::Instrument; use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest}; #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] use crate::{ + consts, core::payment_methods::cards::create_encrypted_data, events::audit_events::{AuditEvent, AuditEventType}, }; @@ -45,6 +47,7 @@ use crate::{ api::{self, ConnectorCallType, PaymentIdTypeExt}, domain::{self}, storage::{self, enums as storage_enums}, + transformers::ForeignFrom, }, utils::{self, OptionExt}, }; @@ -573,6 +576,39 @@ impl GetTracker, api::PaymentsRequest> for Pa payment_method_info, } = mandate_details; + let additional_pm_data_from_locker = if let Some(ref pm) = payment_method_info { + let card_detail_from_locker: Option = pm + .payment_method_data + .clone() + .map(|x| x.into_inner().expose()) + .and_then(|v| { + v.parse_value("PaymentMethodsData") + .map_err(|err| { + router_env::logger::info!( + "PaymentMethodsData deserialization failed: {:?}", + err + ) + }) + .ok() + }) + .and_then(|pmd| match pmd { + PaymentMethodsData::Card(crd) => Some(api::CardDetailFromLocker::from(crd)), + _ => None, + }); + card_detail_from_locker.map(|card_details| { + let additional_data = card_details.into(); + api_models::payments::AdditionalPaymentData::Card(Box::new(additional_data)) + }) + } else { + None + }; + payment_attempt.payment_method_data = additional_pm_data_from_locker + .as_ref() + .map(Encode::encode_to_value) + .transpose() + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Failed to encode additional pm data")?; + payment_attempt.payment_method = payment_method.or(payment_attempt.payment_method); payment_attempt.payment_method_type = payment_method_type @@ -679,14 +715,13 @@ impl GetTracker, api::PaymentsRequest> for Pa mandate_id: None, mandate_reference_id: Some( api_models::payments::MandateReferenceId::ConnectorMandateId( - api_models::payments::ConnectorMandateReferenceId { - connector_mandate_id: Some( - token.processor_payment_token.clone(), - ), - payment_method_id: None, - update_history: None, - mandate_metadata: None, - }, + ConnectorMandateReferenceId::new( + Some(token.processor_payment_token.clone()), // connector_mandate_id + None, // payment_method_id + None, // update_history + None, // mandate_metadata + None, // connector_mandate_request_reference_id + ), ), ), }) @@ -714,6 +749,17 @@ impl GetTracker, api::PaymentsRequest> for Pa .net_amount .set_order_tax_amount(order_tax_amount); + payment_attempt.connector_mandate_detail = Some( + DieselConnectorMandateReferenceId::foreign_from(ConnectorMandateReferenceId::new( + None, + None, + None, // update_history + None, // mandate_metadata + Some(common_utils::generate_id_with_len( + consts::CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH.to_owned(), + )), // connector_mandate_request_reference_id + )), + ); let payment_data = PaymentData { flow: PhantomData, payment_intent, @@ -1198,31 +1244,6 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to encode additional pm data")?; - let encode_additional_pm_to_value = if let Some(ref pm) = payment_data.payment_method_info { - let card_detail_from_locker: Option = pm - .payment_method_data - .clone() - .map(|x| x.into_inner().expose()) - .and_then(|v| serde_json::from_value::(v).ok()) - .and_then(|pmd| match pmd { - PaymentMethodsData::Card(crd) => Some(api::CardDetailFromLocker::from(crd)), - _ => None, - }); - - card_detail_from_locker.and_then(|card_details| { - let additional_data = card_details.into(); - let additional_data_payment = - AdditionalPaymentData::Card(Box::new(additional_data)); - additional_data_payment - .encode_to_value() - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Failed to encode additional pm data") - .ok() - }) - } else { - None - }; - let customer_details = payment_data.payment_intent.customer_details.clone(); let business_sub_label = payment_data.payment_attempt.business_sub_label.clone(); let authentication_type = payment_data.payment_attempt.authentication_type; @@ -1278,7 +1299,7 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen let m_payment_token = payment_token.clone(); let m_additional_pm_data = encoded_additional_pm_data .clone() - .or(encode_additional_pm_to_value); + .or(payment_data.payment_attempt.payment_method_data); let m_business_sub_label = business_sub_label.clone(); let m_straight_through_algorithm = straight_through_algorithm.clone(); let m_error_code = error_code.clone(); @@ -1350,6 +1371,9 @@ impl UpdateTracker, api::PaymentsRequest> for Paymen surcharge_amount, tax_amount, ), + connector_mandate_detail: payment_data + .payment_attempt + .connector_mandate_detail, }, storage_scheme, ) diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 696bd1468e4b..a9b5b571c5e7 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -13,7 +13,10 @@ use common_utils::{ MinorUnit, }, }; -use diesel_models::ephemeral_key; +use diesel_models::{ + ephemeral_key, + payment_attempt::ConnectorMandateReferenceId as DieselConnectorMandateReferenceId, +}; use error_stack::{self, ResultExt}; use hyperswitch_domain_models::{ mandates::{MandateData, MandateDetails}, @@ -49,7 +52,7 @@ use crate::{ self, enums::{self, IntentStatus}, }, - transformers::ForeignTryFrom, + transformers::{ForeignFrom, ForeignTryFrom}, }, utils::{self, OptionExt}, }; @@ -344,7 +347,7 @@ impl GetTracker, api::PaymentsRequest> for Pa } #[cfg(feature = "v1")] - let payment_attempt = db + let mut payment_attempt = db .insert_payment_attempt(payment_attempt_new, storage_scheme) .await .to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment { @@ -399,12 +402,13 @@ impl GetTracker, api::PaymentsRequest> for Pa api_models::payments::MandateIds { mandate_id: Some(mandate_obj.mandate_id), mandate_reference_id: Some(api_models::payments::MandateReferenceId::ConnectorMandateId( - api_models::payments::ConnectorMandateReferenceId{ - connector_mandate_id: connector_id.connector_mandate_id, - payment_method_id: connector_id.payment_method_id, - update_history: None, - mandate_metadata: None, - } + 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(), + ) )) } }), @@ -436,14 +440,13 @@ impl GetTracker, api::PaymentsRequest> for Pa mandate_id: None, mandate_reference_id: Some( api_models::payments::MandateReferenceId::ConnectorMandateId( - api_models::payments::ConnectorMandateReferenceId { - connector_mandate_id: Some( - token.processor_payment_token.clone(), - ), - payment_method_id: None, - update_history: None, - mandate_metadata: None, - }, + api_models::payments::ConnectorMandateReferenceId::new( + Some(token.processor_payment_token.clone()), + None, + None, + None, + None, + ), ), ), }) @@ -500,8 +503,55 @@ impl GetTracker, api::PaymentsRequest> for Pa .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Card cobadge check failed due to an invalid card network regex")?; + let additional_pm_data_from_locker = if let Some(ref pm) = payment_method_info { + let card_detail_from_locker: Option = pm + .payment_method_data + .clone() + .map(|x| x.into_inner().expose()) + .and_then(|v| { + v.parse_value("PaymentMethodsData") + .map_err(|err| { + router_env::logger::info!( + "PaymentMethodsData deserialization failed: {:?}", + err + ) + }) + .ok() + }) + .and_then(|pmd| match pmd { + PaymentMethodsData::Card(crd) => Some(api::CardDetailFromLocker::from(crd)), + _ => None, + }); + + card_detail_from_locker.map(|card_details| { + let additional_data = card_details.into(); + api_models::payments::AdditionalPaymentData::Card(Box::new(additional_data)) + }) + } else { + None + }; + + payment_attempt.payment_method_data = additional_pm_data_from_locker + .as_ref() + .map(Encode::encode_to_value) + .transpose() + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Failed to encode additional pm data")?; let amount = payment_attempt.get_total_amount().into(); + payment_attempt.connector_mandate_detail = + Some(DieselConnectorMandateReferenceId::foreign_from( + api_models::payments::ConnectorMandateReferenceId::new( + None, + None, + None, // update_history + None, // mandate_metadata + Some(common_utils::generate_id_with_len( + consts::CONNECTOR_MANDATE_REQUEST_REFERENCE_ID_LENGTH.to_owned(), + )), // connector_mandate_request_reference_id + ), + )); + let address = PaymentAddress::new( shipping_address.as_ref().map(From::from), billing_address.as_ref().map(From::from), diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index 2c09ffd8ff20..0234b97032c7 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -181,7 +181,11 @@ impl PostUpdateTracker, types::PaymentsAuthor .ok(); } }; - + let connector_mandate_reference_id = payment_data + .payment_attempt + .connector_mandate_detail + .as_ref() + .map(|detail| ConnectorMandateReferenceId::foreign_from(detail.clone())); let save_payment_call_future = Box::pin(tokenization::save_payment_method( state, connector_name.clone(), @@ -193,6 +197,7 @@ impl PostUpdateTracker, types::PaymentsAuthor billing_name.clone(), payment_method_billing_address, business_profile, + connector_mandate_reference_id.clone(), )); let is_connector_mandate = resp.request.customer_acceptance.is_some() @@ -307,6 +312,7 @@ impl PostUpdateTracker, types::PaymentsAuthor billing_name, payment_method_billing_address.as_ref(), &business_profile, + connector_mandate_reference_id, )) .await; @@ -571,7 +577,7 @@ impl PostUpdateTracker, types::PaymentsSyncData> for where F: 'b + Clone + Send + Sync, { - let (connector_mandate_id, mandate_metadata) = resp + let (connector_mandate_id, mandate_metadata, connector_mandate_request_reference_id) = resp .response .clone() .ok() @@ -584,17 +590,19 @@ impl PostUpdateTracker, types::PaymentsSyncData> for ( mandate_ref.connector_mandate_id.clone(), mandate_ref.mandate_metadata.clone(), + mandate_ref.connector_mandate_request_reference_id.clone(), ) }) } else { None } }) - .unwrap_or((None, None)); + .unwrap_or((None, None, None)); update_connector_mandate_details_for_the_flow( connector_mandate_id, mandate_metadata, + connector_mandate_request_reference_id, payment_data, )?; @@ -1066,6 +1074,12 @@ impl PostUpdateTracker, types::SetupMandateRequestDa field_name: "connector_name", } })?; + let connector_mandate_reference_id = payment_data + .payment_attempt + .connector_mandate_detail + .as_ref() + .map(|detail| ConnectorMandateReferenceId::foreign_from(detail.clone())); + let merchant_connector_id = payment_data.payment_attempt.merchant_connector_id.clone(); let tokenization::SavePaymentMethodDataResponse { payment_method_id, @@ -1082,6 +1096,7 @@ impl PostUpdateTracker, types::SetupMandateRequestDa billing_name, payment_method_billing_address, business_profile, + connector_mandate_reference_id, )) .await?; @@ -1186,7 +1201,7 @@ impl PostUpdateTracker, types::CompleteAuthorizeData where F: 'b + Clone + Send + Sync, { - let (connector_mandate_id, mandate_metadata) = resp + let (connector_mandate_id, mandate_metadata, connector_mandate_request_reference_id) = resp .response .clone() .ok() @@ -1199,16 +1214,18 @@ impl PostUpdateTracker, types::CompleteAuthorizeData ( mandate_ref.connector_mandate_id.clone(), mandate_ref.mandate_metadata.clone(), + mandate_ref.connector_mandate_request_reference_id.clone(), ) }) } else { None } }) - .unwrap_or((None, None)); + .unwrap_or((None, None, None)); update_connector_mandate_details_for_the_flow( connector_mandate_id, mandate_metadata, + connector_mandate_request_reference_id, payment_data, )?; @@ -1595,10 +1612,10 @@ async fn payment_response_update_tracker( }) .unwrap_or(false) { - let (connector_mandate_id, mandate_metadata) = payment_data.payment_attempt.connector_mandate_detail.clone() - .map(|cmr| (cmr.connector_mandate_id, cmr.mandate_metadata)) - .unwrap_or((None, None)); + let (connector_mandate_id, mandate_metadata,connector_mandate_request_reference_id) = payment_data.payment_attempt.connector_mandate_detail.clone() + .map(|cmr| (cmr.connector_mandate_id, cmr.mandate_metadata,cmr.connector_mandate_request_reference_id)) + .unwrap_or((None, None,None)); // Update the connector mandate details with the payment attempt connector mandate id let connector_mandate_details = tokenization::update_connector_mandate_details( @@ -1615,6 +1632,7 @@ async fn payment_response_update_tracker( payment_data.payment_attempt.merchant_connector_id.clone(), connector_mandate_id, mandate_metadata, + connector_mandate_request_reference_id )?; // Update the payment method table with the active mandate record payment_methods::cards::update_payment_method_connector_mandate_details( @@ -2318,15 +2336,33 @@ impl PostUpdateTracker, types::PaymentsAuthor fn update_connector_mandate_details_for_the_flow( connector_mandate_id: Option, mandate_metadata: Option, + connector_mandate_request_reference_id: Option, payment_data: &mut PaymentData, ) -> RouterResult<()> { + let mut original_connector_mandate_reference_id = payment_data + .payment_attempt + .connector_mandate_detail + .as_ref() + .map(|detail| ConnectorMandateReferenceId::foreign_from(detail.clone())); let connector_mandate_reference_id = if connector_mandate_id.is_some() { - Some(ConnectorMandateReferenceId { - connector_mandate_id: connector_mandate_id.clone(), - payment_method_id: None, - update_history: None, - mandate_metadata: mandate_metadata.clone(), - }) + if let Some(ref mut record) = original_connector_mandate_reference_id { + record.update( + connector_mandate_id, + None, + None, + mandate_metadata, + connector_mandate_request_reference_id, + ); + Some(record.clone()) + } else { + Some(ConnectorMandateReferenceId::new( + connector_mandate_id, + None, + None, + mandate_metadata, + connector_mandate_request_reference_id, + )) + } } else { None }; diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index 0b530d4d0541..9005e94c9629 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -329,7 +329,13 @@ impl GetTracker, api::PaymentsRequest> for Pa api_models::payments::MandateIds { mandate_id: Some(mandate_obj.mandate_id), mandate_reference_id: Some(api_models::payments::MandateReferenceId::ConnectorMandateId( - api_models::payments::ConnectorMandateReferenceId {connector_mandate_id:connector_id.connector_mandate_id,payment_method_id:connector_id.payment_method_id, update_history: None, mandate_metadata:connector_id.mandate_metadata, }, + 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() // connector_mandate_request_reference_id + ) )) } }), diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs index c14542de5476..553eb6724868 100644 --- a/crates/router/src/core/payments/tokenization.rs +++ b/crates/router/src/core/payments/tokenization.rs @@ -80,6 +80,7 @@ pub async fn save_payment_method( billing_name: Option>, payment_method_billing_address: Option<&api::Address>, business_profile: &domain::Profile, + mut original_connector_mandate_reference_id: Option, ) -> RouterResult where FData: mandate::MandateBehaviour + Clone, @@ -155,21 +156,23 @@ where .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to serialize customer acceptance to value")?; - let (connector_mandate_id, mandate_metadata) = match responses { - types::PaymentsResponseData::TransactionResponse { - mandate_reference, .. - } => { - if let Some(ref mandate_ref) = *mandate_reference { - ( - mandate_ref.connector_mandate_id.clone(), - mandate_ref.mandate_metadata.clone(), - ) - } else { - (None, None) + let (connector_mandate_id, mandate_metadata, connector_mandate_request_reference_id) = + match responses { + types::PaymentsResponseData::TransactionResponse { + mandate_reference, .. + } => { + if let Some(ref mandate_ref) = *mandate_reference { + ( + mandate_ref.connector_mandate_id.clone(), + mandate_ref.mandate_metadata.clone(), + mandate_ref.connector_mandate_request_reference_id.clone(), + ) + } else { + (None, None, None) + } } - } - _ => (None, None), - }; + _ => (None, None, None), + }; let pm_id = if customer_acceptance.is_some() { let payment_method_create_request = @@ -689,12 +692,24 @@ where }; // check if there needs to be a config if yes then remove it to a different place let connector_mandate_reference_id = if connector_mandate_id.is_some() { - Some(ConnectorMandateReferenceId { - connector_mandate_id: connector_mandate_id.clone(), - payment_method_id: None, - update_history: None, - mandate_metadata: mandate_metadata.clone(), - }) + if let Some(ref mut record) = original_connector_mandate_reference_id { + record.update( + connector_mandate_id, + None, + None, + mandate_metadata, + connector_mandate_request_reference_id, + ); + Some(record.clone()) + } else { + Some(ConnectorMandateReferenceId::new( + connector_mandate_id, + None, + None, + mandate_metadata, + connector_mandate_request_reference_id, + )) + } } else { None }; @@ -728,6 +743,7 @@ pub async fn save_payment_method( _billing_name: Option>, _payment_method_billing_address: Option<&api::Address>, _business_profile: &domain::Profile, + _connector_mandate_request_reference_id: Option, ) -> RouterResult where FData: mandate::MandateBehaviour + Clone, @@ -1134,6 +1150,7 @@ pub fn add_connector_mandate_details_in_payment_method( merchant_connector_id: Option, connector_mandate_id: Option, mandate_metadata: Option, + connector_mandate_request_reference_id: Option, ) -> Option { let mut mandate_details = HashMap::new(); @@ -1149,6 +1166,7 @@ pub fn add_connector_mandate_details_in_payment_method( original_payment_authorized_currency: authorized_currency, mandate_metadata, connector_mandate_status: Some(ConnectorMandateStatus::Active), + connector_mandate_request_reference_id, }, ); Some(storage::PaymentsMandateReference(mandate_details)) @@ -1156,7 +1174,7 @@ pub fn add_connector_mandate_details_in_payment_method( None } } - +#[allow(clippy::too_many_arguments)] pub fn update_connector_mandate_details( mandate_details: Option, payment_method_type: Option, @@ -1165,6 +1183,7 @@ pub fn update_connector_mandate_details( merchant_connector_id: Option, connector_mandate_id: Option, mandate_metadata: Option, + connector_mandate_request_reference_id: Option, ) -> RouterResult> { let mandate_reference = match mandate_details { Some(mut payment_mandate_reference) => { @@ -1178,6 +1197,8 @@ pub fn update_connector_mandate_details( original_payment_authorized_currency: authorized_currency, mandate_metadata: mandate_metadata.clone(), connector_mandate_status: Some(ConnectorMandateStatus::Active), + connector_mandate_request_reference_id: connector_mandate_request_reference_id + .clone(), }; payment_mandate_reference @@ -1190,6 +1211,7 @@ pub fn update_connector_mandate_details( original_payment_authorized_currency: authorized_currency, mandate_metadata: mandate_metadata.clone(), connector_mandate_status: Some(ConnectorMandateStatus::Active), + connector_mandate_request_reference_id, }); Some(payment_mandate_reference) } else { @@ -1203,6 +1225,7 @@ pub fn update_connector_mandate_details( merchant_connector_id, connector_mandate_id, mandate_metadata, + connector_mandate_request_reference_id, ), }; let connector_mandate_details = mandate_reference diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index e059ebdb8b52..95d114d3d684 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -102,6 +102,12 @@ where customer_data: customer, }; + let connector_mandate_request_reference_id = payment_data + .payment_attempt + .connector_mandate_detail + .as_ref() + .and_then(|detail| detail.get_connector_mandate_request_reference_id()); + let router_data = types::RouterData { flow: PhantomData, merchant_id: merchant_account.get_id().clone(), @@ -159,6 +165,7 @@ where integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id, }; Ok(router_data) } @@ -279,7 +286,13 @@ pub async fn construct_payment_router_data_for_authorize<'a>( merchant_order_reference_id: None, integrity_object: None, shipping_cost: payment_data.payment_intent.amount_details.shipping_cost, + additional_payment_method_data: None, }; + let connector_mandate_request_reference_id = payment_data + .payment_attempt + .connector_mandate_detail + .as_ref() + .and_then(|detail| detail.get_connector_mandate_request_reference_id()); // TODO: evaluate the fields in router data, if they are required or not let router_data = types::RouterData { @@ -355,6 +368,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>( integrity_check: Ok(()), additional_merchant_data: None, header_payload, + connector_mandate_request_reference_id, }; Ok(router_data) @@ -501,6 +515,11 @@ where } else { payment_data.address }; + let connector_mandate_request_reference_id = payment_data + .payment_attempt + .connector_mandate_detail + .as_ref() + .and_then(|detail| detail.get_connector_mandate_request_reference_id()); crate::logger::debug!("unified address details {:?}", unified_address); @@ -570,6 +589,7 @@ where ) }), header_payload, + connector_mandate_request_reference_id, }; Ok(router_data) @@ -1538,7 +1558,7 @@ where .and_then(|mandate_ref| match mandate_ref { api_models::payments::MandateReferenceId::ConnectorMandateId( connector_mandate_reference_id, - ) => connector_mandate_reference_id.connector_mandate_id.clone(), + ) => connector_mandate_reference_id.get_connector_mandate_id(), _ => None, }) }); @@ -2112,7 +2132,18 @@ impl TryFrom> for types::PaymentsAuthoriz payment_data.creds_identifier.as_deref(), )); - // payment_method_data is not required during recurring mandate payment, in such case keep default PaymentMethodData as MandatePayment + let additional_payment_method_data = if payment_data.mandate_id.is_some() { + let parsed_additional_payment_data: Option = + payment_data.payment_attempt + .payment_method_data + .as_ref().map(|data| data.clone().parse_value("AdditionalPaymentData")) + .transpose() + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Failed to parse AdditionalPaymentData from payment_data.payment_attempt.payment_method_data")?; + parsed_additional_payment_data + } else { + None + }; let payment_method_data = payment_data.payment_method_data.or_else(|| { if payment_data.mandate_id.is_some() { Some(domain::PaymentMethodData::MandatePayment) @@ -2198,6 +2229,7 @@ impl TryFrom> for types::PaymentsAuthoriz charges, merchant_order_reference_id, integrity_object: None, + additional_payment_method_data, shipping_cost, }) } @@ -3277,20 +3309,23 @@ impl ForeignFrom impl ForeignFrom for ConnectorMandateReferenceId { fn foreign_from(value: DieselConnectorMandateReferenceId) -> Self { - Self { - connector_mandate_id: value.connector_mandate_id, - payment_method_id: value.payment_method_id, - update_history: None, - mandate_metadata: value.mandate_metadata, - } + Self::new( + value.connector_mandate_id, + value.payment_method_id, + None, + value.mandate_metadata, + value.connector_mandate_request_reference_id, + ) } } impl ForeignFrom for DieselConnectorMandateReferenceId { fn foreign_from(value: ConnectorMandateReferenceId) -> Self { Self { - connector_mandate_id: value.connector_mandate_id, - payment_method_id: value.payment_method_id, - mandate_metadata: value.mandate_metadata, + connector_mandate_id: value.get_connector_mandate_id(), + payment_method_id: value.get_payment_method_id(), + mandate_metadata: value.get_mandate_metadata(), + connector_mandate_request_reference_id: value + .get_connector_mandate_request_reference_id(), } } } diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs index def869079117..abd602760fae 100644 --- a/crates/router/src/core/utils.rs +++ b/crates/router/src/core/utils.rs @@ -217,6 +217,7 @@ pub async fn construct_payout_router_data<'a, F>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) @@ -395,6 +396,7 @@ pub async fn construct_refund_router_data<'a, F>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) @@ -705,6 +707,7 @@ pub async fn construct_accept_dispute_router_data<'a>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } @@ -800,6 +803,7 @@ pub async fn construct_submit_evidence_router_data<'a>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } @@ -901,6 +905,7 @@ pub async fn construct_upload_file_router_data<'a>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } @@ -1022,6 +1027,7 @@ pub async fn construct_payments_dynamic_tax_calculation_router_data<'a, F: Clone integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } @@ -1120,6 +1126,7 @@ pub async fn construct_defend_dispute_router_data<'a>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } @@ -1212,6 +1219,7 @@ pub async fn construct_retrieve_file_router_data<'a>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rs index 3d71f5f5553d..fff675503ad4 100644 --- a/crates/router/src/core/webhooks/utils.rs +++ b/crates/router/src/core/webhooks/utils.rs @@ -122,6 +122,7 @@ pub async fn construct_webhook_router_data<'a>( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, }; Ok(router_data) } diff --git a/crates/router/src/services/conversion_impls.rs b/crates/router/src/services/conversion_impls.rs index 22930916093d..33c655eed78a 100644 --- a/crates/router/src/services/conversion_impls.rs +++ b/crates/router/src/services/conversion_impls.rs @@ -76,6 +76,7 @@ fn get_default_router_data( integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, } } diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 1f7c635da004..230ac7531103 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -879,6 +879,7 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData { charges: None, // TODO: allow charges on mandates? merchant_order_reference_id: None, integrity_object: None, + additional_payment_method_data: None, shipping_cost: data.request.shipping_cost, } } @@ -936,6 +937,9 @@ impl ForeignFrom<(&RouterData, T2) integrity_check: Ok(()), additional_merchant_data: data.additional_merchant_data.clone(), header_payload: data.header_payload.clone(), + connector_mandate_request_reference_id: data + .connector_mandate_request_reference_id + .clone(), } } } @@ -1000,6 +1004,7 @@ impl integrity_check: Ok(()), additional_merchant_data: data.additional_merchant_data.clone(), header_payload: data.header_payload.clone(), + connector_mandate_request_reference_id: None, } } } diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs index 052bd5823175..a472296d2a75 100644 --- a/crates/router/src/types/api/verify_connector.rs +++ b/crates/router/src/types/api/verify_connector.rs @@ -57,6 +57,7 @@ impl VerifyConnectorData { charges: None, merchant_order_reference_id: None, integrity_object: None, + additional_payment_method_data: None, shipping_cost: None, } } @@ -116,6 +117,7 @@ impl VerifyConnectorData { integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, } } } diff --git a/crates/router/src/types/storage/payment_method.rs b/crates/router/src/types/storage/payment_method.rs index 20d0ee74b011..7739c0f0ba8f 100644 --- a/crates/router/src/types/storage/payment_method.rs +++ b/crates/router/src/types/storage/payment_method.rs @@ -126,6 +126,7 @@ pub struct PaymentsMandateReferenceRecord { pub original_payment_authorized_currency: Option, pub mandate_metadata: Option, pub connector_mandate_status: Option, + pub connector_mandate_request_reference_id: Option, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs index 5d48a0188ff5..6f4855d1e22a 100644 --- a/crates/router/tests/connectors/aci.rs +++ b/crates/router/tests/connectors/aci.rs @@ -128,6 +128,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData { integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, } } @@ -197,6 +198,7 @@ fn construct_refund_router_data() -> types::RefundsRouterData { integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, } } diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index eccade536c42..52218b211ac1 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -546,6 +546,7 @@ pub trait ConnectorActions: Connector { integrity_check: Ok(()), additional_merchant_data: None, header_payload: None, + connector_mandate_request_reference_id: None, } } @@ -947,6 +948,7 @@ impl Default for PaymentAuthorizeType { charges: None, integrity_object: None, merchant_order_reference_id: None, + additional_payment_method_data: None, shipping_cost: None, }; Self(data)