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(core): Added missing CardNetwork Types in HS <> UCS Integration (#11170)
Shubhodip pal765a67b915e2
diff --git a/Cargo.lock b/Cargo.lockindex 5db8a483ef..7f1c523e2e 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2129,7 +2129,7 @@ dependencies = [[[package]]name = "config_patch_derive"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0#d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0"+source = "git+https://github.com/juspay/connector-service?rev=00ffd3b1d753f72a93b3882585b3eda2a9c9ec55#00ffd3b1d753f72a93b3882585b3eda2a9c9ec55"dependencies = ["proc-macro2","quote",@@ -3800,7 +3800,7 @@ dependencies = [[[package]]name = "grpc-api-types"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0#d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0"+source = "git+https://github.com/juspay/connector-service?rev=00ffd3b1d753f72a93b3882585b3eda2a9c9ec55#00ffd3b1d753f72a93b3882585b3eda2a9c9ec55"dependencies = ["axum 0.8.4","error-stack 0.5.0",@@ -7473,7 +7473,7 @@ dependencies = [[[package]]name = "rust-grpc-client"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0#d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0"+source = "git+https://github.com/juspay/connector-service?rev=00ffd3b1d753f72a93b3882585b3eda2a9c9ec55#00ffd3b1d753f72a93b3882585b3eda2a9c9ec55"dependencies = ["grpc-api-types",]@@ -10263,7 +10263,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"[[package]]name = "ucs_cards"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0#d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0"+source = "git+https://github.com/juspay/connector-service?rev=00ffd3b1d753f72a93b3882585b3eda2a9c9ec55#00ffd3b1d753f72a93b3882585b3eda2a9c9ec55"dependencies = ["bytes 1.10.1","error-stack 0.4.1",@@ -10279,7 +10279,7 @@ dependencies = [[[package]]name = "ucs_common_enums"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0#d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0"+source = "git+https://github.com/juspay/connector-service?rev=00ffd3b1d753f72a93b3882585b3eda2a9c9ec55#00ffd3b1d753f72a93b3882585b3eda2a9c9ec55"dependencies = ["serde","strum 0.26.3",@@ -10290,7 +10290,7 @@ dependencies = [[[package]]name = "ucs_common_utils"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0#d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0"+source = "git+https://github.com/juspay/connector-service?rev=00ffd3b1d753f72a93b3882585b3eda2a9c9ec55#00ffd3b1d753f72a93b3882585b3eda2a9c9ec55"dependencies = ["anyhow","base64 0.21.7",diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.tomlindex 39e741270d..3d5b584878 100644--- a/crates/external_services/Cargo.toml+++ b/crates/external_services/Cargo.toml@@ -69,7 +69,7 @@ reqwest = { version = "0.11.27", features = ["rustls-tls"] }http = "0.2.12"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", rev = "d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "00ffd3b1d753f72a93b3882585b3eda2a9c9ec55", package = "rust-grpc-client" }open-feature = { version = "0.2.5", optional = true }superposition_provider = { version = "0.88.1", optional = true }diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.tomlindex 4a85ddb588..75c04d3054 100644--- a/crates/hyperswitch_interfaces/Cargo.toml+++ b/crates/hyperswitch_interfaces/Cargo.toml@@ -30,7 +30,7 @@ strum = { version = "0.26", features = ["derive"] }thiserror = "1.0.69"time = "0.3.41"url = { version = "2.5.4", features = ["serde"] }-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "00ffd3b1d753f72a93b3882585b3eda2a9c9ec55", package = "rust-grpc-client" }unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.11.24.0", package = "masking" }tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }diff --git a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rsindex b66df23cbf..4f9e546ac6 100644--- a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs+++ b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs@@ -363,34 +363,48 @@ impl ForeignTryFrom<payments_grpc::AdditionalPaymentMethodConnectorResponse>fn foreign_try_from(value: payments_grpc::AdditionalPaymentMethodConnectorResponse,) -> Result<Self, Self::Error> {- let card_data = value.card.unwrap_or_default();-- Ok(Self::Card {- authentication_data: card_data.authentication_data.and_then(|data| {- serde_json::from_slice(&data)- .inspect_err(|e| {- router_env::logger::warn!(- deserialization_error=?e,- "Failed to deserialize authentication_data from UCS connector response"- );- })- .ok()- }),- payment_checks: card_data.payment_checks.and_then(|data| {- serde_json::from_slice(&data)- .inspect_err(|e| {- router_env::logger::warn!(- deserialization_error=?e,- "Failed to deserialize payment_checks from UCS connector response"- );- })- .ok()- }),- card_network: card_data.card_network,- domestic_network: card_data.domestic_network,- // needs to be updated- auth_code: None,- })+ // Handle the oneof payment_method_data field+ match value.payment_method_data {+ Some(payments_grpc::additional_payment_method_connector_response::PaymentMethodData::Card(card_data)) => {+ Ok(Self::Card {+ authentication_data: card_data.authentication_data.and_then(|data| {+ serde_json::from_slice(&data)+ .inspect_err(|e| {+ router_env::logger::warn!(+ deserialization_error=?e,+ "Failed to deserialize authentication_data from UCS connector response"+ );+ })+ .ok()+ }),+ payment_checks: card_data.payment_checks.and_then(|data| {+ serde_json::from_slice(&data)+ .inspect_err(|e| {+ router_env::logger::warn!(+ deserialization_error=?e,+ "Failed to deserialize payment_checks from UCS connector response"+ );+ })+ .ok()+ }),+ card_network: card_data.card_network,+ domestic_network: card_data.domestic_network,+ // needs to be updated+ auth_code: None,+ })+ }+ Some(payments_grpc::additional_payment_method_connector_response::PaymentMethodData::Upi(_)) => {+ Err(error_stack::Report::new(+ UnifiedConnectorServiceError::NotImplemented(+ "UPI payment method data transformation is not yet implemented".to_string(),+ ),+ ))+ }+ None => Err(error_stack::Report::new(+ UnifiedConnectorServiceError::ResponseDeserializationFailed,+ )+ .attach_printable("Unexpected error: payment_method_data is None in UCS connector response")),+ }}}diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex 8f35aac723..68c0b5b2a0 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -88,8 +88,8 @@ reqwest = { version = "0.11.27", features = ["json", "rustls-tls", "gzip", "multring = "0.17.14"rust_decimal = { version = "1.37.1", features = ["serde-with-float", "serde-with-str"] }rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" }-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0", package = "rust-grpc-client" }-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "d1a28bfe75ac219f7a3e5558c3b60fb67a64a5b0", package = "ucs_cards" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "00ffd3b1d753f72a93b3882585b3eda2a9c9ec55", package = "rust-grpc-client" }+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "00ffd3b1d753f72a93b3882585b3eda2a9c9ec55", package = "ucs_cards" }unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.11.24.0", package = "masking" }rustc-hash = "1.1.0"rustls = "0.22"diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rsindex 23f0870d5a..35d4c63dcf 100644--- a/crates/router/src/core/unified_connector_service.rs+++ b/crates/router/src/core/unified_connector_service.rs@@ -627,8 +627,7 @@ pub fn build_unified_connector_service_payment_method(let card_network = card.card_network.clone()- .map(payments_grpc::CardNetwork::foreign_try_from)- .transpose()?;+ .map(payments_grpc::CardNetwork::foreign_from);let card_details = CardDetails {card_number: Some(@@ -1281,8 +1280,7 @@ pub fn build_unified_connector_service_payment_method_for_external_proxy(let card_network = external_vault_card.card_network.clone()- .map(payments_grpc::CardNetwork::foreign_try_from)- .transpose()?;+ .map(payments_grpc::CardNetwork::foreign_from);let card_details = CardDetails {card_number: Some(CardNumber::from_str(external_vault_card.card_number.peek()).change_context(UnifiedConnectorServiceError::RequestEncodingFailedWithReason("Failed to parse card number".to_string())diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex b7df9546ef..e2dd3fea6d 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -746,6 +746,14 @@ impl.map(payments_grpc::FutureUsage::foreign_try_from).transpose()?;+ let merchant_account_metadata = router_data+ .connector_meta_data+ .as_ref()+ .map(serde_json::to_string)+ .transpose()+ .change_context(UnifiedConnectorServiceError::RequestEncodingFailed)?+ .map(|s| s.into());+Ok(Self {transaction_id: connector_transaction_id,encoded_data: router_data.request.encoded_data.clone(),@@ -768,7 +776,7 @@ implsync_type: Some(payments_grpc::SyncRequestType::foreign_from(&router_data.request.sync_type).into(),),- merchant_account_metadata: None,+ merchant_account_metadata,metadata: None,test_mode: router_data.test_mode,})@@ -1095,6 +1103,7 @@ impl.transpose()?,connector_metadata: None,capture_method: capture_method.map(|capture_method| capture_method.into()),+ description: router_data.description.clone(),})}}@@ -1180,6 +1189,7 @@ impl transformers::ForeignTryFrom<&RouterData<Capture, PaymentsCaptureData, Paym.map(|s| s.into()),merchant_account_metadata,test_mode: router_data.test_mode,+ merchant_order_reference_id: router_data.request.merchant_order_reference_id.clone(),})}}@@ -3021,27 +3031,24 @@ impl transformers::ForeignTryFrom<common_enums::PaymentMethodType>}}-impl transformers::ForeignTryFrom<common_enums::CardNetwork> for payments_grpc::CardNetwork {- type Error = error_stack::Report<UnifiedConnectorServiceError>;-- fn foreign_try_from(card_network: common_enums::CardNetwork) -> Result<Self, Self::Error> {+impl ForeignFrom<common_enums::CardNetwork> for payments_grpc::CardNetwork {+ fn foreign_from(card_network: common_enums::CardNetwork) -> Self {match card_network {- common_enums::CardNetwork::Visa => Ok(Self::Visa),- common_enums::CardNetwork::Mastercard => Ok(Self::Mastercard),- common_enums::CardNetwork::JCB => Ok(Self::Jcb),- common_enums::CardNetwork::DinersClub => Ok(Self::Diners),- common_enums::CardNetwork::Discover => Ok(Self::Discover),- common_enums::CardNetwork::CartesBancaires => Ok(Self::CartesBancaires),- common_enums::CardNetwork::UnionPay => Ok(Self::Unionpay),- common_enums::CardNetwork::RuPay => Ok(Self::Rupay),- common_enums::CardNetwork::Maestro => Ok(Self::Maestro),- common_enums::CardNetwork::AmericanExpress => Ok(Self::Amex),- _ => Err(- UnifiedConnectorServiceError::RequestEncodingFailedWithReason(- "Card Network not supported".to_string(),- )- .into(),- ),+ common_enums::CardNetwork::Visa => Self::Visa,+ common_enums::CardNetwork::Mastercard => Self::Mastercard,+ common_enums::CardNetwork::JCB => Self::Jcb,+ common_enums::CardNetwork::DinersClub => Self::Diners,+ common_enums::CardNetwork::Discover => Self::Discover,+ common_enums::CardNetwork::CartesBancaires => Self::CartesBancaires,+ common_enums::CardNetwork::UnionPay => Self::Unionpay,+ common_enums::CardNetwork::RuPay => Self::Rupay,+ common_enums::CardNetwork::Maestro => Self::Maestro,+ common_enums::CardNetwork::AmericanExpress => Self::Amex,+ common_enums::CardNetwork::Interac => Self::InteracCard,+ common_enums::CardNetwork::Star => Self::Star,+ common_enums::CardNetwork::Pulse => Self::Pulse,+ common_enums::CardNetwork::Accel => Self::Accel,+ common_enums::CardNetwork::Nyce => Self::Nyce,}}}@@ -3076,8 +3083,7 @@ impl transformers::ForeignTryFrom<hyperswitch_domain_models::payment_method_datalet card_network = network_token_data.card_network.clone()- .map(payments_grpc::CardNetwork::foreign_try_from)- .transpose()?;+ .map(payments_grpc::CardNetwork::foreign_from);#[cfg(feature = "v1")]let network_token = Self {@@ -3149,8 +3155,7 @@ impllet card_network = card_nti_data.card_network.clone()- .map(payments_grpc::CardNetwork::foreign_try_from)- .transpose()?;+ .map(payments_grpc::CardNetwork::foreign_from);let card_details_for_nti = Self {card_number: Some(@@ -5521,6 +5526,7 @@ impl transformers::ForeignTryFrom<&RouterData<api::Void, PaymentsCancelData, Pay.map(|s| s.into()),merchant_account_metadata,test_mode: router_data.test_mode,+ merchant_order_reference_id: router_data.request.merchant_order_reference_id.clone(),})}}