Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat: Adding new field for merchant_account_metadata (#9952)

Tushar Shukla6055d70c43ac
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index df2accdbd4..3e12d8cfec 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -31,7 +31,6 @@ thiserror = "1.0.69"
time = "0.3.41"
unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "1d0d1e2b31f20e3127e9bf2c5b759a7c4dd91484", package = "rust-grpc-client" }
unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.09.24.0", package = "masking" }
-
# First party crates
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
masking = { version = "0.1.0", path = "../masking" }
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index 1300d072ac..aca8e95333 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -588,10 +588,19 @@ impl
.as_ref()
.map(|id| id.get_string_repr().to_string()),
metadata,
+ merchant_account_metadata: router_data
+ .connector_meta_data
+ .as_ref()
+ .and_then(|meta| meta.peek().as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default(),
test_mode: router_data.test_mode,
connector_customer_id: router_data.connector_customer.clone(),
state,
- merchant_account_metadata: HashMap::new(),
})
}
}
@@ -733,10 +742,19 @@ impl
.collect::<HashMap<String, String>>()
})
.unwrap_or_default(),
+ merchant_account_metadata: router_data
+ .connector_meta_data
+ .as_ref()
+ .and_then(|meta| meta.peek().as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default(),
test_mode: router_data.test_mode,
connector_customer_id: router_data.connector_customer.clone(),
state: None,
- merchant_account_metadata: HashMap::new(),
})
}
}
@@ -847,8 +865,17 @@ impl
customer_acceptance,
browser_info,
payment_experience: None,
+ merchant_account_metadata: router_data
+ .connector_meta_data
+ .as_ref()
+ .and_then(|meta| meta.peek().as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default(),
connector_customer_id: router_data.connector_customer.clone(),
- merchant_account_metadata: HashMap::new(),
state,
})
}
@@ -927,6 +954,16 @@ impl
.collect::<HashMap<String, String>>()
})
.unwrap_or_default(),
+ merchant_account_metadata: router_data
+ .connector_meta_data
+ .as_ref()
+ .and_then(|meta| meta.peek().as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default(),
webhook_url: router_data.request.webhook_url.clone(),
capture_method: capture_method.map(|capture_method| capture_method.into()),
email: router_data
@@ -937,7 +974,6 @@ impl
browser_info,
test_mode: router_data.test_mode,
payment_method_type: None,
- merchant_account_metadata: HashMap::new(),
state,
})
}