-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into refactor/fiserv-cybersource
- Loading branch information
Showing
144 changed files
with
9,499 additions
and
3,399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
use common_utils::events; | ||
use euclid::{ | ||
dssa::types::EuclidAnalysable, | ||
enums, | ||
frontend::{ | ||
ast::Program, | ||
dir::{DirKeyKind, DirValue, EuclidDirFilter}, | ||
}, | ||
types::Metadata, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive( | ||
Clone, | ||
Debug, | ||
Hash, | ||
PartialEq, | ||
Eq, | ||
strum::Display, | ||
strum::EnumVariantNames, | ||
strum::EnumIter, | ||
strum::EnumString, | ||
Serialize, | ||
Deserialize, | ||
)] | ||
#[serde(rename_all = "snake_case")] | ||
#[strum(serialize_all = "snake_case")] | ||
pub enum AuthenticationType { | ||
ThreeDs, | ||
NoThreeDs, | ||
} | ||
impl AuthenticationType { | ||
pub fn to_dir_value(&self) -> DirValue { | ||
match self { | ||
Self::ThreeDs => DirValue::AuthenticationType(enums::AuthenticationType::ThreeDs), | ||
Self::NoThreeDs => DirValue::AuthenticationType(enums::AuthenticationType::NoThreeDs), | ||
} | ||
} | ||
} | ||
|
||
impl EuclidAnalysable for AuthenticationType { | ||
fn get_dir_value_for_analysis(&self, rule_name: String) -> Vec<(DirValue, Metadata)> { | ||
let auth = self.to_string(); | ||
|
||
vec![( | ||
self.to_dir_value(), | ||
std::collections::HashMap::from_iter([( | ||
"AUTHENTICATION_TYPE".to_string(), | ||
serde_json::json!({ | ||
"rule_name":rule_name, | ||
"Authentication_type": auth, | ||
}), | ||
)]), | ||
)] | ||
} | ||
} | ||
|
||
#[derive(Debug, Default, Clone, Serialize, Deserialize)] | ||
pub struct ConditionalConfigs { | ||
pub override_3ds: Option<AuthenticationType>, | ||
} | ||
impl EuclidDirFilter for ConditionalConfigs { | ||
const ALLOWED: &'static [DirKeyKind] = &[ | ||
DirKeyKind::PaymentMethod, | ||
DirKeyKind::CardType, | ||
DirKeyKind::CardNetwork, | ||
DirKeyKind::MetaData, | ||
DirKeyKind::PaymentAmount, | ||
DirKeyKind::PaymentCurrency, | ||
DirKeyKind::CaptureMethod, | ||
DirKeyKind::BillingCountry, | ||
DirKeyKind::BusinessCountry, | ||
]; | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
pub struct DecisionManagerRecord { | ||
pub name: String, | ||
pub program: Program<ConditionalConfigs>, | ||
pub created_at: i64, | ||
pub modified_at: i64, | ||
} | ||
impl events::ApiEventMetric for DecisionManagerRecord { | ||
fn get_api_event_type(&self) -> Option<events::ApiEventsType> { | ||
Some(events::ApiEventsType::Routing) | ||
} | ||
} | ||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct ConditionalConfigReq { | ||
pub name: Option<String>, | ||
pub algorithm: Option<Program<ConditionalConfigs>>, | ||
} | ||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
|
||
pub struct DecisionManagerRequest { | ||
pub name: Option<String>, | ||
pub program: Option<Program<ConditionalConfigs>>, | ||
} | ||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
#[serde(untagged)] | ||
pub enum DecisionManager { | ||
DecisionManagerv0(ConditionalConfigReq), | ||
DecisionManagerv1(DecisionManagerRequest), | ||
} | ||
|
||
impl events::ApiEventMetric for DecisionManager { | ||
fn get_api_event_type(&self) -> Option<events::ApiEventsType> { | ||
Some(events::ApiEventsType::Routing) | ||
} | ||
} | ||
|
||
pub type DecisionManagerResponse = DecisionManagerRecord; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use common_utils::{consts::SURCHARGE_PERCENTAGE_PRECISION_LENGTH, events, types::Percentage}; | ||
use euclid::frontend::{ | ||
ast::Program, | ||
dir::{DirKeyKind, EuclidDirFilter}, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct SurchargeDetails { | ||
pub surcharge: Surcharge, | ||
pub tax_on_surcharge: Option<Percentage<SURCHARGE_PERCENTAGE_PRECISION_LENGTH>>, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case", tag = "type", content = "value")] | ||
pub enum Surcharge { | ||
Fixed(i64), | ||
Rate(Percentage<SURCHARGE_PERCENTAGE_PRECISION_LENGTH>), | ||
} | ||
|
||
#[derive(Debug, Default, Clone, Serialize, Deserialize)] | ||
pub struct SurchargeDecisionConfigs { | ||
pub surcharge_details: Option<SurchargeDetails>, | ||
} | ||
impl EuclidDirFilter for SurchargeDecisionConfigs { | ||
const ALLOWED: &'static [DirKeyKind] = &[ | ||
DirKeyKind::PaymentMethod, | ||
DirKeyKind::MetaData, | ||
DirKeyKind::PaymentAmount, | ||
DirKeyKind::PaymentCurrency, | ||
DirKeyKind::BillingCountry, | ||
DirKeyKind::CardType, | ||
DirKeyKind::CardNetwork, | ||
DirKeyKind::PayLaterType, | ||
DirKeyKind::WalletType, | ||
DirKeyKind::BankTransferType, | ||
DirKeyKind::BankRedirectType, | ||
DirKeyKind::BankDebitType, | ||
DirKeyKind::CryptoType, | ||
]; | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
pub struct SurchargeDecisionManagerRecord { | ||
pub name: String, | ||
pub merchant_surcharge_configs: MerchantSurchargeConfigs, | ||
pub algorithm: Program<SurchargeDecisionConfigs>, | ||
pub created_at: i64, | ||
pub modified_at: i64, | ||
} | ||
|
||
impl events::ApiEventMetric for SurchargeDecisionManagerRecord { | ||
fn get_api_event_type(&self) -> Option<events::ApiEventsType> { | ||
Some(events::ApiEventsType::Routing) | ||
} | ||
} | ||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct SurchargeDecisionConfigReq { | ||
pub name: Option<String>, | ||
pub merchant_surcharge_configs: MerchantSurchargeConfigs, | ||
pub algorithm: Option<Program<SurchargeDecisionConfigs>>, | ||
} | ||
|
||
impl events::ApiEventMetric for SurchargeDecisionConfigReq { | ||
fn get_api_event_type(&self) -> Option<events::ApiEventsType> { | ||
Some(events::ApiEventsType::Routing) | ||
} | ||
} | ||
|
||
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)] | ||
pub struct MerchantSurchargeConfigs { | ||
pub show_surcharge_breakup_screen: Option<bool>, | ||
} | ||
|
||
pub type SurchargeDecisionManagerResponse = SurchargeDecisionManagerRecord; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.