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
feat(connector): [JPMORGAN] add currency-specific merchant ID configuration (#14836)
Vani Gupta02c4ad4aab3a
diff --git a/crates/connector_configs/src/common_config.rs b/crates/connector_configs/src/common_config.rsindex cae6ed28b5..25307d2181 100644--- a/crates/connector_configs/src/common_config.rs+++ b/crates/connector_configs/src/common_config.rs@@ -75,6 +75,14 @@ pub struct PaymentMethodsEnabled {pub payment_method_types: Option<Vec<payment_methods::RequestPaymentMethodTypes>>,}+/// Merchant IDs accepted by the connector configuration request helpers.+#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]+#[serde(untagged)]+pub enum MerchantIdMetadata {+ Single(String),+ ByCurrency(std::collections::HashMap<api_models::enums::Currency, String>),+}+#[serde_with::skip_serializing_none]#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]#[serde(rename_all = "snake_case")]@@ -83,7 +91,7 @@ pub struct ApiModelMetaData {pub merchant_account_id: Option<String>,pub account_name: Option<String>,pub terminal_id: Option<String>,- pub merchant_id: Option<String>,+ pub merchant_id: Option<MerchantIdMetadata>,pub google_pay: Option<GoogleApiModelData>,pub paypal_sdk: Option<PaypalSdkData>,pub apple_pay: Option<ApplePayData>,diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex b9924fdda5..15da298f95 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -142,6 +142,14 @@ pub struct AccountIDSupportedMethods {skrill: HashMap<String, AccountIdConfigForRedirect>,}+/// Merchant ID inputs: a single ID or IDs keyed by settlement currency.+#[derive(Debug, Deserialize, Serialize, Clone)]+#[serde(untagged)]+pub enum MerchantIdConfig {+ Single(InputData),+ ByCurrency(HashMap<api_models::enums::Currency, InputData>),+}+#[serde_with::skip_serializing_none]#[derive(Debug, Deserialize, Serialize, Clone)]pub struct ConfigMetadata {@@ -164,7 +172,7 @@ pub struct ConfigMetadata {pub client_id: Option<InputData>,pub client_secret: Option<InputData>,pub workspace_id: Option<InputData>,- pub merchant_id: Option<InputData>,+ pub merchant_id: Option<MerchantIdConfig>,pub endpoint_prefix: Option<InputData>,pub mcc: Option<InputData>,pub merchant_country_code: Option<InputData>,diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex 00c50f1852..7a5531503c 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -3164,6 +3164,41 @@ placeholder = "Enter the product name (used for marketing purposes from a customrequired = truetype = "Text"+[jpmorgan.metadata.merchant_id.USD]+name = "USD"+label = "USD Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for USD"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.CAD]+name = "CAD"+label = "CAD Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for CAD"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.EUR]+name = "EUR"+label = "EUR Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for EUR"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.GBP]+name = "GBP"+label = "GBP Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for GBP"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.JPY]+name = "JPY"+label = "JPY Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for JPY"+required = true+type = "Text"+[klarna][[klarna.pay_later]]payment_method_type = "klarna"diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex 651e196e6b..71bb6d74d3 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -2784,6 +2784,41 @@ placeholder = "Enter the product name (used for marketing purposes from a customrequired = truetype = "Text"+[jpmorgan.metadata.merchant_id.USD]+name = "USD"+label = "USD Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for USD"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.CAD]+name = "CAD"+label = "CAD Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for CAD"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.EUR]+name = "EUR"+label = "EUR Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for EUR"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.GBP]+name = "GBP"+label = "GBP Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for GBP"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.JPY]+name = "JPY"+label = "JPY Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for JPY"+required = true+type = "Text"+[klarna][[klarna.pay_later]]payment_method_type = "klarna"diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex ad4e6a02a2..ce2806296d 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -3140,6 +3140,41 @@ placeholder = "Enter the product name (used for marketing purposes from a customrequired = truetype = "Text"+[jpmorgan.metadata.merchant_id.USD]+name = "USD"+label = "USD Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for USD"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.CAD]+name = "CAD"+label = "CAD Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for CAD"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.EUR]+name = "EUR"+label = "EUR Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for EUR"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.GBP]+name = "GBP"+label = "GBP Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for GBP"+required = true+type = "Text"++[jpmorgan.metadata.merchant_id.JPY]+name = "JPY"+label = "JPY Merchant ID"+placeholder = "Enter the JPMorgan Merchant ID for JPY"+required = true+type = "Text"+[klarna][[klarna.pay_later]]payment_method_type = "klarna"diff --git a/crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs b/crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rsindex 11b71212e4..0b2a15c9df 100644--- a/crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs@@ -1,3 +1,5 @@+use std::collections::HashMap;+use common_enums::enums::CaptureMethod;use common_utils::{pii::SecretSerdeValue, types::MinorUnit};use error_stack::ResultExt;@@ -56,6 +58,7 @@ pub struct JpmorganAuthUpdateResponse {pub struct JpmorganConnectorMetadataObject {pub company_name: Secret<String>,pub product_name: Secret<String>,+ pub merchant_id: HashMap<common_enums::Currency, Secret<String>>,}impl TryFrom<&Option<SecretSerdeValue>> for JpmorganConnectorMetadataObject {diff --git a/crates/router/src/core/unified_connector_service/connector_config.rs b/crates/router/src/core/unified_connector_service/connector_config.rsindex 1093589318..90cb100b8e 100644--- a/crates/router/src/core/unified_connector_service/connector_config.rs+++ b/crates/router/src/core/unified_connector_service/connector_config.rs@@ -67,6 +67,7 @@ pub struct AdyenMetadata {pub struct JpmorganMetadata {company_name: Secret<String>,product_name: Secret<String>,+ merchant_id: HashMap<Currency, Secret<String>>,}#[derive(Debug, serde::Deserialize)]@@ -697,6 +698,7 @@ pub enum ConnectorSpecificConfig {thumbprint: Secret<String>,private_key: Secret<String>,resource_id: Secret<String>,+ merchant_id: Option<HashMap<Currency, Secret<String>>>,#[serde(skip_serializing_if = "Option::is_none")]company_name: Option<Secret<String>>,#[serde(skip_serializing_if = "Option::is_none")]@@ -1231,6 +1233,9 @@ impl ForeignTryFrom<(Connector, &ConnectorAuthType, Option<&serde_json::Value>)>thumbprint,private_key,resource_id,+ merchant_id: jpm_meta+ .as_ref()+ .map(|m| m.merchant_id.clone()),company_name: jpm_meta.as_ref().map(|m| m.company_name.clone()),product_name: jpm_meta.as_ref().map(|m| m.product_name.clone()),})