Skip to content

chore(payment_methods_v2): fingerprint changes for card #7692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/diesel_models/src/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub struct PaymentMethod {
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
pub id: common_utils::id_type::GlobalPaymentMethodId,
pub secondary_fingerprint_id: Option<String>,
}

impl PaymentMethod {
Expand Down Expand Up @@ -185,6 +186,7 @@ pub struct PaymentMethodNew {
pub payment_method_type_v2: Option<storage_enums::PaymentMethod>,
pub payment_method_subtype: Option<storage_enums::PaymentMethodType>,
pub id: common_utils::id_type::GlobalPaymentMethodId,
pub secondary_fingerprint_id: Option<String>,
}

impl PaymentMethodNew {
Expand Down Expand Up @@ -297,6 +299,7 @@ pub enum PaymentMethodUpdate {
network_token_payment_method_data: Option<Encryption>,
locker_fingerprint_id: Option<String>,
connector_mandate_details: Option<CommonMandateReference>,
secondary_fingerprint_id: Option<String>,
},
ConnectorMandateDetailsUpdate {
connector_mandate_details: Option<CommonMandateReference>,
Expand Down Expand Up @@ -332,6 +335,7 @@ pub struct PaymentMethodUpdateInternal {
network_token_locker_id: Option<String>,
network_token_payment_method_data: Option<Encryption>,
locker_fingerprint_id: Option<String>,
secondary_fingerprint_id: Option<String>,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
Expand All @@ -352,6 +356,7 @@ impl PaymentMethodUpdateInternal {
network_token_locker_id,
network_token_payment_method_data,
locker_fingerprint_id,
secondary_fingerprint_id,
} = self;

PaymentMethod {
Expand Down Expand Up @@ -380,6 +385,7 @@ impl PaymentMethodUpdateInternal {
network_token_locker_id: network_token_locker_id.or(source.network_token_locker_id),
network_token_payment_method_data: network_token_payment_method_data
.or(source.network_token_payment_method_data),
secondary_fingerprint_id: source.secondary_fingerprint_id,
}
}
}
Expand Down Expand Up @@ -720,6 +726,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
network_token_payment_method_data: None,
locker_fingerprint_id: None,
secondary_fingerprint_id: None,
},
PaymentMethodUpdate::LastUsedUpdate { last_used_at } => Self {
payment_method_data: None,
Expand All @@ -736,6 +743,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
network_token_payment_method_data: None,
locker_fingerprint_id: None,
secondary_fingerprint_id: None,
},
PaymentMethodUpdate::UpdatePaymentMethodDataAndLastUsed {
payment_method_data,
Expand All @@ -756,6 +764,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
network_token_payment_method_data: None,
locker_fingerprint_id: None,
secondary_fingerprint_id: None,
},
PaymentMethodUpdate::NetworkTransactionIdAndStatusUpdate {
network_transaction_id,
Expand All @@ -775,6 +784,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
network_token_payment_method_data: None,
locker_fingerprint_id: None,
secondary_fingerprint_id: None,
},
PaymentMethodUpdate::StatusUpdate { status } => Self {
payment_method_data: None,
Expand All @@ -791,6 +801,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
network_token_payment_method_data: None,
locker_fingerprint_id: None,
secondary_fingerprint_id: None,
},
PaymentMethodUpdate::GenericUpdate {
payment_method_data,
Expand All @@ -803,6 +814,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_payment_method_data,
locker_fingerprint_id,
connector_mandate_details,
secondary_fingerprint_id,
} => Self {
payment_method_data,
last_used_at: None,
Expand All @@ -818,6 +830,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_locker_id,
network_token_payment_method_data,
locker_fingerprint_id,
secondary_fingerprint_id,
},
PaymentMethodUpdate::ConnectorMandateDetailsUpdate {
connector_mandate_details,
Expand All @@ -836,6 +849,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
network_token_requestor_reference_id: None,
network_token_payment_method_data: None,
locker_fingerprint_id: None,
secondary_fingerprint_id: None,
},
}
}
Expand Down Expand Up @@ -913,6 +927,7 @@ impl From<&PaymentMethodNew> for PaymentMethod {
.payment_method_billing_address
.clone(),
locker_fingerprint_id: payment_method_new.locker_fingerprint_id.clone(),
secondary_fingerprint_id: payment_method_new.secondary_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(),
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/schema_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,8 @@ diesel::table! {
payment_method_subtype -> Nullable<Varchar>,
#[max_length = 64]
id -> Varchar,
#[max_length = 64]
secondary_fingerprint_id -> Nullable<Varchar>,
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/hyperswitch_domain_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub struct PaymentMethod {
#[encrypt(ty = Value)]
pub network_token_payment_method_data:
Option<Encryptable<domain_payment_method_data::PaymentMethodsData>>,
pub secondary_fingerprint_id: Option<String>,
}

impl PaymentMethod {
Expand Down Expand Up @@ -458,6 +459,7 @@ impl super::behaviour::Conversion for PaymentMethod {
network_token_payment_method_data: self
.network_token_payment_method_data
.map(|val| val.into()),
secondary_fingerprint_id: self.secondary_fingerprint_id,
})
}

Expand Down Expand Up @@ -550,6 +552,7 @@ impl super::behaviour::Conversion for PaymentMethod {
.network_token_requestor_reference_id,
network_token_locker_id: storage_model.network_token_locker_id,
network_token_payment_method_data,
secondary_fingerprint_id: storage_model.secondary_fingerprint_id,
})
}
.await
Expand Down Expand Up @@ -586,6 +589,7 @@ impl super::behaviour::Conversion for PaymentMethod {
network_token_payment_method_data: self
.network_token_payment_method_data
.map(|val| val.into()),
secondary_fingerprint_id: self.secondary_fingerprint_id,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,7 @@ pub async fn create_payment_method_for_intent(
network_token_locker_id: None,
network_token_payment_method_data: None,
network_token_requestor_reference_id: None,
secondary_fingerprint_id: None,
},
storage_scheme,
)
Expand Down Expand Up @@ -1672,6 +1673,7 @@ pub async fn create_pm_additional_data_update(
network_token_payment_method_data: nt_data.map(|data| data.network_token_pmd.into()),
connector_mandate_details: connector_mandate_details_update,
locker_fingerprint_id: vault_fingerprint_id,
secondary_fingerprint_id: None,
};

Ok(pm_update)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE payment_methods
DROP COLUMN IF EXISTS secondary_fingerprint_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE payment_methods ADD COLUMN secondary_fingerprint_id VARCHAR(64) DEFAULT NULL;
Loading