Skip to content

Commit

Permalink
fix(payment_methods_v2): update fingerprint implementation in v2 (#7270)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
prasunna09 and hyperswitch-bot[bot] authored Feb 20, 2025
1 parent d1f537e commit e475f63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ pub async fn create_payment_method(
merchant_account,
key_store,
None,
&customer_id,
)
.await;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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")?;
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payment_methods/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand Down

0 comments on commit e475f63

Please sign in to comment.