Skip to content

Commit 2451e9b

Browse files
Debarshi-GuptaDebarshi Guptahyperswitch-bot[bot]
authored
feat(core): [Card Testing Guard] Implement Card Testing Guard (#7108)
Co-authored-by: Debarshi Gupta <[email protected]> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 7eccebc commit 2451e9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1159
-8
lines changed

api-reference-v2/openapi_spec.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7096,6 +7096,56 @@
70967096
}
70977097
}
70987098
},
7099+
"CardTestingGuardConfig": {
7100+
"type": "object",
7101+
"required": [
7102+
"card_ip_blocking_status",
7103+
"card_ip_blocking_threshold",
7104+
"guest_user_card_blocking_status",
7105+
"guest_user_card_blocking_threshold",
7106+
"customer_id_blocking_status",
7107+
"customer_id_blocking_threshold",
7108+
"card_testing_guard_expiry"
7109+
],
7110+
"properties": {
7111+
"card_ip_blocking_status": {
7112+
"$ref": "#/components/schemas/CardTestingGuardStatus"
7113+
},
7114+
"card_ip_blocking_threshold": {
7115+
"type": "integer",
7116+
"format": "int32",
7117+
"description": "Determines the unsuccessful payment threshold for Card IP Blocking for profile"
7118+
},
7119+
"guest_user_card_blocking_status": {
7120+
"$ref": "#/components/schemas/CardTestingGuardStatus"
7121+
},
7122+
"guest_user_card_blocking_threshold": {
7123+
"type": "integer",
7124+
"format": "int32",
7125+
"description": "Determines the unsuccessful payment threshold for Guest User Card Blocking for profile"
7126+
},
7127+
"customer_id_blocking_status": {
7128+
"$ref": "#/components/schemas/CardTestingGuardStatus"
7129+
},
7130+
"customer_id_blocking_threshold": {
7131+
"type": "integer",
7132+
"format": "int32",
7133+
"description": "Determines the unsuccessful payment threshold for Customer Id Blocking for profile"
7134+
},
7135+
"card_testing_guard_expiry": {
7136+
"type": "integer",
7137+
"format": "int32",
7138+
"description": "Determines Redis Expiry for Card Testing Guard for profile"
7139+
}
7140+
}
7141+
},
7142+
"CardTestingGuardStatus": {
7143+
"type": "string",
7144+
"enum": [
7145+
"enabled",
7146+
"disabled"
7147+
]
7148+
},
70997149
"CardToken": {
71007150
"type": "object",
71017151
"required": [
@@ -18592,6 +18642,14 @@
1859218642
"type": "object",
1859318643
"description": "Product authentication ids",
1859418644
"nullable": true
18645+
},
18646+
"card_testing_guard_config": {
18647+
"allOf": [
18648+
{
18649+
"$ref": "#/components/schemas/CardTestingGuardConfig"
18650+
}
18651+
],
18652+
"nullable": true
1859518653
}
1859618654
},
1859718655
"additionalProperties": false
@@ -18816,6 +18874,14 @@
1881618874
"type": "object",
1881718875
"description": "Product authentication ids",
1881818876
"nullable": true
18877+
},
18878+
"card_testing_guard_config": {
18879+
"allOf": [
18880+
{
18881+
"$ref": "#/components/schemas/CardTestingGuardConfig"
18882+
}
18883+
],
18884+
"nullable": true
1881918885
}
1882018886
}
1882118887
},

api-reference/openapi_spec.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9329,6 +9329,56 @@
93299329
}
93309330
}
93319331
},
9332+
"CardTestingGuardConfig": {
9333+
"type": "object",
9334+
"required": [
9335+
"card_ip_blocking_status",
9336+
"card_ip_blocking_threshold",
9337+
"guest_user_card_blocking_status",
9338+
"guest_user_card_blocking_threshold",
9339+
"customer_id_blocking_status",
9340+
"customer_id_blocking_threshold",
9341+
"card_testing_guard_expiry"
9342+
],
9343+
"properties": {
9344+
"card_ip_blocking_status": {
9345+
"$ref": "#/components/schemas/CardTestingGuardStatus"
9346+
},
9347+
"card_ip_blocking_threshold": {
9348+
"type": "integer",
9349+
"format": "int32",
9350+
"description": "Determines the unsuccessful payment threshold for Card IP Blocking for profile"
9351+
},
9352+
"guest_user_card_blocking_status": {
9353+
"$ref": "#/components/schemas/CardTestingGuardStatus"
9354+
},
9355+
"guest_user_card_blocking_threshold": {
9356+
"type": "integer",
9357+
"format": "int32",
9358+
"description": "Determines the unsuccessful payment threshold for Guest User Card Blocking for profile"
9359+
},
9360+
"customer_id_blocking_status": {
9361+
"$ref": "#/components/schemas/CardTestingGuardStatus"
9362+
},
9363+
"customer_id_blocking_threshold": {
9364+
"type": "integer",
9365+
"format": "int32",
9366+
"description": "Determines the unsuccessful payment threshold for Customer Id Blocking for profile"
9367+
},
9368+
"card_testing_guard_expiry": {
9369+
"type": "integer",
9370+
"format": "int32",
9371+
"description": "Determines Redis Expiry for Card Testing Guard for profile"
9372+
}
9373+
}
9374+
},
9375+
"CardTestingGuardStatus": {
9376+
"type": "string",
9377+
"enum": [
9378+
"enabled",
9379+
"disabled"
9380+
]
9381+
},
93329382
"CardToken": {
93339383
"type": "object",
93349384
"required": [
@@ -23049,6 +23099,14 @@
2304923099
"type": "object",
2305023100
"description": "Product authentication ids",
2305123101
"nullable": true
23102+
},
23103+
"card_testing_guard_config": {
23104+
"allOf": [
23105+
{
23106+
"$ref": "#/components/schemas/CardTestingGuardConfig"
23107+
}
23108+
],
23109+
"nullable": true
2305223110
}
2305323111
},
2305423112
"additionalProperties": false
@@ -23295,6 +23353,14 @@
2329523353
"type": "object",
2329623354
"description": "Product authentication ids",
2329723355
"nullable": true
23356+
},
23357+
"card_testing_guard_config": {
23358+
"allOf": [
23359+
{
23360+
"$ref": "#/components/schemas/CardTestingGuardConfig"
23361+
}
23362+
],
23363+
"nullable": true
2329823364
}
2329923365
}
2330023366
},

crates/api_models/src/admin.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,31 @@ impl MerchantAccountCreate {
238238
}
239239
}
240240

241+
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
242+
pub struct CardTestingGuardConfig {
243+
/// Determines if Card IP Blocking is enabled for profile
244+
pub card_ip_blocking_status: CardTestingGuardStatus,
245+
/// Determines the unsuccessful payment threshold for Card IP Blocking for profile
246+
pub card_ip_blocking_threshold: i32,
247+
/// Determines if Guest User Card Blocking is enabled for profile
248+
pub guest_user_card_blocking_status: CardTestingGuardStatus,
249+
/// Determines the unsuccessful payment threshold for Guest User Card Blocking for profile
250+
pub guest_user_card_blocking_threshold: i32,
251+
/// Determines if Customer Id Blocking is enabled for profile
252+
pub customer_id_blocking_status: CardTestingGuardStatus,
253+
/// Determines the unsuccessful payment threshold for Customer Id Blocking for profile
254+
pub customer_id_blocking_threshold: i32,
255+
/// Determines Redis Expiry for Card Testing Guard for profile
256+
pub card_testing_guard_expiry: i32,
257+
}
258+
259+
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
260+
#[serde(rename_all = "snake_case")]
261+
pub enum CardTestingGuardStatus {
262+
Enabled,
263+
Disabled,
264+
}
265+
241266
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema)]
242267
pub struct AuthenticationConnectorDetails {
243268
/// List of authentication connectors
@@ -1912,6 +1937,9 @@ pub struct ProfileCreate {
19121937
#[schema(value_type = Option<Object>, example = r#"{ "click_to_pay": "mca_ushduqwhdohwd", "netcetera": "mca_kwqhudqwd" }"#)]
19131938
pub authentication_product_ids:
19141939
Option<common_types::payments::AuthenticationConnectorAccountMap>,
1940+
1941+
/// Card Testing Guard Configs
1942+
pub card_testing_guard_config: Option<CardTestingGuardConfig>,
19151943
}
19161944

19171945
#[nutype::nutype(
@@ -2030,6 +2058,9 @@ pub struct ProfileCreate {
20302058
#[schema(value_type = Option<Object>, example = r#"{ "click_to_pay": "mca_ushduqwhdohwd", "netcetera": "mca_kwqhudqwd" }"#)]
20312059
pub authentication_product_ids:
20322060
Option<common_types::payments::AuthenticationConnectorAccountMap>,
2061+
2062+
/// Card Testing Guard Configs
2063+
pub card_testing_guard_config: Option<CardTestingGuardConfig>,
20332064
}
20342065

20352066
#[cfg(feature = "v1")]
@@ -2171,6 +2202,9 @@ pub struct ProfileResponse {
21712202
#[schema(value_type = Option<Object>, example = r#"{ "click_to_pay": "mca_ushduqwhdohwd", "netcetera": "mca_kwqhudqwd" }"#)]
21722203
pub authentication_product_ids:
21732204
Option<common_types::payments::AuthenticationConnectorAccountMap>,
2205+
2206+
/// Card Testing Guard Configs
2207+
pub card_testing_guard_config: Option<CardTestingGuardConfig>,
21742208
}
21752209

21762210
#[cfg(feature = "v2")]
@@ -2295,6 +2329,9 @@ pub struct ProfileResponse {
22952329
#[schema(value_type = Option<Object>, example = r#"{ "click_to_pay": "mca_ushduqwhdohwd", "netcetera": "mca_kwqhudqwd" }"#)]
22962330
pub authentication_product_ids:
22972331
Option<common_types::payments::AuthenticationConnectorAccountMap>,
2332+
2333+
/// Card Testing Guard Configs
2334+
pub card_testing_guard_config: Option<CardTestingGuardConfig>,
22982335
}
22992336

23002337
#[cfg(feature = "v1")]
@@ -2426,6 +2463,9 @@ pub struct ProfileUpdate {
24262463
#[schema(value_type = Option<Object>, example = r#"{ "click_to_pay": "mca_ushduqwhdohwd", "netcetera": "mca_kwqhudqwd" }"#)]
24272464
pub authentication_product_ids:
24282465
Option<common_types::payments::AuthenticationConnectorAccountMap>,
2466+
2467+
/// Card Testing Guard Configs
2468+
pub card_testing_guard_config: Option<CardTestingGuardConfig>,
24292469
}
24302470

24312471
#[cfg(feature = "v2")]
@@ -2538,6 +2578,9 @@ pub struct ProfileUpdate {
25382578
#[schema(value_type = Option<Object>, example = r#"{ "click_to_pay": "mca_ushduqwhdohwd", "netcetera": "mca_kwqhudqwd" }"#)]
25392579
pub authentication_product_ids:
25402580
Option<common_types::payments::AuthenticationConnectorAccountMap>,
2581+
2582+
/// Card Testing Guard Configs
2583+
pub card_testing_guard_config: Option<CardTestingGuardConfig>,
25412584
}
25422585

25432586
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]

crates/common_utils/src/consts.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,24 @@ pub const X_REQUEST_ID: &str = "x-request-id";
152152

153153
/// Default Tenant ID for the `Global` tenant
154154
pub const DEFAULT_GLOBAL_TENANT_ID: &str = "global";
155+
156+
/// Default status of Card IP Blocking
157+
pub const DEFAULT_CARD_IP_BLOCKING_STATUS: bool = false;
158+
159+
/// Default Threshold for Card IP Blocking
160+
pub const DEFAULT_CARD_IP_BLOCKING_THRESHOLD: i32 = 3;
161+
162+
/// Default status of Guest User Card Blocking
163+
pub const DEFAULT_GUEST_USER_CARD_BLOCKING_STATUS: bool = false;
164+
165+
/// Default Threshold for Card Blocking for Guest Users
166+
pub const DEFAULT_GUEST_USER_CARD_BLOCKING_THRESHOLD: i32 = 10;
167+
168+
/// Default status of Customer ID Blocking
169+
pub const DEFAULT_CUSTOMER_ID_BLOCKING_STATUS: bool = false;
170+
171+
/// Default Threshold for Customer ID Blocking
172+
pub const DEFAULT_CUSTOMER_ID_BLOCKING_THRESHOLD: i32 = 5;
173+
174+
/// Default Card Testing Guard Redis Expiry in seconds
175+
pub const DEFAULT_CARD_TESTING_GUARD_EXPIRY_IN_SECS: i32 = 3600;

0 commit comments

Comments
 (0)