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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(blocklist): widen card_bin to 6-10 digits and deprecate extended_card_bin (#13861)
Ayush Anand1aa79421a516
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex de9684799b..d77643666c 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -6776,7 +6776,7 @@}],"requestBody": {- "description": "A multipart/form-data request with a `file` field containing a UTF-8 CSV (max 5 MiB). The CSV must have a header row: `type,data,metadata`. `type`: one of `card_bin` (6 digits), `extended_card_bin` (8 digits), `fingerprint`. `metadata`: optional, `key=value` pairs separated by `;` (e.g. `reason=fraud;source=manual`). Maximum 100,000 data rows.",+ "description": "A multipart/form-data request with a `file` field containing a UTF-8 CSV (max 5 MiB). The CSV must have a header row: `type,data,metadata`. `type`: one of `generic_card_bin` (6 to 10 digits), `fingerprint`. `metadata`: optional, `key=value` pairs separated by `;` (e.g. `reason=fraud;source=manual`). Maximum 100,000 data rows.","content": {"multipart/form-data": {"schema": {@@ -15425,10 +15425,12 @@},"BlocklistDataKind": {"type": "string",+ "description": "`card_bin` (6 digits) and `extended_card_bin` (8 digits) are deprecated, use\n`generic_card_bin`, which accepts 6 to 10 digits.","enum": ["payment_method","card_bin",- "extended_card_bin"+ "extended_card_bin",+ "generic_card_bin"]},"BlocklistRequest": {@@ -15447,7 +15449,9 @@]},"data": {- "type": "string"+ "type": "string",+ "description": "Deprecated, use `generic_card_bin`. A card number prefix of exactly 6 digits.",+ "deprecated": true}}},@@ -15483,7 +15487,28 @@]},"data": {- "type": "string"+ "type": "string",+ "description": "Deprecated, use `generic_card_bin`. A card number prefix of exactly 8 digits.",+ "deprecated": true+ }+ }+ },+ {+ "type": "object",+ "required": [+ "type",+ "data"+ ],+ "properties": {+ "type": {+ "type": "string",+ "enum": [+ "generic_card_bin"+ ]+ },+ "data": {+ "type": "string",+ "description": "A card number prefix of 6 to 10 digits."}}}diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 88dbd70a9e..3d0fa2644e 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -10079,10 +10079,12 @@},"BlocklistDataKind": {"type": "string",+ "description": "`card_bin` (6 digits) and `extended_card_bin` (8 digits) are deprecated, use\n`generic_card_bin`, which accepts 6 to 10 digits.","enum": ["payment_method","card_bin",- "extended_card_bin"+ "extended_card_bin",+ "generic_card_bin"]},"BlocklistRequest": {@@ -10101,7 +10103,9 @@]},"data": {- "type": "string"+ "type": "string",+ "description": "Deprecated, use `generic_card_bin`. A card number prefix of exactly 6 digits.",+ "deprecated": true}}},@@ -10137,7 +10141,28 @@]},"data": {- "type": "string"+ "type": "string",+ "description": "Deprecated, use `generic_card_bin`. A card number prefix of exactly 8 digits.",+ "deprecated": true+ }+ }+ },+ {+ "type": "object",+ "required": [+ "type",+ "data"+ ],+ "properties": {+ "type": {+ "type": "string",+ "enum": [+ "generic_card_bin"+ ]+ },+ "data": {+ "type": "string",+ "description": "A card number prefix of 6 to 10 digits."}}}diff --git a/crates/api_models/src/blocklist.rs b/crates/api_models/src/blocklist.rsindex 5da7bf1da8..a355d18c0a 100644--- a/crates/api_models/src/blocklist.rs+++ b/crates/api_models/src/blocklist.rs@@ -9,9 +9,15 @@ const DEFAULT_BATCH_LIST_LIMIT: u8 = 10;#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]#[serde(rename_all = "snake_case", tag = "type", content = "data")]pub enum BlocklistRequest {+ /// Deprecated, use `generic_card_bin`. A card number prefix of exactly 6 digits.+ #[deprecated(note = "use GenericCardBin, which accepts 6 to 10 digits")]CardBin(String),Fingerprint(String),+ /// Deprecated, use `generic_card_bin`. A card number prefix of exactly 8 digits.+ #[deprecated(note = "use GenericCardBin, which accepts 6 to 10 digits")]ExtendedCardBin(String),+ /// A card number prefix of 6 to 10 digits.+ GenericCardBin(String),}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]diff --git a/crates/cards/src/validate.rs b/crates/cards/src/validate.rsindex f1e65d53da..d7df302d2b 100644--- a/crates/cards/src/validate.rs+++ b/crates/cards/src/validate.rs@@ -15,6 +15,13 @@ pub const MIN_CARD_NUMBER_LENGTH: usize = 8;/// Maximum limit of a card number will not exceed 19 by ISO standardspub const MAX_CARD_NUMBER_LENGTH: usize = 19;+/// Narrowest card number prefix that may be blocklisted+pub const MIN_CARD_BIN_LENGTH: usize = 6;++/// Widest card number prefix that may be blocklisted. Bounded well short of a full card number+/// because blocklist prefixes are stored in plaintext, unlike vault-hashed card numbers.+pub const MAX_CARD_BIN_LENGTH: usize = 10;+#[derive(Debug, Deserialize, Serialize, Error)]#[error("{0}")]pub struct CardNumberValidationErr(&'static str);@@ -28,12 +35,22 @@ pub struct CardNumber(StrongSecret<String, CardNumberStrategy>);pub struct NetworkToken(StrongSecret<String, CardNumberStrategy>);impl CardNumber {+ fn get_bin_prefix(&self, len: usize) -> String {+ self.0.peek().chars().take(len).collect::<String>()+ }+pub fn get_card_isin(&self) -> String {- self.0.peek().chars().take(6).collect::<String>()+ self.get_bin_prefix(6)}pub fn get_extended_card_bin(&self) -> String {- self.0.peek().chars().take(8).collect::<String>()+ self.get_bin_prefix(8)+ }++ pub fn get_blocklist_bin_prefixes(&self) -> Vec<String> {+ (MIN_CARD_BIN_LENGTH..=MAX_CARD_BIN_LENGTH)+ .map(|len| self.get_bin_prefix(len))+ .collect()}pub fn get_card_no(&self) -> String {self.0.peek().chars().collect::<String>()diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex c041f3be1d..d1d87a2977 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -669,6 +669,8 @@ impl PaymentResourceUpdateStatus {}}+/// `card_bin` (6 digits) and `extended_card_bin` (8 digits) are deprecated, use+/// `generic_card_bin`, which accepts 6 to 10 digits.#[derive(Clone,Copy,@@ -687,8 +689,11 @@ impl PaymentResourceUpdateStatus {#[strum(serialize_all = "snake_case")]pub enum BlocklistDataKind {PaymentMethod,+ /// Deprecated, superseded by `GenericCardBin`CardBin,+ /// Deprecated, superseded by `GenericCardBin`ExtendedCardBin,+ GenericCardBin,}#[derive(Debug)]diff --git a/crates/diesel_models/src/query/blocklist.rs b/crates/diesel_models/src/query/blocklist.rsindex 9e6b80ff93..3d906a9f02 100644--- a/crates/diesel_models/src/query/blocklist.rs+++ b/crates/diesel_models/src/query/blocklist.rs@@ -10,6 +10,21 @@ use crate::{DatabaseConnectionWithContext, StorageResult,};+/// The generic kind also matches the deprecated fixed-width kinds, so rows written before+/// `generic_card_bin` existed stay visible.+fn equivalent_data_kinds(+ data_kind: common_enums::BlocklistDataKind,+) -> Vec<common_enums::BlocklistDataKind> {+ match data_kind {+ common_enums::BlocklistDataKind::GenericCardBin => vec![+ common_enums::BlocklistDataKind::GenericCardBin,+ common_enums::BlocklistDataKind::CardBin,+ common_enums::BlocklistDataKind::ExtendedCardBin,+ ],+ other => vec![other],+ }+}+impl BlocklistNew {pub async fn insert(self,@@ -81,6 +96,29 @@ impl Blocklist {.await}+ pub async fn find_by_processor_merchant_id_profile_id_fingerprint_ids(+ conn: &DatabaseConnectionWithContext<'_>,+ processor_merchant_id: &common_utils::id_type::MerchantId,+ profile_id: &common_utils::id_type::ProfileId,+ fingerprint_ids: Vec<String>,+ ) -> StorageResult<Option<Self>> {+ generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(+ conn,+ dsl::processor_merchant_id+ .eq(processor_merchant_id.to_owned())+ .or(dsl::processor_merchant_id+ .is_null()+ .and(dsl::merchant_id.eq(processor_merchant_id.to_owned())))+ .and(dsl::fingerprint_id.eq_any(fingerprint_ids))+ .and(+ dsl::profile_id+ .eq(profile_id.to_owned())+ .or(dsl::profile_id.is_null()),+ ),+ )+ .await+ }+// Fallback function for stagger release - finds by merchant_id when processor_merchant_id is NULLpub async fn find_by_merchant_id_fingerprint_id(conn: &DatabaseConnectionWithContext<'_>,@@ -123,6 +161,7 @@ impl Blocklist {limit: i64,offset: i64,) -> StorageResult<Vec<Self>> {+ let data_kinds = equivalent_data_kinds(data_kind);generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(conn,dsl::processor_merchant_id@@ -130,7 +169,7 @@ impl Blocklist {.or(dsl::processor_merchant_id.is_null().and(dsl::merchant_id.eq(processor_merchant_id.to_owned())))- .and(dsl::data_kind.eq(data_kind.to_owned())),+ .and(dsl::data_kind.eq_any(data_kinds)),Some(limit),Some(offset),Some(dsl::created_at.desc()),@@ -146,6 +185,7 @@ impl Blocklist {limit: i64,offset: i64,) -> StorageResult<Vec<Self>> {+ let data_kinds = equivalent_data_kinds(data_kind);generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(conn,dsl::processor_merchant_id@@ -153,7 +193,7 @@ impl Blocklist {.or(dsl::processor_merchant_id.is_null().and(dsl::merchant_id.eq(processor_merchant_id.to_owned())))- .and(dsl::data_kind.eq(data_kind.to_owned()))+ .and(dsl::data_kind.eq_any(data_kinds)).and(dsl::profile_id.eq(profile_id.to_owned())@@ -171,6 +211,7 @@ impl Blocklist {processor_merchant_id: &common_utils::id_type::MerchantId,data_kind: common_enums::BlocklistDataKind,) -> StorageResult<usize> {+ let data_kinds = equivalent_data_kinds(data_kind);generics::generic_count::<<Self as HasTable>::Table, _>(conn,dsl::processor_merchant_id@@ -178,7 +219,7 @@ impl Blocklist {.or(dsl::processor_merchant_id.is_null().and(dsl::merchant_id.eq(processor_merchant_id.to_owned())))- .and(dsl::data_kind.eq(data_kind.to_owned())),+ .and(dsl::data_kind.eq_any(data_kinds)),).await}@@ -189,6 +230,7 @@ impl Blocklist {profile_id: &common_utils::id_type::ProfileId,data_kind: common_enums::BlocklistDataKind,) -> StorageResult<usize> {+ let data_kinds = equivalent_data_kinds(data_kind);generics::generic_count::<<Self as HasTable>::Table, _>(conn,dsl::processor_merchant_id@@ -196,7 +238,7 @@ impl Blocklist {.or(dsl::processor_merchant_id.is_null().and(dsl::merchant_id.eq(processor_merchant_id.to_owned())))- .and(dsl::data_kind.eq(data_kind.to_owned()))+ .and(dsl::data_kind.eq_any(data_kinds)).and(dsl::profile_id.eq(profile_id.to_owned())diff --git a/crates/openapi/src/routes/blocklist.rs b/crates/openapi/src/routes/blocklist.rsindex 6526e95198..71427ca8fe 100644--- a/crates/openapi/src/routes/blocklist.rs+++ b/crates/openapi/src/routes/blocklist.rs@@ -83,7 +83,7 @@ pub async fn list_blocked_payment_methods() {}content_type = "multipart/form-data",description = "A multipart/form-data request with a `file` field containing a UTF-8 CSV (max 5 MiB). \The CSV must have a header row: `type,data,metadata`. \- `type`: one of `card_bin` (6 digits), `extended_card_bin` (8 digits), `fingerprint`. \+ `type`: one of `generic_card_bin` (6 to 10 digits), `fingerprint`. \`metadata`: optional, `key=value` pairs separated by `;` (e.g. `reason=fraud;source=manual`). \Maximum 100,000 data rows.",),diff --git a/crates/router/src/core/blocklist/batch.rs b/crates/router/src/core/blocklist/batch.rsindex 6cca6f6920..c0dc8bc885 100644--- a/crates/router/src/core/blocklist/batch.rs+++ b/crates/router/src/core/blocklist/batch.rs@@ -88,6 +88,7 @@ impl BlocklistRow {match kind {"card_bin" => Some(common_enums::BlocklistDataKind::CardBin),"extended_card_bin" => Some(common_enums::BlocklistDataKind::ExtendedCardBin),+ "generic_card_bin" => Some(common_enums::BlocklistDataKind::GenericCardBin),"fingerprint" => Some(common_enums::BlocklistDataKind::PaymentMethod),_ => None,}@@ -106,7 +107,7 @@ impl BlocklistRow {common_enums::BlocklistDataKind::CardBin,data.clone(),format!(- "unknown type `{kind}`; expected card_bin, extended_card_bin, or fingerprint"+ "unknown type `{kind}`; expected generic_card_bin, card_bin, extended_card_bin, or fingerprint"),)})?;@@ -120,20 +121,16 @@ impl BlocklistRow {));}+ let is_invalid = super::utils::validate_bin(&data, parsed_kind).is_err();let format_error = match parsed_kind {common_enums::BlocklistDataKind::CardBin => {- if data.len() == 6 && data.chars().all(|c| c.is_ascii_digit()) {- None- } else {- Some("card_bin must be exactly 6 digits")- }+ is_invalid.then_some("card_bin must be exactly 6 digits")}common_enums::BlocklistDataKind::ExtendedCardBin => {- if data.len() == 8 && data.chars().all(|c| c.is_ascii_digit()) {- None- } else {- Some("extended_card_bin must be exactly 8 digits")- }+ is_invalid.then_some("extended_card_bin must be exactly 8 digits")+ }+ common_enums::BlocklistDataKind::GenericCardBin => {+ is_invalid.then_some("generic_card_bin must be a 6 to 10 digit number")}common_enums::BlocklistDataKind::PaymentMethod => None,};@@ -229,6 +226,7 @@ fn rows_to_csv_bytes(rows: &[BlocklistRow]) -> RouterResult<Vec<u8>> {let type_str = match row.data_kind {common_enums::BlocklistDataKind::CardBin => "card_bin",common_enums::BlocklistDataKind::ExtendedCardBin => "extended_card_bin",+ common_enums::BlocklistDataKind::GenericCardBin => "generic_card_bin",common_enums::BlocklistDataKind::PaymentMethod => "fingerprint",};writerdiff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rsindex 058b3bb7d9..879fab82c1 100644--- a/crates/router/src/core/blocklist/utils.rs+++ b/crates/router/src/core/blocklist/utils.rs@@ -41,15 +41,13 @@ pub async fn delete_entry_from_blocklist(.await?;let blocklist_entry = match request {- api_blocklist::DeleteFromBlocklistRequest::CardBin(bin) => {+ #[allow(deprecated)]+ api_blocklist::DeleteFromBlocklistRequest::CardBin(bin)+ | api_blocklist::DeleteFromBlocklistRequest::ExtendedCardBin(bin)+ | api_blocklist::DeleteFromBlocklistRequest::GenericCardBin(bin) => {delete_card_bin_blocklist_entry(state, &bin, processor_merchant_id, &profile_id).await?}- api_blocklist::DeleteFromBlocklistRequest::ExtendedCardBin(xbin) => {- delete_card_bin_blocklist_entry(state, &xbin, processor_merchant_id, &profile_id)- .await?- }-api_blocklist::DeleteFromBlocklistRequest::Fingerprint(fingerprint_id) => state.store.delete_blocklist_entry_by_processor_merchant_id_profile_id_fingerprint_id(@@ -152,28 +150,32 @@ pub async fn list_blocklist_entries_for_merchant(})}-fn validate_card_bin(bin: &str) -> RouterResult<()> {- if bin.len() == 6 && bin.chars().all(|c| c.is_ascii_digit()) {- Ok(())- } else {- Err(errors::ApiErrorResponse::InvalidDataFormat {- field_name: "data".to_string(),- expected_format: "a 6 digit number".to_string(),- }- .into())- }-}+pub(super) fn validate_bin(+ bin: &str,+ data_kind: common_enums::BlocklistDataKind,+) -> RouterResult<()> {+ let expected = match data_kind {+ common_enums::BlocklistDataKind::CardBin => Some((6..=6, "a 6 digit number")),+ common_enums::BlocklistDataKind::ExtendedCardBin => Some((8..=8, "an 8 digit number")),+ common_enums::BlocklistDataKind::GenericCardBin => Some((+ cards::validate::MIN_CARD_BIN_LENGTH..=cards::validate::MAX_CARD_BIN_LENGTH,+ "a 6 to 10 digit number",+ )),+ // A fingerprint is an opaque hash, it has no digit format to enforce.+ common_enums::BlocklistDataKind::PaymentMethod => None,+ };-fn validate_extended_card_bin(bin: &str) -> RouterResult<()> {- if bin.len() == 8 && bin.chars().all(|c| c.is_ascii_digit()) {- Ok(())- } else {- Err(errors::ApiErrorResponse::InvalidDataFormat {- field_name: "data".to_string(),- expected_format: "an 8 digit number".to_string(),- }- .into())- }+ expected.map_or(Ok(()), |(lengths, expected_format)| {+ (lengths.contains(&bin.len()) && cards::validate::validate_card_number_chars(bin).is_ok())+ .then_some(())+ .ok_or_else(|| {+ errors::ApiErrorResponse::InvalidDataFormat {+ field_name: "data".to_string(),+ expected_format: expected_format.to_string(),+ }+ .into()+ })+ })}pub async fn insert_entry_into_blocklist(@@ -194,8 +196,9 @@ pub async fn insert_entry_into_blocklist(.await?;let blocklist_entry = match &to_block {+ #[allow(deprecated)]api_blocklist::AddToBlocklistRequest::CardBin(bin) => {- validate_card_bin(bin)?;+ validate_bin(bin, common_enums::BlocklistDataKind::CardBin)?;duplicate_check_insert_bin(bin,state,@@ -206,8 +209,9 @@ pub async fn insert_entry_into_blocklist(.await?}+ #[allow(deprecated)]api_blocklist::AddToBlocklistRequest::ExtendedCardBin(bin) => {- validate_extended_card_bin(bin)?;+ validate_bin(bin, common_enums::BlocklistDataKind::ExtendedCardBin)?;duplicate_check_insert_bin(bin,state,@@ -218,6 +222,18 @@ pub async fn insert_entry_into_blocklist(.await?}+ api_blocklist::AddToBlocklistRequest::GenericCardBin(bin) => {+ validate_bin(bin, common_enums::BlocklistDataKind::GenericCardBin)?;+ duplicate_check_insert_bin(+ bin,+ state,+ platform,+ &profile_id,+ common_enums::BlocklistDataKind::GenericCardBin,+ )+ .await?+ }+api_blocklist::AddToBlocklistRequest::Fingerprint(fingerprint_id) => {let blocklist_entry_result = state.store@@ -422,26 +438,14 @@ pub async fn should_payment_be_blocked(None};- // Hashed Cardbin to check whether or not this payment should be blocked.- let card_bin_fingerprint = payment_method_data+ let card_bin_prefixes = payment_method_data.as_ref().and_then(|pm_data| match pm_data {- domain::EligibilityPaymentMethodData::Card(card) => {- Some(card.card_number.get_card_isin())- }+ domain::EligibilityPaymentMethodData::Card(card) => Some(&card.card_number),_ => None,- });-- // Hashed Extended Cardbin to check whether or not this payment should be blocked.- let extended_card_bin_fingerprint =- payment_method_data- .as_ref()- .and_then(|pm_data| match pm_data {- domain::EligibilityPaymentMethodData::Card(card) => {- Some(card.card_number.get_extended_card_bin())- }- _ => None,- });+ })+ .map(cards::CardNumber::get_blocklist_bin_prefixes)+ .unwrap_or_default();// Extended bin of the wallet's decrypted token, to check whether or not this payment should be blocked.let decrypted_token_extended_bin = payment_method_data@@ -449,56 +453,25 @@ pub async fn should_payment_be_blocked(.and_then(|pm_data| pm_data.get_decrypted_token_extended_bin());//validating the payment method.- let mut blocklist_futures = Vec::new();let profile_id = business_profile.get_id();+ let fingerprint_ids = card_number_fingerprint+ .into_iter()+ .chain(card_bin_prefixes)+ .chain(decrypted_token_extended_bin)+ .collect::<Vec<_>>();- if let Some(card_number_fingerprint) = card_number_fingerprint.as_ref() {- blocklist_futures.push(- db.find_blocklist_entry_by_processor_merchant_id_profile_id_fingerprint_id(- processor_merchant_id,- profile_id,- card_number_fingerprint,- ),- );- }-- if let Some(card_bin_fingerprint) = card_bin_fingerprint.as_ref() {- blocklist_futures.push(- db.find_blocklist_entry_by_processor_merchant_id_profile_id_fingerprint_id(- processor_merchant_id,- profile_id,- card_bin_fingerprint,- ),- );- }-- if let Some(extended_card_bin_fingerprint) = extended_card_bin_fingerprint.as_ref() {- blocklist_futures.push(- db.find_blocklist_entry_by_processor_merchant_id_profile_id_fingerprint_id(- processor_merchant_id,- profile_id,- extended_card_bin_fingerprint,- ),- );- }-- if let Some(decrypted_token_extended_bin) = decrypted_token_extended_bin.as_ref() {- blocklist_futures.push(- db.find_blocklist_entry_by_processor_merchant_id_profile_id_fingerprint_id(+ let mut block_reason: Option<BlockReason> = None;+ if !fingerprint_ids.is_empty() {+ match db+ .find_blocklist_entries_by_processor_merchant_id_profile_id_fingerprint_ids(processor_merchant_id,profile_id,- decrypted_token_extended_bin,- ),- );- }-- let blocklist_lookups = futures::future::join_all(blocklist_futures).await;-- let mut block_reason: Option<BlockReason> = None;- for lookup in blocklist_lookups {- match lookup {- Ok(_) => {- block_reason = Some(BlockReason::BlockedBin);+ fingerprint_ids,+ )+ .await+ {+ Ok(entry) => {+ block_reason = entry.is_some().then_some(BlockReason::BlockedBin);}Err(e) => {logger::error!(blocklist_db_error=?e, "failed db operations for blocklist");diff --git a/crates/router/src/db/blocklist.rs b/crates/router/src/db/blocklist.rsindex 5442dd309c..a843310a7f 100644--- a/crates/router/src/db/blocklist.rs+++ b/crates/router/src/db/blocklist.rs@@ -30,6 +30,13 @@ pub trait BlocklistInterface {fingerprint_id: &str,) -> CustomResult<storage::Blocklist, errors::StorageError>;+ async fn find_blocklist_entries_by_processor_merchant_id_profile_id_fingerprint_ids(+ &self,+ processor_merchant_id: &common_utils::id_type::MerchantId,+ profile_id: &common_utils::id_type::ProfileId,+ fingerprint_ids: Vec<String>,+ ) -> CustomResult<Option<storage::Blocklist>, errors::StorageError>;+async fn delete_blocklist_entry_by_processor_merchant_id_fingerprint_id(&self,processor_merchant_id: &common_utils::id_type::MerchantId,@@ -180,6 +187,24 @@ impl BlocklistInterface for Store {}}+ #[instrument(skip_all)]+ async fn find_blocklist_entries_by_processor_merchant_id_profile_id_fingerprint_ids(+ &self,+ processor_merchant_id: &common_utils::id_type::MerchantId,+ profile_id: &common_utils::id_type::ProfileId,+ fingerprint_ids: Vec<String>,+ ) -> CustomResult<Option<storage::Blocklist>, errors::StorageError> {+ let conn = connection::pg_connection_read(self).await?;+ storage::Blocklist::find_by_processor_merchant_id_profile_id_fingerprint_ids(+ &conn,+ processor_merchant_id,+ profile_id,+ fingerprint_ids,+ )+ .await+ .map_err(|error| report!(errors::StorageError::from(error)))+ }+#[instrument(skip_all)]async fn list_blocklist_entries_by_processor_merchant_id(&self,@@ -415,6 +440,15 @@ impl BlocklistInterface for MockDb {Err(errors::StorageError::MockDbError)?}+ async fn find_blocklist_entries_by_processor_merchant_id_profile_id_fingerprint_ids(+ &self,+ _processor_merchant_id: &common_utils::id_type::MerchantId,+ _profile_id: &common_utils::id_type::ProfileId,+ _fingerprint_ids: Vec<String>,+ ) -> CustomResult<Option<storage::Blocklist>, errors::StorageError> {+ Err(errors::StorageError::MockDbError)?+ }+async fn list_blocklist_entries_by_processor_merchant_id(&self,_processor_merchant_id: &common_utils::id_type::MerchantId,@@ -547,6 +581,22 @@ impl BlocklistInterface for KafkaStore {.await}+ #[instrument(skip_all)]+ async fn find_blocklist_entries_by_processor_merchant_id_profile_id_fingerprint_ids(+ &self,+ processor_merchant_id: &common_utils::id_type::MerchantId,+ profile_id: &common_utils::id_type::ProfileId,+ fingerprint_ids: Vec<String>,+ ) -> CustomResult<Option<storage::Blocklist>, errors::StorageError> {+ self.diesel_store+ .find_blocklist_entries_by_processor_merchant_id_profile_id_fingerprint_ids(+ processor_merchant_id,+ profile_id,+ fingerprint_ids,+ )+ .await+ }+#[instrument(skip_all)]async fn delete_blocklist_entry_by_processor_merchant_id_fingerprint_id(&self,diff --git a/migrations/2026-08-28-120000_add_generic_card_bin_to_blocklist_data_kind/down.sql b/migrations/2026-08-28-120000_add_generic_card_bin_to_blocklist_data_kind/down.sqlnew file mode 100644index 0000000000..f88262ebf4--- /dev/null+++ b/migrations/2026-08-28-120000_add_generic_card_bin_to_blocklist_data_kind/down.sql@@ -0,0 +1,3 @@+-- Postgres does not support removing a value from an enum type without+-- recreating it; this is a no-op to keep the migration reversible in form.+SELECT 1;diff --git a/migrations/2026-08-28-120000_add_generic_card_bin_to_blocklist_data_kind/up.sql b/migrations/2026-08-28-120000_add_generic_card_bin_to_blocklist_data_kind/up.sqlnew file mode 100644index 0000000000..dc332e502b--- /dev/null+++ b/migrations/2026-08-28-120000_add_generic_card_bin_to_blocklist_data_kind/up.sql@@ -0,0 +1,2 @@+-- Add the `generic_card_bin` blocklist kind, a card number prefix of 6 to 10 digits.+ALTER TYPE "BlocklistDataKind" ADD VALUE IF NOT EXISTS 'generic_card_bin';