mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(dynamic_routing): add open router integration for elimination routing (#7896)
This commit is contained in:
@ -10,14 +10,14 @@ pub use euclid::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::enums::{Currency, PaymentMethod, RoutableConnectors};
|
||||
use crate::enums::{Currency, PaymentMethod};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct OpenRouterDecideGatewayRequest {
|
||||
pub payment_info: PaymentInfo,
|
||||
pub merchant_id: id_type::ProfileId,
|
||||
pub eligible_gateway_list: Option<Vec<RoutableConnectors>>,
|
||||
pub eligible_gateway_list: Option<Vec<String>>,
|
||||
pub ranking_algorithm: Option<RankingAlgorithm>,
|
||||
pub elimination_enabled: Option<bool>,
|
||||
}
|
||||
@ -80,7 +80,7 @@ pub struct UnifiedError {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateScorePayload {
|
||||
pub merchant_id: id_type::ProfileId,
|
||||
pub gateway: RoutableConnectors,
|
||||
pub gateway: String,
|
||||
pub status: TxnStatus,
|
||||
pub payment_id: id_type::PaymentId,
|
||||
}
|
||||
@ -91,7 +91,7 @@ pub enum TxnStatus {
|
||||
Started,
|
||||
AuthenticationFailed,
|
||||
JuspayDeclined,
|
||||
PendingVBV,
|
||||
PendingVbv,
|
||||
VBVSuccessful,
|
||||
Authorized,
|
||||
AuthorizationFailed,
|
||||
@ -111,12 +111,3 @@ pub enum TxnStatus {
|
||||
Failure,
|
||||
Declined,
|
||||
}
|
||||
|
||||
impl From<bool> for TxnStatus {
|
||||
fn from(value: bool) -> Self {
|
||||
match value {
|
||||
true => Self::Charged,
|
||||
_ => Self::Failure,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -642,6 +642,17 @@ impl DynamicRoutingAlgorithmRef {
|
||||
pub fn update_volume_split(&mut self, volume: Option<u8>) {
|
||||
self.dynamic_routing_volume_split = volume
|
||||
}
|
||||
|
||||
pub fn is_elimination_enabled(&self) -> bool {
|
||||
self.elimination_routing_algorithm
|
||||
.as_ref()
|
||||
.map(|elimination_routing| {
|
||||
elimination_routing.enabled_feature
|
||||
== DynamicRoutingFeatures::DynamicConnectorSelection
|
||||
|| elimination_routing.enabled_feature == DynamicRoutingFeatures::Metrics
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, serde::Serialize, serde::Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user