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(UCS): Added CardDetailsForNetworkTransactionId & NetworkToken payments support for Hyperswitch<>UCS tunnel (#10796)
Saptak Dutta39b43a428cb9
diff --git a/Cargo.lock b/Cargo.lockindex 42e73554ab..affd858c75 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3790,7 +3790,7 @@ dependencies = [[[package]]name = "grpc-api-types"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=b978b0eac62ca98f291f70d4168e0ba1d62711cb#b978b0eac62ca98f291f70d4168e0ba1d62711cb"+source = "git+https://github.com/juspay/connector-service?rev=a910df283e18aa625070dc9aea6cd31d83f7167e#a910df283e18aa625070dc9aea6cd31d83f7167e"dependencies = ["axum 0.8.4","error-stack 0.5.0",@@ -7450,7 +7450,7 @@ dependencies = [[[package]]name = "rust-grpc-client"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=b978b0eac62ca98f291f70d4168e0ba1d62711cb#b978b0eac62ca98f291f70d4168e0ba1d62711cb"+source = "git+https://github.com/juspay/connector-service?rev=a910df283e18aa625070dc9aea6cd31d83f7167e#a910df283e18aa625070dc9aea6cd31d83f7167e"dependencies = ["grpc-api-types",]@@ -10240,7 +10240,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"[[package]]name = "ucs_cards"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=b978b0eac62ca98f291f70d4168e0ba1d62711cb#b978b0eac62ca98f291f70d4168e0ba1d62711cb"+source = "git+https://github.com/juspay/connector-service?rev=a910df283e18aa625070dc9aea6cd31d83f7167e#a910df283e18aa625070dc9aea6cd31d83f7167e"dependencies = ["bytes 1.10.1","error-stack 0.4.1",@@ -10256,7 +10256,7 @@ dependencies = [[[package]]name = "ucs_common_enums"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=b978b0eac62ca98f291f70d4168e0ba1d62711cb#b978b0eac62ca98f291f70d4168e0ba1d62711cb"+source = "git+https://github.com/juspay/connector-service?rev=a910df283e18aa625070dc9aea6cd31d83f7167e#a910df283e18aa625070dc9aea6cd31d83f7167e"dependencies = ["serde","strum 0.26.3",@@ -10267,7 +10267,7 @@ dependencies = [[[package]]name = "ucs_common_utils"version = "0.1.0"-source = "git+https://github.com/juspay/connector-service?rev=b978b0eac62ca98f291f70d4168e0ba1d62711cb#b978b0eac62ca98f291f70d4168e0ba1d62711cb"+source = "git+https://github.com/juspay/connector-service?rev=a910df283e18aa625070dc9aea6cd31d83f7167e#a910df283e18aa625070dc9aea6cd31d83f7167e"dependencies = ["anyhow","base64 0.21.7",diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.tomlindex a67f92d9ad..167b8df516 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 = "b978b0eac62ca98f291f70d4168e0ba1d62711cb", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "a910df283e18aa625070dc9aea6cd31d83f7167e", 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 9a1d3b91b3..e9791808c1 100644--- a/crates/hyperswitch_interfaces/Cargo.toml+++ b/crates/hyperswitch_interfaces/Cargo.toml@@ -29,7 +29,7 @@ serde_json = "1.0.140"strum = { version = "0.26", features = ["derive"] }thiserror = "1.0.69"time = "0.3.41"-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "b978b0eac62ca98f291f70d4168e0ba1d62711cb", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "a910df283e18aa625070dc9aea6cd31d83f7167e", 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"] }# First party cratesdiff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex 7e82f906bd..47448c2d06 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 = "b978b0eac62ca98f291f70d4168e0ba1d62711cb", package = "rust-grpc-client" }-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "b978b0eac62ca98f291f70d4168e0ba1d62711cb", package = "ucs_cards" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "a910df283e18aa625070dc9aea6cd31d83f7167e", package = "rust-grpc-client" }+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "a910df283e18aa625070dc9aea6cd31d83f7167e", 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/payments.rs b/crates/router/src/core/payments.rsindex fe7558f717..38d2dd4b26 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -5360,18 +5360,44 @@ where).await?;- let gateway_context = gateway_context::RouterGatewayContext::new(- platform.clone(),- header_payload.clone(),- business_profile,- merchant_connector_account.clone(),- ExecutionPath::Direct,+ let (execution_path, updated_state) = should_call_unified_connector_service(+ state,+ platform,+ &router_data,+ None,+ call_connector_action.clone(),None,+ )+ .await?;++ let lineage_ids = grpc_client::LineageIds::new(+ business_profile.merchant_id.clone(),+ business_profile.get_id().clone(),);+ let execution_mode = match execution_path {+ ExecutionPath::UnifiedConnectorService => ExecutionMode::Primary,+ ExecutionPath::ShadowUnifiedConnectorService => ExecutionMode::Shadow,+ // ExecutionMode is irrelevant for Direct path in this context+ ExecutionPath::Direct => ExecutionMode::NotApplicable,+ };++ let gateway_context = gateway_context::RouterGatewayContext {+ creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),+ platform: platform.clone(),+ header_payload: header_payload.clone(),+ lineage_ids,+ merchant_connector_account: merchant_connector_account.clone(),+ execution_path,+ execution_mode,+ };++ // Update feature metadata to track Direct routing usage for stickiness+ update_gateway_system_in_feature_metadata(payment_data, gateway_context.get_gateway_system())?;+let add_access_token_result = router_data.add_access_token(- state,+ &updated_state,&connector,platform,payment_data.get_creds_identifier(),@@ -5380,7 +5406,7 @@ where.await?;router_data- .add_session_token(state, &connector, &gateway_context)+ .add_session_token(&updated_state, &connector, &gateway_context).await?;let mut should_continue_further = access_token::update_router_data_with_access_token_result(@@ -5390,7 +5416,7 @@ where);(router_data, should_continue_further) = complete_preprocessing_steps_if_required(- state,+ &updated_state,&connector,payment_data,router_data,@@ -5410,7 +5436,11 @@ wherelet (connector_request, should_continue_further) = if should_continue_further {// Check if the actual flow specific request can be built with available datarouter_data- .build_flow_specific_connector_request(state, &connector, call_connector_action.clone())+ .build_flow_specific_connector_request(+ &updated_state,+ &connector,+ call_connector_action.clone(),+ ).await?} else {(None, false)@@ -5420,7 +5450,7 @@ whereoperation.to_domain()?.add_task_to_process_tracker(- state,+ &updated_state,payment_data.get_payment_attempt(),validate_result.requeue,schedule_time,@@ -5435,7 +5465,7 @@ where(_, *payment_data) = operation.to_update_tracker()?.update_trackers(- state,+ &updated_state,req_state,platform.get_processor(),payment_data.clone(),@@ -5453,7 +5483,7 @@ whererouter_data.status = payment_data.get_payment_attempt().status;router_data.decide_flows(- state,+ &updated_state,&connector,call_connector_action,connector_request,diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rsindex d4c5588c2a..af48368638 100644--- a/crates/router/src/core/unified_connector_service.rs+++ b/crates/router/src/core/unified_connector_service.rs@@ -39,7 +39,7 @@ use hyperswitch_domain_models::{};use masking::{ExposeInterface, PeekInterface, Secret};use router_env::{instrument, logger, tracing};-use unified_connector_service_cards::CardNumber;+use unified_connector_service_cards::{CardNumber, NetworkToken};use unified_connector_service_client::payments::{self as payments_grpc, payment_method::PaymentMethod, CardDetails, ClassicReward,CryptoCurrency, EVoucher, OpenBanking, PaymentServiceAuthorizeResponse,@@ -668,15 +668,21 @@ pub fn build_unified_connector_service_payment_method() => {let upi_details = payments_grpc::UpiCollect {vpa_id: upi_collect_data.vpa_id.map(|vpa| vpa.expose().into()),+ upi_source: None,};PaymentMethod::UpiCollect(upi_details)}hyperswitch_domain_models::payment_method_data::UpiData::UpiIntent(_) => {- let upi_details = payments_grpc::UpiIntent { app_name: None };+ let upi_details = payments_grpc::UpiIntent {+ app_name: None,+ upi_source: None,+ };PaymentMethod::UpiIntent(upi_details)}hyperswitch_domain_models::payment_method_data::UpiData::UpiQr(_) => {- let upi_details = payments_grpc::UpiQr {};+ let upi_details = payments_grpc::UpiQr {+ upi_source: None,+ };PaymentMethod::UpiQr(upi_details)}};@@ -817,6 +823,89 @@ pub fn build_unified_connector_service_payment_method(})),})}+ hyperswitch_domain_models::payment_method_data::PaymentMethodData::CardDetailsForNetworkTransactionId(card_nti_data) => {+ let card_network = card_nti_data+ .card_network+ .clone()+ .map(payments_grpc::CardNetwork::foreign_try_from)+ .transpose()?;++ let card_details_for_nti = payments_grpc::CardDetailsForNetworkTransactionId {+ card_number: Some(+ CardNumber::from_str(&card_nti_data.card_number.get_card_no()).change_context(+ UnifiedConnectorServiceError::RequestEncodingFailedWithReason(+ "Failed to parse card number".to_string(),+ ),+ )?,+ ),+ card_exp_month: Some(card_nti_data.card_exp_month.expose().into()),+ card_exp_year: Some(card_nti_data.card_exp_year.expose().into()),+ card_issuer: card_nti_data.card_issuer.clone(),+ card_network: card_network.map(|card_network| card_network.into()),+ card_type: card_nti_data.card_type.clone(),+ card_issuing_country: card_nti_data.card_issuing_country.clone(),+ bank_code: card_nti_data.bank_code.clone(),+ nick_name: card_nti_data.nick_name.map(|n| n.expose().into()),+ card_holder_name: card_nti_data.card_holder_name.map(|name| name.expose().into()),+ };++ Ok(payments_grpc::PaymentMethod {+ payment_method: Some(PaymentMethod::CardDetailsForNetworkTransactionId(card_details_for_nti)),+ })+ }+ hyperswitch_domain_models::payment_method_data::PaymentMethodData::NetworkToken(network_token_data) => {+ let card_network = network_token_data+ .card_network+ .clone()+ .map(payments_grpc::CardNetwork::foreign_try_from)+ .transpose()?;++ #[cfg(feature = "v1")]+ let network_token = payments_grpc::NetworkTokenData {+ token_number: Some(+ NetworkToken::from_str(&network_token_data.token_number.get_card_no()).change_context(+ UnifiedConnectorServiceError::RequestEncodingFailedWithReason(+ "Failed to parse token number".to_string(),+ ),+ )?,+ ),+ token_exp_month: Some(network_token_data.token_exp_month.expose().into()),+ token_exp_year: Some(network_token_data.token_exp_year.expose().into()),+ token_cryptogram: network_token_data.token_cryptogram.map(|cryptogram| cryptogram.expose().into()),+ card_issuer: network_token_data.card_issuer.clone(),+ card_network: card_network.map(|card_network| card_network.into()),+ card_type: network_token_data.card_type.clone(),+ card_issuing_country: network_token_data.card_issuing_country.clone(),+ bank_code: network_token_data.bank_code.clone(),+ nick_name: network_token_data.nick_name.map(|n| n.expose().into()),+ eci: network_token_data.eci,+ };++ #[cfg(feature = "v2")]+ let network_token = payments_grpc::NetworkTokenData {+ token_number: Some(+ NetworkToken::from_str(&network_token_data.network_token.get_card_no()).change_context(+ UnifiedConnectorServiceError::RequestEncodingFailedWithReason(+ "Failed to parse token number".to_string(),+ ),+ )?,+ ),+ token_exp_month: Some(network_token_data.network_token_exp_month.expose().into()),+ token_exp_year: Some(network_token_data.network_token_exp_year.expose().into()),+ token_cryptogram: network_token_data.cryptogram.map(|cryptogram| cryptogram.expose().into()),+ card_issuer: network_token_data.card_issuer.clone(),+ card_network: card_network.map(|card_network| card_network.into()),+ card_type: network_token_data.card_type.clone().map(|ct| ct.to_string()),+ card_issuing_country: network_token_data.card_issuing_country.map(|cic| cic.to_string()),+ bank_code: network_token_data.bank_code.clone(),+ nick_name: network_token_data.nick_name.map(|n| n.expose().into()),+ eci: network_token_data.eci,+ };++ Ok(payments_grpc::PaymentMethod {+ payment_method: Some(PaymentMethod::NetworkToken(network_token)),+ })+ }_ => Err(UnifiedConnectorServiceError::NotImplemented(format!("Unimplemented payment method: {payment_method_data:?}"))diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex 9d2822443f..6eeffd14cc 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -731,12 +731,19 @@ implamount: router_data.request.amount.get_amount_as_i64(),currency: currency.into(),state,- connector_metadata: None,- merchant_account_metadata: HashMap::new(),- metadata: HashMap::new(),+ connector_metadata: router_data+ .request+ .connector_meta+ .as_ref()+ .map(serde_json::to_string)+ .transpose()+ .change_context(UnifiedConnectorServiceError::RequestEncodingFailed)?+ .map(|s| s.into()),sync_type: Some(payments_grpc::SyncRequestType::foreign_from(&router_data.request.sync_type).into(),),+ merchant_account_metadata: HashMap::new(),+ metadata: HashMap::new(),})}}@@ -1751,15 +1758,52 @@ impllet address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;- let mandate_reference = match &router_data.request.mandate_id {+ let mandate_reference_id = match &router_data.request.mandate_id {Some(mandate) => match &mandate.mandate_reference_id {Some(api_models::payments::MandateReferenceId::ConnectorMandateId(connector_mandate_id,- )) => Some(payments_grpc::MandateReference {- mandate_id: connector_mandate_id.get_connector_mandate_id(),- payment_method_id: connector_mandate_id.get_payment_method_id(),- connector_mandate_request_reference_id: connector_mandate_id- .get_connector_mandate_request_reference_id(),+ )) => Some(payments_grpc::MandateReferenceId {+ mandate_id_type: Some(+ payments_grpc::mandate_reference_id::MandateIdType::ConnectorMandateId(+ payments_grpc::ConnectorMandateReferenceId {+ connector_mandate_id: connector_mandate_id+ .get_connector_mandate_id(),+ payment_method_id: connector_mandate_id.get_payment_method_id(),+ connector_mandate_request_reference_id: connector_mandate_id+ .get_connector_mandate_request_reference_id(),+ },+ ),+ ),+ }),+ Some(api_models::payments::MandateReferenceId::NetworkMandateId(+ network_mandate_id,+ )) => Some(payments_grpc::MandateReferenceId {+ mandate_id_type: Some(+ payments_grpc::mandate_reference_id::MandateIdType::NetworkMandateId(+ network_mandate_id.clone(),+ ),+ ),+ }),+ Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(+ network_token_with_nti,+ )) => Some(payments_grpc::MandateReferenceId {+ mandate_id_type: Some(+ payments_grpc::mandate_reference_id::MandateIdType::NetworkTokenWithNti(+ payments_grpc::NetworkTokenWithNti {+ network_transaction_id: network_token_with_nti+ .network_transaction_id+ .clone(),+ token_exp_month: network_token_with_nti+ .token_exp_month+ .clone()+ .map(|exp| exp.expose().into()),+ token_exp_year: network_token_with_nti+ .token_exp_year+ .clone()+ .map(|exp| exp.expose().into()),+ },+ ),+ ),}),_ => {return Err(UnifiedConnectorServiceError::MissingRequiredField {@@ -1781,13 +1825,33 @@ impl.as_ref().map(ConnectorState::foreign_from);+ let payment_method = match router_data.request.payment_method_data {+ hyperswitch_domain_models::payment_method_data::PaymentMethodData::MandatePayment => {+ None+ }+ _ => Some(+ unified_connector_service::build_unified_connector_service_payment_method(+ router_data.request.payment_method_data.clone(),+ router_data.request.payment_method_type,+ )?,+ ),+ };++ let authentication_data = router_data+ .request+ .authentication_data+ .clone()+ .map(payments_grpc::AuthenticationData::foreign_try_from)+ .transpose()?;+Ok(Self {request_ref_id: Some(Identifier {id_type: Some(payments_grpc::identifier::IdType::Id(router_data.connector_request_reference_id.clone(),)),}),- mandate_reference,+ payment_method,+ mandate_reference_id,amount: router_data.request.amount,currency: currency.into(),minor_amount: router_data.request.amount,@@ -1840,6 +1904,7 @@ impl.request.shipping_cost.map(|shipping_cost| shipping_cost.get_amount_as_i64()),+ authentication_data,connector_metadata: HashMap::new(),})}@@ -2511,7 +2576,7 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceRepeatEverythingRconnector_metadata,network_txn_id: response.network_txn_id.clone(),connector_response_reference_id,- incremental_authorization_allowed: None,+ incremental_authorization_allowed: response.incremental_authorization_allowed,charges: None,},status,@@ -4492,6 +4557,7 @@ impl transformers::ForeignTryFrom<&RouterData<Execute, RefundsData, RefundsRespometadata: HashMap::new(),test_mode: router_data.test_mode,payment_method_type,+ customer_id: None,})}}@@ -4854,8 +4920,8 @@ implmerchant_account_metadata: HashMap::new(),// depricated field we have to remove this/ Default to unspecified connectorconnector: 0_i32,- connector_metadata: HashMap::new(),metadata: HashMap::new(),+ connector_metadata: HashMap::new(),})}}