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

feat(card): extend card-bin-blocking config with networks, funding, segment types, and per-wallet rules (#13437)

Ayush Anand62901afa3171
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index b0c8813607..ea5a91ded5 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -15614,6 +15614,45 @@
"type": "boolean",
"description": "Whether to block if BIN is provided but no matching record found in cards_info table.\nDefaults to false (allow payment if BIN not found in database).",
"nullable": true
+ },
+ "card_networks": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CardNetwork"
+ },
+ "description": "Set of card networks to block",
+ "nullable": true
+ },
+ "funding_sources": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/FundingSource"
+ },
+ "description": "Set of card funding sources to block",
+ "nullable": true
+ },
+ "card_segment_types": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CardSegmentType"
+ },
+ "description": "Set of card segment types to block",
+ "nullable": true
+ },
+ "block_virtual_cards": {
+ "type": "boolean",
+ "description": "Whether virtual cards should be blocked",
+ "nullable": true
+ },
+ "block_non_reloadable_prepaid_cards": {
+ "type": "boolean",
+ "description": "Whether non-reloadable prepaid cards should be blocked",
+ "nullable": true
+ },
+ "gambling_blocked": {
+ "type": "boolean",
+ "description": "Whether cards from BINs marked for gambling should be blocked",
+ "nullable": true
}
}
},
@@ -16224,6 +16263,15 @@
}
}
},
+ "CardSegmentType": {
+ "type": "string",
+ "enum": [
+ "business",
+ "commercial",
+ "consumer",
+ "government"
+ ]
+ },
"CardSpecificFeatures": {
"type": "object",
"required": [
@@ -22362,6 +22410,16 @@
"post"
]
},
+ "FundingSource": {
+ "type": "string",
+ "enum": [
+ "CREDIT",
+ "DEBIT",
+ "DEFERRED DEBIT",
+ "PREPAID",
+ "CHARGE CARD"
+ ]
+ },
"FutureUsage": {
"type": "string",
"description": "Specifies how the payment method can be used for future payments.\n- `off_session`: The payment method can be used for future payments when the customer is not present.\n- `on_session`: The payment method is intended for use only when the customer is present during checkout.\nIf omitted, defaults to `on_session`.",
@@ -45296,7 +45354,23 @@
"items": {
"$ref": "#/components/schemas/CardType"
},
- "description": "Set of card types to block for wallet payments (e.g., [\"Credit\", \"Debit\"])",
+ "description": "Set of card types to block for all wallet payments (e.g., [\"Credit\", \"Debit\"]).\nRetained for backwards compatibility with existing configurations.",
+ "nullable": true
+ },
+ "apple_pay": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CardBlockingConfig"
+ }
+ ],
+ "nullable": true
+ },
+ "google_pay": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CardBlockingConfig"
+ }
+ ],
"nullable": true
}
}
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index 66d723ad9d..73478b76b8 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -334,14 +334,34 @@ pub struct CardBlockingConfig {
/// Whether to block if BIN is provided but no matching record found in cards_info table.
/// Defaults to false (allow payment if BIN not found in database).
pub block_if_bin_info_unavailable: Option<bool>,
+ /// Set of card networks to block
+ #[schema(value_type = Option<Vec<CardNetwork>>)]
+ pub card_networks: Option<HashSet<common_enums::CardNetwork>>,
+ /// Set of card funding sources to block
+ #[schema(value_type = Option<Vec<FundingSource>>)]
+ pub funding_sources: Option<HashSet<common_enums::FundingSource>>,
+ /// Set of card segment types to block
+ #[schema(value_type = Option<Vec<CardSegmentType>>)]
+ pub card_segment_types: Option<HashSet<common_enums::CardSegmentType>>,
+ /// Whether virtual cards should be blocked
+ pub block_virtual_cards: Option<bool>,
+ /// Whether non-reloadable prepaid cards should be blocked
+ pub block_non_reloadable_prepaid_cards: Option<bool>,
+ /// Whether cards from BINs marked for gambling should be blocked
+ pub gambling_blocked: Option<bool>,
}
/// Wallet-specific blocking configuration for Apple Pay and Google Pay
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
pub struct WalletBlockingConfig {
- /// Set of card types to block for wallet payments (e.g., ["Credit", "Debit"])
+ /// Set of card types to block for all wallet payments (e.g., ["Credit", "Debit"]).
+ /// Retained for backwards compatibility with existing configurations.
#[schema(value_type = Option<Vec<CardType>>)]
pub card_types: Option<HashSet<common_enums::CardType>>,
+ /// Apple Pay-specific blocking configuration
+ pub apple_pay: Option<CardBlockingConfig>,
+ /// Google Pay-specific blocking configuration
+ pub google_pay: Option<CardBlockingConfig>,
}
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index aa3559dcf4..6761571959 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -3391,6 +3391,29 @@ pub enum FundingSource {
ChargeCard,
}
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumIter,
+ strum::EnumString,
+ utoipa::ToSchema,
+)]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "UPPERCASE")]
+pub enum CardSegmentType {
+ Business,
+ Commercial,
+ Consumer,
+ Government,
+}
+
#[derive(
Clone,
Debug,
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rs
index 7de95d96a2..3f66690a3b 100644
--- a/crates/diesel_models/src/business_profile.rs
+++ b/crates/diesel_models/src/business_profile.rs
@@ -694,13 +694,30 @@ pub struct CardBlockingConfig {
/// Whether to block if BIN is provided but no matching record found in cards_info table.
/// Defaults to false (allow payment if BIN not found in database).
pub block_if_bin_info_unavailable: Option<bool>,
+ /// Set of card networks to block
+ pub card_networks: Option<HashSet<common_enums::CardNetwork>>,
+ /// Set of card funding sources to block
+ pub funding_sources: Option<HashSet<common_enums::FundingSource>>,
+ /// Set of card segment types to block
+ pub card_segment_types: Option<HashSet<common_enums::CardSegmentType>>,
+ /// Whether virtual cards should be blocked
+ pub block_virtual_cards: Option<bool>,
+ /// Whether non-reloadable prepaid cards should be blocked
+ pub block_non_reloadable_prepaid_cards: Option<bool>,
+ /// Whether cards from BINs marked for gambling should be blocked
+ pub gambling_blocked: Option<bool>,
}
/// Wallet-specific blocking configuration for Apple Pay and Google Pay
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct WalletBlockingConfig {
- /// Set of card types to block (e.g., ["Credit", "Debit"])
+ /// Set of card types to block for all wallet payments (e.g., ["Credit", "Debit"]).
+ /// Retained for backwards compatibility with existing configurations.
pub card_types: Option<HashSet<common_enums::CardType>>,
+ /// Apple Pay-specific blocking configuration
+ pub apple_pay: Option<CardBlockingConfig>,
+ /// Google Pay-specific blocking configuration
+ pub google_pay: Option<CardBlockingConfig>,
}
impl WalletBlockingConfig {
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 487fccf73b..9a340e45ff 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -384,6 +384,8 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::admin::PaymentMethodBlockingConfig,
api_models::admin::CardBlockingConfig,
api_models::admin::WalletBlockingConfig,
+ api_models::enums::CardSegmentType,
+ api_models::enums::FundingSource,
api_models::admin::SurchargeConnectorDetails,
api_models::merchant_connector_webhook_management::ConnectorWebhookRegisterRequest,
api_models::merchant_connector_webhook_management::WebhookSecretErrorDetails,
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 009b7ffbf1..b5bbf19cd6 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -651,9 +651,14 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {
let mut domain_merchant_account = domain::MerchantAccount::from(merchant_account);
- CreateProfile::new(self.primary_business_details.clone())
- .create_profiles(state, &mut domain_merchant_account, &key_store)
- .await?;
+ Box::pin(
+ CreateProfile::new(self.primary_business_details.clone()).create_profiles(
+ state,
+ &mut domain_merchant_account,
+ &key_store,
+ ),
+ )
+ .await?;
Ok(domain_merchant_account)
}
@@ -774,12 +779,12 @@ impl CreateProfile {
Self::CreateFromPrimaryBusinessDetails {
primary_business_details,
} => {
- let business_profiles = Self::create_profiles_for_each_business_details(
+ let business_profiles = Box::pin(Self::create_profiles_for_each_business_details(
state,
merchant_account.clone(),
primary_business_details,
key_store,
- )
+ ))
.await?;
// Update the default business profile in merchant account
@@ -790,9 +795,12 @@ impl CreateProfile {
}
}
Self::CreateDefaultProfile => {
- let business_profile = self
- .create_default_business_profile(state, merchant_account.clone(), key_store)
- .await?;
+ let business_profile = Box::pin(self.create_default_business_profile(
+ state,
+ merchant_account.clone(),
+ key_store,
+ ))
+ .await?;
merchant_account.default_profile = Some(business_profile.get_id().to_owned());
}
@@ -1190,13 +1198,13 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {
self.primary_business_details
.clone()
.async_map(|primary_business_details| async {
- let _ = create_profile_from_business_labels(
+ let _ = Box::pin(create_profile_from_business_labels(
state,
db,
key_store,
merchant_id,
primary_business_details,
- )
+ ))
.await;
})
.await;
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 8ab2827ddb..8b21990544 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -2456,6 +2456,12 @@ impl ForeignFrom<api_models::admin::CardBlockingConfig>
card_subtypes: item.card_subtypes,
issuers: item.issuers,
block_if_bin_info_unavailable: item.block_if_bin_info_unavailable,
+ card_networks: item.card_networks,
+ funding_sources: item.funding_sources,
+ card_segment_types: item.card_segment_types,
+ block_virtual_cards: item.block_virtual_cards,
+ block_non_reloadable_prepaid_cards: item.block_non_reloadable_prepaid_cards,
+ gambling_blocked: item.gambling_blocked,
}
}
}
@@ -2466,6 +2472,8 @@ impl ForeignFrom<api_models::admin::WalletBlockingConfig>
fn foreign_from(item: api_models::admin::WalletBlockingConfig) -> Self {
Self {
card_types: item.card_types,
+ apple_pay: item.apple_pay.map(|config| config.foreign_into()),
+ google_pay: item.google_pay.map(|config| config.foreign_into()),
}
}
}
@@ -2491,6 +2499,12 @@ impl ForeignFrom<diesel_models::business_profile::CardBlockingConfig>
card_subtypes: item.card_subtypes,
issuers: item.issuers,
block_if_bin_info_unavailable: item.block_if_bin_info_unavailable,
+ card_networks: item.card_networks,
+ funding_sources: item.funding_sources,
+ card_segment_types: item.card_segment_types,
+ block_virtual_cards: item.block_virtual_cards,
+ block_non_reloadable_prepaid_cards: item.block_non_reloadable_prepaid_cards,
+ gambling_blocked: item.gambling_blocked,
}
}
}
@@ -2501,6 +2515,8 @@ impl ForeignFrom<diesel_models::business_profile::WalletBlockingConfig>
fn foreign_from(item: diesel_models::business_profile::WalletBlockingConfig) -> Self {
Self {
card_types: item.card_types,
+ apple_pay: item.apple_pay.map(|config| config.foreign_into()),
+ google_pay: item.google_pay.map(|config| config.foreign_into()),
}
}
}