mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
refactor(routing): add support to accept the saving_percentage in decision engine response (#8388)
This commit is contained in:
@ -67,17 +67,32 @@ pub struct DecidedGateway {
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
pub struct DebitRoutingOutput {
|
pub struct DebitRoutingOutput {
|
||||||
pub co_badged_card_networks: Vec<common_enums::CardNetwork>,
|
pub co_badged_card_networks_info: Vec<CoBadgedCardNetworksInfo>,
|
||||||
pub issuer_country: common_enums::CountryAlpha2,
|
pub issuer_country: common_enums::CountryAlpha2,
|
||||||
pub is_regulated: bool,
|
pub is_regulated: bool,
|
||||||
pub regulated_name: Option<common_enums::RegulatedName>,
|
pub regulated_name: Option<common_enums::RegulatedName>,
|
||||||
pub card_type: common_enums::CardType,
|
pub card_type: common_enums::CardType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
|
pub struct CoBadgedCardNetworksInfo {
|
||||||
|
pub network: common_enums::CardNetwork,
|
||||||
|
pub saving_percentage: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DebitRoutingOutput {
|
||||||
|
pub fn get_co_badged_card_networks(&self) -> Vec<common_enums::CardNetwork> {
|
||||||
|
self.co_badged_card_networks_info
|
||||||
|
.iter()
|
||||||
|
.map(|data| data.network.clone())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<&DebitRoutingOutput> for payment_methods::CoBadgedCardData {
|
impl From<&DebitRoutingOutput> for payment_methods::CoBadgedCardData {
|
||||||
fn from(output: &DebitRoutingOutput) -> Self {
|
fn from(output: &DebitRoutingOutput) -> Self {
|
||||||
Self {
|
Self {
|
||||||
co_badged_card_networks: output.co_badged_card_networks.clone(),
|
co_badged_card_networks: output.get_co_badged_card_networks(),
|
||||||
issuer_country_code: output.issuer_country,
|
issuer_country_code: output.issuer_country,
|
||||||
is_regulated: output.is_regulated,
|
is_regulated: output.is_regulated,
|
||||||
regulated_name: output.regulated_name.clone(),
|
regulated_name: output.regulated_name.clone(),
|
||||||
@ -96,7 +111,7 @@ impl TryFrom<(payment_methods::CoBadgedCardData, String)> for DebitRoutingReques
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
co_badged_card_networks: output.co_badged_card_networks,
|
co_badged_card_networks_info: output.co_badged_card_networks,
|
||||||
issuer_country: output.issuer_country_code,
|
issuer_country: output.issuer_country_code,
|
||||||
is_regulated: output.is_regulated,
|
is_regulated: output.is_regulated,
|
||||||
regulated_name: output.regulated_name,
|
regulated_name: output.regulated_name,
|
||||||
@ -114,7 +129,7 @@ pub struct CoBadgedCardRequest {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct DebitRoutingRequestData {
|
pub struct DebitRoutingRequestData {
|
||||||
pub co_badged_card_networks: Vec<common_enums::CardNetwork>,
|
pub co_badged_card_networks_info: Vec<common_enums::CardNetwork>,
|
||||||
pub issuer_country: common_enums::CountryAlpha2,
|
pub issuer_country: common_enums::CountryAlpha2,
|
||||||
pub is_regulated: bool,
|
pub is_regulated: bool,
|
||||||
pub regulated_name: Option<common_enums::RegulatedName>,
|
pub regulated_name: Option<common_enums::RegulatedName>,
|
||||||
|
|||||||
@ -256,8 +256,8 @@ where
|
|||||||
get_debit_routing_output::<F, D>(state, payment_data, acquirer_country).await?;
|
get_debit_routing_output::<F, D>(state, payment_data, acquirer_country).await?;
|
||||||
|
|
||||||
logger::debug!(
|
logger::debug!(
|
||||||
"Sorted co-badged networks: {:?}",
|
"Sorted co-badged networks info: {:?}",
|
||||||
debit_routing_output.co_badged_card_networks
|
debit_routing_output.co_badged_card_networks_info
|
||||||
);
|
);
|
||||||
|
|
||||||
let key_store = db
|
let key_store = db
|
||||||
@ -281,7 +281,7 @@ where
|
|||||||
&profile_id,
|
&profile_id,
|
||||||
&key_store,
|
&key_store,
|
||||||
vec![connector_data.clone()],
|
vec![connector_data.clone()],
|
||||||
debit_routing_output.co_badged_card_networks.clone(),
|
debit_routing_output.get_co_badged_card_networks(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| {
|
.map_err(|error| {
|
||||||
@ -455,7 +455,7 @@ where
|
|||||||
&profile_id,
|
&profile_id,
|
||||||
&key_store,
|
&key_store,
|
||||||
connector_data_list.clone(),
|
connector_data_list.clone(),
|
||||||
debit_routing_output.co_badged_card_networks.clone(),
|
debit_routing_output.get_co_badged_card_networks(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|error| {
|
.map_err(|error| {
|
||||||
|
|||||||
Reference in New Issue
Block a user