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(router): add pay_via_single_use_token connector config to control connector tokenization per payment method type (#15039)
Akshaya Shankar63940c3be37a
diff --git a/Cargo.lock b/Cargo.lockindex ac883df141..7b4e06c4ab 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.2#32f71920cb45a0c9bbfaeb7fdfd129cd56a5cf57"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"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.2#32f71920cb45a0c9bbfaeb7fdfd129cd56a5cf57"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"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.2#32f71920cb45a0c9bbfaeb7fdfd129cd56a5cf57"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"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.2#32f71920cb45a0c9bbfaeb7fdfd129cd56a5cf57"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"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.2#32f71920cb45a0c9bbfaeb7fdfd129cd56a5cf57"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"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.2#32f71920cb45a0c9bbfaeb7fdfd129cd56a5cf57"+source = "git+https://github.com/juspay/connector-service?tag=2026.11.02.3#5e72a2d94543e69444b7695db04e1021befe29c5"dependencies = ["anyhow","base64 0.21.7",diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 2b504f1467..c3cd571e9d 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -32064,6 +32064,15 @@}}},+ "PayViaSingleUseToken": {+ "type": "string",+ "description": "Whether to exchange the payment method data for a connector single-use token before authorize / setup mandate",+ "enum": [+ "default",+ "enabled",+ "disabled"+ ]+ },"PaylaterResponse": {"type": "object","properties": {@@ -45694,6 +45703,14 @@"description": "Indicates whether the payment method is eligible for installment payments (e.g., EMI, BNPL). Optional.","example": true,"nullable": true+ },+ "pay_via_single_use_token": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PayViaSingleUseToken"+ }+ ],+ "nullable": true}}},diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 0af554edb0..1727c9307a 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -22788,6 +22788,15 @@}}},+ "PayViaSingleUseToken": {+ "type": "string",+ "description": "Whether to exchange the payment method data for a connector single-use token before authorize / setup mandate",+ "enum": [+ "default",+ "enabled",+ "disabled"+ ]+ },"PaylaterResponse": {"type": "object","properties": {@@ -32475,6 +32484,14 @@"description": "Indicates whether the payment method is eligible for installment payments (e.g., EMI, BNPL). Optional.","example": true,"nullable": true+ },+ "pay_via_single_use_token": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PayViaSingleUseToken"+ }+ ],+ "nullable": true}}},diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 6e4c3982fa..3919e56dea 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -6,10 +6,10 @@ use std::{};use cards::CardNumber;-pub use common_types::payments::SurchargeErrorDetails;use common_types::payments::{ApplePayPredecryptData, BillingFrequency, GPayPredecryptData, InstallmentInterestRate,};+pub use common_types::{payment_methods::PayViaSingleUseToken, payments::SurchargeErrorDetails};#[cfg(feature = "v1")]use common_utils::crypto::OptionalEncryptableName;use common_utils::{@@ -2806,6 +2806,11 @@ pub struct RequestPaymentMethodTypes {/// Indicates whether the payment method is eligible for installment payments (e.g., EMI, BNPL). Optional.#[schema(example = true)]pub installment_payment_enabled: Option<bool>,++ /// Indicates whether the payment should be made via a single-use token.+ /// `None` is treated as `default`, the default behaviour is followed (the current behaviour).+ #[schema(value_type = Option<PayViaSingleUseToken>)]+ pub pay_via_single_use_token: Option<PayViaSingleUseToken>,}impl RequestPaymentMethodTypes {/// Get payment_method_typediff --git a/crates/common_types/src/payment_methods.rs b/crates/common_types/src/payment_methods.rsindex 0e23b48b05..bb2083c2ed 100644--- a/crates/common_types/src/payment_methods.rs+++ b/crates/common_types/src/payment_methods.rs@@ -110,6 +110,21 @@ impl PaymentMethodsEnabled {}}+/// Whether to exchange the payment method data for a connector single-use token before authorize / setup mandate+#[derive(+ Debug, Clone, Copy, Default, serde::Serialize, serde::Deserialize, ToSchema, PartialEq, Eq, Hash,+)]+#[serde(rename_all = "snake_case")]+pub enum PayViaSingleUseToken {+ /// Hyperswitch decides whether to make the payment via a single-use token, based on the connector's default requirement+ #[default]+ Default,+ /// Create a single-use token for subsequent authorization or mandate setup.+ Enabled,+ /// Don't create a single-use token before authorization or mandate setup+ Disabled,+}+/// Details of a specific payment method subtype enabled for the connector for the given merchant account#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema, PartialEq, Eq, Hash)]pub struct RequestPaymentMethodTypes {@@ -158,6 +173,11 @@ pub struct RequestPaymentMethodTypes {/// Indicates whether the payment method is eligible for installment payments (e.g., EMI, BNPL). Optional.#[schema(example = true)]pub installment_payment_enabled: Option<bool>,++ /// Indicates whether the payment should be made via a single-use token.+ /// `None` is treated as `default`, the default behaviour is followed (the current behaviour).+ #[schema(value_type = Option<PayViaSingleUseToken>)]+ pub pay_via_single_use_token: Option<PayViaSingleUseToken>,}impl From<RequestPaymentMethodTypesV1> for RequestPaymentMethodTypes {@@ -172,6 +192,7 @@ impl From<RequestPaymentMethodTypesV1> for RequestPaymentMethodTypes {maximum_amount: value.maximum_amount,recurring_enabled: value.recurring_enabled,installment_payment_enabled: value.installment_payment_enabled,+ pay_via_single_use_token: value.pay_via_single_use_token,}}}@@ -187,6 +208,7 @@ struct RequestPaymentMethodTypesV1 {pub maximum_amount: Option<common_utils::types::MinorUnit>,pub recurring_enabled: Option<bool>,pub installment_payment_enabled: Option<bool>,+ pub pay_via_single_use_token: Option<PayViaSingleUseToken>,}impl RequestPaymentMethodTypes {diff --git a/crates/connector_configs/src/common_config.rs b/crates/connector_configs/src/common_config.rsindex 25307d2181..993ec8b8bf 100644--- a/crates/connector_configs/src/common_config.rs+++ b/crates/connector_configs/src/common_config.rs@@ -185,6 +185,10 @@ pub struct Provider {), value_type = Option<AcceptedCountries>)]pub accepted_countries: Option<api_models::admin::AcceptedCountries>,pub payment_experience: Option<api_models::enums::PaymentExperience>,+ /// Indicates whether the payment should be made via a single-use token at the connector.+ /// `None` is treated as `default`, the default behaviour is followed (the current behaviour).+ #[schema(value_type = Option<PayViaSingleUseToken>)]+ pub pay_via_single_use_token: Option<payment_methods::PayViaSingleUseToken>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex 15da298f95..2558899d4e 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -243,6 +243,26 @@ pub struct ConnectorWebhookRegisterDetailsConfig {pub event_types: Option<Vec<String>>,}+/// Wallet flow, based on who decrypts the wallet token+#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]+#[serde(rename_all = "snake_case")]+pub enum WalletFlow {+ /// The wallet token is decrypted by the connector+ Encrypt,+ /// The wallet token is decrypted by Hyperswitch or Merchant+ Decrypt,+}++/// Input to be collected for `pay_via_single_use_token` of a payment method type+#[serde_with::skip_serializing_none]+#[derive(Debug, Deserialize, Serialize, Clone)]+pub struct PayViaSingleUseTokenInputData {+ /// Wallet flows for which the value has to be collected+ pub flows: Vec<WalletFlow>,+ #[serde(flatten)]+ pub input_data: InputData,+}+#[serde_with::skip_serializing_none]#[derive(Debug, Deserialize, Serialize, Clone)]pub struct ConnectorTomlConfig {@@ -269,6 +289,9 @@ pub struct ConnectorTomlConfig {pub is_verifiable: Option<bool>,pub real_time_payment: Option<Vec<Provider>>,pub network_token: Option<Vec<Provider>>,+ /// Inputs to be collected for `pay_via_single_use_token`, keyed by payment method type+ pub pay_via_single_use_token:+ Option<HashMap<api_models::enums::PaymentMethodType, PayViaSingleUseTokenInputData>>,}#[serde_with::skip_serializing_none]#[derive(Debug, Deserialize, Serialize, Clone)]diff --git a/crates/connector_configs/src/response_modifier.rs b/crates/connector_configs/src/response_modifier.rsindex 272354f417..1283ace533 100644--- a/crates/connector_configs/src/response_modifier.rs+++ b/crates/connector_configs/src/response_modifier.rs@@ -75,6 +75,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -87,6 +88,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -99,6 +101,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -111,6 +114,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -123,6 +127,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -135,6 +140,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -147,6 +153,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -159,6 +166,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -171,6 +179,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -183,6 +192,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -195,6 +205,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -207,6 +218,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -219,6 +231,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -231,6 +244,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: method_type.payment_experience,+ pay_via_single_use_token: method_type.pay_via_single_use_token,})}}@@ -243,6 +257,7 @@ impl ConnectorApiIntegrationPayload {accepted_currencies: method_type.accepted_currencies.clone(),accepted_countries: method_type.accepted_countries.clone(),payment_experience: None,+ pay_via_single_use_token: method_type.pay_via_single_use_token,},));}diff --git a/crates/connector_configs/src/transformer.rs b/crates/connector_configs/src/transformer.rsindex 8c49283740..3fe293dee7 100644--- a/crates/connector_configs/src/transformer.rs+++ b/crates/connector_configs/src/transformer.rs@@ -28,6 +28,7 @@ impl DashboardRequestPayload {accepted_currencies: None,accepted_countries: None,payment_experience: None,+ pay_via_single_use_token: None,}}@@ -100,6 +101,7 @@ impl DashboardRequestPayload {payment_method,method_type.payment_experience,),+ pay_via_single_use_token: method_type.pay_via_single_use_token,};payment_method_types.push(data)}@@ -134,6 +136,7 @@ impl DashboardRequestPayload {accepted_currencies: method.accepted_currencies,accepted_countries: method.accepted_countries,payment_experience: None,+ pay_via_single_use_token: None,};card_payment_method_types.push(data)}diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex cc189dec41..2c9e0e65be 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -5247,6 +5247,24 @@ options=["CRYPTOGRAM_3DS"][[stripe.wallet]]payment_method_type = "revolut_pay"is_verifiable = true+[stripe.pay_via_single_use_token.apple_pay]+flows=["decrypt"]+name="pay_via_single_use_token"+label="Pay via single-use token"+placeholder="Select"+required=false+type="Select"+options=["default","enabled","disabled"]++[stripe.pay_via_single_use_token.google_pay]+flows=["decrypt"]+name="pay_via_single_use_token"+label="Pay via single-use token"+placeholder="Select"+required=false+type="Select"+options=["default","enabled","disabled"]+[stripe.connector_auth.HeaderKey]api_key="Secret Key"[stripe.connector_webhook_details]diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex 654167cf29..30942d8be6 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -4531,6 +4531,24 @@ payment_method_type = "google_pay"[[stripe.wallet]]payment_method_type = "revolut_pay"is_verifiable = true+[stripe.pay_via_single_use_token.apple_pay]+flows=["decrypt"]+name="pay_via_single_use_token"+label="Pay via single-use token"+placeholder="Select"+required=false+type="Select"+options=["default","enabled","disabled"]++[stripe.pay_via_single_use_token.google_pay]+flows=["decrypt"]+name="pay_via_single_use_token"+label="Pay via single-use token"+placeholder="Select"+required=false+type="Select"+options=["default","enabled","disabled"]+[stripe.connector_auth.HeaderKey]api_key = "Secret Key"[stripe.connector_webhook_details]diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex 8a29c94153..069407ea43 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -5208,6 +5208,24 @@ payment_method_type = "cashapp"[[stripe.wallet]]payment_method_type = "revolut_pay"is_verifiable = true+[stripe.pay_via_single_use_token.apple_pay]+flows=["decrypt"]+name="pay_via_single_use_token"+label="Pay via single-use token"+placeholder="Select"+required=false+type="Select"+options=["default","enabled","disabled"]++[stripe.pay_via_single_use_token.google_pay]+flows=["decrypt"]+name="pay_via_single_use_token"+label="Pay via single-use token"+placeholder="Select"+required=false+type="Select"+options=["default","enabled","disabled"]+[stripe.connector_auth.HeaderKey]api_key = "Secret Key"[stripe.connector_webhook_details]diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.tomlindex 7d54ef2d64..e0707e48b9 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.2", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.02.3", 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/stripe.rs b/crates/hyperswitch_connectors/src/connectors/stripe.rsindex d0e8e1fa34..01af826b0e 100644--- a/crates/hyperswitch_connectors/src/connectors/stripe.rs+++ b/crates/hyperswitch_connectors/src/connectors/stripe.rs@@ -3865,4 +3865,86 @@ impl ConnectorSpecifications for Stripe {) -> api::ConnectorCustomerAction {api::ConnectorCustomerAction::CallConnectorCustomer}++ fn get_single_use_token_support(+ &self,+ payment_method_data: &PaymentMethodData,+ payment_method_token: Option<&hyperswitch_domain_models::router_data::PaymentMethodToken>,+ ) -> Option<api::SingleUseTokenSupport> {+ match (payment_method_data, payment_method_token) {+ // Pre-decrypted token can be sent either via a single-use token or directly as a network token+ (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePay(_),+ ),+ Some(hyperswitch_domain_models::router_data::PaymentMethodToken::ApplePayDecrypt(+ _,+ )),+ )+ | (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePay(_),+ ),+ Some(hyperswitch_domain_models::router_data::PaymentMethodToken::GooglePayDecrypt(+ _,+ )),+ ) => Some(api::SingleUseTokenSupport::Supported),+ // Encrypted Apple Pay token has to be exchanged for a single-use token+ (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePay(_),+ ),+ _,+ ) => Some(api::SingleUseTokenSupport::Required),+ // Encrypted Google Pay token is already a Stripe token, it is sent directly+ (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePay(_),+ ),+ _,+ ) => Some(api::SingleUseTokenSupport::NotSupported),+ _ => None,+ }+ }++ fn get_single_use_token_support_for_setup_mandate(+ &self,+ payment_method_data: &PaymentMethodData,+ payment_method_token: Option<&hyperswitch_domain_models::router_data::PaymentMethodToken>,+ ) -> Option<api::SingleUseTokenSupport> {+ match (payment_method_data, payment_method_token) {+ // Pre-decrypted token can be sent either via a single-use token or directly as a network token+ (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePay(_),+ ),+ Some(hyperswitch_domain_models::router_data::PaymentMethodToken::ApplePayDecrypt(+ _,+ )),+ )+ | (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePay(_),+ ),+ Some(hyperswitch_domain_models::router_data::PaymentMethodToken::GooglePayDecrypt(+ _,+ )),+ ) => Some(api::SingleUseTokenSupport::Supported),+ // Encrypted Apple Pay token has to be exchanged for a single-use token+ (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePay(_),+ ),+ _,+ ) => Some(api::SingleUseTokenSupport::Required),+ // Encrypted Google Pay token is already a Stripe token, it is sent directly+ (+ PaymentMethodData::Wallet(+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePay(_),+ ),+ _,+ ) => Some(api::SingleUseTokenSupport::NotSupported),+ _ => None,+ }+ }}diff --git a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rsindex 283df6cf4d..f513db4917 100644--- a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs@@ -75,6 +75,11 @@ pub mod auth_headers {pub const STRIPE_VERSION: &str = "2022-11-15";}+/// Tokenization method sent to Stripe for decrypted wallet tokens+const APPLE_PAY_TOKENIZATION_METHOD: &str = "apple_pay";+const GOOGLE_PAY_TOKENIZATION_METHOD: &str = "android_pay";+const GOOGLE_PAY_DPAN_TOKENIZATION_METHOD: &str = "google_pay_dpan";+trait GetRequestIncrementalAuthorization {fn get_request_incremental_authorization(&self) -> Option<bool>;}@@ -775,6 +780,7 @@ pub enum StripeWallet {RevolutPay(RevolutpayPayment),ApplePayPredecryptToken(Box<StripeApplePayPredecrypt>),GooglePayPredecryptToken(Box<StripeGooglePayPredecrypt>),+ WalletNetworkTokenPayment(Box<StripeWalletNetworkTokenPayment>),}#[derive(Debug, Eq, PartialEq, Serialize)]@@ -804,11 +810,117 @@ pub struct StripeGooglePayPredecrypt {#[serde(rename = "card[cryptogram]")]cryptogram: Secret<String>,#[serde(rename = "card[eci]")]- eci: String,+ eci: Option<String>,#[serde(rename = "card[tokenization_method]")]tokenization_method: String,}+/// Pre-decrypted wallet (Apple Pay / Google Pay) token sent as a network token directly in the+/// payment intent, used when the payment is not made via a single-use token+#[derive(Debug, Eq, PartialEq, Serialize)]+pub struct StripeWalletNetworkTokenPayment {+ #[serde(rename = "payment_method_data[type]")]+ payment_method_data_type: StripePaymentMethodType,+ #[serde(rename = "payment_method_data[card][exp_month]")]+ exp_month: Secret<String>,+ #[serde(rename = "payment_method_data[card][exp_year]")]+ exp_year: Secret<String>,+ #[serde(rename = "payment_method_data[card][last4]")]+ last4: String,+ #[serde(rename = "payment_method_data[card][network_token][number]")]+ network_token_number: cards::CardNumber,+ #[serde(rename = "payment_method_data[card][network_token][exp_month]")]+ network_token_exp_month: Secret<String>,+ #[serde(rename = "payment_method_data[card][network_token][exp_year]")]+ network_token_exp_year: Secret<String>,+ #[serde(rename = "payment_method_data[card][network_token][tokenization_method]")]+ tokenization_method: String,+ #[serde(rename = "payment_method_options[card][network_token][cryptogram]")]+ cryptogram: Secret<String>,+ #[serde(rename = "payment_method_options[card][network_token][electronic_commerce_indicator]")]+ eci: Option<String>,+}++impl From<&common_types::payments::ApplePayPredecryptData> for StripeWalletNetworkTokenPayment {+ fn from(decrypt_data: &common_types::payments::ApplePayPredecryptData) -> Self {+ let expiry_year_4_digit = decrypt_data.get_four_digit_expiry_year();+ Self {+ payment_method_data_type: StripePaymentMethodType::Card,+ exp_month: decrypt_data.application_expiration_month.clone(),+ exp_year: expiry_year_4_digit.clone(),+ last4: decrypt_data.application_primary_account_number.get_last4(),+ network_token_number: decrypt_data.application_primary_account_number.clone(),+ network_token_exp_month: decrypt_data.application_expiration_month.clone(),+ network_token_exp_year: expiry_year_4_digit,+ tokenization_method: APPLE_PAY_TOKENIZATION_METHOD.to_string(),+ cryptogram: decrypt_data.payment_data.online_payment_cryptogram.clone(),+ eci: decrypt_data.payment_data.eci_indicator.clone(),+ }+ }+}++impl StripeWalletNetworkTokenPayment {+ /// Returns `None` when the decrypted Google Pay token has no cryptogram (PAN_ONLY), such+ /// tokens are sent as a regular card+ fn try_from_google_pay_predecrypt_data(+ decrypt_data: &common_types::payments::GPayPredecryptData,+ ) -> Result<Option<Self>, error_stack::Report<ConnectorError>> {+ decrypt_data+ .cryptogram+ .clone()+ .map(|cryptogram| {+ decrypt_data+ .get_four_digit_expiry_year()+ .change_context(ConnectorError::InvalidDataFormat {+ field_name: "expiry_year_4_digit".into(),+ })+ .attach_printable(+ "Failed to get four digit expiry year from decrypted Google Pay token",+ )+ .map(|expiry_year_4_digit| Self {+ payment_method_data_type: StripePaymentMethodType::Card,+ exp_month: decrypt_data.card_exp_month.clone(),+ exp_year: expiry_year_4_digit.clone(),+ last4: decrypt_data.application_primary_account_number.get_last4(),+ network_token_number: decrypt_data+ .application_primary_account_number+ .clone(),+ network_token_exp_month: decrypt_data.card_exp_month.clone(),+ network_token_exp_year: expiry_year_4_digit,+ tokenization_method: GOOGLE_PAY_DPAN_TOKENIZATION_METHOD.to_string(),+ cryptogram,+ eci: decrypt_data.eci_indicator.clone(),+ })+ })+ .transpose()+ }+}++/// Returns the pre-decrypted wallet (Apple Pay / Google Pay) token as a network token payment method data, used when+/// the payment is not made via a single-use token. Returns `None` if the payment method token is not a pre-decrypted+/// wallet token, or if it is a Google Pay token without cryptogram (sent as a regular card).+fn get_wallet_network_token_payment_data(+ payment_method_data: &PaymentMethodData,+ payment_method_token: Option<&PaymentMethodToken>,+) -> Result<Option<StripePaymentMethodData>, error_stack::Report<ConnectorError>> {+ let network_token_payment = match (payment_method_data, payment_method_token) {+ (+ PaymentMethodData::Wallet(WalletData::ApplePay(_)),+ Some(PaymentMethodToken::ApplePayDecrypt(decrypt_data)),+ ) => Some(StripeWalletNetworkTokenPayment::from(decrypt_data.as_ref())),+ (+ PaymentMethodData::Wallet(WalletData::GooglePay(_)),+ Some(PaymentMethodToken::GooglePayDecrypt(decrypt_data)),+ ) => StripeWalletNetworkTokenPayment::try_from_google_pay_predecrypt_data(decrypt_data)?,+ _ => None,+ };+ Ok(network_token_payment.map(|network_token_payment| {+ StripePaymentMethodData::Wallet(StripeWallet::WalletNetworkTokenPayment(Box::new(+ network_token_payment,+ )))+ }))+}+#[derive(Debug, Eq, PartialEq, Serialize)]pub struct StripeApplePay {pub pk_token: Secret<String>,@@ -1832,7 +1944,7 @@ implexp_month: decrypt_data.application_expiration_month,eci: decrypt_data.payment_data.eci_indicator,cryptogram: decrypt_data.payment_data.online_payment_cryptogram,- tokenization_method: "apple_pay".to_string(),+ tokenization_method: APPLE_PAY_TOKENIZATION_METHOD.to_string(),}),)))} else if let Some(PaymentMethodToken::Token(applepay_token)) =@@ -2040,25 +2152,19 @@ implfield_name: "expiry_year_4_digit".into(),})?;- match (- predecrypted_data.cryptogram.clone(),- predecrypted_data.eci_indicator.clone(),- ) {- (Some(cryptogram), Some(eci)) => {- Ok(Self::Wallet(StripeWallet::GooglePayPredecryptToken(- Box::new(StripeGooglePayPredecrypt {- number: predecrypted_data- .application_primary_account_number- .clone(),- exp_year: expiry_year_4_digit,- exp_month: predecrypted_data.card_exp_month.clone(),- cryptogram,- eci,- tokenization_method: "android_pay".to_string(),- }),- )))- }- _ => Ok(Self::Card(StripeCardData {+ // ECI is optional for the predecrypted token, only the cryptogram is required+ match predecrypted_data.cryptogram.clone() {+ Some(cryptogram) => Ok(Self::Wallet(StripeWallet::GooglePayPredecryptToken(+ Box::new(StripeGooglePayPredecrypt {+ number: predecrypted_data.application_primary_account_number.clone(),+ exp_year: expiry_year_4_digit,+ exp_month: predecrypted_data.card_exp_month.clone(),+ cryptogram,+ eci: predecrypted_data.eci_indicator.clone(),+ tokenization_method: GOOGLE_PAY_TOKENIZATION_METHOD.to_string(),+ }),+ ))),+ None => Ok(Self::Card(StripeCardData {payment_method_data_type: StripePaymentMethodType::Card,payment_method_data_card_number: predecrypted_data.application_primary_account_number@@ -2494,12 +2600,22 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequestwallet_name: "Apple Pay".to_string(),})?;- let payment_method_token = match payment_method_token {- PaymentMethodToken::Token(payment_method_token) => payment_method_token,- PaymentMethodToken::ApplePayDecrypt(_) => {- Err(ConnectorError::InvalidWalletToken {- wallet_name: "Apple Pay".to_string(),- })?+ match payment_method_token {+ PaymentMethodToken::Token(payment_method_token) => {+ Some(StripePaymentMethodData::Wallet(+ StripeWallet::ApplepayPayment(ApplepayPayment {+ token: payment_method_token,+ payment_method_types: StripePaymentMethodType::Card,+ }),+ ))+ }+ // Payment is not made via a single-use token, send the decrypted token directly+ PaymentMethodToken::ApplePayDecrypt(decrypt_data) => {+ Some(StripePaymentMethodData::Wallet(+ StripeWallet::WalletNetworkTokenPayment(Box::new(+ StripeWalletNetworkTokenPayment::from(decrypt_data.as_ref()),+ )),+ ))}PaymentMethodToken::PazeDecrypt(_) => {Err(crate::unimplemented_payment_method!("Paze", "Stripe"))?@@ -2507,13 +2623,15 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequestPaymentMethodToken::GooglePayDecrypt(_) => {Err(crate::unimplemented_payment_method!("Google Pay", "Stripe"))?}- };- Some(StripePaymentMethodData::Wallet(- StripeWallet::ApplepayPayment(ApplepayPayment {- token: payment_method_token,- payment_method_types: StripePaymentMethodType::Card,- }),- ))+ }+ }+ // Payment is not made via a single-use token, send the decrypted token directly+ PaymentMethodData::Wallet(WalletData::GooglePay(_)) => {+ get_wallet_network_token_payment_data(+ &item.request.payment_method_data,+ item.payment_method_token.as_ref(),+ )?+ .or(payment_data)}_ => payment_data,}@@ -2792,7 +2910,14 @@ impl TryFrom<&SetupMandateRouterData> for SetupIntentRequest {fn try_from(item: &SetupMandateRouterData) -> Result<Self, Self::Error> {//Only cards supported for mandateslet pm_type = StripePaymentMethodType::Card;- let payment_data = StripePaymentMethodData::try_from((item, item.auth_type, pm_type))?;+ // Setup mandate is not made via a single-use token, send the decrypted wallet token directly+ let payment_data = match get_wallet_network_token_payment_data(+ &item.request.payment_method_data,+ item.payment_method_token.as_ref(),+ )? {+ Some(network_token_payment_data) => network_token_payment_data,+ None => StripePaymentMethodData::try_from((item, item.auth_type, pm_type))?,+ };let meta_data = Some(get_transaction_metadata(item.request.metadata.clone(),diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.tomlindex e262ba917c..506f641c26 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.2", package = "rust-grpc-client" }+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", tag = "2026.11.02.3", package = "rust-grpc-client" }tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }# First party cratesdiff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rsindex 79b49d8c8b..efb0a23f82 100644--- a/crates/hyperswitch_interfaces/src/api.rs+++ b/crates/hyperswitch_interfaces/src/api.rs@@ -49,9 +49,10 @@ pub use hyperswitch_domain_models::router_request_types::CurrentFlowInfo;use hyperswitch_domain_models::{connector_endpoints::Connectors,errors::api_error_response::ApiErrorResponse,+ payment_method_data::PaymentMethodData,router_data::{AccessToken, AccessTokenAuthenticationResponse, ConnectorAuthType, ErrorResponse,- RouterData,+ PaymentMethodToken, RouterData,},router_data_v2::{flow_common_types::{@@ -416,6 +417,17 @@ pub enum AlternateFlow {PreAuthenticate,}+/// Single-use token support of the connector for a payment+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum SingleUseTokenSupport {+ /// The payment can be made only via a single-use token+ Required,+ /// The payment can be made either via a single-use token or directly+ Supported,+ /// The payment can be made only directly, without a single-use token+ NotSupported,+}+/// The Preprocessing flow that must be made before the current flow.////// For example, PreProcessing flow must be made before Authorize flow.@@ -690,6 +702,30 @@ pub trait ConnectorSpecifications {true}+ /// Single-use token support of the connector in the authorize flow for the given payment method data and payment+ /// method token (e.g. pre-decrypted wallet token). The single-use token is created at the connector right before+ /// authorization and is used only for that payment, it is not stored at the connector and is unrelated to mandates.+ /// `None` means it is not implemented for the connector, and the default behaviour is followed.+ fn get_single_use_token_support(+ &self,+ _payment_method_data: &PaymentMethodData,+ _payment_method_token: Option<&PaymentMethodToken>,+ ) -> Option<SingleUseTokenSupport> {+ None+ }++ /// Single-use token support of the connector in the setup mandate flow for the given payment method data and+ /// payment method token (e.g. pre-decrypted wallet token). The single-use token is created at the connector right+ /// before the setup mandate call and is used only for that call.+ /// `None` means it is not implemented for the connector, and the default behaviour is followed.+ fn get_single_use_token_support_for_setup_mandate(+ &self,+ _payment_method_data: &PaymentMethodData,+ _payment_method_token: Option<&PaymentMethodToken>,+ ) -> Option<SingleUseTokenSupport> {+ None+ }+/// Check if connector should trigger handle response without initiating a call to the connectorfn should_trigger_handle_response_without_body(&self) -> bool {falsediff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rsindex 9ddd5f3cd3..f14a19e24c 100644--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs@@ -929,6 +929,38 @@ impl ConnectorSpecifications for ConnectorEnum {}}+ fn get_single_use_token_support(+ &self,+ payment_method_data: &hyperswitch_domain_models::payment_method_data::PaymentMethodData,+ payment_method_token: Option<&hyperswitch_domain_models::router_data::PaymentMethodToken>,+ ) -> Option<api::SingleUseTokenSupport> {+ match self {+ Self::Old(connector) => {+ connector.get_single_use_token_support(payment_method_data, payment_method_token)+ }+ Self::New(connector) => {+ connector.get_single_use_token_support(payment_method_data, payment_method_token)+ }+ }+ }++ fn get_single_use_token_support_for_setup_mandate(+ &self,+ payment_method_data: &hyperswitch_domain_models::payment_method_data::PaymentMethodData,+ payment_method_token: Option<&hyperswitch_domain_models::router_data::PaymentMethodToken>,+ ) -> Option<api::SingleUseTokenSupport> {+ match self {+ Self::Old(connector) => connector.get_single_use_token_support_for_setup_mandate(+ payment_method_data,+ payment_method_token,+ ),+ Self::New(connector) => connector.get_single_use_token_support_for_setup_mandate(+ payment_method_data,+ payment_method_token,+ ),+ }+ }+fn should_trigger_handle_response_without_body(&self) -> bool {match self {Self::Old(connector) => connector.should_trigger_handle_response_without_body(),diff --git a/crates/kgraph_utils/benches/evaluation.rs b/crates/kgraph_utils/benches/evaluation.rsindex 40d0885dad..762ad7b9a3 100644--- a/crates/kgraph_utils/benches/evaluation.rs+++ b/crates/kgraph_utils/benches/evaluation.rs@@ -44,6 +44,7 @@ fn build_test_data(maximum_amount: Some(MinorUnit::new(1000)),recurring_enabled: Some(true),installment_payment_enabled: Some(true),+ pay_via_single_use_token: None,});}diff --git a/crates/kgraph_utils/src/mca.rs b/crates/kgraph_utils/src/mca.rsindex 3bab24f8b5..8cde784bf9 100644--- a/crates/kgraph_utils/src/mca.rs+++ b/crates/kgraph_utils/src/mca.rs@@ -1172,6 +1172,7 @@ mod tests {maximum_amount: Some(MinorUnit::new(1000)),recurring_enabled: Some(true),installment_payment_enabled: Some(true),+ pay_via_single_use_token: None,},RequestPaymentMethodTypes {payment_method_type: api_enums::PaymentMethodType::Debit,@@ -1188,6 +1189,7 @@ mod tests {maximum_amount: Some(MinorUnit::new(1000)),recurring_enabled: Some(true),installment_payment_enabled: Some(true),+ pay_via_single_use_token: None,},]),}]),diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 9894a20c30..f364d66a2a 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -469,6 +469,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::customers::CustomerResponse,api_models::admin::AcceptedCountries,api_models::admin::AcceptedCurrencies,+ common_types::payment_methods::PayViaSingleUseToken,api_models::enums::AdyenSplitType,api_models::enums::PixKey,api_models::enums::PaymentType,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex e73c191af6..0e87ebfd7d 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -366,6 +366,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::customers::CustomerResponse,api_models::admin::AcceptedCountries,api_models::admin::AcceptedCurrencies,+ common_types::payment_methods::PayViaSingleUseToken,api_models::enums::AdyenSplitType,api_models::enums::ProductType,api_models::enums::PaymentType,diff --git a/crates/payment_methods/src/lib.rs b/crates/payment_methods/src/lib.rsindex 30381201ac..a52382649d 100644--- a/crates/payment_methods/src/lib.rs+++ b/crates/payment_methods/src/lib.rs@@ -3,6 +3,7 @@ pub mod configs;pub mod controller;pub mod core;pub mod helpers;+pub mod single_use_token;pub mod state;#[cfg(feature = "v1")]pub mod types;diff --git a/crates/payment_methods/src/single_use_token.rs b/crates/payment_methods/src/single_use_token.rsnew file mode 100644index 0000000000..9b838a415a--- /dev/null+++ b/crates/payment_methods/src/single_use_token.rs@@ -0,0 +1,99 @@+use common_types::payment_methods::PayViaSingleUseToken;+use error_stack::report;+use hyperswitch_domain_models::{+ payment_method_data::PaymentMethodData, router_data::PaymentMethodToken,+};+use hyperswitch_interfaces::{+ api::{ConnectorSpecifications, SingleUseTokenSupport},+ connector_integration_interface::ConnectorEnum,+};++use crate::core::errors::{ApiErrorResponse, PmResult};++/// Flows in which the payment can be made via a single-use token+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum SingleUseTokenFlow {+ Authorize,+ SetupMandate,+}++/// Decision on whether the payment should be made via a single-use token created at the connector before authorization+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum SingleUseTokenDecision {+ Default,+ PayViaSingleUseToken,+ PayDirectly,+}++impl SingleUseTokenDecision {+ pub fn is_connector_tokenization_enabled(+ self,+ is_connector_tokenization_enabled_by_default: bool,+ ) -> bool {+ match self {+ Self::Default => is_connector_tokenization_enabled_by_default,+ Self::PayViaSingleUseToken => true,+ Self::PayDirectly => false,+ }+ }+}++/// Decides whether the payment should be made via a single-use token from the `pay_via_single_use_token` config,+/// erroring if the connector support conflicts with the config+pub fn decide_single_use_token(+ connector: &ConnectorEnum,+ connector_name: &str,+ single_use_token_flow: Option<SingleUseTokenFlow>,+ pay_via_single_use_token: Option<PayViaSingleUseToken>,+ payment_method_data: Option<&PaymentMethodData>,+ payment_method_token: Option<&PaymentMethodToken>,+) -> PmResult<SingleUseTokenDecision> {+ let pay_via_single_use_token = pay_via_single_use_token.unwrap_or_default();++ // The connector single-use token support is checked only when `Enabled` / `Disabled` is configured, for the+ // flows that can be made via a single-use token, and when the payment method data is available (not for+ // saved payment methods)+ let single_use_token_support = match pay_via_single_use_token {+ PayViaSingleUseToken::Default => None,+ PayViaSingleUseToken::Enabled | PayViaSingleUseToken::Disabled => {+ single_use_token_flow.zip(payment_method_data).and_then(+ |(single_use_token_flow, payment_method_data)| match single_use_token_flow {+ SingleUseTokenFlow::Authorize => connector+ .get_single_use_token_support(payment_method_data, payment_method_token),+ SingleUseTokenFlow::SetupMandate => connector+ .get_single_use_token_support_for_setup_mandate(+ payment_method_data,+ payment_method_token,+ ),+ },+ )+ }+ };++ match (pay_via_single_use_token, single_use_token_support) {+ // Not configured, or not implemented for the connector, follow the default behaviour+ (PayViaSingleUseToken::Default, _) | (_, None) => Ok(SingleUseTokenDecision::Default),+ (PayViaSingleUseToken::Enabled, Some(single_use_token_support)) => {+ if single_use_token_support == SingleUseTokenSupport::NotSupported {+ Err(report!(ApiErrorResponse::InvalidConnectorConfiguration {+ config: format!(+ "pay_via_single_use_token: tokenization is not supported for the payment method type with connector {connector_name}"+ ),+ }))+ } else {+ Ok(SingleUseTokenDecision::PayViaSingleUseToken)+ }+ }+ (PayViaSingleUseToken::Disabled, Some(single_use_token_support)) => {+ if single_use_token_support == SingleUseTokenSupport::Required {+ Err(report!(ApiErrorResponse::InvalidConnectorConfiguration {+ config: format!(+ "pay_via_single_use_token: payment without tokenization is not supported for the payment method type with connector {connector_name}"+ ),+ }))+ } else {+ Ok(SingleUseTokenDecision::PayDirectly)+ }+ }+ }+}diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex a23744c3da..0ebbad6e8c 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.2", package = "rust-grpc-client" }-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", tag = "2026.11.02.2", package = "ucs_cards" }+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" }rustc-hash = "1.1.0"rustls = { version = "0.23", default-features = false, features = ["aws-lc-rs",diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex eb2899b109..e268ffc3b8 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -81,6 +81,8 @@ use hyperswitch_interfaces::api::ConnectorSpecifications;use hyperswitch_masking::{ExposeInterface, PeekInterface, Secret};#[cfg(feature = "v2")]use operations::ValidateStatusForOperation;+#[cfg(feature = "v1")]+use payment_methods::single_use_token;use redis_interface::errors::RedisError;use router_env::{instrument, tracing};#[cfg(feature = "olap")]@@ -6939,17 +6941,24 @@ where// Internal surcharge only; external surcharge is prepared before connector selection.populate_surcharge_details(state, business_profile, payment_data).await?;- let (pd, tokenization_action) = Box::pin(get_connector_tokenization_action_when_confirm_true(- state,- operation,- payment_data,- validate_result,- platform,- business_profile,- should_retry_with_pan,- feature_config,- ))- .await?;+ let (pd, tokenization_action) =+ Box::pin(get_connector_tokenization_action_when_confirm_true(+ state,+ operation,+ payment_data,+ validate_result,+ platform,+ business_profile,+ should_retry_with_pan,+ feature_config,+ &connector,+ &merchant_connector_account,+ <RouterData<F, RouterDReq, router_types::PaymentsResponseData> as Feature<+ F,+ RouterDReq,+ >>::single_use_token_flow(),+ ))+ .await?;*payment_data = pd;// This is used to apply any kind of routing decision to the required data,@@ -10280,6 +10289,56 @@ fn is_payment_method_type_allowed_for_connector(}}+/// Fetches the `pay_via_single_use_token` config of the payment method type from the merchant connector account+#[cfg(feature = "v1")]+fn get_pay_via_single_use_token_from_mca(+ merchant_connector_account: &helpers::MerchantConnectorAccountType,+ payment_method: storage::enums::PaymentMethod,+ payment_method_type: Option<storage::enums::PaymentMethodType>,+) -> Option<common_types::payment_methods::PayViaSingleUseToken> {+ let payment_methods_enabled = match merchant_connector_account {+ helpers::MerchantConnectorAccountType::DbVal(merchant_connector_account) => {+ merchant_connector_account.payment_methods_enabled.as_ref()+ }+ helpers::MerchantConnectorAccountType::CacheVal(_) => None,+ };++ payment_methods_enabled.zip(payment_method_type).and_then(+ |(payment_methods_enabled, payment_method_type)| {+ payment_methods_enabled+ .iter()+ .filter_map(|payment_methods_enabled| {+ payment_methods_enabled+ .clone()+ .parse_value::<api_models::admin::PaymentMethodsEnabled>(+ "PaymentMethodsEnabled",+ )+ .inspect_err(|err| {+ logger::error!(+ "Unable to deserialize payment methods enabled: {:?}",+ err+ )+ })+ .ok()+ })+ .filter(|payment_methods_enabled| {+ payment_methods_enabled.payment_method == payment_method+ })+ .flat_map(|payment_methods_enabled| {+ payment_methods_enabled+ .payment_method_types+ .unwrap_or_default()+ })+ .find(|request_payment_method_type| {+ request_payment_method_type.payment_method_type == payment_method_type+ })+ .and_then(|request_payment_method_type| {+ request_payment_method_type.pay_via_single_use_token+ })+ },+ )+}+#[cfg(feature = "v1")]#[allow(clippy::too_many_arguments)]async fn decide_payment_method_tokenize_action(@@ -10393,6 +10452,9 @@ pub async fn get_connector_tokenization_action_when_confirm_true<F, Req, D>(business_profile: &domain::Profile,should_retry_with_pan: bool,feature_config: &core_utils::FeatureConfig,+ connector_data: &api::ConnectorData,+ merchant_connector_account: &helpers::MerchantConnectorAccountType,+ single_use_token_flow: Option<single_use_token::SingleUseTokenFlow>,) -> RouterResult<(D, TokenizationAction)>whereF: Send + Clone,@@ -10451,6 +10513,19 @@ wherepayment_data.get_payment_attempt().authentication_type,)?;+ let single_use_token_decision = single_use_token::decide_single_use_token(+ &connector_data.connector,+ &connector_data.connector_name.to_string(),+ single_use_token_flow,+ get_pay_via_single_use_token_from_mca(+ merchant_connector_account,+ payment_method,+ payment_method_type,+ ),+ payment_data.get_payment_method_data(),+ payment_data.get_payment_method_token(),+ )?;+let is_network_transaction_id_flow = payment_data.get_mandate_id().as_ref()@@ -10458,15 +10533,16 @@ where.map(|mandate_reference| mandate_reference.is_network_mandate_id()).unwrap_or(false);- let payment_method_action = decide_payment_method_tokenize_action(+ let payment_method_action = Box::pin(decide_payment_method_tokenize_action(state,&connector,payment_method,payment_data.get_payment_intent().clone(),payment_data.get_token(),- is_connector_tokenization_enabled,+ single_use_token_decision+ .is_connector_tokenization_enabled(is_connector_tokenization_enabled),is_network_transaction_id_flow,- )+ )).await?;let connector_tokenization_action = match payment_method_action {diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rsindex 0a9c77ae27..1ce2ea684b 100644--- a/crates/router/src/core/payments/flows.rs+++ b/crates/router/src/core/payments/flows.rs@@ -30,6 +30,7 @@ use hyperswitch_domain_models::{payments as domain_payments,router_request_types::{CurrentFlowInfo, PaymentsCaptureData},};+use payment_methods::single_use_token;use crate::{core::{@@ -98,6 +99,14 @@ pub trait Feature<F, T> {None}+ /// Flow used to decide whether the payment should be made via a single-use token, `None` if not applicable+ fn single_use_token_flow() -> Option<single_use_token::SingleUseTokenFlow>+ where+ Self: Sized,+ {+ None+ }+async fn decide_flows<'a>(self,state: &SessionState,diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rsindex 00b5b39ab4..d4279d9c63 100644--- a/crates/router/src/core/payments/flows/authorize_flow.rs+++ b/crates/router/src/core/payments/flows/authorize_flow.rs@@ -23,6 +23,7 @@ use hyperswitch_interfaces::{unified_connector_service::transformers as ucs_transformers,};use hyperswitch_masking::ExposeInterface;+use payment_methods::single_use_token;use unified_connector_service_client::payments as payments_grpc;// use router_env::tracing::Instrument;@@ -215,6 +216,10 @@ impl#[async_trait]impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAuthorizeRouterData {+ fn single_use_token_flow() -> Option<single_use_token::SingleUseTokenFlow> {+ Some(single_use_token::SingleUseTokenFlow::Authorize)+ }+fn current_flow_info(&self) -> Option<api_interface::CurrentFlowInfo> {Some(api_interface::CurrentFlowInfo::Authorize {auth_type: self.auth_type,diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rsindex b5c3dedbfa..5aff546473 100644--- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs+++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs@@ -12,6 +12,7 @@ use hyperswitch_interfaces::{api::{self as api_interface, ConnectorSpecifications},consts as interface_consts,};+use payment_methods::single_use_token;use router_env::logger;use super::{ConstructFlowSpecificData, Feature};@@ -111,6 +112,10 @@ impl#[async_trait]impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::SetupMandateRouterData {+ fn single_use_token_flow() -> Option<single_use_token::SingleUseTokenFlow> {+ Some(single_use_token::SingleUseTokenFlow::SetupMandate)+ }+fn current_flow_info(&self) -> Option<api_interface::CurrentFlowInfo> {Some(api_interface::CurrentFlowInfo::SetupMandate {auth_type: self.auth_type,