feat(router): add auto retries configs in profile CRUD apis (#6134)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sai Harsha Vardhan
2024-09-29 17:06:57 +05:30
committed by GitHub
parent c7bb9ccda3
commit bf47b560c2
10 changed files with 133 additions and 1 deletions

View File

@ -21220,6 +21220,18 @@
"is_network_tokenization_enabled": {
"type": "boolean",
"description": "Indicates if is_network_tokenization_enabled is enabled or not.\nIf set to `true` is_network_tokenization_enabled will be checked."
},
"is_auto_retries_enabled": {
"type": "boolean",
"description": "Indicates if is_auto_retries_enabled is enabled or not.",
"nullable": true
},
"max_auto_retries_enabled": {
"type": "integer",
"format": "int32",
"description": "Maximum number of auto retries allowed for a payment",
"nullable": true,
"minimum": 0
}
},
"additionalProperties": false
@ -21251,7 +21263,8 @@
"enable_payment_response_hash",
"redirect_to_merchant_with_http_post",
"is_tax_connector_enabled",
"is_network_tokenization_enabled"
"is_network_tokenization_enabled",
"is_auto_retries_enabled"
],
"properties": {
"merchant_id": {
@ -21436,6 +21449,18 @@
"description": "Indicates if is_network_tokenization_enabled is enabled or not.\nIf set to `true` is_network_tokenization_enabled will be checked.",
"default": false,
"example": false
},
"is_auto_retries_enabled": {
"type": "boolean",
"description": "Indicates if is_auto_retries_enabled is enabled or not.",
"default": false,
"example": false
},
"max_auto_retries_enabled": {
"type": "integer",
"format": "int32",
"description": "Maximum number of auto retries allowed for a payment",
"nullable": true
}
}
},

View File

@ -1971,6 +1971,12 @@ pub struct ProfileCreate {
/// If set to `true` is_network_tokenization_enabled will be checked.
#[serde(default)]
pub is_network_tokenization_enabled: bool,
/// Indicates if is_auto_retries_enabled is enabled or not.
pub is_auto_retries_enabled: Option<bool>,
/// Maximum number of auto retries allowed for a payment
pub max_auto_retries_enabled: Option<u8>,
}
#[nutype::nutype(
@ -2202,6 +2208,13 @@ pub struct ProfileResponse {
/// If set to `true` is_network_tokenization_enabled will be checked.
#[schema(default = false, example = false)]
pub is_network_tokenization_enabled: bool,
/// Indicates if is_auto_retries_enabled is enabled or not.
#[schema(default = false, example = false)]
pub is_auto_retries_enabled: bool,
/// Maximum number of auto retries allowed for a payment
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v2")]
@ -2431,6 +2444,12 @@ pub struct ProfileUpdate {
/// Indicates if is_network_tokenization_enabled is enabled or not.
pub is_network_tokenization_enabled: Option<bool>,
/// Indicates if is_auto_retries_enabled is enabled or not.
pub is_auto_retries_enabled: Option<bool>,
/// Maximum number of auto retries allowed for a payment
pub max_auto_retries_enabled: Option<u8>,
}
#[cfg(feature = "v2")]

View File

@ -55,6 +55,8 @@ pub struct Profile {
pub version: common_enums::ApiVersion,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: bool,
pub is_auto_retries_enabled: Option<bool>,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v1")]
@ -96,6 +98,8 @@ pub struct ProfileNew {
pub is_tax_connector_enabled: Option<bool>,
pub version: common_enums::ApiVersion,
pub is_network_tokenization_enabled: bool,
pub is_auto_retries_enabled: Option<bool>,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v1")]
@ -134,6 +138,8 @@ pub struct ProfileUpdateInternal {
pub is_tax_connector_enabled: Option<bool>,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: Option<bool>,
pub is_auto_retries_enabled: Option<bool>,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v1")]
@ -171,6 +177,8 @@ impl ProfileUpdateInternal {
is_tax_connector_enabled,
dynamic_routing_algorithm,
is_network_tokenization_enabled,
is_auto_retries_enabled,
max_auto_retries_enabled,
} = self;
Profile {
profile_id: source.profile_id,
@ -228,6 +236,8 @@ impl ProfileUpdateInternal {
.or(source.dynamic_routing_algorithm),
is_network_tokenization_enabled: is_network_tokenization_enabled
.unwrap_or(source.is_network_tokenization_enabled),
is_auto_retries_enabled: is_auto_retries_enabled.or(source.is_auto_retries_enabled),
max_auto_retries_enabled: max_auto_retries_enabled.or(source.max_auto_retries_enabled),
}
}
}
@ -279,6 +289,8 @@ pub struct Profile {
pub version: common_enums::ApiVersion,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: bool,
pub is_auto_retries_enabled: Option<bool>,
pub max_auto_retries_enabled: Option<i16>,
}
impl Profile {
@ -334,6 +346,8 @@ pub struct ProfileNew {
pub id: common_utils::id_type::ProfileId,
pub version: common_enums::ApiVersion,
pub is_network_tokenization_enabled: bool,
pub is_auto_retries_enabled: Option<bool>,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v2")]
@ -373,6 +387,8 @@ pub struct ProfileUpdateInternal {
pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
pub is_network_tokenization_enabled: Option<bool>,
pub is_auto_retries_enabled: Option<bool>,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v2")]
@ -411,6 +427,8 @@ impl ProfileUpdateInternal {
payout_routing_algorithm_id,
default_fallback_routing,
is_network_tokenization_enabled,
is_auto_retries_enabled,
max_auto_retries_enabled,
} = self;
Profile {
id: source.id,
@ -471,6 +489,8 @@ impl ProfileUpdateInternal {
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: is_network_tokenization_enabled
.unwrap_or(source.is_network_tokenization_enabled),
is_auto_retries_enabled: is_auto_retries_enabled.or(source.is_auto_retries_enabled),
max_auto_retries_enabled: max_auto_retries_enabled.or(source.max_auto_retries_enabled),
}
}
}

View File

@ -211,6 +211,8 @@ diesel::table! {
version -> ApiVersion,
dynamic_routing_algorithm -> Nullable<Json>,
is_network_tokenization_enabled -> Bool,
is_auto_retries_enabled -> Nullable<Bool>,
max_auto_retries_enabled -> Nullable<Int2>,
}
}

View File

@ -218,6 +218,8 @@ diesel::table! {
version -> ApiVersion,
dynamic_routing_algorithm -> Nullable<Json>,
is_network_tokenization_enabled -> Bool,
is_auto_retries_enabled -> Nullable<Bool>,
max_auto_retries_enabled -> Nullable<Int2>,
}
}

View File

@ -56,6 +56,8 @@ pub struct Profile {
pub version: common_enums::ApiVersion,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: bool,
pub is_auto_retries_enabled: bool,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v1")]
@ -94,6 +96,8 @@ pub struct ProfileSetter {
pub is_tax_connector_enabled: bool,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: bool,
pub is_auto_retries_enabled: bool,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v1")]
@ -139,6 +143,8 @@ impl From<ProfileSetter> for Profile {
version: consts::API_VERSION,
dynamic_routing_algorithm: value.dynamic_routing_algorithm,
is_network_tokenization_enabled: value.is_network_tokenization_enabled,
is_auto_retries_enabled: value.is_auto_retries_enabled,
max_auto_retries_enabled: value.max_auto_retries_enabled,
}
}
}
@ -186,6 +192,8 @@ pub struct ProfileGeneralUpdate {
pub is_tax_connector_enabled: Option<bool>,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: Option<bool>,
pub is_auto_retries_enabled: Option<bool>,
pub max_auto_retries_enabled: Option<i16>,
}
#[cfg(feature = "v1")]
@ -246,6 +254,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
is_tax_connector_enabled,
dynamic_routing_algorithm,
is_network_tokenization_enabled,
is_auto_retries_enabled,
max_auto_retries_enabled,
} = *update;
Self {
@ -281,6 +291,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
is_tax_connector_enabled,
dynamic_routing_algorithm,
is_network_tokenization_enabled,
is_auto_retries_enabled,
max_auto_retries_enabled,
}
}
ProfileUpdate::RoutingAlgorithmUpdate {
@ -318,6 +330,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
is_tax_connector_enabled: None,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::DynamicRoutingAlgorithmUpdate {
dynamic_routing_algorithm,
@ -353,6 +367,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
is_tax_connector_enabled: None,
dynamic_routing_algorithm,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::ExtendedCardInfoUpdate {
is_extended_card_info_enabled,
@ -388,6 +404,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
is_tax_connector_enabled: None,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::ConnectorAgnosticMitUpdate {
is_connector_agnostic_mit_enabled,
@ -423,6 +441,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
is_tax_connector_enabled: None,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::NetworkTokenizationUpdate {
is_network_tokenization_enabled,
@ -458,6 +478,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
is_tax_connector_enabled: None,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
}
}
@ -512,6 +534,8 @@ impl super::behaviour::Conversion for Profile {
version: self.version,
dynamic_routing_algorithm: self.dynamic_routing_algorithm,
is_network_tokenization_enabled: self.is_network_tokenization_enabled,
is_auto_retries_enabled: Some(self.is_auto_retries_enabled),
max_auto_retries_enabled: self.max_auto_retries_enabled,
})
}
@ -578,6 +602,8 @@ impl super::behaviour::Conversion for Profile {
version: item.version,
dynamic_routing_algorithm: item.dynamic_routing_algorithm,
is_network_tokenization_enabled: item.is_network_tokenization_enabled,
is_auto_retries_enabled: item.is_auto_retries_enabled.unwrap_or(false),
max_auto_retries_enabled: item.max_auto_retries_enabled,
})
}
.await
@ -628,6 +654,8 @@ impl super::behaviour::Conversion for Profile {
is_tax_connector_enabled: Some(self.is_tax_connector_enabled),
version: self.version,
is_network_tokenization_enabled: self.is_network_tokenization_enabled,
is_auto_retries_enabled: Some(self.is_auto_retries_enabled),
max_auto_retries_enabled: self.max_auto_retries_enabled,
})
}
}
@ -896,6 +924,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
tax_connector_id: None,
is_tax_connector_enabled: None,
is_network_tokenization_enabled,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
}
}
ProfileUpdate::RoutingAlgorithmUpdate {
@ -934,6 +964,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
tax_connector_id: None,
is_tax_connector_enabled: None,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::ExtendedCardInfoUpdate {
is_extended_card_info_enabled,
@ -970,6 +1002,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
tax_connector_id: None,
is_tax_connector_enabled: None,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::ConnectorAgnosticMitUpdate {
is_connector_agnostic_mit_enabled,
@ -1006,6 +1040,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
tax_connector_id: None,
is_tax_connector_enabled: None,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::DefaultRoutingFallbackUpdate {
default_fallback_routing,
@ -1042,6 +1078,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
tax_connector_id: None,
is_tax_connector_enabled: None,
is_network_tokenization_enabled: None,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
ProfileUpdate::NetworkTokenizationUpdate {
is_network_tokenization_enabled,
@ -1078,6 +1116,8 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {
tax_connector_id: None,
is_tax_connector_enabled: None,
is_network_tokenization_enabled,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
},
}
}
@ -1134,6 +1174,8 @@ impl super::behaviour::Conversion for Profile {
version: self.version,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: self.is_network_tokenization_enabled,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
})
}
@ -1253,6 +1295,8 @@ impl super::behaviour::Conversion for Profile {
is_tax_connector_enabled: Some(self.is_tax_connector_enabled),
version: self.version,
is_network_tokenization_enabled: self.is_network_tokenization_enabled,
is_auto_retries_enabled: None,
max_auto_retries_enabled: None,
})
}
}

View File

@ -3537,6 +3537,8 @@ impl ProfileCreateBridge for api::ProfileCreate {
.always_collect_shipping_details_from_wallet_connector,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: self.is_network_tokenization_enabled,
is_auto_retries_enabled: self.is_auto_retries_enabled.unwrap_or_default(),
max_auto_retries_enabled: self.max_auto_retries_enabled.map(i16::from),
}))
}
@ -3884,6 +3886,8 @@ impl ProfileUpdateBridge for api::ProfileUpdate {
is_tax_connector_enabled: self.is_tax_connector_enabled,
dynamic_routing_algorithm: self.dynamic_routing_algorithm,
is_network_tokenization_enabled: self.is_network_tokenization_enabled,
is_auto_retries_enabled: self.is_auto_retries_enabled,
max_auto_retries_enabled: self.max_auto_retries_enabled.map(i16::from),
},
)))
}

View File

@ -168,6 +168,8 @@ impl ForeignTryFrom<domain::Profile> for ProfileResponse {
tax_connector_id: item.tax_connector_id,
is_tax_connector_enabled: item.is_tax_connector_enabled,
is_network_tokenization_enabled: item.is_network_tokenization_enabled,
is_auto_retries_enabled: item.is_auto_retries_enabled,
max_auto_retries_enabled: item.max_auto_retries_enabled,
})
}
}
@ -353,5 +355,7 @@ pub async fn create_profile_from_merchant_account(
is_tax_connector_enabled: request.is_tax_connector_enabled,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: request.is_network_tokenization_enabled,
is_auto_retries_enabled: request.is_auto_retries_enabled.unwrap_or_default(),
max_auto_retries_enabled: request.max_auto_retries_enabled.map(i16::from),
}))
}

View File

@ -0,0 +1,6 @@
-- This file should undo anything in `up.sql`
-- Drop is_auto_retries_enabled column from business_profile table
ALTER TABLE business_profile DROP COLUMN IF EXISTS is_auto_retries_enabled;
-- Drop max_auto_retries_enabled column from business_profile table
ALTER TABLE business_profile DROP COLUMN IF EXISTS max_auto_retries_enabled;

View File

@ -0,0 +1,6 @@
-- Your SQL goes here
-- Add is_auto_retries_enabled column in business_profile table
ALTER TABLE business_profile ADD COLUMN IF NOT EXISTS is_auto_retries_enabled BOOLEAN;
-- Add max_auto_retries_enabled column in business_profile table
ALTER TABLE business_profile ADD COLUMN IF NOT EXISTS max_auto_retries_enabled SMALLINT;