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

fix(payment_methods_v2): update fingerprint implementation in v2 (#7270)

Prasunna Soppae475f63967a7
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 6ebc7bde5e..237a097b79 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -921,6 +921,7 @@ pub async fn create_payment_method(
merchant_account,
key_store,
None,
+ &customer_id,
)
.await;
@@ -1513,14 +1514,16 @@ pub async fn vault_payment_method(
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
existing_vault_id: Option<domain::VaultId>,
+ customer_id: &id_type::GlobalCustomerId,
) -> RouterResult<(pm_types::AddVaultResponse, String)> {
let db = &*state.store;
// get fingerprint_id from vault
- let fingerprint_id_from_vault = vault::get_fingerprint_id_from_vault(state, pmd)
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to get fingerprint_id from vault")?;
+ let fingerprint_id_from_vault =
+ vault::get_fingerprint_id_from_vault(state, pmd, customer_id.get_string_repr().to_owned())
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to get fingerprint_id from vault")?;
// throw back error if payment method is duplicated
when(
@@ -1796,6 +1799,7 @@ pub async fn update_payment_method_core(
&merchant_account,
&key_store,
current_vault_id, // using current vault_id for now, will have to refactor this
+ &payment_method.customer_id,
) // to generate new one on each vaulting later on
.await
.attach_printable("Failed to add payment method in vault")?;
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 300f1e3054..93461c6315 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -1257,8 +1257,8 @@ pub async fn get_fingerprint_id_from_vault<
>(
state: &routes::SessionState,
data: &D,
+ key: String,
) -> CustomResult<String, errors::VaultError> {
- let key = data.get_vaulting_data_key();
let data = serde_json::to_string(data)
.change_context(errors::VaultError::RequestEncodingFailed)
.attach_printable("Failed to encode Vaulting data to string")?;