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(payment-methods): generate fingerprint_id scoped at merchant level (#14392)
Kashif40033ebc5c5d
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 1c5f3e0772..e4a24f6a5a 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -24872,6 +24872,12 @@}],"nullable": true+ },+ "fingerprint_id": {+ "type": "string",+ "description": "A merchant-scoped fingerprint of the card, identical for the same card saved against\ndifferent customers of the merchant. Present only when payment method fingerprinting is\nenabled.",+ "example": "wyH7yWdtaRhxDkVE1cvs",+ "nullable": true}}},diff --git a/config/config.example.toml b/config/config.example.tomlindex 8a0f9063ec..5c36b33aab 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -291,6 +291,7 @@ locker_enabled = true # Boolean to enable or disable saving cardsttl_for_storage_in_secs = 220752000 # Time to live for storage entries in lockercreate_entity_on_merchant_create = false # Boolean to call the locker's entity-create API during merchant account creation, aborting creation on locker failureplain_fingerprint_response = true # Ask the vault for plain (unencrypted) fingerprint responses; honoured only if the vault has opted in (v2)+use_batched_fingerprint = false # Derive a vaulting's fingerprints in one call to the vault's batch fingerprint API instead of one call each; the vault must support it (v2)[delayed_session_response]connectors_with_delayed_session_response = "trustpay,payme" # List of connectors which has delayed session responsediff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.tomlindex d2df89822f..5b8175ac8c 100644--- a/config/deployments/env_specific.toml+++ b/config/deployments/env_specific.toml@@ -168,6 +168,7 @@ redis_temp_locker_encryption_key = "redis_temp_locker_encryption_key" # Encryptittl_for_storage_in_secs = 220752000 # Time to live for storage entries in lockercreate_entity_on_merchant_create = false # Boolean to call the locker's entity-create API during merchant account creation, aborting creation on locker failureplain_fingerprint_response = true # Ask the vault for plain (unencrypted) fingerprint responses; honoured only if the vault has opted in (v2)+use_batched_fingerprint = false # Derive a vaulting's fingerprints in one call to the vault's batch fingerprint API instead of one call each; the vault must support it (v2)diff --git a/config/development.toml b/config/development.tomlindex adaf10369c..dfa3f723a8 100644--- a/config/development.toml+++ b/config/development.toml@@ -203,6 +203,7 @@ locker_enabled = truettl_for_storage_in_secs = 220752000create_entity_on_merchant_create = falseplain_fingerprint_response = true+use_batched_fingerprint = false[forex_api]api_key = ""diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex b5a3b51b3f..8d99bb08bc 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -148,6 +148,7 @@ locker_enabled = truettl_for_storage_in_secs = 220752000create_entity_on_merchant_create = falseplain_fingerprint_response = true+use_batched_fingerprint = false[jwekey]vault_encryption_key = ""diff --git a/config/superposition_seed.toml b/config/superposition_seed.tomlindex 894e6b7e2e..8ae7b92fb9 100644--- a/config/superposition_seed.toml+++ b/config/superposition_seed.toml@@ -2701,11 +2701,12 @@ pt_mapping_outgoing_connector_webhooks = { value = { default_mapping = { frequen"payments.should_return_raw_payment_method_details" = { value = false, schema = { type = "boolean" }, description = "Whether to return raw payment method details (v2 only)", change_reason = "Initial setup" }"card_issuer.list_max_limit" = { value = 18000, schema = { maximum = 4294967295, minimum = 0, type = "integer" }, description = "Maximum number of card issuers the card issuer list endpoint reads", change_reason = "Initial setup" }"payments.network_token_fetch_timeout_in_secs" = { value = 4, schema = { maximum = 4294967295, minimum = 0, type = "integer" }, description = "Timeout in seconds for network token fetch", change_reason = "Initial setup" }-should_schedule_modular_backward_compat = { value = false, schema = { type = "boolean" }, description = "Whether to schedule PM modular backward compatibility PT for a provider merchant, with organization fallback", change_reason = "Initial setup" }+"system.should_schedule_modular_backward_compat" = { value = false, schema = { type = "boolean" }, description = "Whether to schedule PM modular backward compatibility PT for a provider merchant, with organization fallback", change_reason = "Initial setup" }"system.should_schedule_modular_forward_compat" = { value = false, schema = { type = "boolean" }, description = "Whether to schedule PM modular forward compatibility PT for a provider merchant, with organization fallback", change_reason = "Initial setup" }"payments.should_store_eligibility_check_data_for_authentication" = { value = false, schema = { type = "boolean" }, description = "Whether to store eligibility check data during authentication", change_reason = "Initial setup" }"system.should_trigger_backwards_compatibility_inline" = { value = false, schema = { type = "boolean" }, description = "Whether to trigger PM modular backward compatibility inline for a provider merchant, with organization fallback", change_reason = "Initial setup" }"vaulting.should_trigger_fingerprint_migration" = { value = false, schema = { type = "boolean" }, description = "Whether to trigger fingerprint and entity_id migration for a merchant", change_reason = "Initial setup" }+"vaulting.should_generate_merchant_scoped_payment_method_fingerprint" = { value = false, schema = { type = "boolean" }, description = "Whether vaulting a card also derives a merchant-scoped fingerprint for it", change_reason = "Initial setup" }"routing.threeds_routing_region_uas" = { value = "region1", schema = { enum = ["region1","region2",diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 01950b6510..df1de0aaff 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -1556,6 +1556,12 @@ pub struct PaymentMethodResponse {/// The acknowledgement status of the payment method update#[schema(value_type = Option<AcknowledgementStatus>)]pub acknowledgement_status: Option<common_enums::AcknowledgementStatus>,++ /// A merchant-scoped fingerprint of the card, identical for the same card saved against+ /// different customers of the merchant. Present only when payment method fingerprinting is+ /// enabled.+ #[schema(example = "wyH7yWdtaRhxDkVE1cvs")]+ pub fingerprint_id: Option<String>,}#[cfg(feature = "v2")]diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rsindex 82d38f2089..61f9ac7569 100644--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs@@ -4533,7 +4533,7 @@ impl From<payment_methods::CardDetail> for CardDetailsPaymentMethod {expiry_year: Some(item.card_exp_year),card_holder_name: item.card_holder_name,nick_name: item.nick_name,- card_isin: None,+ card_isin: Some(item.card_number.get_card_isin()),card_issuer: item.card_issuer,card_network: item.card_network,card_type: item.card_type.map(|card| card.to_string()),diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rsindex 2089c7e593..dee462b00a 100644--- a/crates/router/src/configs/defaults.rs+++ b/crates/router/src/configs/defaults.rs@@ -69,6 +69,8 @@ impl Default for super::settings::Locker {create_entity_on_merchant_create: false,#[cfg(feature = "v2")]plain_fingerprint_response: true,+ #[cfg(feature = "v2")]+ use_batched_fingerprint: false,}}}diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex 26263a2856..01de3aab16 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -1133,6 +1133,8 @@ pub struct Locker {pub create_entity_on_merchant_create: bool,#[cfg(feature = "v2")]pub plain_fingerprint_response: bool,+ #[cfg(feature = "v2")]+ pub use_batched_fingerprint: bool,}impl Locker {diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex 52bae25a76..f26343ad96 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -192,6 +192,15 @@ pub const V2_ADD_VAULT_REQUEST_URL: &str = "/api/v2/vault/add";/// Vault Get Fingerprint request urlpub const V2_VAULT_FINGERPRINT_REQUEST_URL: &str = "/api/v2/vault/fingerprint";+/// Label for the vault fingerprint in a batched vault fingerprint request+pub const VAULT_FINGERPRINT_LABEL: &str = "vault";++/// Label for the auxiliary fingerprint in a batched vault fingerprint request+pub const AUXILIARY_FINGERPRINT_LABEL: &str = "auxiliary";++/// Label for the merchant fingerprint in a batched vault fingerprint request+pub const MERCHANT_FINGERPRINT_LABEL: &str = "merchant";+/// Vault Retrieve request urlpub const V2_VAULT_RETRIEVE_REQUEST_URL: &str = "/api/v2/vault/retrieve";@@ -320,6 +329,12 @@ pub const IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID: &str =// Default payment method storing TTL in redis in secondspub const DEFAULT_PAYMENT_METHOD_STORE_TTL: i64 = 86400; // 1 day+/// Redis key prefix for the merchant-scoped card fingerprint, which is never persisted+pub const MERCHANT_FINGERPRINT_REDIS_PREFIX: &str = "merchant_fingerprint";++/// How long a merchant-scoped card fingerprint stays retrievable after the card was last vaulted+pub const MERCHANT_FINGERPRINT_TTL: i64 = 86400; // 1 day+// Countries and separately encoded territories where PSD2 or the equivalent UK// strong customer authentication rules apply.pub const SCA_MANDATED_COUNTRIES: [Country; 39] = [@@ -509,6 +524,10 @@ pub mod superposition {/// Trigger fingerprint migration configuration keypub const SHOULD_TRIGGER_FINGERPRINT_MIGRATION: &str ="vaulting.should_trigger_fingerprint_migration";+ /// Merchant-scoped payment method fingerprint configuration key (org and merchant scoped).+ /// When enabled, vaulting a card also derives a merchant-keyed fingerprint for it.+ pub const SHOULD_GENERATE_MERCHANT_SCOPED_PAYMENT_METHOD_FINGERPRINT: &str =+ "vaulting.should_generate_merchant_scoped_payment_method_fingerprint";/// Timeout (in seconds) for fetching a network token from the tokenization service during a/// payment configuration keypub const NETWORK_TOKEN_FETCH_TIMEOUT_IN_SECS: &str =diff --git a/crates/router/src/core/account_updater/store.rs b/crates/router/src/core/account_updater/store.rsindex 0e3c8d0c86..048228aa4c 100644--- a/crates/router/src/core/account_updater/store.rs+++ b/crates/router/src/core/account_updater/store.rs@@ -84,24 +84,25 @@ async fn write_refreshed_card(let vaulting_data = domain::PaymentMethodVaultingData::Card(new_card);- let (fingerprint_id_result, auxiliary_fingerprint_id_result) = tokio::join!(- vault::get_fingerprint_id_for_payment_method(- state,- &vaulting_data,- customer_id.get_string_repr().to_owned(),- ),- vault::get_auxiliary_fingerprint_id_for_payment_method(- state,- &vaulting_data,- customer_id.get_string_repr().to_owned(),- ),- );+ let merchant_fingerprint_secret =+ pm_core::resolve_merchant_fingerprint_secret(state, platform, &vaulting_data).await;- let locker_fingerprint_id = fingerprint_id_result- .change_context(AccountUpdaterError::StoreFailed)- .attach_printable("Failed to fingerprint the refreshed card")?;+ let vault::PaymentMethodFingerprints {+ vault_fingerprint_id: locker_fingerprint_id,+ auxiliary_fingerprint_id,+ merchant_fingerprint_id,+ } = vault::get_fingerprints_for_payment_method(+ state,+ &vaulting_data,+ customer_id.get_string_repr().to_owned(),+ merchant_fingerprint_secret,+ )+ .await+ .change_context(AccountUpdaterError::StoreFailed)+ .attach_printable("Failed to fingerprint the refreshed card")?;- let auxiliary_fingerprint_id = auxiliary_fingerprint_id_result+ let auxiliary_fingerprint_id = auxiliary_fingerprint_id+ .get_required_value("auxiliary_fingerprint_id").change_context(AccountUpdaterError::StoreFailed).attach_printable("Failed to compute the auxiliary fingerprint for the refreshed card")?;@@ -111,7 +112,7 @@ async fn write_refreshed_card();Ok(None)} else {- Box::pin(store_refreshed_card(+ let refreshed_payment_method = Box::pin(store_refreshed_card(state,platform,profile,@@ -122,8 +123,16 @@ async fn write_refreshed_card(locker_fingerprint_id,auxiliary_fingerprint_id,))- .await- .map(Some)+ .await?;++ pm_core::cache_merchant_fingerprint_id(+ state,+ &refreshed_payment_method.id,+ merchant_fingerprint_id.as_deref(),+ )+ .await;++ Ok(Some(refreshed_payment_method))}}diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rsindex 661adba578..1caa4c303b 100644--- a/crates/router/src/core/blocklist/utils.rs+++ b/crates/router/src/core/blocklist/utils.rs@@ -8,14 +8,13 @@ use diesel_models::{configs,};use error_stack::ResultExt;-use hyperswitch_masking::{PeekInterface, StrongSecret};+use hyperswitch_masking::StrongSecret;use super::{errors, transformers::generate_fingerprint_and_get_id, SessionState};use crate::{core::{configs::dimension_state,errors::{RouterResult, StorageErrorExt},- metrics,payments::PaymentData,utils as core_utils,},@@ -412,34 +411,6 @@ pub async fn insert_entry_into_blocklist(Ok(blocklist_entry.foreign_into())}-pub async fn get_merchant_fingerprint_secret(- state: &SessionState,- merchant_account: &domain::MerchantAccount,-) -> RouterResult<String> {- match merchant_account.fingerprint_secret.as_ref() {- Some(secret) => Ok(secret.peek().clone()),- None => {- logger::warn!(- merchant_id = ?merchant_account.get_id(),- "fingerprint_secret missing from merchant account; falling back to Superposition"- );- metrics::FINGERPRINT_SECRET_SUPERPOSITION_FETCH_COUNT.add(1, &[]);- let dimensions = dimension_state::Dimensions::new()- .with_processor_merchant_id(merchant_account.get_id().clone().into());- let secret = dimensions- .get_fingerprint_secret(&*state.store, state.superposition_service.as_ref(), None)- .await;-- match secret.is_empty() {- false => Ok(secret),- true => Err(errors::ApiErrorResponse::InternalServerError).attach_printable(- "fingerprint_secret not found in merchant account or Superposition",- ),- }- }- }-}-// The duplicate check is not atomic with the insert, so a collision still means "already blocked".fn map_blocklist_insert_error(error: error_stack::Report<errors::StorageError>,@@ -536,7 +507,7 @@ pub async fn check_blocklist(let db = &state.store;let processor_merchant_id = processor.get_account().get_id();let merchant_fingerprint_secret =- get_merchant_fingerprint_secret(state, processor.get_account()).await?;+ core_utils::get_merchant_fingerprint_secret(state, processor.get_account()).await?;// Hashed Fingerprint to check whether or not this payment should be blocked.let card_number_fingerprint =@@ -939,7 +910,7 @@ pub async fn generate_payment_fingerprint(match fingerprint_source {Some((pan, fingerprint_type)) => {let merchant_fingerprint_secret =- get_merchant_fingerprint_secret(state, merchant_account).await?;+ core_utils::get_merchant_fingerprint_secret(state, merchant_account).await?;let fingerprint_id = generate_fingerprint_and_get_id(state,diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rsindex 41365300ca..134eed154e 100644--- a/crates/router/src/core/configs/dimension_config.rs+++ b/crates/router/src/core/configs/dimension_config.rs@@ -536,6 +536,18 @@ impl DatabaseBackedConfig for ShouldTriggerFingerprintMigration {}}+config! {+ superposition_key = SHOULD_GENERATE_MERCHANT_SCOPED_PAYMENT_METHOD_FINGERPRINT,+ output = bool,+ default = false,+ requires = dimension_state::DimensionsWithProviderMerchantIdAndOrgId,+ targeting_key = id_type::CustomerId+}++impl DatabaseBackedConfig for ShouldGenerateMerchantScopedPaymentMethodFingerprint {+ const KEY: &'static str = "should_generate_merchant_scoped_payment_method_fingerprint";+}+config! {superposition_key = NETWORK_TOKEN_FETCH_TIMEOUT_IN_SECS,output = u32,diff --git a/crates/router/src/core/offer_engine/velocity.rs b/crates/router/src/core/offer_engine/velocity.rsindex b7dc8ef053..85862dfc6f 100644--- a/crates/router/src/core/offer_engine/velocity.rs+++ b/crates/router/src/core/offer_engine/velocity.rs@@ -4,10 +4,9 @@ use hyperswitch_masking::StrongSecret;use crate::{core::{- blocklist::{- transformers::generate_fingerprint_and_get_id, utils::get_merchant_fingerprint_secret,- },+ blocklist::transformers::generate_fingerprint_and_get_id,errors::{self, RouterResult},+ utils::get_merchant_fingerprint_secret,},routes::SessionState,types::domain,diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 6f9db970d3..b30936e06b 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -2072,17 +2072,21 @@ fn resolve_based_on_duplication_status(logger::info!("Payment method is duplicated with update-eligible status in legacy locker, updating existing payment method");- Ok(PaymentMethodResolver(PaymentMethodResolution::Update {- fingerprint_id: None,- payment_method_id,- payment_method: Box::new(pm),- source_payment_method_data: payment_method_data.clone(),- }))+ Ok(PaymentMethodResolver {+ resolution: PaymentMethodResolution::Update {+ fingerprint_id: None,+ payment_method_id,+ payment_method: Box::new(pm),+ source_payment_method_data: payment_method_data.clone(),+ },+ merchant_fingerprint_id: None,+ })} else if pm.status == enums::PaymentMethodStatus::Active {logger::info!("Payment method is duplicated, returning existing payment method");- Ok(PaymentMethodResolver(PaymentMethodResolution::Get(- Box::new(pm),- )))+ Ok(PaymentMethodResolver {+ resolution: PaymentMethodResolution::Get(Box::new(pm)),+ merchant_fingerprint_id: None,+ })} else {logger::info!("Payment method is in awaiting data or processing state, no existing payment method entry found with locker id"@@ -2096,9 +2100,10 @@ fn resolve_based_on_duplication_status(}None => {logger::info!("No duplication check data available from legacy locker");- Ok(PaymentMethodResolver(PaymentMethodResolution::Get(- Box::new(pm),- )))+ Ok(PaymentMethodResolver {+ resolution: PaymentMethodResolution::Get(Box::new(pm)),+ merchant_fingerprint_id: None,+ })}}}@@ -2125,6 +2130,94 @@ pub struct FingerprintDetails {pub auxiliary_fingerprint_id: Option<String>,}+#[cfg(feature = "v2")]+async fn is_merchant_fingerprint_enabled(+ state: &SessionState,+ platform: &domain::Platform,+) -> bool {+ let dimensions = dimension_state::Dimensions::new()+ .with_provider_merchant_id(platform.get_provider().get_provider_merchant_id())+ .with_organization_id(+ platform+ .get_provider()+ .get_account()+ .organization_id+ .clone(),+ );++ utils::get_should_generate_merchant_scoped_payment_method_fingerprint(state, &dimensions, None)+ .await+}++/// The merchant's fingerprint secret, when the fingerprint is enabled and the data is a card.+/// `None` means the vault is not asked for a merchant fingerprint at all.+#[cfg(feature = "v2")]+pub(crate) async fn resolve_merchant_fingerprint_secret(+ state: &SessionState,+ platform: &domain::Platform,+ payment_method_data: &domain::PaymentMethodVaultingData,+) -> Option<Secret<String>> {+ let is_card = matches!(+ payment_method_data,+ domain::PaymentMethodVaultingData::Card(_)+ | domain::PaymentMethodVaultingData::CardNumber(_)+ );++ match is_card && is_merchant_fingerprint_enabled(state, platform).await {+ true => core_utils::get_merchant_fingerprint_secret(+ state,+ platform.get_provider().get_account(),+ )+ .await+ .inspect_err(|error| logger::warn!(?error, "No merchant fingerprint secret"))+ .ok()+ .map(Secret::new),+ false => None,+ }+}++#[cfg(feature = "v2")]+fn merchant_fingerprint_redis_key(payment_method_id: &id_type::GlobalPaymentMethodId) -> String {+ format!(+ "{}_{}",+ consts::MERCHANT_FINGERPRINT_REDIS_PREFIX,+ payment_method_id.get_string_repr()+ )+}++/// The fingerprint is never persisted, only cached against the payment method.+#[cfg(feature = "v2")]+pub(crate) async fn cache_merchant_fingerprint_id(+ state: &SessionState,+ payment_method_id: &id_type::GlobalPaymentMethodId,+ merchant_fingerprint_id: Option<&str>,+) {+ if let Some(merchant_fingerprint_id) = merchant_fingerprint_id {+ core_utils::cache_value_with_expiry(+ state,+ &merchant_fingerprint_redis_key(payment_method_id),+ "String",+ &merchant_fingerprint_id,+ consts::MERCHANT_FINGERPRINT_TTL,+ )+ .await;+ }+}++#[cfg(feature = "v2")]+async fn attach_merchant_fingerprint_id(+ state: &SessionState,+ response: api::PaymentMethodResponse,+ merchant_fingerprint_id: Option<String>,+) -> api::PaymentMethodResponse {+ cache_merchant_fingerprint_id(state, &response.id, merchant_fingerprint_id.as_deref()).await;++ api::PaymentMethodResponse {+ fingerprint_id: merchant_fingerprint_id,+ ..response+ }+}+#[cfg(feature = "v2")]#[derive(Debug, Clone, Copy)]pub enum LockerType {@@ -2306,36 +2399,70 @@ impl LockerOperations for GenericLocker {) -> RouterResult<PaymentMethodResolver> {let db = &*state.store;- // The auxiliary fingerprint runs as its own task so it never sits in front of the- // primary one, and is awaited only when the primary lookup misses.- let auxiliary_fingerprint_task = {- use router_env::tracing::Instrument;+ let merchant_fingerprint_secret =+ resolve_merchant_fingerprint_secret(state, platform, &payment_method_data).await;- let state = state.clone();- let payment_method_data = payment_method_data.clone();- let customer_id = customer_id.get_string_repr().to_owned();- tokio::spawn(- async move {- vault::get_auxiliary_fingerprint_id_for_payment_method(- &state,+ let (fingerprints, auxiliary_fingerprint_task, merchant_fingerprint_task) =+ match state.conf.locker.use_batched_fingerprint {+ true => (+ vault::get_fingerprints_for_payment_method(+ state,&payment_method_data,- customer_id,+ customer_id.get_string_repr().to_owned(),+ merchant_fingerprint_secret,+ )+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable(+ "Failed to get fingerprints from vault using generic strategy",+ )?,+ None,+ None,+ ),+ false => {+ let auxiliary_fingerprint_task = vault::spawn_fingerprint_task(+ state,+ &payment_method_data,+ Secret::new(customer_id.get_string_repr().to_owned()),+ consts::AUXILIARY_FINGERPRINT_LABEL,+ );+ let merchant_fingerprint_task = merchant_fingerprint_secret.map(|key| {+ vault::spawn_fingerprint_task(+ state,+ &payment_method_data,+ key,+ consts::MERCHANT_FINGERPRINT_LABEL,+ )+ });++ let vault_fingerprint_id = vault::get_fingerprint_id_for_payment_method(+ state,+ &payment_method_data,+ customer_id.get_string_repr().to_owned(),).await.change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable(+ "Failed to get fingerprint_id from vault using generic strategy",+ )?;++ (+ vault::PaymentMethodFingerprints {+ vault_fingerprint_id,+ auxiliary_fingerprint_id: None,+ merchant_fingerprint_id: None,+ },+ Some(auxiliary_fingerprint_task),+ merchant_fingerprint_task,+ )}- .in_current_span(),- )- };+ };- let fingerprint_id = vault::get_fingerprint_id_for_payment_method(- state,- &payment_method_data,- customer_id.get_string_repr().to_owned(),- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed to get fingerprint_id from vault using generic strategy")?;+ let vault::PaymentMethodFingerprints {+ vault_fingerprint_id: fingerprint_id,+ auxiliary_fingerprint_id,+ merchant_fingerprint_id,+ } = fingerprints;match db.find_payment_method_by_fingerprint_id(@@ -2344,40 +2471,48 @@ impl LockerOperations for GenericLocker {).await{- Ok(existing_pm) => match existing_pm.status {- enums::PaymentMethodStatus::New | enums::PaymentMethodStatus::Inactive => {- logger::info!(+ Ok(existing_pm) => {+ let resolution = match existing_pm.status {+ enums::PaymentMethodStatus::New | enums::PaymentMethodStatus::Inactive => {+ logger::info!("Payment method is duplicated with update-eligible status, updating existing payment method");- let payment_method_id = existing_pm.id.clone();- Ok(PaymentMethodResolver(PaymentMethodResolution::Update {- fingerprint_id: Some(fingerprint_id),- payment_method_id,- payment_method: Box::new(existing_pm),- source_payment_method_data: payment_method_data,- }))- }- enums::PaymentMethodStatus::Active => {- logger::info!(- "Payment method is duplicated, returning existing payment method"- );- Ok(PaymentMethodResolver(PaymentMethodResolution::Get(- Box::new(existing_pm),- )))- }- enums::PaymentMethodStatus::AwaitingData- | enums::PaymentMethodStatus::Processing- | enums::PaymentMethodStatus::Redacted => {- logger::info!(+ let payment_method_id = existing_pm.id.clone();+ Ok(PaymentMethodResolution::Update {+ fingerprint_id: Some(fingerprint_id),+ payment_method_id,+ payment_method: Box::new(existing_pm),+ source_payment_method_data: payment_method_data,+ })+ }+ enums::PaymentMethodStatus::Active => {+ logger::info!(+ "Payment method is duplicated, returning existing payment method"+ );+ Ok(PaymentMethodResolution::Get(Box::new(existing_pm)))+ }+ enums::PaymentMethodStatus::AwaitingData+ | enums::PaymentMethodStatus::Processing+ | enums::PaymentMethodStatus::Redacted => {+ logger::info!("Payment method is in awaiting data or processing state, no existing payment method entry found with fingerprint id");- Err(- report!(errors::ApiErrorResponse::InternalServerError).attach_printable(- "Payment method is in invalid state, expected New or Inactive",- ),+ Err(report!(errors::ApiErrorResponse::InternalServerError)+ .attach_printable(+ "Payment method is in invalid state, expected New or Inactive",+ ))+ }+ }?;++ Ok(PaymentMethodResolver {+ resolution,+ merchant_fingerprint_id: vault::resolve_fingerprint_task(+ merchant_fingerprint_task,+ merchant_fingerprint_id,)- }- },+ .await?,+ })+ }Err(err) => {when(!err.current_context().is_db_not_found(), || {Err(err)@@ -2387,28 +2522,33 @@ impl LockerOperations for GenericLocker {logger::debug!("Payment method not found, falling back to creation");- let auxiliary_fingerprint_id = auxiliary_fingerprint_task- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable(- "Failed to get auxiliary fingerprint_id from vault using generic strategy",- )??;-let locker_resolver = LockerTypeResolver {locker_type: LockerType::Generic,card_reference: None,};- let fingerprint_details = FingerprintDetails {- fingerprint_id: Some(fingerprint_id),- auxiliary_fingerprint_id: Some(auxiliary_fingerprint_id.clone()),- };+ let (auxiliary_fingerprint_id, merchant_fingerprint_id) = tokio::join!(+ vault::resolve_fingerprint_task(+ auxiliary_fingerprint_task,+ auxiliary_fingerprint_id,+ ),+ vault::resolve_fingerprint_task(+ merchant_fingerprint_task,+ merchant_fingerprint_id,+ ),+ );- Ok(PaymentMethodResolver(PaymentMethodResolution::Create {- fingerprint_details: Some(fingerprint_details),- payment_method_data,- locker_resolver,- }))+ Ok(PaymentMethodResolver {+ resolution: PaymentMethodResolution::Create {+ fingerprint_details: Some(FingerprintDetails {+ fingerprint_id: Some(fingerprint_id),+ auxiliary_fingerprint_id: auxiliary_fingerprint_id?,+ }),+ payment_method_data,+ locker_resolver,+ },+ merchant_fingerprint_id: merchant_fingerprint_id?,+ })}}}@@ -2681,11 +2821,14 @@ impl LockerOperations for LegacyLocker {card_reference: Some(legacy_locker_res.card_reference),};- Ok(PaymentMethodResolver(PaymentMethodResolution::Create {- fingerprint_details: None,- payment_method_data: payment_method_data.clone(),- locker_resolver,- }))+ Ok(PaymentMethodResolver {+ resolution: PaymentMethodResolution::Create {+ fingerprint_details: None,+ payment_method_data: payment_method_data.clone(),+ locker_resolver,+ },+ merchant_fingerprint_id: None,+ })}}}@@ -2826,7 +2969,10 @@ impl LockerType {}#[cfg(feature = "v2")]-pub struct PaymentMethodResolver(PaymentMethodResolution);+pub struct PaymentMethodResolver {+ resolution: PaymentMethodResolution,+ merchant_fingerprint_id: Option<String>,+}#[cfg(feature = "v2")]#[allow(clippy::too_many_arguments)]@@ -2964,7 +3110,12 @@ impl PaymentMethodResolver {billing_address: Option<Encryptable<hyperswitch_domain_models::address::Address>>,) -> RouterResult<(api::PaymentMethodResponse, domain::PaymentMethod)> {let db = &*state.store;- match self.0 {+ let Self {+ resolution,+ merchant_fingerprint_id,+ } = self;++ let (response, payment_method) = match resolution {PaymentMethodResolution::Get(existing_pm) => {logger::debug!("Payment method is duplicate, found {:?}", existing_pm.id);let card_cvc = req@@ -3126,7 +3277,12 @@ impl PaymentMethodResolver {)).await}- }+ }?;++ Ok((+ attach_merchant_fingerprint_id(state, response, merchant_fingerprint_id).await,+ payment_method,+ ))}}@@ -3334,10 +3490,13 @@ pub async fn create_generic_volatile_payment_method(|| (customer_id.is_some()&& resolve_payment_method_integration_type(state, platform).await== pm_types::PaymentMethodIntegrationType::PayThenVault);- let (payment_method_id, fingerprint_details) =+ let (payment_method_id, fingerprint_details, merchant_fingerprint_id) =match customer_id.as_ref().filter(|_| should_resolve_fingerprint) {Some(customer_id) => {- let resolution = payment_method_resolver(+ let PaymentMethodResolver {+ resolution,+ merchant_fingerprint_id,+ } = payment_method_resolver(state,platform,customer_id,@@ -3347,7 +3506,7 @@ pub async fn create_generic_volatile_payment_method(.await.attach_printable("Failed to resolve volatile payment method")?;- match resolution.0 {+ match resolution {PaymentMethodResolution::Get(existing_payment_method) => (existing_payment_method.id.clone(),Some(FingerprintDetails {@@ -3356,6 +3515,7 @@ pub async fn create_generic_volatile_payment_method(.auxiliary_fingerprint_id.clone(),}),+ merchant_fingerprint_id,),PaymentMethodResolution::Update {fingerprint_id,@@ -3370,14 +3530,19 @@ pub async fn create_generic_volatile_payment_method(.auxiliary_fingerprint_id.clone(),}),+ merchant_fingerprint_id,),PaymentMethodResolution::Create {fingerprint_details,..- } => (payment_method_id, fingerprint_details),+ } => (+ payment_method_id,+ fingerprint_details,+ merchant_fingerprint_id,+ ),}}- None => (payment_method_id, None),+ None => (payment_method_id, None, None),};let vaulting_result = vault_payment_method_in_volatile_storage(@@ -3503,7 +3668,10 @@ pub async fn create_generic_volatile_payment_method(Err(e) => Err(e),}?;- Ok((response, payment_method))+ Ok((+ attach_merchant_fingerprint_id(state, response, merchant_fingerprint_id).await,+ payment_method,+ ))}#[cfg(feature = "v2")]@@ -6281,6 +6449,18 @@ pub async fn retrieve_payment_method(.map(|billing| billing.into_inner()).map(From::from);+ let fingerprint_id = match is_merchant_fingerprint_enabled(&state, &platform).await {+ true => {+ core_utils::read_cached_value::<String>(+ &state,+ &merchant_fingerprint_redis_key(&payment_method.id),+ "String",+ )+ .await+ }+ false => None,+ };+transformers::generate_payment_method_response(&payment_method,&single_use_token_in_cache,@@ -6293,6 +6473,10 @@ pub async fn retrieve_payment_method(billing,None,)+ .map(|response| api::PaymentMethodResponse {+ fingerprint_id,+ ..response+ }).map(services::ApplicationResponse::Json)}diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rsindex 11bf6915c1..ed0dc00b90 100644--- a/crates/router/src/core/payment_methods/transformers.rs+++ b/crates/router/src/core/payment_methods/transformers.rs@@ -788,6 +788,7 @@ pub fn generate_payment_method_response(raw_payment_method_data,billing,acknowledgement_status,+ fingerprint_id: None,};Ok(resp)diff --git a/crates/router/src/core/payment_methods/utils.rs b/crates/router/src/core/payment_methods/utils.rsindex 93c83363fb..b3be1f2204 100644--- a/crates/router/src/core/payment_methods/utils.rs+++ b/crates/router/src/core/payment_methods/utils.rs@@ -853,6 +853,20 @@ pub async fn get_payment_method_integration_type(.await}+pub async fn get_should_generate_merchant_scoped_payment_method_fingerprint(+ state: &SessionState,+ dimensions: &dimension_state::DimensionsWithProviderMerchantIdAndOrgId,+ customer_id: Option<&common_utils::id_type::CustomerId>,+) -> bool {+ dimensions+ .get_should_generate_merchant_scoped_payment_method_fingerprint(+ state.store.as_ref(),+ state.superposition_service.as_ref(),+ customer_id,+ )+ .await+}+pub async fn get_should_perform_sdk_vaulting(state: &SessionState,dimensions: &dimension_state::DimensionsWithOrgId,diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rsindex b10817a48d..83a8551aab 100644--- a/crates/router/src/core/payment_methods/vault.rs+++ b/crates/router/src/core/payment_methods/vault.rs@@ -3,6 +3,8 @@ use std::{collections::HashMap, str::FromStr};use common_enums::{BankNames, PaymentMethodType};#[cfg(any(feature = "v1", feature = "v2"))]use common_utils::encryption::Encryption;+#[cfg(feature = "v2")]+use common_utils::ext_traits::AsyncExt;use common_utils::{crypto::{DecodeMessage, EncodeMessage, GcmAes256},ext_traits::{BytesExt, Encode},@@ -18,6 +20,8 @@ use hyperswitch_domain_models::router_flow_types::{use hyperswitch_domain_models::{router_data_v2::flow_common_types::VaultConnectorFlowData, types::VaultRouterData,};+#[cfg(feature = "v2")]+use hyperswitch_masking::ExposeInterface;use hyperswitch_masking::PeekInterface;#[cfg(feature = "v2")]use payment_methods::controller::DeleteCardResp;@@ -2423,17 +2427,189 @@ pub async fn get_fingerprint_id_for_payment_method(}#[cfg(feature = "v2")]-pub async fn get_auxiliary_fingerprint_id_for_payment_method(+pub type FingerprintTask = tokio::task::JoinHandle<RouterResult<Option<String>>>;++/// Auxiliary and merchant fingerprints use the same data, scoped by a different key.+#[cfg(feature = "v2")]+pub fn spawn_fingerprint_task(+ state: &routes::SessionState,+ payment_method_data: &domain::PaymentMethodVaultingData,+ key: hyperswitch_masking::Secret<String>,+ kind: &'static str,+) -> FingerprintTask {+ use router_env::tracing::Instrument;++ let state = state.clone();+ let data = payment_method_data.to_auxiliary_fingerprint_data();+ tokio::spawn(+ async move {+ data.as_ref()+ .async_map(|data| get_fingerprint_id_from_vault(&state, data, key.expose()))+ .await+ .transpose()+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable(format!("Failed to generate {kind} fingerprint"))+ }+ .in_current_span(),+ )+}++/// Batched fingerprints are already available; non-batched ones are awaited at their use site.+#[cfg(feature = "v2")]+pub async fn resolve_fingerprint_task(+ task: Option<FingerprintTask>,+ fingerprint: Option<String>,+) -> RouterResult<Option<String>> {+ match task {+ Some(task) => task+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Failed to join fingerprint task")?,+ None => Ok(fingerprint),+ }+}++/// The fingerprints a single vaulting derives.+#[cfg(feature = "v2")]+pub struct PaymentMethodFingerprints {+ pub vault_fingerprint_id: String,+ pub auxiliary_fingerprint_id: Option<String>,+ pub merchant_fingerprint_id: Option<String>,+}++/// Derives the vault, auxiliary and merchant fingerprints concurrently: in one batched call to the+/// vault's fingerprint API when `use_batched_fingerprint` is set, and in one call each otherwise.+#[cfg(feature = "v2")]+#[instrument(skip_all)]+pub async fn get_fingerprints_for_payment_method(state: &routes::SessionState,payment_method_data: &domain::PaymentMethodVaultingData,customer_id: String,-) -> CustomResult<String, errors::VaultError> {- let fingerprint_data = payment_method_data- .to_auxiliary_fingerprint_data()- .ok_or(errors::VaultError::GenerateFingerprintFailed)- .attach_printable("Failed to generate auxiliary fingerprint data")?;+ merchant_fingerprint_secret: Option<hyperswitch_masking::Secret<String>>,+) -> CustomResult<PaymentMethodFingerprints, errors::VaultError> {+ let vault_data = payment_method_data.to_fingerprint_data();+ // Absent for payment methods that carry nothing to fingerprint beyond the vault payload.+ let auxiliary_data = payment_method_data.to_auxiliary_fingerprint_data();+ // The merchant fingerprint is the auxiliary data keyed by the merchant's secret.+ let merchant_request = auxiliary_data.as_ref().zip(merchant_fingerprint_secret);++ match state.conf.locker.use_batched_fingerprint {+ true => {+ let fingerprints = [+ Some(batch_fingerprint_entry(+ consts::VAULT_FINGERPRINT_LABEL,+ &vault_data,+ hyperswitch_masking::Secret::new(customer_id.clone()),+ )),+ auxiliary_data.as_ref().map(|data| {+ batch_fingerprint_entry(+ consts::AUXILIARY_FINGERPRINT_LABEL,+ data,+ hyperswitch_masking::Secret::new(customer_id.clone()),+ )+ }),+ merchant_request.map(|(data, key)| {+ batch_fingerprint_entry(consts::MERCHANT_FINGERPRINT_LABEL, data, key)+ }),+ ]+ .into_iter()+ .flatten()+ .collect::<Result<Vec<_>, _>>()?;++ let mut fingerprint_ids =+ get_fingerprint_ids_from_vault_batch(state, fingerprints).await?;+ let auxiliary_fingerprint_id =+ fingerprint_ids.remove(consts::AUXILIARY_FINGERPRINT_LABEL);++ match (+ fingerprint_ids.remove(consts::VAULT_FINGERPRINT_LABEL),+ auxiliary_data.is_some() == auxiliary_fingerprint_id.is_some(),+ ) {+ (Some(vault_fingerprint_id), true) => Ok(PaymentMethodFingerprints {+ vault_fingerprint_id,+ auxiliary_fingerprint_id,+ merchant_fingerprint_id: fingerprint_ids+ .remove(consts::MERCHANT_FINGERPRINT_LABEL),+ }),+ _ => Err(report!(errors::VaultError::GenerateFingerprintFailed))+ .attach_printable("Vault did not return every requested fingerprint"),+ }+ }+ false => {+ let (vault_fingerprint_id, auxiliary_fingerprint_id, merchant_fingerprint_id) = tokio::join!(+ get_fingerprint_id_from_vault(state, &vault_data, customer_id.clone()),+ auxiliary_data.as_ref().async_map(|data| {+ get_fingerprint_id_from_vault(state, data, customer_id.clone())+ }),+ merchant_request.async_map(|(data, key)| {+ get_fingerprint_id_from_vault(state, data, key.expose())+ }),+ );- get_fingerprint_id_from_vault(state, &fingerprint_data, customer_id).await+ Ok(PaymentMethodFingerprints {+ vault_fingerprint_id: vault_fingerprint_id?,+ auxiliary_fingerprint_id: auxiliary_fingerprint_id.transpose()?,+ merchant_fingerprint_id: merchant_fingerprint_id.transpose()?,+ })+ }+ }+}++#[cfg(feature = "v2")]+fn batch_fingerprint_entry<D: serde::Serialize>(+ label: &str,+ data: &D,+ key: hyperswitch_masking::Secret<String>,+) -> CustomResult<pm_types::VaultBatchFingerprintEntry, errors::VaultError> {+ serde_json::to_string(data)+ .change_context(errors::VaultError::RequestEncodingFailed)+ .attach_printable("Failed to encode fingerprint data to string")+ .map(|data| pm_types::VaultBatchFingerprintEntry {+ label: label.to_owned(),+ data: hyperswitch_masking::Secret::new(data),+ key,+ })+}++#[cfg(feature = "v2")]+fn fingerprint_response_headers(state: &routes::SessionState) -> Option<HashMap<String, String>> {+ state.conf.locker.plain_fingerprint_response.then(|| {+ HashMap::from([(+ consts::V2_VAULT_FP_RESPONSE_ENCODING_HEADER.to_string(),+ consts::V2_VAULT_FP_RESPONSE_ENCODING_PLAIN.to_string(),+ )])+ })+}++#[cfg(feature = "v2")]+#[instrument(skip_all)]+async fn get_fingerprint_ids_from_vault_batch(+ state: &routes::SessionState,+ fingerprints: Vec<pm_types::VaultBatchFingerprintEntry>,+) -> CustomResult<HashMap<String, String>, errors::VaultError> {+ let payload = pm_types::VaultBatchFingerprintRequest {+ batch_data: fingerprints,+ }+ .encode_to_vec()+ .change_context(errors::VaultError::RequestEncodingFailed)+ .attach_printable("Failed to encode VaultBatchFingerprintRequest")?;++ let response = call_to_vault::<pm_types::GetVaultFingerprint>(+ state,+ payload,+ None,+ fingerprint_response_headers(state),+ )+ .await+ .change_context(errors::VaultError::VaultAPIError)+ .attach_printable("Call to vault failed")?;++ let batch_response: pm_types::VaultBatchFingerprintResponse = response+ .parse_struct("VaultBatchFingerprintResponse")+ .change_context(errors::VaultError::ResponseDeserializationFailed)+ .attach_printable("Failed to parse data into VaultBatchFingerprintResponse")?;++ Ok(batch_response.fingerprints)}#[cfg(feature = "v2")]@@ -2452,18 +2628,15 @@ async fn get_fingerprint_id_from_vault<D: serde::Serialize>(.change_context(errors::VaultError::RequestEncodingFailed).attach_printable("Failed to encode VaultFingerprintRequestNew")?;- let additional_headers = state.conf.locker.plain_fingerprint_response.then(|| {- HashMap::from([(- consts::V2_VAULT_FP_RESPONSE_ENCODING_HEADER.to_string(),- consts::V2_VAULT_FP_RESPONSE_ENCODING_PLAIN.to_string(),- )])- });-- let resp =- call_to_vault::<pm_types::GetVaultFingerprint>(state, payload, None, additional_headers)- .await- .change_context(errors::VaultError::VaultAPIError)- .attach_printable("Call to vault failed")?;+ let resp = call_to_vault::<pm_types::GetVaultFingerprint>(+ state,+ payload,+ None,+ fingerprint_response_headers(state),+ )+ .await+ .change_context(errors::VaultError::VaultAPIError)+ .attach_printable("Call to vault failed")?;let fingerprint_resp: pm_types::VaultFingerprintResponse = resp.parse_struct("VaultFingerprintResponse")diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex 07f294877f..40f3049fd4 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -37,11 +37,11 @@ use hyperswitch_domain_models::{use hyperswitch_interfaces::api::ConnectorSpecifications;#[cfg(feature = "frm")]use hyperswitch_interfaces::configs::Connectors;+#[cfg(feature = "payouts")]+use hyperswitch_masking::ExposeInterface;#[cfg(feature = "v2")]use hyperswitch_masking::ExposeOptionInterface;-use hyperswitch_masking::Secret;-#[cfg(feature = "payouts")]-use hyperswitch_masking::{ExposeInterface, PeekInterface};+use hyperswitch_masking::{PeekInterface, Secret};use maud::{html, PreEscaped};use redis_interface::errors::RedisError;use regex::Regex;@@ -74,6 +74,34 @@ use crate::{utils::{generate_id, OptionExt, ValueExt},};+pub async fn get_merchant_fingerprint_secret(+ state: &SessionState,+ merchant_account: &domain::MerchantAccount,+) -> RouterResult<String> {+ match merchant_account.fingerprint_secret.as_ref() {+ Some(secret) => Ok(secret.peek().clone()),+ None => {+ router_env::logger::warn!(+ merchant_id = ?merchant_account.get_id(),+ "fingerprint_secret missing from merchant account; falling back to Superposition"+ );+ super::metrics::FINGERPRINT_SECRET_SUPERPOSITION_FETCH_COUNT.add(1, &[]);+ let dimensions = dimension_state::Dimensions::new()+ .with_processor_merchant_id(merchant_account.get_id().clone().into());+ let secret = dimensions+ .get_fingerprint_secret(&*state.store, state.superposition_service.as_ref(), None)+ .await;++ match secret.is_empty() {+ false => Ok(secret),+ true => Err(errors::ApiErrorResponse::InternalServerError).attach_printable(+ "fingerprint_secret not found in merchant account or Superposition",+ ),+ }+ }+ }+}+#[derive(Debug, Clone, Default)]pub struct FeatureConfig {pub is_payment_method_modular_allowed: bool,diff --git a/crates/router/src/types/payment_methods.rs b/crates/router/src/types/payment_methods.rsindex 6322db78c8..3c36b241f9 100644--- a/crates/router/src/types/payment_methods.rs+++ b/crates/router/src/types/payment_methods.rs@@ -55,6 +55,28 @@ pub struct VaultFingerprintResponse {pub fingerprint_id: String,}+/// A batched request to the fingerprint API: `batch_data` in place of `data` and `key`.+#[cfg(feature = "v2")]+#[derive(Debug, serde::Deserialize, serde::Serialize)]+pub struct VaultBatchFingerprintRequest {+ pub batch_data: Vec<VaultBatchFingerprintEntry>,+}++/// `label` is opaque to the vault and keys the entry's fingerprint in the response.+#[cfg(feature = "v2")]+#[derive(Debug, serde::Deserialize, serde::Serialize)]+pub struct VaultBatchFingerprintEntry {+ pub label: String,+ pub data: Secret<String>,+ pub key: Secret<String>,+}++#[cfg(feature = "v2")]+#[derive(Debug, serde::Deserialize, serde::Serialize)]+pub struct VaultBatchFingerprintResponse {+ pub fingerprints: std::collections::HashMap<String, String>,+}+#[cfg(feature = "v1")]#[derive(Debug, serde::Deserialize, serde::Serialize)]pub struct AddVaultRequest<D> {