Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(config): update installment currency config deserialization (#11747)
Ayush Anand88e7ea6c8688
diff --git a/config/config.example.toml b/config/config.example.tomlindex e2f6dbdb22..bcb3921b61 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -616,7 +616,7 @@ card.credit = "adyen" # Installment supported payment method type and connectorcard.debit = "adyen" # Installment supported payment method type and connector for card[installment_config]-adyen = ["BRL", "MXN", "JPY"] # Connectors and their supported currencies for installment payments+adyen = "BRL,MXN,JPY" # Connectors and their supported currencies for installment payments# Required fields info used while listing the payment_method_data[required_fields.pay_later] # payment_method = "pay_later"diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex fa27488cec..6e8f9dba60 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -287,7 +287,7 @@ card.credit = "adyen"card.debit = "adyen"[installment_config]-adyen = ["BRL", "MXN", "JPY"]+adyen = "BRL,MXN,JPY"[network_transaction_id_supported_connectors]connector_list = "adyen,archipel,checkout,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 8f242335d4..387d7dead0 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -287,7 +287,7 @@ card.credit = "adyen"card.debit = "adyen"[installment_config]-adyen = ["BRL", "MXN", "JPY"]+adyen = "BRL,MXN,JPY"[network_transaction_id_supported_connectors]connector_list = "adyen,archipel,checkout,cybersource,stripe,nuvei,worldpayvantiv"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex cd5f85534a..77e6c180e8 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -294,7 +294,7 @@ card.credit = "adyen"card.debit = "adyen"[installment_config]-adyen = ["BRL", "MXN", "JPY"]+adyen = "BRL,MXN,JPY"[network_transaction_id_supported_connectors]connector_list = "adyen,archipel,checkout,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"diff --git a/config/development.toml b/config/development.tomlindex 4277b560af..16dd0c211e 100644--- a/config/development.toml+++ b/config/development.toml@@ -1223,7 +1223,7 @@ card.credit = "adyen"card.debit = "adyen"[installment_config]-adyen = ["BRL", "MXN", "JPY"]+adyen = "BRL,MXN,JPY"[network_transaction_id_supported_connectors]connector_list = "adyen,archipel,checkout,cybersource,novalnet,nuvei,stripe,worldpay,worldpayvantiv"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex ad1d1cfb69..399d4057bd 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -1120,7 +1120,7 @@ card.credit = "adyen"card.debit = "adyen"[installment_config]-adyen = ["BRL", "MXN", "JPY"]+adyen = "BRL,MXN,JPY"[network_transaction_id_supported_connectors]connector_list = "adyen,archipel,checkout,cybersource,novalnet,stripe,worldpay,worldpayvantiv"diff --git a/crates/payment_methods/src/configs/settings.rs b/crates/payment_methods/src/configs/settings.rsindex a157ef6a3a..a84a2fa08d 100644--- a/crates/payment_methods/src/configs/settings.rs+++ b/crates/payment_methods/src/configs/settings.rs@@ -110,9 +110,21 @@ pub struct SupportedConnectorsForInstallments(#[serde(deserialize_with = "deserialize_hashset")] pub HashSet<enums::Connector>,);+#[derive(Debug, Clone, Default)]+pub struct CurrencyList(pub HashSet<common_enums::enums::Currency>);++impl<'de> Deserialize<'de> for CurrencyList {+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>+ where+ D: serde::Deserializer<'de>,+ {+ deserialize_hashset(deserializer).map(CurrencyList)+ }+}+#[derive(Debug, Deserialize, Clone, Default)]#[serde(default)]-pub struct InstallmentConfig(pub HashMap<enums::Connector, Vec<common_enums::enums::Currency>>);+pub struct InstallmentConfig(pub HashMap<enums::Connector, CurrencyList>);impl InstallmentConfig {pub fn is_connector_currency_supported(@@ -122,7 +134,7 @@ impl InstallmentConfig {) -> bool {self.0.get(connector)- .map(|currencies| currencies.contains(¤cy))+ .map(|currencies| currencies.0.contains(¤cy)).unwrap_or(false)}}