mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
fix(core): [CARD TESTING GUARD] Added Card Testing Guard Config response in case of NULL (#7478)
Co-authored-by: Debarshi Gupta <debarshi.gupta@Debarshi-Gupta-CM92YWDXFD.local> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: debarshi.gupta <debarshi.gupta@juspay.in>
This commit is contained in:
@ -641,6 +641,25 @@ pub struct CardTestingGuardConfig {
|
|||||||
|
|
||||||
common_utils::impl_to_sql_from_sql_json!(CardTestingGuardConfig);
|
common_utils::impl_to_sql_from_sql_json!(CardTestingGuardConfig);
|
||||||
|
|
||||||
|
impl Default for CardTestingGuardConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
is_card_ip_blocking_enabled: common_utils::consts::DEFAULT_CARD_IP_BLOCKING_STATUS,
|
||||||
|
card_ip_blocking_threshold: common_utils::consts::DEFAULT_CARD_IP_BLOCKING_THRESHOLD,
|
||||||
|
is_guest_user_card_blocking_enabled:
|
||||||
|
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_STATUS,
|
||||||
|
guest_user_card_blocking_threshold:
|
||||||
|
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_THRESHOLD,
|
||||||
|
is_customer_id_blocking_enabled:
|
||||||
|
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_STATUS,
|
||||||
|
customer_id_blocking_threshold:
|
||||||
|
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_THRESHOLD,
|
||||||
|
card_testing_guard_expiry:
|
||||||
|
common_utils::consts::DEFAULT_CARD_TESTING_GUARD_EXPIRY_IN_SECS,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression)]
|
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression)]
|
||||||
#[diesel(sql_type = diesel::sql_types::Json)]
|
#[diesel(sql_type = diesel::sql_types::Json)]
|
||||||
pub struct WebhookDetails {
|
pub struct WebhookDetails {
|
||||||
|
|||||||
@ -3703,26 +3703,10 @@ impl ProfileCreateBridge for api::ProfileCreate {
|
|||||||
"fs",
|
"fs",
|
||||||
)));
|
)));
|
||||||
|
|
||||||
let card_testing_guard_config = match self.card_testing_guard_config {
|
let card_testing_guard_config = self
|
||||||
Some(card_testing_guard_config) => Some(CardTestingGuardConfig::foreign_from(
|
.card_testing_guard_config
|
||||||
card_testing_guard_config,
|
.map(CardTestingGuardConfig::foreign_from)
|
||||||
)),
|
.or(Some(CardTestingGuardConfig::default()));
|
||||||
None => Some(CardTestingGuardConfig {
|
|
||||||
is_card_ip_blocking_enabled: common_utils::consts::DEFAULT_CARD_IP_BLOCKING_STATUS,
|
|
||||||
card_ip_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_CARD_IP_BLOCKING_THRESHOLD,
|
|
||||||
is_guest_user_card_blocking_enabled:
|
|
||||||
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_STATUS,
|
|
||||||
guest_user_card_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_THRESHOLD,
|
|
||||||
is_customer_id_blocking_enabled:
|
|
||||||
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_STATUS,
|
|
||||||
customer_id_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_THRESHOLD,
|
|
||||||
card_testing_guard_expiry:
|
|
||||||
common_utils::consts::DEFAULT_CARD_TESTING_GUARD_EXPIRY_IN_SECS,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(domain::Profile::from(domain::ProfileSetter {
|
Ok(domain::Profile::from(domain::ProfileSetter {
|
||||||
profile_id,
|
profile_id,
|
||||||
@ -3874,26 +3858,10 @@ impl ProfileCreateBridge for api::ProfileCreate {
|
|||||||
"fs",
|
"fs",
|
||||||
)));
|
)));
|
||||||
|
|
||||||
let card_testing_guard_config = match self.card_testing_guard_config {
|
let card_testing_guard_config = self
|
||||||
Some(card_testing_guard_config) => Some(CardTestingGuardConfig::foreign_from(
|
.card_testing_guard_config
|
||||||
card_testing_guard_config,
|
.map(CardTestingGuardConfig::foreign_from)
|
||||||
)),
|
.or(Some(CardTestingGuardConfig::default()));
|
||||||
None => Some(CardTestingGuardConfig {
|
|
||||||
is_card_ip_blocking_enabled: common_utils::consts::DEFAULT_CARD_IP_BLOCKING_STATUS,
|
|
||||||
card_ip_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_CARD_IP_BLOCKING_THRESHOLD,
|
|
||||||
is_guest_user_card_blocking_enabled:
|
|
||||||
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_STATUS,
|
|
||||||
guest_user_card_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_THRESHOLD,
|
|
||||||
is_customer_id_blocking_enabled:
|
|
||||||
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_STATUS,
|
|
||||||
customer_id_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_THRESHOLD,
|
|
||||||
card_testing_guard_expiry:
|
|
||||||
common_utils::consts::DEFAULT_CARD_TESTING_GUARD_EXPIRY_IN_SECS,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(domain::Profile::from(domain::ProfileSetter {
|
Ok(domain::Profile::from(domain::ProfileSetter {
|
||||||
id: profile_id,
|
id: profile_id,
|
||||||
|
|||||||
@ -16,7 +16,7 @@ pub use api_models::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use common_utils::{ext_traits::ValueExt, types::keymanager as km_types};
|
use common_utils::{ext_traits::ValueExt, types::keymanager as km_types};
|
||||||
use diesel_models::organization::OrganizationBridge;
|
use diesel_models::{business_profile::CardTestingGuardConfig, organization::OrganizationBridge};
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
use hyperswitch_domain_models::merchant_key_store::MerchantKeyStore;
|
use hyperswitch_domain_models::merchant_key_store::MerchantKeyStore;
|
||||||
use masking::{ExposeInterface, PeekInterface, Secret};
|
use masking::{ExposeInterface, PeekInterface, Secret};
|
||||||
@ -141,6 +141,10 @@ impl ForeignTryFrom<domain::Profile> for ProfileResponse {
|
|||||||
let masked_outgoing_webhook_custom_http_headers =
|
let masked_outgoing_webhook_custom_http_headers =
|
||||||
outgoing_webhook_custom_http_headers.map(MaskedHeaders::from_headers);
|
outgoing_webhook_custom_http_headers.map(MaskedHeaders::from_headers);
|
||||||
|
|
||||||
|
let card_testing_guard_config = item
|
||||||
|
.card_testing_guard_config
|
||||||
|
.or(Some(CardTestingGuardConfig::default()));
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
merchant_id: item.merchant_id,
|
merchant_id: item.merchant_id,
|
||||||
profile_id,
|
profile_id,
|
||||||
@ -186,9 +190,7 @@ impl ForeignTryFrom<domain::Profile> for ProfileResponse {
|
|||||||
always_request_extended_authorization: item.always_request_extended_authorization,
|
always_request_extended_authorization: item.always_request_extended_authorization,
|
||||||
is_click_to_pay_enabled: item.is_click_to_pay_enabled,
|
is_click_to_pay_enabled: item.is_click_to_pay_enabled,
|
||||||
authentication_product_ids: item.authentication_product_ids,
|
authentication_product_ids: item.authentication_product_ids,
|
||||||
card_testing_guard_config: item
|
card_testing_guard_config: card_testing_guard_config.map(ForeignInto::foreign_into),
|
||||||
.card_testing_guard_config
|
|
||||||
.map(ForeignInto::foreign_into),
|
|
||||||
is_clear_pan_retries_enabled: item.is_clear_pan_retries_enabled,
|
is_clear_pan_retries_enabled: item.is_clear_pan_retries_enabled,
|
||||||
force_3ds_challenge: item.force_3ds_challenge,
|
force_3ds_challenge: item.force_3ds_challenge,
|
||||||
is_debit_routing_enabled: Some(item.is_debit_routing_enabled),
|
is_debit_routing_enabled: Some(item.is_debit_routing_enabled),
|
||||||
@ -224,6 +226,10 @@ impl ForeignTryFrom<domain::Profile> for ProfileResponse {
|
|||||||
let masked_outgoing_webhook_custom_http_headers =
|
let masked_outgoing_webhook_custom_http_headers =
|
||||||
outgoing_webhook_custom_http_headers.map(MaskedHeaders::from_headers);
|
outgoing_webhook_custom_http_headers.map(MaskedHeaders::from_headers);
|
||||||
|
|
||||||
|
let card_testing_guard_config = item
|
||||||
|
.card_testing_guard_config
|
||||||
|
.or(Some(CardTestingGuardConfig::default()));
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
merchant_id: item.merchant_id,
|
merchant_id: item.merchant_id,
|
||||||
id,
|
id,
|
||||||
@ -264,9 +270,7 @@ impl ForeignTryFrom<domain::Profile> for ProfileResponse {
|
|||||||
is_network_tokenization_enabled: item.is_network_tokenization_enabled,
|
is_network_tokenization_enabled: item.is_network_tokenization_enabled,
|
||||||
is_click_to_pay_enabled: item.is_click_to_pay_enabled,
|
is_click_to_pay_enabled: item.is_click_to_pay_enabled,
|
||||||
authentication_product_ids: item.authentication_product_ids,
|
authentication_product_ids: item.authentication_product_ids,
|
||||||
card_testing_guard_config: item
|
card_testing_guard_config: card_testing_guard_config.map(ForeignInto::foreign_into),
|
||||||
.card_testing_guard_config
|
|
||||||
.map(ForeignInto::foreign_into),
|
|
||||||
is_clear_pan_retries_enabled: item.is_clear_pan_retries_enabled,
|
is_clear_pan_retries_enabled: item.is_clear_pan_retries_enabled,
|
||||||
is_debit_routing_enabled: Some(item.is_debit_routing_enabled),
|
is_debit_routing_enabled: Some(item.is_debit_routing_enabled),
|
||||||
merchant_business_country: item.merchant_business_country,
|
merchant_business_country: item.merchant_business_country,
|
||||||
@ -335,25 +339,10 @@ pub async fn create_profile_from_merchant_account(
|
|||||||
"fs",
|
"fs",
|
||||||
)));
|
)));
|
||||||
|
|
||||||
let card_testing_guard_config = match request.card_testing_guard_config {
|
let card_testing_guard_config = request
|
||||||
Some(card_testing_guard_config) => Some(CardTestingGuardConfig::foreign_from(
|
.card_testing_guard_config
|
||||||
card_testing_guard_config,
|
.map(CardTestingGuardConfig::foreign_from)
|
||||||
)),
|
.or(Some(CardTestingGuardConfig::default()));
|
||||||
None => Some(CardTestingGuardConfig {
|
|
||||||
is_card_ip_blocking_enabled: common_utils::consts::DEFAULT_CARD_IP_BLOCKING_STATUS,
|
|
||||||
card_ip_blocking_threshold: common_utils::consts::DEFAULT_CARD_IP_BLOCKING_THRESHOLD,
|
|
||||||
is_guest_user_card_blocking_enabled:
|
|
||||||
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_STATUS,
|
|
||||||
guest_user_card_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_GUEST_USER_CARD_BLOCKING_THRESHOLD,
|
|
||||||
is_customer_id_blocking_enabled:
|
|
||||||
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_STATUS,
|
|
||||||
customer_id_blocking_threshold:
|
|
||||||
common_utils::consts::DEFAULT_CUSTOMER_ID_BLOCKING_THRESHOLD,
|
|
||||||
card_testing_guard_expiry:
|
|
||||||
common_utils::consts::DEFAULT_CARD_TESTING_GUARD_EXPIRY_IN_SECS,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(domain::Profile::from(domain::ProfileSetter {
|
Ok(domain::Profile::from(domain::ProfileSetter {
|
||||||
profile_id,
|
profile_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user