Skip to content
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

refactor(core): inclusion of locker to store fingerprints #3630

Merged
merged 39 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f512127
refactor(blocklist): replacement of KMS with locker to encrpyt and st…
prajjwalkumar17 Feb 12, 2024
e29c754
chore: removed the generate fingerprint route which was created for t…
prajjwalkumar17 Feb 12, 2024
e4dd967
chore: run formatter
hyperswitch-bot[bot] Feb 12, 2024
940af45
chore: add migration for inclusion of fingerprint_id in attempt
prajjwalkumar17 Feb 14, 2024
85d5c75
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 14, 2024
fd74951
Merge branch 'main' into blocklist_locker_compatibility
prajjwalkumar17 Feb 14, 2024
7bf1ea7
chore: add intent fingerprint as the successful attempt's fingerprint
prajjwalkumar17 Feb 14, 2024
d539f16
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 14, 2024
5fc3da4
chore: run formatter
hyperswitch-bot[bot] Feb 14, 2024
9185ad5
chore: address comments
prajjwalkumar17 Feb 15, 2024
ca3df04
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 15, 2024
e5ad811
chore: run formatter
hyperswitch-bot[bot] Feb 15, 2024
a7c4ffe
chore: address comments for function names
prajjwalkumar17 Feb 15, 2024
c56e775
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 15, 2024
db33baa
chore: run formatter
hyperswitch-bot[bot] Feb 15, 2024
eeaa40e
Merge branch 'main' into blocklist_locker_compatibility
prajjwalkumar17 Feb 15, 2024
389072b
chore: address comments for duplicate structs in api_models
prajjwalkumar17 Feb 15, 2024
9928a64
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 15, 2024
e036814
chore: run formatter
hyperswitch-bot[bot] Feb 15, 2024
7510be3
chore: address commnets
prajjwalkumar17 Feb 16, 2024
6292e65
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 16, 2024
d50f0df
Merge branch 'main' into blocklist_locker_compatibility
prajjwalkumar17 Feb 16, 2024
d418669
chore: address comments
prajjwalkumar17 Feb 19, 2024
3c3fb48
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 19, 2024
7596bdb
chore: address comments
prajjwalkumar17 Feb 19, 2024
2a379d2
Merge branch 'main' into blocklist_locker_compatibility
prajjwalkumar17 Feb 19, 2024
73ed462
chore: address comments
prajjwalkumar17 Feb 19, 2024
368f84d
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 19, 2024
77ba647
chore: run formatter
hyperswitch-bot[bot] Feb 19, 2024
4cbbd98
Merge branch 'main' into blocklist_locker_compatibility
prajjwalkumar17 Feb 19, 2024
23ee73c
chore: updated locker configs
prajjwalkumar17 Feb 19, 2024
336fc8f
chore: updated locker configs
prajjwalkumar17 Feb 19, 2024
9439dc1
chore: run formatter
hyperswitch-bot[bot] Feb 19, 2024
c3d7c2c
chore: updated locker bypass urls
prajjwalkumar17 Feb 20, 2024
82cb2e5
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 20, 2024
3418129
Merge branch 'main' into blocklist_locker_compatibility
prajjwalkumar17 Feb 20, 2024
539723d
fix: remove status_code being printed in EndRequest log
Narayanbhat166 Feb 20, 2024
f6f9817
Merge branch 'blocklist_locker_compatibility' of https://github.com/j…
prajjwalkumar17 Feb 20, 2024
f4b5d8e
Merge branch 'main' into blocklist_locker_compatibility
prajjwalkumar17 Feb 20, 2024
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
18 changes: 18 additions & 0 deletions crates/api_models/src/blocklist.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use common_enums::enums;
use common_utils::events::ApiEventMetric;
use masking::StrongSecret;
use utoipa::ToSchema;

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
Expand All @@ -10,6 +11,15 @@ pub enum BlocklistRequest {
ExtendedCardBin(String),
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct GenerateFingerprintRequest {
pub card: Card,
pub hash_key: StrongSecret<String>,
}
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct Card {
pub card_number: StrongSecret<String>,
}
pub type AddToBlocklistRequest = BlocklistRequest;
pub type DeleteFromBlocklistRequest = BlocklistRequest;

Expand All @@ -22,6 +32,11 @@ pub struct BlocklistResponse {
pub created_at: time::PrimitiveDateTime,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub struct GenerateFingerprintResponsePayload {
pub card_fingerprint: String,
prajjwalkumar17 marked this conversation as resolved.
Show resolved Hide resolved
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct ToggleBlocklistResponse {
pub blocklist_guard_status: String,
Expand Down Expand Up @@ -54,4 +69,7 @@ impl ApiEventMetric for BlocklistRequest {}
impl ApiEventMetric for BlocklistResponse {}
impl ApiEventMetric for ToggleBlocklistResponse {}
impl ApiEventMetric for ListBlocklistQuery {}
impl ApiEventMetric for GenerateFingerprintRequest {}
impl ApiEventMetric for ToggleBlocklistQuery {}
impl ApiEventMetric for GenerateFingerprintResponsePayload {}
impl ApiEventMetric for Card {}
4 changes: 4 additions & 0 deletions crates/data_models/src/payments/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub struct PaymentAttempt {
pub unified_code: Option<String>,
pub unified_message: Option<String>,
pub mandate_data: Option<MandateDetails>,
pub fingerprint_id: Option<String>,
}

impl PaymentAttempt {
Expand Down Expand Up @@ -238,6 +239,7 @@ pub struct PaymentAttemptNew {
pub unified_code: Option<String>,
pub unified_message: Option<String>,
pub mandate_data: Option<MandateDetails>,
pub fingerprint_id: Option<String>,
}

impl PaymentAttemptNew {
Expand Down Expand Up @@ -270,6 +272,7 @@ pub enum PaymentAttemptUpdate {
capture_method: Option<storage_enums::CaptureMethod>,
surcharge_amount: Option<i64>,
tax_amount: Option<i64>,
fingerprint_id: Option<String>,
updated_by: String,
},
UpdateTrackers {
Expand Down Expand Up @@ -307,6 +310,7 @@ pub enum PaymentAttemptUpdate {
surcharge_amount: Option<i64>,
tax_amount: Option<i64>,
merchant_connector_id: Option<String>,
fingerprint_id: Option<String>,
},
RejectUpdate {
status: storage_enums::AttemptStatus,
Expand Down
3 changes: 3 additions & 0 deletions crates/data_models/src/payments/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pub enum PaymentIntentUpdate {
amount_captured: Option<i64>,
return_url: Option<String>,
updated_by: String,
fingerprint_id: Option<String>,
incremental_authorization_allowed: Option<bool>,
},
MetadataUpdate {
Expand Down Expand Up @@ -335,6 +336,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
// currency,
status,
amount_captured,
fingerprint_id,
// customer_id,
return_url,
updated_by,
Expand All @@ -344,6 +346,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
// currency: Some(currency),
status: Some(status),
amount_captured,
fingerprint_id,
// customer_id,
return_url,
modified_at: Some(common_utils::date_time::now()),
Expand Down
11 changes: 11 additions & 0 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub struct PaymentAttempt {
pub unified_message: Option<String>,
pub net_amount: Option<i64>,
pub mandate_data: Option<storage_enums::MandateDetails>,
pub fingerprint_id: Option<String>,
}

impl PaymentAttempt {
Expand Down Expand Up @@ -140,6 +141,7 @@ pub struct PaymentAttemptNew {
pub unified_message: Option<String>,
pub net_amount: Option<i64>,
pub mandate_data: Option<storage_enums::MandateDetails>,
pub fingerprint_id: Option<String>,
}

impl PaymentAttemptNew {
Expand Down Expand Up @@ -177,6 +179,7 @@ pub enum PaymentAttemptUpdate {
capture_method: Option<storage_enums::CaptureMethod>,
surcharge_amount: Option<i64>,
tax_amount: Option<i64>,
fingerprint_id: Option<String>,
updated_by: String,
},
UpdateTrackers {
Expand Down Expand Up @@ -212,6 +215,7 @@ pub enum PaymentAttemptUpdate {
amount_capturable: Option<i64>,
surcharge_amount: Option<i64>,
tax_amount: Option<i64>,
fingerprint_id: Option<String>,
updated_by: String,
merchant_connector_id: Option<String>,
},
Expand Down Expand Up @@ -351,6 +355,7 @@ pub struct PaymentAttemptUpdateInternal {
encoded_data: Option<String>,
unified_code: Option<Option<String>>,
unified_message: Option<Option<String>>,
fingerprint_id: Option<String>,
}

impl PaymentAttemptUpdateInternal {
Expand Down Expand Up @@ -411,6 +416,7 @@ impl PaymentAttemptUpdate {
encoded_data,
unified_code,
unified_message,
fingerprint_id,
} = PaymentAttemptUpdateInternal::from(self).populate_derived_fields(&source);
PaymentAttempt {
amount: amount.unwrap_or(source.amount),
Expand Down Expand Up @@ -452,6 +458,7 @@ impl PaymentAttemptUpdate {
encoded_data: encoded_data.or(source.encoded_data),
unified_code: unified_code.unwrap_or(source.unified_code),
unified_message: unified_message.unwrap_or(source.unified_message),
fingerprint_id: fingerprint_id.or(source.fingerprint_id),
..source
}
}
Expand All @@ -476,6 +483,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_method,
surcharge_amount,
tax_amount,
fingerprint_id,
updated_by,
} => Self {
amount: Some(amount),
Expand All @@ -494,6 +502,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_method,
surcharge_amount,
tax_amount,
fingerprint_id,
updated_by,
..Default::default()
},
Expand Down Expand Up @@ -527,6 +536,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
merchant_connector_id,
surcharge_amount,
tax_amount,
fingerprint_id,
} => Self {
amount: Some(amount),
currency: Some(currency),
Expand All @@ -549,6 +559,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
merchant_connector_id: merchant_connector_id.map(Some),
surcharge_amount,
tax_amount,
fingerprint_id,
..Default::default()
},
PaymentAttemptUpdate::VoidUpdate {
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub enum PaymentIntentUpdate {
ResponseUpdate {
status: storage_enums::IntentStatus,
amount_captured: Option<i64>,
fingerprint_id: Option<String>,
return_url: Option<String>,
updated_by: String,
incremental_authorization_allowed: Option<bool>,
Expand Down Expand Up @@ -405,6 +406,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
// currency,
status,
amount_captured,
fingerprint_id,
// customer_id,
return_url,
updated_by,
Expand All @@ -414,6 +416,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
// currency: Some(currency),
status: Some(status),
amount_captured,
fingerprint_id,
// customer_id,
return_url,
modified_at: Some(common_utils::date_time::now()),
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ diesel::table! {
unified_message -> Nullable<Varchar>,
net_amount -> Nullable<Int8>,
mandate_data -> Nullable<Jsonb>,
#[max_length = 64]
fingerprint_id -> Nullable<Varchar>,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/user/sample_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub struct PaymentAttemptBatchNew {
pub unified_message: Option<String>,
pub net_amount: Option<i64>,
pub mandate_data: Option<MandateDetails>,
pub fingerprint_id: Option<String>,
}

#[allow(dead_code)]
Expand Down Expand Up @@ -122,6 +123,7 @@ impl PaymentAttemptBatchNew {
unified_message: self.unified_message,
net_amount: self.net_amount,
mandate_data: self.mandate_data,
fingerprint_id: self.fingerprint_id,
}
}
}
Loading
Loading