Skip to content

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

feat(payment-methods): add parent fingerprint ID support in payment methods (#12189)

Gaurav Rawat020a25618377
diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rs
index 622bea87bf..786d4ad906 100644
--- a/crates/diesel_models/src/payment_method.rs
+++ b/crates/diesel_models/src/payment_method.rs
@@ -115,6 +115,7 @@ pub struct PaymentMethod {
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
pub external_vault_token_data: Option<Encryption>,
+ pub auxiliary_fingerprint_id: Option<String>,
}
impl PaymentMethod {
@@ -204,6 +205,7 @@ pub struct PaymentMethodNew {
pub network_token_payment_method_data: Option<Encryption>,
pub external_vault_token_data: Option<Encryption>,
pub locker_fingerprint_id: Option<String>,
+ pub auxiliary_fingerprint_id: Option<String>,
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
pub id: common_utils::id_type::GlobalPaymentMethodId,
@@ -456,6 +458,7 @@ impl PaymentMethodUpdateInternal {
last_modified_by: last_modified_by.or(source.last_modified_by),
customer_details: customer_details.or(source.customer_details),
network_tokenization_data: source.network_tokenization_data,
+ auxiliary_fingerprint_id: source.auxiliary_fingerprint_id,
}
}
}
@@ -1209,6 +1212,7 @@ impl From<&PaymentMethodNew> for PaymentMethod {
.payment_method_billing_address
.clone(),
locker_fingerprint_id: payment_method_new.locker_fingerprint_id.clone(),
+ auxiliary_fingerprint_id: payment_method_new.auxiliary_fingerprint_id.clone(),
payment_method_type_v2: payment_method_new.payment_method_type_v2,
payment_method_subtype: payment_method_new.payment_method_subtype,
id: payment_method_new.id.clone(),
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index 783142cf3c..89d11e0bca 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -1364,6 +1364,8 @@ diesel::table! {
#[max_length = 64]
payment_method_subtype -> Nullable<Varchar>,
external_vault_token_data -> Nullable<Bytea>,
+ #[max_length = 64]
+ auxiliary_fingerprint_id -> Nullable<Varchar>,
}
}
diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rs
index 11d774d3b5..f112673d7f 100644
--- a/crates/hyperswitch_domain_models/src/payment_methods.rs
+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs
@@ -130,6 +130,7 @@ pub struct PaymentMethod {
pub payment_method_billing_address: Option<Encryptable<Address>>,
pub updated_by: Option<String>,
pub locker_fingerprint_id: Option<String>,
+ pub auxiliary_fingerprint_id: Option<String>,
pub version: common_enums::ApiVersion,
pub network_token_requestor_reference_id: Option<String>,
pub network_token_locker_id: Option<String>,
@@ -763,6 +764,7 @@ impl super::behaviour::Conversion for PaymentMethod {
.map(|last_modified_by| last_modified_by.to_string()),
customer_details: self.customer_details.map(|val| val.into()),
network_tokenization_data: self.network_tokenization_data.map(|val| val.into()),
+ auxiliary_fingerprint_id: self.auxiliary_fingerprint_id,
})
}
@@ -903,6 +905,7 @@ impl super::behaviour::Conversion for PaymentMethod {
.and_then(|last_modified_by| last_modified_by.parse::<CreatedBy>().ok()),
customer_details,
network_tokenization_data,
+ auxiliary_fingerprint_id: storage_model.auxiliary_fingerprint_id,
})
}
.await
@@ -948,6 +951,7 @@ impl super::behaviour::Conversion for PaymentMethod {
.last_modified_by
.map(|last_modified_by| last_modified_by.to_string()),
customer_details: self.customer_details.map(|val| val.into()),
+ auxiliary_fingerprint_id: self.auxiliary_fingerprint_id,
})
}
}
diff --git a/crates/hyperswitch_domain_models/src/vault.rs b/crates/hyperswitch_domain_models/src/vault.rs
index a48d293259..ecbe3fbc55 100644
--- a/crates/hyperswitch_domain_models/src/vault.rs
+++ b/crates/hyperswitch_domain_models/src/vault.rs
@@ -25,6 +25,13 @@ pub enum FingerprintData {
CardNumber(cards::CardNumber),
BankDebit(FingerprintBankDebitData),
}
+#[derive(Debug, Deserialize, Serialize, Clone)]
+pub enum AuxiliaryFingerprintData {
+ CardNumber(cards::CardNumber),
+ NetworkToken(cards::NetworkToken),
+ CardNumberData(cards::CardNumber),
+ BankDebit(hyperswitch_masking::Secret<String>),
+}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
pub struct FingerprintBankDebitData {
@@ -219,6 +226,27 @@ impl PaymentMethodVaultingData {
}
}
+ #[cfg(feature = "v2")]
+ pub fn to_auxiliary_fingerprint_data(&self) -> AuxiliaryFingerprintData {
+ match self {
+ Self::Card(card) => AuxiliaryFingerprintData::CardNumber(card.card_number.clone()),
+ Self::NetworkToken(nt) => {
+ AuxiliaryFingerprintData::NetworkToken(nt.network_token.clone())
+ }
+ Self::CardNumber(card_number) => {
+ AuxiliaryFingerprintData::CardNumber(card_number.clone())
+ }
+ Self::BankDebit(bank_debit) => {
+ let account_number = match bank_debit {
+ payment_method_data::BankDebitDetail::Ach { account_number, .. } => {
+ account_number.clone()
+ }
+ };
+ AuxiliaryFingerprintData::BankDebit(account_number)
+ }
+ }
+ }
+
#[cfg(feature = "v2")]
pub fn get_bank_debit_fingerprint_data(
bank_debit: &payment_method_data::BankDebitDetail,
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 2a7ea358b7..830021ab92 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -1473,12 +1473,18 @@ pub enum PaymentMethodResolution {
source_payment_method_data: domain::PaymentMethodVaultingData,
},
Create {
- fingerprint_id: Option<String>,
+ fingerprint_details: Option<FingerprintDetails>,
payment_method_data: domain::PaymentMethodVaultingData,
locker_resolver: LockerTypeResolver,
},
}
+#[cfg(feature = "v2")]
+pub struct FingerprintDetails {
+ pub fingerprint_id: Option<String>,
+ pub auxiliary_fingerprint_id: Option<String>,
+}
+
#[cfg(feature = "v2")]
#[derive(Debug, Clone, Copy)]
pub enum LockerType {
@@ -1693,13 +1699,30 @@ impl LockerOperations for GenericLocker {
logger::debug!("Payment method not found, falling back to creation");
+ let auxiliary_fingerprint_id =
+ vault::get_auxiliary_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 auxiliary fingerprint_id from vault using generic strategy",
+ )?;
+
let locker_resolver = LockerTypeResolver {
locker_type: LockerType::Generic,
card_reference: None,
};
- Ok(PaymentMethodResolver(PaymentMethodResolution::Create {
+ let fingerprint_details = FingerprintDetails {
fingerprint_id: Some(fingerprint_id),
+ auxiliary_fingerprint_id: Some(auxiliary_fingerprint_id.clone()),
+ };
+
+ Ok(PaymentMethodResolver(PaymentMethodResolution::Create {
+ fingerprint_details: Some(fingerprint_details),
payment_method_data,
locker_resolver,
}))
@@ -1974,8 +1997,9 @@ impl LockerOperations for LegacyLocker {
locker_type: LockerType::Legacy,
card_reference: Some(legacy_locker_res.card_reference),
};
+
Ok(PaymentMethodResolver(PaymentMethodResolution::Create {
- fingerprint_id: None,
+ fingerprint_details: None,
payment_method_data: payment_method_data.clone(),
locker_resolver,
}))
@@ -2349,10 +2373,17 @@ impl PaymentMethodResolver {
}
PaymentMethodResolution::Create {
- fingerprint_id,
+ fingerprint_details,
payment_method_data,
locker_resolver,
} => {
+ let fingerprint_id = fingerprint_details
+ .as_ref()
+ .and_then(|details| details.fingerprint_id.clone());
+
+ let auxiliary_fingerprint_id = fingerprint_details
+ .and_then(|details| details.auxiliary_fingerprint_id.clone());
+
let payment_method = create_payment_method_for_intent(
state,
req.metadata.clone(),
@@ -2363,6 +2394,7 @@ impl PaymentMethodResolver {
platform.get_provider().get_account().storage_scheme,
billing_address.clone(),
platform.get_initiator(),
+ auxiliary_fingerprint_id,
)
.await?;
Box::pin(execute_payment_method_create(
@@ -3351,6 +3383,7 @@ pub async fn payment_method_intent_create(
provider.get_account().storage_scheme,
payment_method_billing_address,
initiator,
+ None,
)
.await
.attach_printable("Failed to add Payment method to DB")?;
@@ -3738,6 +3771,7 @@ pub async fn create_payment_method_for_intent(
Encryptable<hyperswitch_domain_models::address::Address>,
>,
initiator: Option<&domain::Initiator>,
+ auxiliary_fingerprint_id: Option<String>,
) -> CustomResult<domain::PaymentMethod, errors::ApiErrorResponse> {
use josekit::jwe::zip::deflate::DeflateJweCompression::Def;
@@ -3778,6 +3812,7 @@ pub async fn create_payment_method_for_intent(
last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),
customer_details: None,
network_tokenization_data: None,
+ auxiliary_fingerprint_id,
},
storage_scheme,
)
@@ -3865,6 +3900,7 @@ pub async fn construct_payment_method_object(
last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),
customer_details: None,
network_tokenization_data: None,
+ auxiliary_fingerprint_id: None,
})
}
@@ -3930,6 +3966,7 @@ pub async fn create_payment_method_for_confirm(
last_modified_by: initiator.and_then(|initiator| initiator.to_created_by()),
customer_details: None,
network_tokenization_data: None,
+ auxiliary_fingerprint_id: None,
},
storage_scheme,
)
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 5c113bfd2b..144c58d0f7 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -1975,6 +1975,17 @@ pub async fn get_fingerprint_id_for_payment_method(
get_fingerprint_id_from_vault(state, &fingerprint_data, customer_id).await
}
+#[cfg(feature = "v2")]
+pub async fn get_auxiliary_fingerprint_id_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();
+
+ get_fingerprint_id_from_vault(state, &fingerprint_data, customer_id).await
+}
+
#[cfg(feature = "v2")]
#[instrument(skip_all)]
async fn get_fingerprint_id_from_vault<D: serde::Serialize>(
diff --git a/v2_compatible_migrations/2026-05-06-140219-0000_add-auxiliary-fingerprint/down.sql b/v2_compatible_migrations/2026-05-06-140219-0000_add-auxiliary-fingerprint/down.sql
new file mode 100644
index 0000000000..7be3fbeadb
--- /dev/null
+++ b/v2_compatible_migrations/2026-05-06-140219-0000_add-auxiliary-fingerprint/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+Alter table payment_methods drop column auxiliary_fingerprint_id;
\ No newline at end of file
diff --git a/v2_compatible_migrations/2026-05-06-140219-0000_add-auxiliary-fingerprint/up.sql b/v2_compatible_migrations/2026-05-06-140219-0000_add-auxiliary-fingerprint/up.sql
new file mode 100644
index 0000000000..4fbd3317ad
--- /dev/null
+++ b/v2_compatible_migrations/2026-05-06-140219-0000_add-auxiliary-fingerprint/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+Alter table payment_methods add column auxiliary_fingerprint_id varchar(64);
\ No newline at end of file