mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
refactor(required_fields): move pm required fields to pm crate (#7539)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -5477,10 +5477,15 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
|||||||
name = "payment_methods"
|
name = "payment_methods"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"api_models",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"common_utils",
|
"common_utils",
|
||||||
"dyn-clone",
|
"dyn-clone",
|
||||||
"hyperswitch_domain_models",
|
"hyperswitch_domain_models",
|
||||||
|
"hyperswitch_interfaces",
|
||||||
|
"masking",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"storage_impl",
|
"storage_impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -8,16 +8,22 @@ license.workspace = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.79"
|
async-trait = "0.1.79"
|
||||||
dyn-clone = "1.0.17"
|
dyn-clone = "1.0.17"
|
||||||
|
masking = { version = "0.1.0", path = "../masking" }
|
||||||
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
|
serde_json = "1.0.115"
|
||||||
|
|
||||||
|
api_models = { version = "0.1.0", path = "../api_models", features = ["errors", "control_center_theme"] }
|
||||||
common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext", "logs", "metrics", "keymanager", "encryption_service"] }
|
common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext", "logs", "metrics", "keymanager", "encryption_service"] }
|
||||||
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
|
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
|
||||||
storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false }
|
storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false }
|
||||||
|
hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["v1"]
|
default = ["v1", "dummy_connector"]
|
||||||
v1 = ["hyperswitch_domain_models/v1", "storage_impl/v1", "common_utils/v1"]
|
v1 = ["hyperswitch_domain_models/v1", "storage_impl/v1", "common_utils/v1"]
|
||||||
v2 = [ "payment_methods_v2"]
|
v2 = [ "payment_methods_v2"]
|
||||||
payment_methods_v2 = [ "hyperswitch_domain_models/payment_methods_v2", "storage_impl/payment_methods_v2", "common_utils/payment_methods_v2"]
|
payment_methods_v2 = [ "hyperswitch_domain_models/payment_methods_v2", "storage_impl/payment_methods_v2", "common_utils/payment_methods_v2"]
|
||||||
|
dummy_connector = ["api_models/dummy_connector", "hyperswitch_interfaces/dummy_connector"]
|
||||||
2
crates/payment_methods/src/configs.rs
Normal file
2
crates/payment_methods/src/configs.rs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pub mod payment_connector_required_fields;
|
||||||
|
pub mod settings;
|
||||||
File diff suppressed because it is too large
Load Diff
144
crates/payment_methods/src/configs/settings.rs
Normal file
144
crates/payment_methods/src/configs/settings.rs
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
|
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
||||||
|
use common_utils::errors::CustomResult;
|
||||||
|
use hyperswitch_interfaces::secrets_interface::{
|
||||||
|
secret_handler::SecretsHandler,
|
||||||
|
secret_state::{RawSecret, SecretStateContainer, SecuredSecret},
|
||||||
|
SecretManagementInterface, SecretsManagementError,
|
||||||
|
};
|
||||||
|
use masking::Secret;
|
||||||
|
use serde::{self, Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
#[cfg_attr(feature = "v2", derive(Default))] // Configs are read from the config file in config/payment_required_fields.toml
|
||||||
|
pub struct RequiredFields(pub HashMap<enums::PaymentMethod, PaymentMethodType>);
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct PaymentMethodType(pub HashMap<enums::PaymentMethodType, ConnectorFields>);
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct ConnectorFields {
|
||||||
|
pub fields: HashMap<enums::Connector, RequiredFieldFinal>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "v1")]
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct RequiredFieldFinal {
|
||||||
|
pub mandate: HashMap<String, RequiredFieldInfo>,
|
||||||
|
pub non_mandate: HashMap<String, RequiredFieldInfo>,
|
||||||
|
pub common: HashMap<String, RequiredFieldInfo>,
|
||||||
|
}
|
||||||
|
#[cfg(feature = "v2")]
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct RequiredFieldFinal {
|
||||||
|
pub mandate: Option<Vec<RequiredFieldInfo>>,
|
||||||
|
pub non_mandate: Option<Vec<RequiredFieldInfo>>,
|
||||||
|
pub common: Option<Vec<RequiredFieldInfo>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Clone, Default)]
|
||||||
|
pub struct PaymentMethodAuth {
|
||||||
|
pub redis_expiry: i64,
|
||||||
|
pub pm_auth_key: Secret<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl SecretsHandler for PaymentMethodAuth {
|
||||||
|
async fn convert_to_raw_secret(
|
||||||
|
value: SecretStateContainer<Self, SecuredSecret>,
|
||||||
|
secret_management_client: &dyn SecretManagementInterface,
|
||||||
|
) -> CustomResult<SecretStateContainer<Self, RawSecret>, SecretsManagementError> {
|
||||||
|
let payment_method_auth = value.get_inner();
|
||||||
|
|
||||||
|
let pm_auth_key = secret_management_client
|
||||||
|
.get_secret(payment_method_auth.pm_auth_key.clone())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(value.transition_state(|payment_method_auth| Self {
|
||||||
|
pm_auth_key,
|
||||||
|
..payment_method_auth
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Clone, Default)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct EligiblePaymentMethods {
|
||||||
|
#[serde(deserialize_with = "deserialize_hashset")]
|
||||||
|
pub sdk_eligible_payment_methods: HashSet<String>,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
|
pub struct SupportedPaymentMethodsForMandate(
|
||||||
|
pub HashMap<enums::PaymentMethod, SupportedPaymentMethodTypesForMandate>,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
|
pub struct SupportedPaymentMethodTypesForMandate(
|
||||||
|
pub HashMap<enums::PaymentMethodType, SupportedConnectorsForMandate>,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
|
pub struct SupportedConnectorsForMandate {
|
||||||
|
#[serde(deserialize_with = "deserialize_hashset")]
|
||||||
|
pub connector_list: HashSet<enums::Connector>,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
|
pub struct Mandates {
|
||||||
|
pub supported_payment_methods: SupportedPaymentMethodsForMandate,
|
||||||
|
pub update_mandate_supported: SupportedPaymentMethodsForMandate,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
|
pub struct ZeroMandates {
|
||||||
|
pub supported_payment_methods: SupportedPaymentMethodsForMandate,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deserialize_hashset_inner<T>(value: impl AsRef<str>) -> Result<HashSet<T>, String>
|
||||||
|
where
|
||||||
|
T: Eq + std::str::FromStr + std::hash::Hash,
|
||||||
|
<T as std::str::FromStr>::Err: std::fmt::Display,
|
||||||
|
{
|
||||||
|
let (values, errors) = value
|
||||||
|
.as_ref()
|
||||||
|
.trim()
|
||||||
|
.split(',')
|
||||||
|
.map(|s| {
|
||||||
|
T::from_str(s.trim()).map_err(|error| {
|
||||||
|
format!(
|
||||||
|
"Unable to deserialize `{}` as `{}`: {error}",
|
||||||
|
s.trim(),
|
||||||
|
std::any::type_name::<T>()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.fold(
|
||||||
|
(HashSet::new(), Vec::new()),
|
||||||
|
|(mut values, mut errors), result| match result {
|
||||||
|
Ok(t) => {
|
||||||
|
values.insert(t);
|
||||||
|
(values, errors)
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
errors.push(error);
|
||||||
|
(values, errors)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if !errors.is_empty() {
|
||||||
|
Err(format!("Some errors occurred:\n{}", errors.join("\n")))
|
||||||
|
} else {
|
||||||
|
Ok(values)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deserialize_hashset<'a, D, T>(deserializer: D) -> Result<HashSet<T>, D::Error>
|
||||||
|
where
|
||||||
|
D: serde::Deserializer<'a>,
|
||||||
|
T: Eq + std::str::FromStr + std::hash::Hash,
|
||||||
|
<T as std::str::FromStr>::Err: std::fmt::Display,
|
||||||
|
{
|
||||||
|
use serde::de::Error;
|
||||||
|
|
||||||
|
deserialize_hashset_inner(<String>::deserialize(deserializer)?).map_err(D::Error::custom)
|
||||||
|
}
|
||||||
@ -1 +1,2 @@
|
|||||||
|
pub mod configs;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
|||||||
@ -26,15 +26,15 @@ oltp = ["storage_impl/oltp"]
|
|||||||
kv_store = ["scheduler/kv_store"]
|
kv_store = ["scheduler/kv_store"]
|
||||||
accounts_cache = []
|
accounts_cache = []
|
||||||
vergen = ["router_env/vergen"]
|
vergen = ["router_env/vergen"]
|
||||||
dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "hyperswitch_interfaces/dummy_connector", "kgraph_utils/dummy_connector", "hyperswitch_domain_models/dummy_connector"]
|
dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "hyperswitch_interfaces/dummy_connector", "kgraph_utils/dummy_connector", "payment_methods/dummy_connector", "hyperswitch_domain_models/dummy_connector"]
|
||||||
external_access_dc = ["dummy_connector"]
|
external_access_dc = ["dummy_connector"]
|
||||||
detailed_errors = ["api_models/detailed_errors", "error-stack/serde"]
|
detailed_errors = ["api_models/detailed_errors", "error-stack/serde"]
|
||||||
payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_connectors/payouts", "hyperswitch_domain_models/payouts", "storage_impl/payouts"]
|
payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_connectors/payouts", "hyperswitch_domain_models/payouts", "storage_impl/payouts"]
|
||||||
payout_retry = ["payouts"]
|
payout_retry = ["payouts"]
|
||||||
recon = ["email", "api_models/recon"]
|
recon = ["email", "api_models/recon"]
|
||||||
retry = []
|
retry = []
|
||||||
v2 = ["customer_v2", "payment_methods_v2", "common_default", "api_models/v2", "diesel_models/v2", "hyperswitch_domain_models/v2", "storage_impl/v2", "kgraph_utils/v2", "common_utils/v2", "hyperswitch_connectors/v2","hyperswitch_interfaces/v2", "common_types/v2","revenue_recovery","refunds_v2","scheduler/v2","euclid/v2"]
|
v2 = ["customer_v2", "payment_methods_v2", "common_default", "api_models/v2", "diesel_models/v2", "hyperswitch_domain_models/v2", "storage_impl/v2", "kgraph_utils/v2", "common_utils/v2", "hyperswitch_connectors/v2","hyperswitch_interfaces/v2", "common_types/v2","revenue_recovery","scheduler/v2", "refunds_v2", "euclid/v2", "payment_methods/v2"]
|
||||||
v1 = ["common_default", "api_models/v1", "diesel_models/v1", "hyperswitch_domain_models/v1", "storage_impl/v1", "hyperswitch_interfaces/v1", "kgraph_utils/v1", "common_utils/v1", "hyperswitch_connectors/v1", "common_types/v1","scheduler/v1"]
|
v1 = ["common_default", "api_models/v1", "diesel_models/v1", "hyperswitch_domain_models/v1", "storage_impl/v1", "hyperswitch_interfaces/v1", "kgraph_utils/v1", "common_utils/v1", "hyperswitch_connectors/v1", "common_types/v1","scheduler/v1", "payment_methods/v1"]
|
||||||
customer_v2 = ["api_models/customer_v2", "diesel_models/customer_v2", "hyperswitch_domain_models/customer_v2", "storage_impl/customer_v2"]
|
customer_v2 = ["api_models/customer_v2", "diesel_models/customer_v2", "hyperswitch_domain_models/customer_v2", "storage_impl/customer_v2"]
|
||||||
payment_methods_v2 = ["api_models/payment_methods_v2", "diesel_models/payment_methods_v2", "hyperswitch_domain_models/payment_methods_v2", "storage_impl/payment_methods_v2", "common_utils/payment_methods_v2"]
|
payment_methods_v2 = ["api_models/payment_methods_v2", "diesel_models/payment_methods_v2", "hyperswitch_domain_models/payment_methods_v2", "storage_impl/payment_methods_v2", "common_utils/payment_methods_v2"]
|
||||||
dynamic_routing = ["external_services/dynamic_routing", "storage_impl/dynamic_routing", "api_models/dynamic_routing"]
|
dynamic_routing = ["external_services/dynamic_routing", "storage_impl/dynamic_routing", "api_models/dynamic_routing"]
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
|
||||||
use common_utils::id_type;
|
use common_utils::id_type;
|
||||||
|
|
||||||
#[cfg(feature = "payouts")]
|
#[cfg(feature = "payouts")]
|
||||||
pub mod payout_required_fields;
|
pub mod payout_required_fields;
|
||||||
|
|
||||||
pub mod payment_connector_required_fields;
|
|
||||||
|
|
||||||
impl Default for super::settings::Server {
|
impl Default for super::settings::Server {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -174,206 +171,3 @@ impl Default for super::settings::ApiKeys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_billing_required_fields() -> HashMap<String, RequiredFieldInfo> {
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"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,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_shipping_required_fields() -> HashMap<String, RequiredFieldInfo> {
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"shipping.phone.number".to_string(),
|
|
||||||
RequiredFieldInfo {
|
|
||||||
required_field: "shipping.phone.number".to_string(),
|
|
||||||
display_name: "phone_number".to_string(),
|
|
||||||
field_type: enums::FieldType::UserPhoneNumber,
|
|
||||||
value: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"shipping.phone.country_code".to_string(),
|
|
||||||
RequiredFieldInfo {
|
|
||||||
required_field: "shipping.phone.country_code".to_string(),
|
|
||||||
display_name: "dialing_code".to_string(),
|
|
||||||
field_type: enums::FieldType::UserPhoneNumberCountryCode,
|
|
||||||
value: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"shipping.email".to_string(),
|
|
||||||
RequiredFieldInfo {
|
|
||||||
required_field: "shipping.email".to_string(),
|
|
||||||
display_name: "email".to_string(),
|
|
||||||
field_type: enums::FieldType::UserEmailAddress,
|
|
||||||
value: None,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -224,25 +224,6 @@ impl SecretsHandler for settings::ApplepayMerchantConfigs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl SecretsHandler for settings::PaymentMethodAuth {
|
|
||||||
async fn convert_to_raw_secret(
|
|
||||||
value: SecretStateContainer<Self, SecuredSecret>,
|
|
||||||
secret_management_client: &dyn SecretManagementInterface,
|
|
||||||
) -> CustomResult<SecretStateContainer<Self, RawSecret>, SecretsManagementError> {
|
|
||||||
let payment_method_auth = value.get_inner();
|
|
||||||
|
|
||||||
let pm_auth_key = secret_management_client
|
|
||||||
.get_secret(payment_method_auth.pm_auth_key.clone())
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(value.transition_state(|payment_method_auth| Self {
|
|
||||||
pm_auth_key,
|
|
||||||
..payment_method_auth
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl SecretsHandler for settings::KeyManagerConfig {
|
impl SecretsHandler for settings::KeyManagerConfig {
|
||||||
async fn convert_to_raw_secret(
|
async fn convert_to_raw_secret(
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use std::{
|
|||||||
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
use analytics::{opensearch::OpenSearchConfig, ReportConfig};
|
use analytics::{opensearch::OpenSearchConfig, ReportConfig};
|
||||||
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
use api_models::enums;
|
||||||
use common_utils::{ext_traits::ConfigExt, id_type, types::theme::EmailThemeConfig};
|
use common_utils::{ext_traits::ConfigExt, id_type, types::theme::EmailThemeConfig};
|
||||||
use config::{Environment, File};
|
use config::{Environment, File};
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
@ -25,6 +25,11 @@ use hyperswitch_interfaces::secrets_interface::secret_state::{
|
|||||||
RawSecret, SecretState, SecretStateContainer, SecuredSecret,
|
RawSecret, SecretState, SecretStateContainer, SecuredSecret,
|
||||||
};
|
};
|
||||||
use masking::Secret;
|
use masking::Secret;
|
||||||
|
pub use payment_methods::configs::settings::{
|
||||||
|
ConnectorFields, EligiblePaymentMethods, Mandates, PaymentMethodAuth, PaymentMethodType,
|
||||||
|
RequiredFieldFinal, RequiredFields, SupportedConnectorsForMandate,
|
||||||
|
SupportedPaymentMethodTypesForMandate, SupportedPaymentMethodsForMandate, ZeroMandates,
|
||||||
|
};
|
||||||
use redis_interface::RedisSettings;
|
use redis_interface::RedisSettings;
|
||||||
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
|
pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry};
|
||||||
use rust_decimal::Decimal;
|
use rust_decimal::Decimal;
|
||||||
@ -416,19 +421,6 @@ pub struct ForexApi {
|
|||||||
pub redis_ttl_in_seconds: u32,
|
pub redis_ttl_in_seconds: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Default)]
|
|
||||||
pub struct PaymentMethodAuth {
|
|
||||||
pub redis_expiry: i64,
|
|
||||||
pub pm_auth_key: Secret<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Default)]
|
|
||||||
#[serde(default)]
|
|
||||||
pub struct EligiblePaymentMethods {
|
|
||||||
#[serde(deserialize_with = "deserialize_hashset")]
|
|
||||||
pub sdk_eligible_payment_methods: HashSet<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Default)]
|
#[derive(Debug, Deserialize, Clone, Default)]
|
||||||
pub struct DefaultExchangeRates {
|
pub struct DefaultExchangeRates {
|
||||||
pub base_currency: String,
|
pub base_currency: String,
|
||||||
@ -510,17 +502,6 @@ pub struct CorsSettings {
|
|||||||
pub allowed_methods: HashSet<String>,
|
pub allowed_methods: HashSet<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct Mandates {
|
|
||||||
pub supported_payment_methods: SupportedPaymentMethodsForMandate,
|
|
||||||
pub update_mandate_supported: SupportedPaymentMethodsForMandate,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct ZeroMandates {
|
|
||||||
pub supported_payment_methods: SupportedPaymentMethodsForMandate,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Default)]
|
#[derive(Debug, Deserialize, Clone, Default)]
|
||||||
pub struct NetworkTransactionIdSupportedConnectors {
|
pub struct NetworkTransactionIdSupportedConnectors {
|
||||||
#[serde(deserialize_with = "deserialize_hashset")]
|
#[serde(deserialize_with = "deserialize_hashset")]
|
||||||
@ -545,22 +526,6 @@ pub struct NetworkTokenizationService {
|
|||||||
pub check_token_status_url: url::Url,
|
pub check_token_status_url: url::Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct SupportedPaymentMethodsForMandate(
|
|
||||||
pub HashMap<enums::PaymentMethod, SupportedPaymentMethodTypesForMandate>,
|
|
||||||
);
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct SupportedPaymentMethodTypesForMandate(
|
|
||||||
pub HashMap<enums::PaymentMethodType, SupportedConnectorsForMandate>,
|
|
||||||
);
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct SupportedConnectorsForMandate {
|
|
||||||
#[serde(deserialize_with = "deserialize_hashset")]
|
|
||||||
pub connector_list: HashSet<enums::Connector>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Default)]
|
#[derive(Debug, Deserialize, Clone, Default)]
|
||||||
pub struct PaymentMethodTokenFilter {
|
pub struct PaymentMethodTokenFilter {
|
||||||
#[serde(deserialize_with = "deserialize_hashset")]
|
#[serde(deserialize_with = "deserialize_hashset")]
|
||||||
@ -647,34 +612,6 @@ pub struct NotAvailableFlows {
|
|||||||
#[cfg_attr(feature = "v2", derive(Default))] // Configs are read from the config file in config/payout_required_fields.toml
|
#[cfg_attr(feature = "v2", derive(Default))] // Configs are read from the config file in config/payout_required_fields.toml
|
||||||
pub struct PayoutRequiredFields(pub HashMap<enums::PaymentMethod, PaymentMethodType>);
|
pub struct PayoutRequiredFields(pub HashMap<enums::PaymentMethod, PaymentMethodType>);
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
#[cfg_attr(feature = "v2", derive(Default))] // Configs are read from the config file in config/payment_required_fields.toml
|
|
||||||
pub struct RequiredFields(pub HashMap<enums::PaymentMethod, PaymentMethodType>);
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct PaymentMethodType(pub HashMap<enums::PaymentMethodType, ConnectorFields>);
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct ConnectorFields {
|
|
||||||
pub fields: HashMap<enums::Connector, RequiredFieldFinal>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "v1")]
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct RequiredFieldFinal {
|
|
||||||
pub mandate: HashMap<String, RequiredFieldInfo>,
|
|
||||||
pub non_mandate: HashMap<String, RequiredFieldInfo>,
|
|
||||||
pub common: HashMap<String, RequiredFieldInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "v2")]
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
|
||||||
pub struct RequiredFieldFinal {
|
|
||||||
pub mandate: Option<Vec<RequiredFieldInfo>>,
|
|
||||||
pub non_mandate: Option<Vec<RequiredFieldInfo>>,
|
|
||||||
pub common: Option<Vec<RequiredFieldInfo>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, Clone)]
|
#[derive(Debug, Default, Deserialize, Clone)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct Secrets {
|
pub struct Secrets {
|
||||||
|
|||||||
@ -4,6 +4,9 @@ use std::{
|
|||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use ::payment_methods::configs::payment_connector_required_fields::{
|
||||||
|
get_billing_required_fields, get_shipping_required_fields,
|
||||||
|
};
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(feature = "v1", feature = "v2"),
|
any(feature = "v1", feature = "v2"),
|
||||||
not(feature = "payment_methods_v2")
|
not(feature = "payment_methods_v2")
|
||||||
@ -91,10 +94,7 @@ use crate::routes::app::SessionStateInfo;
|
|||||||
#[cfg(feature = "payouts")]
|
#[cfg(feature = "payouts")]
|
||||||
use crate::types::domain::types::AsyncLift;
|
use crate::types::domain::types::AsyncLift;
|
||||||
use crate::{
|
use crate::{
|
||||||
configs::{
|
configs::settings,
|
||||||
defaults::{get_billing_required_fields, get_shipping_required_fields},
|
|
||||||
settings,
|
|
||||||
},
|
|
||||||
consts as router_consts,
|
consts as router_consts,
|
||||||
core::{
|
core::{
|
||||||
errors::{self, StorageErrorExt},
|
errors::{self, StorageErrorExt},
|
||||||
|
|||||||
Reference in New Issue
Block a user