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): [WorldpayVantiv] add bodykey auth with currency-specific merchant ID configuration (#15074)
Akshaya Shankarc4c1d57470ad
diff --git a/Cargo.lock b/Cargo.lockindex 7b4e06c4ab..8c21969b1f 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2236,7 +2236,7 @@ dependencies = [[[package]]name = "config_patch_derive"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.03.0#417e5491f87a317b5cd27bce07768b14363d858c"dependencies = ["proc-macro2","quote",@@ -4247,7 +4247,7 @@ dependencies = [[[package]]name = "grpc-api-types"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.03.0#417e5491f87a317b5cd27bce07768b14363d858c"dependencies = ["axum 0.8.4","bytes 1.10.1",@@ -8397,7 +8397,7 @@ dependencies = [[[package]]name = "rust-grpc-client"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.03.0#417e5491f87a317b5cd27bce07768b14363d858c"dependencies = ["grpc-api-types",]@@ -11345,7 +11345,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"[[package]]name = "ucs_cards"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.03.0#417e5491f87a317b5cd27bce07768b14363d858c"dependencies = ["bytes 1.10.1","error-stack 0.4.1",@@ -11361,7 +11361,7 @@ dependencies = [[[package]]name = "ucs_common_enums"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.03.0#417e5491f87a317b5cd27bce07768b14363d858c"dependencies = ["serde","strum 0.26.3",@@ -11372,7 +11372,7 @@ dependencies = [[[package]]name = "ucs_common_utils"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.03.0#417e5491f87a317b5cd27bce07768b14363d858c"dependencies = ["anyhow","base64 0.21.7",diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.tomlindex e0707e48b9..f293c30dde 100644--- a/crates/external_services/Cargo.toml+++ b/crates/external_services/Cargo.toml@@ -87,7 +87,7 @@ http = "1.3.1"url = { version = "2.5.4", features = ["serde"] }quick-xml = { version = "0.31.0", features = ["serialize"] }-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.02.3", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.03.0", package = "rust-grpc-client" }open-feature = { version = "0.2.5", optional = true }bytes = { version = "1.10.1", optional = true }futures = { version = "0.3.31", optional = true }diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rsindex 07f418dfb0..e9c98d1dcd 100644--- a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs@@ -1,3 +1,5 @@+use std::collections::HashMap;+use common_utils::{ext_traits::Encode,pii,@@ -77,7 +79,28 @@ impl<T> From<(MinorUnit, T)> for WorldpayvantivRouterData<T> {pub struct WorldpayvantivAuthType {pub(super) user: Secret<String>,pub(super) password: Secret<String>,- pub(super) merchant_id: Secret<String>,+ /// Merchant ID from the connector credentials, present only for `SignatureKey` auth.+ /// For `BodyKey` auth, the merchant ID is picked by currency from the connector metadata.+ pub(super) merchant_id: Option<Secret<String>>,+}++impl WorldpayvantivAuthType {+ fn get_merchant_id(+ &self,+ connector_meta_data: &Option<pii::SecretSerdeValue>,+ currency: Option<common_enums::Currency>,+ ) -> Result<Secret<String>, error_stack::Report<errors::ConnectorError>> {+ match &self.merchant_id {+ Some(merchant_id) => Ok(merchant_id.clone()),+ None => {+ let currency = currency.ok_or(errors::ConnectorError::MissingRequiredField {+ field_name: "currency".into(),+ })?;+ WorldpayvantivMetadataObject::try_from(connector_meta_data)?+ .get_merchant_id_for_currency(currency)+ }+ }+ }}impl TryFrom<&ConnectorAuthType> for WorldpayvantivAuthType {@@ -91,7 +114,12 @@ impl TryFrom<&ConnectorAuthType> for WorldpayvantivAuthType {} => Ok(Self {user: api_key.to_owned(),password: api_secret.to_owned(),- merchant_id: key1.to_owned(),+ merchant_id: Some(key1.to_owned()),+ }),+ ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {+ user: api_key.to_owned(),+ password: key1.to_owned(),+ merchant_id: None,}),_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),}@@ -122,8 +150,83 @@ pub struct WorldpayvantivPaymentMetadata {#[derive(Debug, Default, Serialize, Deserialize)]pub struct WorldpayvantivMetadataObject {pub report_group: String,- pub merchant_config_currency: common_enums::Currency,+ /// Currency supported by the merchant ID in the connector credentials, required for `SignatureKey` auth+ pub merchant_config_currency: Option<common_enums::Currency>,pub fraud_filter_override: Option<bool>,+ /// Merchant IDs keyed by currency, required for `BodyKey` auth+ pub merchant_id: Option<HashMap<common_enums::Currency, Secret<String>>>,+}++impl WorldpayvantivMetadataObject {+ /// Validates that the metadata has the config required for the auth type, `merchant_config_currency` for+ /// `SignatureKey` auth and at least one merchant ID in `merchant_id` for `BodyKey` auth+ pub fn validate_for_auth_type(+ &self,+ auth_type: &WorldpayvantivAuthType,+ ) -> Result<(), error_stack::Report<errors::ConnectorError>> {+ match auth_type.merchant_id {+ Some(_) => {+ self.merchant_config_currency.ok_or(+ errors::ConnectorError::InvalidConnectorConfig {+ config: "merchant_config_currency",+ },+ )?;+ }+ None => {+ self.merchant_id+ .as_ref()+ .filter(|merchant_id| !merchant_id.is_empty())+ .ok_or(errors::ConnectorError::InvalidConnectorConfig {+ config: "merchant_id",+ })?;+ }+ }+ Ok(())+ }++ /// Returns the merchant ID for a payment in the currency. For `SignatureKey` auth, the currency should match+ /// `merchant_config_currency` and the merchant ID from the connector credentials is used. For `BodyKey` auth, the+ /// merchant ID configured for the currency is used.+ fn get_merchant_id_for_payment(+ &self,+ auth_type: &WorldpayvantivAuthType,+ currency: common_enums::Currency,+ ) -> Result<Secret<String>, error_stack::Report<errors::ConnectorError>> {+ match &auth_type.merchant_id {+ Some(merchant_id) => {+ let merchant_config_currency = self.merchant_config_currency.ok_or(+ errors::ConnectorError::InvalidConnectorConfig {+ config: "merchant_config_currency",+ },+ )?;+ if merchant_config_currency != currency {+ Err(errors::ConnectorError::CurrencyNotSupported {+ message: currency.to_string(),+ connector: "Worldpayvantiv",+ })?+ }+ Ok(merchant_id.clone())+ }+ None => self.get_merchant_id_for_currency(currency),+ }+ }++ /// Returns the merchant ID configured for the currency, used for `BodyKey` auth+ fn get_merchant_id_for_currency(+ &self,+ currency: common_enums::Currency,+ ) -> Result<Secret<String>, error_stack::Report<errors::ConnectorError>> {+ let merchant_id = self+ .merchant_id+ .as_ref()+ .and_then(|merchant_id| merchant_id.get(¤cy))+ .cloned()+ .ok_or(errors::ConnectorError::CurrencyNotSupported {+ message: currency.to_string(),+ connector: "Worldpayvantiv",+ })?;+ Ok(merchant_id)+ }}impl TryFrom<&Option<pii::SecretSerdeValue>> for WorldpayvantivMetadataObject {@@ -794,12 +897,12 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnl}let worldpayvantiv_metadata =WorldpayvantivMetadataObject::try_from(&item.router_data.connector_meta_data)?;- if worldpayvantiv_metadata.merchant_config_currency != item.router_data.request.currency {- Err(errors::ConnectorError::CurrencyNotSupported {- message: item.router_data.request.currency.to_string(),- connector: "Worldpayvantiv",- })?- };+ let worldpayvantiv_auth_type =+ WorldpayvantivAuthType::try_from(&item.router_data.connector_auth_type)?;+ let merchant_id = worldpayvantiv_metadata.get_merchant_id_for_payment(+ &worldpayvantiv_auth_type,+ item.router_data.request.currency,+ )?;let (card, cardholder_authentication) = get_vantiv_card_data(&item.router_data.request.payment_method_data,@@ -828,8 +931,6 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnl.and_then(|worldpayvantiv_metadata| worldpayvantiv_metadata.fraud_filter_override).or(worldpayvantiv_metadata.fraud_filter_override);- let worldpayvantiv_auth_type =- WorldpayvantivAuthType::try_from(&item.router_data.connector_auth_type)?;let authentication = Authentication {user: worldpayvantiv_auth_type.user,password: worldpayvantiv_auth_type.password,@@ -920,7 +1021,7 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>> for CnpOnlOk(Self {version: worldpayvantiv_constants::WORLDPAYVANTIV_VERSION.to_string(),xmlns: worldpayvantiv_constants::XMLNS.to_string(),- merchant_id: worldpayvantiv_auth_type.merchant_id,+ merchant_id,authentication,authorization,sale,@@ -946,12 +1047,9 @@ impl TryFrom<&SetupMandateRouterData> for CnpOnlineRequest {let worldpayvantiv_metadata =WorldpayvantivMetadataObject::try_from(&item.connector_meta_data)?;- if worldpayvantiv_metadata.merchant_config_currency != item.request.currency {- Err(errors::ConnectorError::CurrencyNotSupported {- message: item.request.currency.to_string(),- connector: "Worldpayvantiv",- })?- };+ let worldpayvantiv_auth_type = WorldpayvantivAuthType::try_from(&item.connector_auth_type)?;+ let merchant_id = worldpayvantiv_metadata+ .get_merchant_id_for_payment(&worldpayvantiv_auth_type, item.request.currency)?;let (card, cardholder_authentication) = get_vantiv_card_data(&item.request.payment_method_data,@@ -976,7 +1074,6 @@ impl TryFrom<&SetupMandateRouterData> for CnpOnlineRequest {.clone().and_then(|worldpayvantiv_metadata| worldpayvantiv_metadata.fraud_filter_override).or(worldpayvantiv_metadata.fraud_filter_override);- let worldpayvantiv_auth_type = WorldpayvantivAuthType::try_from(&item.connector_auth_type)?;let authentication = Authentication {user: worldpayvantiv_auth_type.user,password: worldpayvantiv_auth_type.password,@@ -1024,7 +1121,7 @@ impl TryFrom<&SetupMandateRouterData> for CnpOnlineRequest {Ok(Self {version: worldpayvantiv_constants::WORLDPAYVANTIV_VERSION.to_string(),xmlns: worldpayvantiv_constants::XMLNS.to_string(),- merchant_id: worldpayvantiv_auth_type.merchant_id,+ merchant_id,authentication,authorization: Some(authorization_data),sale: None,@@ -1235,6 +1332,10 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsCaptureRouterData>> for CnpOnlinlet worldpayvantiv_auth_type =WorldpayvantivAuthType::try_from(&item.router_data.connector_auth_type)?;+ let merchant_id = worldpayvantiv_auth_type.get_merchant_id(+ &item.router_data.connector_meta_data,+ Some(item.router_data.request.currency),+ )?;let authentication = Authentication {user: worldpayvantiv_auth_type.user,password: worldpayvantiv_auth_type.password,@@ -1243,7 +1344,7 @@ impl TryFrom<&WorldpayvantivRouterData<&PaymentsCaptureRouterData>> for CnpOnlinOk(Self {version: worldpayvantiv_constants::WORLDPAYVANTIV_VERSION.to_string(),xmlns: worldpayvantiv_constants::XMLNS.to_string(),- merchant_id: worldpayvantiv_auth_type.merchant_id,+ merchant_id,authentication,authorization: None,sale: None,@@ -1286,6 +1387,10 @@ impl<F> TryFrom<&WorldpayvantivRouterData<&RefundsRouterData<F>>> for CnpOnlineRlet worldpayvantiv_auth_type =WorldpayvantivAuthType::try_from(&item.router_data.connector_auth_type)?;+ let merchant_id = worldpayvantiv_auth_type.get_merchant_id(+ &item.router_data.connector_meta_data,+ Some(item.router_data.request.currency),+ )?;let authentication = Authentication {user: worldpayvantiv_auth_type.user,password: worldpayvantiv_auth_type.password,@@ -1294,7 +1399,7 @@ impl<F> TryFrom<&WorldpayvantivRouterData<&RefundsRouterData<F>>> for CnpOnlineROk(Self {version: worldpayvantiv_constants::WORLDPAYVANTIV_VERSION.to_string(),xmlns: worldpayvantiv_constants::XMLNS.to_string(),- merchant_id: worldpayvantiv_auth_type.merchant_id,+ merchant_id,authentication,authorization: None,sale: None,@@ -1952,6 +2057,8 @@ impl TryFrom<&PaymentsCancelRouterData> for CnpOnlineRequest {});let worldpayvantiv_auth_type = WorldpayvantivAuthType::try_from(&item.connector_auth_type)?;+ let merchant_id = worldpayvantiv_auth_type+ .get_merchant_id(&item.connector_meta_data, item.request.currency)?;let authentication = Authentication {user: worldpayvantiv_auth_type.user,password: worldpayvantiv_auth_type.password,@@ -1960,7 +2067,7 @@ impl TryFrom<&PaymentsCancelRouterData> for CnpOnlineRequest {Ok(Self {version: worldpayvantiv_constants::WORLDPAYVANTIV_VERSION.to_string(),xmlns: worldpayvantiv_constants::XMLNS.to_string(),- merchant_id: worldpayvantiv_auth_type.merchant_id,+ merchant_id,authentication,authorization: None,sale: None,@@ -1991,6 +2098,8 @@ impl TryFrom<&PaymentsCancelPostCaptureRouterData> for CnpOnlineRequest {});let worldpayvantiv_auth_type = WorldpayvantivAuthType::try_from(&item.connector_auth_type)?;+ let merchant_id = worldpayvantiv_auth_type+ .get_merchant_id(&item.connector_meta_data, item.request.currency)?;let authentication = Authentication {user: worldpayvantiv_auth_type.user,password: worldpayvantiv_auth_type.password,@@ -1999,7 +2108,7 @@ impl TryFrom<&PaymentsCancelPostCaptureRouterData> for CnpOnlineRequest {Ok(Self {version: worldpayvantiv_constants::WORLDPAYVANTIV_VERSION.to_string(),xmlns: worldpayvantiv_constants::XMLNS.to_string(),- merchant_id: worldpayvantiv_auth_type.merchant_id,+ merchant_id,authentication,authorization: None,sale: None,diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.tomlindex 506f641c26..4c6d950dcc 100644--- a/crates/hyperswitch_interfaces/Cargo.toml+++ b/crates/hyperswitch_interfaces/Cargo.toml@@ -36,7 +36,7 @@ time = "0.3.41"tonic = "0.14"url = { version = "2.5.4", features = ["serde"] }-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.02.3", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.03.0", package = "rust-grpc-client" }tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }# First party cratesdiff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex 0ebbad6e8c..ad8c906a8d 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -256,8 +256,8 @@ rust_decimal = { version = "1.37.1", features = [] }rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" }-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.02.3", package = "rust-grpc-client" }-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", tag = "2026.11.02.3", package = "ucs_cards" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.03.0", package = "rust-grpc-client" }+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", tag = "2026.11.03.0", package = "ucs_cards" }rustc-hash = "1.1.0"rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs",diff --git a/crates/router/src/core/connector_validation.rs b/crates/router/src/core/connector_validation.rsindex cc6a83455b..6fe7f8446a 100644--- a/crates/router/src/core/connector_validation.rs+++ b/crates/router/src/core/connector_validation.rs@@ -663,10 +663,12 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {Ok(())}api_enums::Connector::Worldpayvantiv => {- worldpayvantiv::transformers::WorldpayvantivAuthType::try_from(self.auth_type)?;+ let auth_type =+ worldpayvantiv::transformers::WorldpayvantivAuthType::try_from(self.auth_type)?;worldpayvantiv::transformers::WorldpayvantivMetadataObject::try_from(self.connector_meta_data,- )?;+ )?+ .validate_for_auth_type(&auth_type)?;Ok(())}api_enums::Connector::Worldpayxml => {diff --git a/crates/router/src/core/unified_connector_service/connector_config.rs b/crates/router/src/core/unified_connector_service/connector_config.rsindex 90cb100b8e..22e0ca6f89 100644--- a/crates/router/src/core/unified_connector_service/connector_config.rs+++ b/crates/router/src/core/unified_connector_service/connector_config.rs@@ -70,6 +70,11 @@ pub struct JpmorganMetadata {merchant_id: HashMap<Currency, Secret<String>>,}+#[derive(Debug, serde::Deserialize)]+pub struct WorldpayvantivMetadata {+ merchant_id: Option<HashMap<Currency, Secret<String>>>,+}+#[derive(Debug, serde::Deserialize)]pub struct SantanderPayoutMetadata {client_id: Secret<String>,@@ -806,7 +811,12 @@ pub enum ConnectorSpecificConfig {Worldpayvantiv {user: Secret<String>,password: Secret<String>,- merchant_id: Secret<String>,+ /// Merchant ID from the connector credentials, for `SignatureKey` / `MultiAuthKey` auth+ #[serde(skip_serializing_if = "Option::is_none")]+ merchant_id: Option<Secret<String>>,+ /// Merchant IDs keyed by currency from the connector metadata, for `BodyKey` auth+ #[serde(skip_serializing_if = "Option::is_none")]+ merchant_id_by_currency: Option<HashMap<Currency, Secret<String>>>,},/// Trustly connector configurationTrustly {@@ -1980,7 +1990,8 @@ impl ForeignTryFrom<(Connector, &ConnectorAuthType, Option<&serde_json::Value>)>} => Ok(Self::Worldpayvantiv {user: api_key.clone(),password: api_secret.clone(),- merchant_id: key1.clone(),+ merchant_id: Some(key1.clone()),+ merchant_id_by_currency: None,}),ConnectorAuthType::MultiAuthKey {api_key,@@ -1990,10 +2001,28 @@ impl ForeignTryFrom<(Connector, &ConnectorAuthType, Option<&serde_json::Value>)>} => Ok(Self::Worldpayvantiv {user: api_key.clone(),password: api_secret.clone(),- merchant_id: key1.clone(),+ merchant_id: Some(key1.clone()),+ merchant_id_by_currency: None,}),+ ConnectorAuthType::BodyKey { api_key, key1 } => {+ let merchant_id_by_currency = metadata+ .map(|m| {+ m.clone()+ .parse_value::<WorldpayvantivMetadata>("WorldpayvantivMetadata")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Invalid Worldpayvantiv metadata format")+ })+ .transpose()?+ .and_then(|m| m.merchant_id);+ Ok(Self::Worldpayvantiv {+ user: api_key.clone(),+ password: key1.clone(),+ merchant_id: None,+ merchant_id_by_currency,+ })+ }_ => Err(err(- "Worldpayvantiv requires SignatureKey or MultiAuthKey auth type",+ "Worldpayvantiv requires SignatureKey, MultiAuthKey or BodyKey auth type",)),},Connector::Payme => match auth {