diff --git a/src/decider/gatewaydecider/flow_new.rs b/src/decider/gatewaydecider/flow_new.rs index da66ac7b..f0dea493 100644 --- a/src/decider/gatewaydecider/flow_new.rs +++ b/src/decider/gatewaydecider/flow_new.rs @@ -65,14 +65,14 @@ pub async fn decider_full_payload_hs_function( }; let dreq = dreq_.to_domain_decider_request().await; - let resolve_bin = match Utils::fetch_extended_card_bin(&dreq.txnCardInfo.clone()) { + let resolve_bin = match Utils::fetch_extended_card_bin(&dreq.txn_card_info.clone()) { Some(card_bin) => Some(card_bin), - None => match dreq.txnCardInfo.card_isin { + None => match dreq.txn_card_info.card_isin { Some(c_isin) => { let res_bin = Utils::get_card_bin_from_token_bin(6, c_isin.as_str()).await; Some(res_bin) } - None => dreq.txnCardInfo.card_isin.clone(), + None => dreq.txn_card_info.card_isin.clone(), }, }; logger::debug!( @@ -81,28 +81,28 @@ pub async fn decider_full_payload_hs_function( "{:?}", resolve_bin.clone() ); - let m_vault_provider = Utils::get_vault_provider(dreq.cardToken.as_deref()); + let m_vault_provider = Utils::get_vault_provider(dreq.card_token.as_deref()); let update_txn_card_info = TxnCardInfo { card_isin: resolve_bin, - ..dreq.txnCardInfo + ..dreq.txn_card_info }; let decider_params = T::DeciderParams { - dpMerchantAccount: dreq.merchantAccount, - dpOrder: dreq.orderReference, - dpTxnDetail: dreq.txnDetail, - dpTxnOfferDetails: dreq.txnOfferDetails, + dpMerchantAccount: dreq.merchant_account, + dpOrder: dreq.order_reference, + dpTxnDetail: dreq.txn_detail, + dpTxnOfferDetails: dreq.txn_offer_details, dpTxnCardInfo: update_txn_card_info, dpTxnOfferInfo: None, dpVaultProvider: m_vault_provider, - dpTxnType: dreq.txnType, + dpTxnType: dreq.txn_type, dpMerchantPrefs: merchant_prefs, - dpOrderMetadata: dreq.orderMetadata, + dpOrderMetadata: dreq.order_metadata, dpEnforceGatewayList: enforced_gateway_filter, - dpPriorityLogicOutput: dreq.priorityLogicOutput, - dpPriorityLogicScript: dreq.priorityLogicScript, - dpEDCCApplied: dreq.isEdccApplied, - dpShouldConsumeResult: dreq.shouldConsumeResult, + dpPriorityLogicOutput: dreq.priority_logic_output, + dpPriorityLogicScript: dreq.priority_logic_script, + dpEDCCApplied: dreq.is_edcc_applied, + dpShouldConsumeResult: dreq.should_consume_result, }; if dreq_.ranking_algorithm == Some(RankingAlgorithm::NtwBasedRouting) { @@ -136,7 +136,7 @@ pub async fn run_decider_flow( ) -> Result { let txnCreationTime = deciderParams .dpTxnDetail - .dateCreated + .date_created .clone() .to_string() .replace(" ", "T") @@ -162,14 +162,14 @@ pub async fn run_decider_flow( .dpTxnDetail .gateway .clone() - .or(deciderParams.dpOrder.preferredGateway.clone()); + .or(deciderParams.dpOrder.preferred_gateway.clone()); // let gatewayMgaIdMap = getGatewayToMGAIdMapF(&allMgas, &functionalGateways); logger::warn!( action = "PreferredGateway", tag = "PreferredGateway", "Preferred gateway provided by merchant for {:?} = {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, preferredGateway .clone() .map_or("None".to_string(), |pgw| pgw.to_string()) @@ -226,7 +226,7 @@ pub async fn run_decider_flow( "Preferred gateway {:?} functional/valid for merchant {:?} in txn {:?}", pgw, &deciderParams.dpMerchantAccount.merchantId, - deciderParams.dpTxnDetail.txnId + deciderParams.dpTxnDetail.txn_id ); Utils::log_gateway_decider_approach( &mut decider_flow, @@ -285,7 +285,7 @@ pub async fn run_decider_flow( tag = "gatewayPriorityList", action = "gatewayPriorityList", "Gateway priority for merchant for {:?} = {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, gatewayPriorityList ); @@ -294,7 +294,7 @@ pub async fn run_decider_flow( tag = "gatewayPriorityList", action = "Enforcing Priority Logic", "Enforcing Priority Logic for {:?}", - deciderParams.dpTxnDetail.txnId + deciderParams.dpTxnDetail.txn_id ); let (res, priorityLogicOutput) = filter_functional_gateways_with_enforcement( &mut decider_flow, @@ -308,7 +308,7 @@ pub async fn run_decider_flow( tag = "gatewayPriorityList", action = "gatewayPriorityList", "Functional gateways after filtering for Enforcement Logic for {:?} : {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, res ); decider_flow @@ -337,7 +337,7 @@ pub async fn run_decider_flow( action = "GW_Filtering", "Functional gateways after {:?} for {:?} : {:?}", "FilterByPriorityLogic", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, uniqueFunctionalGateways ); @@ -444,7 +444,7 @@ pub async fn run_decider_flow( action = "Decided Gateway", tag = "Decided Gateway", "Gateway decided for {:?} = {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, decidedGateway ); @@ -502,7 +502,7 @@ pub async fn run_decider_flow( }; let key = [ C::GATEWAY_SCORING_DATA, - &deciderParams.dpTxnDetail.txnUuid.clone(), + &deciderParams.dpTxnDetail.txn_uuid.clone(), ] .concat(); let updated_gateway_scoring_data = T::GatewayScoringData { diff --git a/src/decider/gatewaydecider/flows.rs b/src/decider/gatewaydecider/flows.rs index 4506eafb..628cc426 100644 --- a/src/decider/gatewaydecider/flows.rs +++ b/src/decider/gatewaydecider/flows.rs @@ -129,7 +129,7 @@ pub async fn decider_full_payload_hs_function( dreq: T::DomainDeciderRequest, ) -> Result<(T::DecidedGateway, Vec<(String, Vec)>), T::ErrorResponse> { let merchant_prefs = match ETM::merchant_iframe_preferences::getMerchantIPrefsByMId( - dreq.txnDetail.merchantId.0.clone(), + dreq.txn_detail.merchant_id.0.clone(), ) .await { @@ -139,7 +139,7 @@ pub async fn decider_full_payload_hs_function( tag = "getMerchantPrefsByMId", action = "getMerchantPrefsByMId", "Merchant iframe preferences not found for id: {:?}", - dreq.txnDetail.merchantId + dreq.txn_detail.merchant_id ); Err(T::ErrorResponse { status: "400".to_string(), @@ -160,15 +160,15 @@ pub async fn decider_full_payload_hs_function( })? } }; - let enforced_gateway_filter = handle_enforced_gateway(dreq.enforceGatewayList); - let resolve_bin = match Utils::fetch_extended_card_bin(&dreq.txnCardInfo.clone()) { + let enforced_gateway_filter = handle_enforced_gateway(dreq.enforce_gateway_list); + let resolve_bin = match Utils::fetch_extended_card_bin(&dreq.txn_card_info.clone()) { Some(card_bin) => Some(card_bin), - None => match dreq.txnCardInfo.card_isin { + None => match dreq.txn_card_info.card_isin { Some(c_isin) => { let res_bin = Utils::get_card_bin_from_token_bin(6, c_isin.as_str()).await; Some(res_bin) } - None => dreq.txnCardInfo.card_isin.clone(), + None => dreq.txn_card_info.card_isin.clone(), }, }; logger::debug!( @@ -177,28 +177,28 @@ pub async fn decider_full_payload_hs_function( "{:?}", resolve_bin.clone() ); - let m_vault_provider = Utils::get_vault_provider(dreq.cardToken.as_deref()); + let m_vault_provider = Utils::get_vault_provider(dreq.card_token.as_deref()); let update_txn_card_info = TxnCardInfo { card_isin: resolve_bin, - ..dreq.txnCardInfo + ..dreq.txn_card_info }; let decider_params = T::DeciderParams { - dpMerchantAccount: dreq.merchantAccount, - dpOrder: dreq.orderReference, - dpTxnDetail: dreq.txnDetail, - dpTxnOfferDetails: dreq.txnOfferDetails, + dpMerchantAccount: dreq.merchant_account, + dpOrder: dreq.order_reference, + dpTxnDetail: dreq.txn_detail, + dpTxnOfferDetails: dreq.txn_offer_details, dpTxnCardInfo: update_txn_card_info, dpTxnOfferInfo: None, dpVaultProvider: m_vault_provider, - dpTxnType: dreq.txnType, + dpTxnType: dreq.txn_type, dpMerchantPrefs: merchant_prefs, - dpOrderMetadata: dreq.orderMetadata, + dpOrderMetadata: dreq.order_metadata, dpEnforceGatewayList: enforced_gateway_filter, - dpPriorityLogicOutput: dreq.priorityLogicOutput, - dpPriorityLogicScript: dreq.priorityLogicScript, - dpEDCCApplied: dreq.isEdccApplied, - dpShouldConsumeResult: dreq.shouldConsumeResult, + dpPriorityLogicOutput: dreq.priority_logic_output, + dpPriorityLogicScript: dreq.priority_logic_script, + dpEDCCApplied: dreq.is_edcc_applied, + dpShouldConsumeResult: dreq.should_consume_result, }; run_decider_flow(decider_params, true).await } @@ -255,7 +255,7 @@ fn handle_enforced_gateway(gateway_list: Option>) -> Option>) -> Option Result<(T::DecidedGateway, Vec<(String, Vec)>), T::ErrorResponse> { let txnCreationTime = deciderParams .dpTxnDetail - .dateCreated + .date_created .clone() .to_string() .replace(" ", "T") @@ -346,14 +346,14 @@ pub async fn run_decider_flow( .dpTxnDetail .gateway .clone() - .or(deciderParams.dpOrder.preferredGateway.clone()); + .or(deciderParams.dpOrder.preferred_gateway.clone()); let gatewayMgaIdMap = get_gateway_to_mga_id_map_f(&allMgas, &functionalGateways); logger::warn!( action = "PreferredGateway", tag = "PreferredGateway", "Preferred gateway provided by merchant for {:?} = {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, preferredGateway .clone() .map_or("None".to_string(), |pgw| pgw.to_string()) @@ -411,7 +411,7 @@ pub async fn run_decider_flow( "Preferred gateway {:?} functional/valid for merchant {:?} in txn {:?}", pgw, &deciderParams.dpMerchantAccount.merchantId, - deciderParams.dpTxnDetail.txnId + deciderParams.dpTxnDetail.txn_id ); Utils::log_gateway_decider_approach( &mut decider_flow, @@ -459,7 +459,7 @@ pub async fn run_decider_flow( tag = "gatewayPriorityList", action = "gatewayPriorityList", "Gateway priority for merchant for {:?} = {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, gatewayPriorityList ); @@ -468,7 +468,7 @@ pub async fn run_decider_flow( tag = "gatewayPriorityList", action = "Enforcing Priority Logic", "Enforcing Priority Logic for {:?}", - deciderParams.dpTxnDetail.txnId + deciderParams.dpTxnDetail.txn_id ); let (res, priorityLogicOutput) = filter_functional_gateways_with_enforcement( &mut decider_flow, @@ -482,7 +482,7 @@ pub async fn run_decider_flow( tag = "gatewayPriorityList", action = "gatewayPriorityList", "Functional gateways after filtering for Enforcement Logic for {:?} : {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, res ); decider_flow @@ -511,7 +511,7 @@ pub async fn run_decider_flow( action = "GW_Filtering", "Functional gateways after {:?} for {:?} : {:?}", "FilterByPriorityLogic", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, uniqueFunctionalGateways ); @@ -619,7 +619,7 @@ pub async fn run_decider_flow( action = "Decided Gateway", tag = "Decided Gateway", "Gateway decided for {:?} = {:?}", - &deciderParams.dpTxnDetail.txnId, + &deciderParams.dpTxnDetail.txn_id, decidedGateway ); @@ -680,7 +680,7 @@ pub async fn run_decider_flow( let key = [ C::GATEWAY_SCORING_DATA, - &deciderParams.dpTxnDetail.txnUuid.clone(), + &deciderParams.dpTxnDetail.txn_uuid.clone(), ] .concat(); let updated_gateway_scoring_data = T::GatewayScoringData { @@ -969,7 +969,7 @@ pub async fn getFailureReasonWithFilter( let preferred_gateway_m = txn_detail .gateway .clone() - .or_else(|| order_reference.preferredGateway.clone()); + .or_else(|| order_reference.preferred_gateway.clone()); let filter_list = filterList(&debug_filter_list); let configured_gateways_m = filter_list .iter() @@ -1013,7 +1013,7 @@ pub async fn getFailureReasonWithFilter( format!( "No functional gateways after filtering for authType {}", txn_card_info - .authType + .auth_type .as_ref() .map(|auth_type| auth_type.clone().to_string()) .unwrap_or_default() @@ -1034,8 +1034,8 @@ pub async fn getFailureReasonWithFilter( .map(|emi| emi.to_lowercase()) .unwrap_or_else(|| "emi".to_string()) ); - let emi_bank = format!("{} ", txn_detail.emiBank.clone().unwrap_or_default()); - if Utils::is_card_transaction(txn_card_info) && txn_detail.isEmi != Some(true) { + let emi_bank = format!("{} ", txn_detail.emi_bank.clone().unwrap_or_default()); + if Utils::is_card_transaction(txn_card_info) && txn_detail.is_emi != Some(true) { "Gateways configured supports only emi transaction.".to_string() } else if Utils::is_card_transaction(txn_card_info) { let is_bin_eligible = Utils::check_if_bin_is_eligible_for_emi( @@ -1065,7 +1065,7 @@ pub async fn getFailureReasonWithFilter( "filterFunctionalGatewaysForPaymentMethod" => { format!( "No functional gateways supporting {} payment method.", - txn_card_info.paymentMethod + txn_card_info.payment_method ) } "filterFunctionalGatewaysForTokenProvider" => { @@ -1090,14 +1090,14 @@ pub async fn getFailureReasonWithFilter( } } "filterFunctionalGatewaysForConsumerFinance" => { - if txn_card_info.paymentMethodType == CONSUMER_FINANCE { + if txn_card_info.payment_method_type == CONSUMER_FINANCE { "No functional gateways supporting Consumer Finance transaction.".to_string() } else { "Gateways configured supports only Consumer Finance transaction.".to_string() } } "filterFunctionalGatewaysForUpi" => { - if txn_card_info.paymentMethodType == UPI { + if txn_card_info.payment_method_type == UPI { "No functional gateways supporting UPI transaction.".to_string() } else if !is_google_pay_txn(txn_card_info.clone()) { "Gateways configured supports only UPI transaction.".to_string() @@ -1115,12 +1115,12 @@ pub async fn getFailureReasonWithFilter( "filterFunctionalGatewaysForTxnDetailType" => { format!( "No functional gateways supporting {:?}transaction.", - txn_detail.txnType + txn_detail.txn_type ) } "filterFunctionalGatewaysForReward" => { if txn_card_info.card_type == Some(CardType::Reward) - || txn_card_info.paymentMethodType == REWARD + || txn_card_info.payment_method_type == REWARD { "No functional gateways supporting Reward transaction.".to_string() } else { @@ -1128,7 +1128,7 @@ pub async fn getFailureReasonWithFilter( } } "filterFunctionalGatewaysForCash" => { - if txn_card_info.paymentMethodType == CASH { + if txn_card_info.payment_method_type == CASH { "No functional gateways supporting CASH transaction.".to_string() } else { "Gateways configured supports only CASH transaction.".to_string() @@ -1146,7 +1146,7 @@ pub async fn getFailureReasonWithFilter( .as_ref() .and_then(|meta| meta.isCvvLessTxn) .unwrap_or(false) - && txn_card_info.authType == Some(AuthType::Moto) + && txn_card_info.auth_type == Some(AuthType::Moto) { format!( "No functional gateways supporting cvv less {}repeat moto transaction.", diff --git a/src/decider/gatewaydecider/gw_filter.rs b/src/decider/gatewaydecider/gw_filter.rs index 7eeede3a..86ced50e 100644 --- a/src/decider/gatewaydecider/gw_filter.rs +++ b/src/decider/gatewaydecider/gw_filter.rs @@ -84,7 +84,7 @@ pub fn returnGwListWithLog( let fgws = this.writer.functionalGateways.clone(); // Get the transaction ID from the context - let txn_id = this.get().dpTxnDetail.txnId.clone(); + let txn_id = this.get().dpTxnDetail.txn_id.clone(); // Log the filtered gateways logger::debug!( @@ -150,7 +150,7 @@ pub fn setGws(this: &mut DeciderFlow<'_>, gws: Vec) { // let _ = getFunctionalGateways(); // let gws = filterFunctionalGateways(); // if gws.is_empty() { -// let txnId = asks(|ctx| ctx.dpTxnDetail.txnId.clone()); +// let txnId = asks(|ctx| ctx.dpTxnDetail.txn_id.clone()); // let merchantId = asks(|ctx| ctx.dpTxnDetail.merchantId.clone()); // log_warning("GW_Filtering", format!( // "There are no functional gateways for {} for merchant: {}", @@ -182,8 +182,8 @@ pub async fn newGwFilters( let _ = getFunctionalGateways(this).await; let gws = filterFunctionalGateways(this).await; if gws.is_empty() { - let txnId = this.get().dpTxnDetail.txnId.clone(); - let merchantId = this.get().dpTxnDetail.merchantId.clone(); + let txnId = this.get().dpTxnDetail.txn_id.clone(); + let merchantId = this.get().dpTxnDetail.merchant_id.clone(); logger::warn!( tag = "GW_Filtering", action = "GW_Filtering", @@ -238,7 +238,7 @@ pub async fn getFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList { let txn_card_info = this.get().dpTxnCardInfo.clone(); let oref = this.get().dpOrder.clone(); let macc = this.get().dpMerchantAccount.clone(); - let txn_id = this.get().dpTxnDetail.txnId.clone(); + let txn_id = this.get().dpTxnDetail.txn_id.clone(); let txn_detail = this.get().dpTxnDetail.clone(); let is_edcc_applied = this.get().dpEDCCApplied; let enforce_gateway_list = this.get().dpEnforceGatewayList.clone(); @@ -280,7 +280,7 @@ pub async fn getFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList { Utils::set_payment_flow_list(this, payment_flow_list); let mgas_ = match ( - txn_detail.isEmi.unwrap_or(false) || Utils::is_reccuring_payment_transaction(&txn_detail), + txn_detail.is_emi.unwrap_or(false) || Utils::is_reccuring_payment_transaction(&txn_detail), &enforce_gateway_list, ) { (false, _) => enabled_gateway_accounts.clone(), @@ -379,7 +379,7 @@ pub async fn getFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList { mga, &txn_card_info, txn_detail - .txnObjectType + .txn_object_type .clone() .unwrap_or(TxnObjectType::Unknown), &mga_eligible_seamless_gateways, @@ -622,7 +622,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList let txnCardInfo = this.get().dpTxnCardInfo.clone(); let mAcc = this.get().dpMerchantAccount.clone(); let mInternalMeta: Option = txnDetail - .internalMetadata + .internal_metadata .as_ref() .and_then(|meta| serde_json::from_str(meta.peek()).ok()); @@ -631,7 +631,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList // CVV Less Gateway Validations if Utils::is_card_transaction(&txnCardInfo) { if let Some(true) = mInternalMeta.as_ref().and_then(|meta| meta.isCvvLessTxn) { - if txnCardInfo.authType == Some(AuthType::Moto) { + if txnCardInfo.auth_type == Some(AuthType::Moto) { let st = getGws(this); let authTypeRestrictedGateways = findByNameFromRedis::>>( @@ -640,7 +640,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList .await .unwrap_or_else(HashMap::new); let motoSupportedGateways: Vec = txnCardInfo - .authType + .auth_type .as_ref() .and_then(|auth_type| authTypeRestrictedGateways.get(auth_type)) .cloned() @@ -653,12 +653,12 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways after filtering for MOTO cvvLessTxns support for txn_id: {:?}", - txnDetail.txnId + txnDetail.txn_id ); setGws(this, filtered_gateways); } else if Utils::is_token_repeat_txn(mInternalMeta.clone()) { let brand = txnCardInfo - .cardSwitchProvider + .card_switch_provider .as_ref() .map(|provider| provider.peek().to_string()) .unwrap_or_else(|| "DEFAULT".to_string()); @@ -685,7 +685,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList tag = "CVVLESS-ERROR", action = "CVVLESS-ERROR", "CVVLESS_FLOW_DISABLED for txn_id: {:?}", - txnDetail.txnId + txnDetail.txn_id ); Vec::new() } else { @@ -745,7 +745,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways after filtering for token repeat cvvLessTxns support for txn_id: {:?}", - txnDetail.txnId + txnDetail.txn_id ); setGws(this, functionalGateways); } else { @@ -781,7 +781,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways after filtering for token repeat cvvLessTxns support for txn_id: {:?}", - txnDetail.txnId + txnDetail.txn_id ); setGws(this, functionalGateways) } @@ -798,7 +798,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList .into_iter() .chain( cardBrandToCvvLessTxnSupportedGateways - .get(&txnCardInfo.paymentMethod) + .get(&txnCardInfo.payment_method) .cloned() .unwrap_or_default(), ) @@ -815,7 +815,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways after filtering for cvvLessTxns for txn_id: {:?}", - txnDetail.txnId + txnDetail.txn_id ); setGws(this, filtered_gateways); } @@ -826,7 +826,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList // Card token based repeat transaction gateway filter if Utils::is_card_transaction(&txnCardInfo) && Utils::is_token_repeat_txn(mInternalMeta.clone()) { - if let Some(secAuthType) = txnCardInfo.authType.clone() { + if let Some(secAuthType) = txnCardInfo.auth_type.clone() { if secAuthType == AuthType::Otp { let mTokenRepeatOtpSupportedGateways = Utils::get_token_supported_gateways( txnDetail.clone(), @@ -865,7 +865,7 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList } // Amex BTA Card based gateway filter - if Utils::is_card_transaction(&txnCardInfo) && txnCardInfo.authType == Some(AuthType::Moto) { + if Utils::is_card_transaction(&txnCardInfo) && txnCardInfo.auth_type == Some(AuthType::Moto) { let paymentFlowList = Utils::get_payment_flow_list_from_txn_detail(&txnDetail); let st = getGws(this); if paymentFlowList.contains(&"TA_FILE".to_string()) { @@ -888,13 +888,13 @@ pub async fn filterFunctionalGateways(this: &mut DeciderFlow<'_>) -> GatewayList tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways before filtering for MerchantContainer for txn_id: {:?}", - txnDetail.txnId + txnDetail.txn_id ); let merchantContainerSupportedGateways: Vec = findByNameFromRedis(C::MerchantContainerSupportedGateways.get_key()) .await .unwrap_or_default(); - let filtered_gateways: Vec = if txnCardInfo.paymentMethodType == MERCHANT_CONTAINER { + let filtered_gateways: Vec = if txnCardInfo.payment_method_type == MERCHANT_CONTAINER { st.into_iter() .filter(|gw| merchantContainerSupportedGateways.contains(gw)) .collect() @@ -920,7 +920,7 @@ async fn check_cvv_less_support_rupay(txnCardInfo: &TxnCardInfo) -> bool { let mCardType = txnCardInfo.card_type.as_ref().map(ETCA::card_type_to_text); if let Some(bCode) = bankCode { let feature_key = - C::getTokenRepeatCvvLessBankCodeKey(txnCardInfo.cardSwitchProvider.clone()).get_key(); + C::getTokenRepeatCvvLessBankCodeKey(txnCardInfo.card_switch_provider.clone()).get_key(); let dimension = format!( "{}::{}", bCode, @@ -1036,7 +1036,7 @@ pub async fn filterGatewaysForAuthType( if let Some(ref card_isin) = txn_card_info.card_isin { // Filter for OTP authentication type if txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::Otp) .unwrap_or(false) @@ -1056,7 +1056,7 @@ pub async fn filterGatewaysForAuthType( // Filter for MOTO authentication type if txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::Moto) .unwrap_or(false) @@ -1076,7 +1076,7 @@ pub async fn filterGatewaysForAuthType( // Filter for NoThreeDs authentication type if txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::NoThreeDs) .unwrap_or(false) @@ -1096,7 +1096,7 @@ pub async fn filterGatewaysForAuthType( // Filter for VIES authentication type if txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::Vies) .unwrap_or(false) @@ -1199,7 +1199,7 @@ pub async fn filterGatewaysForAuthType( macc, card_isin.to_string(), card_info_check_needed_gateways, - txn_card_info.authType, + txn_card_info.auth_type, ) .await?; @@ -1207,7 +1207,7 @@ pub async fn filterGatewaysForAuthType( tag = "filterFunctionalGatewaysForAuthType", action = "filterFunctionalGatewaysForAuthType", "Functional gateways after filtering after DISABLE_DECIDER_BIN_ELIGIBILITY_CHECK check: {:?}: {:?}", - txn_detail.txnId, + txn_detail.txn_id, gci_validated_gws .iter() .chain(auth_type_supported_gws.iter()) @@ -1244,7 +1244,7 @@ fn isGatewayCardInfoCheckNeeded( ) -> bool { // Check for ATM PIN auth type and if the gateway is in the restricted list txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::Atmpin) .unwrap_or(false) @@ -1252,7 +1252,7 @@ fn isGatewayCardInfoCheckNeeded( || // Check for OTP auth type and if the gateway supports it txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::Otp) .unwrap_or(false) @@ -1260,7 +1260,7 @@ fn isGatewayCardInfoCheckNeeded( || // Check for MOTO auth type and if the gateway supports it txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::Moto) .unwrap_or(false) @@ -1276,19 +1276,19 @@ fn isAuthTypeSupportedGateway( ) -> bool { // First try to get gateways for this auth type from the restricted map txn_card_info - .authType + .auth_type .as_ref() .and_then(|auth_type| auth_type_restricted_gateways.get(auth_type)) .map(|gws| gws.contains(gateway)) .unwrap_or_else(|| { // Check if auth type is VIES (special case that's always allowed) (txn_card_info - .authType + .auth_type .as_ref() .map(|at| *at == AuthType::Vies) .unwrap_or(false)) || !(txn_card_info - .authType + .auth_type .as_ref() .map(|auth_type| { *auth_type != AuthType::Atmpin @@ -1296,7 +1296,7 @@ fn isAuthTypeSupportedGateway( }) .unwrap_or(false)) && !(txn_card_info - .authType + .auth_type .as_ref() .map(|auth_type| { *auth_type != AuthType::Otp @@ -1346,7 +1346,7 @@ pub async fn filterFunctionalGatewaysForOTMFlow(this: &mut DeciderFlow<'_>) -> V // Check if this is a One-Time Mandate flow let payment_flow_list = Utils::get_payment_flow_list_from_txn_detail(&txn_detail); let is_otm_flow = payment_flow_list.contains(&"ONE_TIME_MANDATE".to_string()); - let internal_tracking_info = txn_detail.internalTrackingInfo.clone(); + let internal_tracking_info = txn_detail.internal_tracking_info.clone(); if is_otm_flow { // Get order metadata and ref IDs @@ -1384,13 +1384,13 @@ pub async fn filterFunctionalGatewaysForOTMFlow(this: &mut DeciderFlow<'_>) -> V .collect::>(); // If we have a valid bank code, do additional filtering based on payment method flow - if let Some(jbc) = find_bank_code(txn_card_info.paymentMethod).await { + if let Some(jbc) = find_bank_code(txn_card_info.payment_method).await { // Find all gateway payment method flows for OTM with this bank code let all_gpmf_entries = GPMF::find_all_gpmf_by_country_code_gw_pf_id_pmt_jbcid_db( crate::types::country::country_iso::CountryISO::IND, gw_list, PaymentFlow::OneTimeMandate, - txn_card_info.paymentMethodType, + txn_card_info.payment_method_type, jbc.id, ) .await @@ -1504,7 +1504,7 @@ pub async fn filterGatewaysForValidationType( tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways after filtering after filterGatewaysCardInfo for txn_id {:?}: {:?}", - txn_detail.txnId, m_new_gateways + txn_detail.txn_id, m_new_gateways ); // Clean gateway list and combine with excluded list @@ -1538,19 +1538,19 @@ pub async fn filterGatewaysForValidationType( tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways after filtering for token repeat Mandate support for txn_id {:?}: {:?}", - txn_detail.txnId, final_gws + txn_detail.txn_id, final_gws ); setGws(this, final_gws); } // Handle non-express checkout, non-token repeat transactions - if !txn_detail.expressCheckout.unwrap_or(false) + if !txn_detail.express_checkout.unwrap_or(false) && !Utils::is_token_repeat_txn(m_internal_meta) { let m_mandate_guest_checkout_supported_gateways: Option> = findByNameFromRedis( - C::getmandateGuestCheckoutKey(txn_card_info.cardSwitchProvider).get_key(), + C::getmandateGuestCheckoutKey(txn_card_info.card_switch_provider).get_key(), ) .await; @@ -1569,7 +1569,7 @@ pub async fn filterGatewaysForValidationType( tag = "filterFunctionalGateways", action = "filterFunctionalGateways", "Functional gateways after filtering for Mandate Guest Checkout support for txn_id {:?}: {:?}", - txn_detail.txnId, final_gws + txn_detail.txn_id, final_gws ); setGws(this, final_gws); @@ -1587,7 +1587,7 @@ pub async fn filterGatewaysForValidationType( if is_otm_flow { logger::info!( "Skipping processing for OTM flow for txn_id {:?}", - txn_detail.txnId.clone() + txn_detail.txn_id.clone() ); } else // Filter enabled gateway accounts @@ -1655,7 +1655,7 @@ pub async fn filterGatewaysForValidationType( txn_card_info.clone(), enabled_gateway_accounts.clone(), validation_type, - transaction_id_to_text(txn_detail.txnId.clone()), + transaction_id_to_text(txn_detail.txn_id.clone()), ) .await; @@ -1683,7 +1683,7 @@ pub async fn filterGatewaysForValidationType( logger::debug!( "nst for filterGatewaysForValidationType for txn_id {:?}: {:?}", - txn_detail.txnId.clone(), + txn_detail.txn_id.clone(), nst ); @@ -2052,7 +2052,7 @@ pub async fn filterByGatewayRule( gw_list_acc: Vec, txn_offer_detail: &ETOD::TxnOfferDetail, ) -> Vec { - match &txn_offer_detail.gatewayInfo { + match &txn_offer_detail.gateway_info { // If no gateway info in offer, return original list None => gw_list_acc, @@ -2083,16 +2083,16 @@ pub async fn filterByGatewayRule( // Commented out log as requested // debug!( // "For txn with id = {}, offerId = {}, parsing result is {:?}", - // txn_detail.txnId, - // txn_offer_detail.offerId, + // txn_detail.txn_id, + // txn_offer_detail.offer_id, // err // ); logger::debug!( tag = "GatewayRuleParsingError", action = "GatewayRuleParsingError", "For txn with id = {:?}, offerId = {}, parsing result is {:?}", - txn_detail.txnId, - txn_offer_detail.offerId, + txn_detail.txn_id, + txn_offer_detail.offer_id, err ); @@ -2115,11 +2115,11 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { tag = "GW_Filtering", action = "GW_Filtering", "For txn with id = {:?} isEmi = {:?}", - txn_detail.txnId, - txn_detail.isEmi + txn_detail.txn_id, + txn_detail.is_emi ); - if txn_detail.isEmi.unwrap_or(false) { + if txn_detail.is_emi.unwrap_or(false) { let is_mandate_txn = Utils::is_mandate_transaction(&txn_detail); let si_on_emi_card_supported_gateways: HashSet = findByNameFromRedis::>(C::SiOnEmiCardSupportedGateways.get_key()) @@ -2154,7 +2154,7 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { logger::debug!( "For txn with id = {:?}, Filtering out gateways: {:?} for card brand: {:?}", - txn_detail.txnId, + txn_detail.txn_id, disabled_gws, card_brand.unwrap_or_else(|| "UNKNOWN".to_string()) ); @@ -2217,7 +2217,7 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { { "ALT_ID" } else if txn_detail - .emiBank + .emi_bank .as_deref() .is_some_and(|bank| bank.ends_with("_CLEMI")) { @@ -2231,7 +2231,7 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { tag = "filterGatewaysForEmi", action = "filterGatewaysForEmi", "filterGatewaysForEmi gateway list before getGatewayBankEmiSupport for txn_id :{:?}, where gateway is : {:?}", - txn_detail.txnId, + txn_detail.txn_id, gws.clone() ); @@ -2243,15 +2243,15 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { .await; if gbes_v2_flag { let gbes_v2_list_ = SGBES::get_gateway_bank_emi_support_v2( - txn_detail.emiBank.clone(), + txn_detail.emi_bank.clone(), gws.clone(), scope_.to_string(), - txn_detail.emiTenure, + txn_detail.emi_tenure, ) .await; let gbes_v2_list = if scope_ == "ALT_ID" { - let emi_bank = txn_detail.emiBank.clone(); + let emi_bank = txn_detail.emi_bank.clone(); let mut gbesV2List = Vec::new(); for gbes in gbes_v2_list_.clone() { let is_enabled = if let Some(emi_bank) = emi_bank.clone() { @@ -2277,10 +2277,10 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { tag = "GBESV2 Entry Not Found", action = "GBESV2 Entry Not Found", "GBESV2 Entry Not Found For emiBank - {:?}, gateways - {:?}, scope_ - {:?}, tenure - {:?}", - txn_detail.emiBank, + txn_detail.emi_bank, gws.clone(), scope_, - txn_detail.emiTenure + txn_detail.emi_tenure ); } let gbes_v2_filtered: Vec = gbes_v2_list @@ -2294,7 +2294,7 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { match mb_metadata.and_then(|meta| meta.supported_networks) { Some(supported_networks) => supported_networks .iter() - .any(|network| txn_card_info.paymentMethod == network.to_string()), + .any(|network| txn_card_info.payment_method == network.to_string()), None => true, } }) @@ -2303,14 +2303,14 @@ pub async fn filterGatewaysForEmi(this: &mut DeciderFlow<'_>) -> GatewayList { extractGatewaysV2(gbes_v2_filtered) } else { let gbes_list_ = SGBES::get_gateway_bank_emi_support( - txn_detail.emiBank.clone(), + txn_detail.emi_bank.clone(), gws.clone(), scope_.to_string(), ) .await; let gbes_list = if scope_ == "ALT_ID" { - let emi_bank = txn_detail.emiBank.clone(); + let emi_bank = txn_detail.emi_bank.clone(); let mut gbesList = Vec::new(); for gbes in gbes_list_.clone() { let is_enabled = if let Some(emi_bank) = emi_bank.clone() { @@ -2410,14 +2410,14 @@ pub async fn filterGatewaysForPaymentMethod(this: &mut DeciderFlow<'_>) -> Vec) -> Vec) -> Vec String { if matches!( - txn_card_info.paymentMethodType.as_str(), + txn_card_info.payment_method_type.as_str(), CONSUMER_FINANCE | UPI | REWARD | CASH ) { - txn_card_info.paymentMethod.clone() + txn_card_info.payment_method.clone() } else { - txn_card_info.cardIssuerBankName.clone().unwrap_or_default() + txn_card_info.card_issuer_bank_name.clone().unwrap_or_default() } } @@ -2569,7 +2569,7 @@ fn canAcceptPaymentMethod(mga: &MerchantGatewayAccount, pm: &str) -> bool { pub async fn filterGatewaysForTokenProvider(this: &mut DeciderFlow<'_>) -> GatewayList { let st = getGws(this); let vault = this.get().dpVaultProvider.clone(); - let txn_id = this.get().dpTxnDetail.txnId.clone(); + let txn_id = this.get().dpTxnDetail.txn_id.clone(); logger::debug!( tag = "filterGatewaysForTokenProvider", @@ -2791,7 +2791,7 @@ pub fn validate_only_one_mga( tag = "INVALID_MGA_CONFIGURATION", action = "INVALID_MGA_CONFIGURATION", "txn_id: {:?}, gwt: {}", - txn_detail.txnId, + txn_detail.txn_id, gwt ); None @@ -2807,7 +2807,7 @@ pub fn filterForEMITenureSpecificMGAs(this: &mut DeciderFlow<'_>) -> Vec let txn_detail = this.get().dpTxnDetail.clone(); // Only filter if transaction is EMI - if txn_detail.isEmi.unwrap_or(false) { + if txn_detail.is_emi.unwrap_or(false) { // Get current functional gateways let st = getGws(this); @@ -2830,9 +2830,9 @@ pub fn filterForEMITenureSpecificMGAs(this: &mut DeciderFlow<'_>) -> Vec match serde_json::from_str::(acc_details) { Ok(emi_details) => { // Check if EMI details match transaction EMI requirements - get_emi(emi_details.isEmi) == txn_detail.isEmi.unwrap_or(false) + get_emi(emi_details.isEmi) == txn_detail.is_emi.unwrap_or(false) && get_tenure(emi_details.emiTenure) - == txn_detail.emiTenure.unwrap_or(0) + == txn_detail.emi_tenure.unwrap_or(0) } _ => true, // If parsing fails, keep the gateway } @@ -2888,7 +2888,7 @@ pub async fn filterGatewaysForConsumerFinance(this: &mut DeciderFlow<'_>) -> Vec .into_iter() .collect::>(); - if txn_card_info.paymentMethodType == CONSUMER_FINANCE { + if txn_card_info.payment_method_type == CONSUMER_FINANCE { let consumer_finance_also_gateways: Vec = findByNameFromRedis::>(C::ConsumerFinanceAlsoGateways.get_key()) .await @@ -2938,7 +2938,7 @@ pub async fn filterGatewaysForUpi(this: &mut DeciderFlow<'_>) -> Vec { //Convert upi_only_gateways to > let upi_only_gateways_hashset = upi_only_gateways.into_iter().collect::>(); - if txn_card_info.paymentMethodType == UPI { + if txn_card_info.payment_method_type == UPI { let upi_also_gateway: Vec = findByNameFromRedis::>(C::UpiAlsoGateways.get_key()) .await @@ -2986,7 +2986,7 @@ pub async fn filterGatewaysForTxnType(this: &mut DeciderFlow<'_>) -> Vec Some(txn_type) => { let mgas = Utils::get_mgas(this).unwrap_or_default(); let (st, curr_mgas) = - if txn_card_info.paymentMethodType == UPI && txn_card_info.paymentMethod == UPI { + if txn_card_info.payment_method_type == UPI && txn_card_info.payment_method == UPI { let functional_mgas: Vec<_> = mgas .iter() .filter(|mga| { @@ -3130,7 +3130,7 @@ pub fn filterGatewaysForUpiPayBasedOnSupportedFlow( pub async fn filterGatewaysForTxnDetailType(this: &mut DeciderFlow<'_>) -> Vec { let st = getGws(this); - let m_txn_type = this.get().dpTxnDetail.txnType.clone(); + let m_txn_type = this.get().dpTxnDetail.txn_type.clone(); let txn_type: &str = m_txn_type.as_deref().unwrap_or(""); let txn_detail_type_restricted_gateways = findByNameFromRedis(C::TxnDetailTypeRestrictedGateways.get_key()) @@ -3167,7 +3167,7 @@ fn get_zero_auth_supported_gateways( pub async fn filterGatewaysForReward(this: &mut DeciderFlow<'_>) -> Vec { let st = getGws(this); - let payment_method_type = this.get().dpTxnCardInfo.paymentMethodType.clone(); + let payment_method_type = this.get().dpTxnCardInfo.payment_method_type.clone(); let card_type = this.get().dpTxnCardInfo.card_type.clone(); let reward_also_gateways: HashSet = findByNameFromRedis(C::RewardAlsoGateways.get_key()) @@ -3201,7 +3201,7 @@ pub async fn filterGatewaysForReward(this: &mut DeciderFlow<'_>) -> Vec pub async fn filterGatewaysForCash(this: &mut DeciderFlow<'_>) -> Vec { let st = getGws(this); - let payment_method_type = this.get().dpTxnCardInfo.paymentMethodType.clone(); + let payment_method_type = this.get().dpTxnCardInfo.payment_method_type.clone(); if payment_method_type != CASH { let cash_only_gateways: Vec = findByNameFromRedis(C::CashOnlyGateways.get_key()) .await diff --git a/src/decider/gatewaydecider/gw_scoring.rs b/src/decider/gatewaydecider/gw_scoring.rs index e0b15095..da1cd0c0 100644 --- a/src/decider/gatewaydecider/gw_scoring.rs +++ b/src/decider/gatewaydecider/gw_scoring.rs @@ -120,7 +120,7 @@ pub fn reset_metric_log_data(decider_flow: &mut DeciderFlow<'_>) { dateCreated: decider_flow .get() .dpTxnDetail - .dateCreated + .date_created .clone() .to_string() .replace(" UTC", "Z") @@ -147,7 +147,7 @@ pub fn return_sm_with_log( do_or_not: bool, ) -> GatewayScoreMap { let sr = decider_flow.writer.gwScoreMap.clone(); - let txn_id = decider_flow.get().dpTxnDetail.txnId.clone(); + let txn_id = decider_flow.get().dpTxnDetail.txn_id.clone(); logger::debug!( tag = "GW_Scoring", action = "GW_Scoring", @@ -204,12 +204,12 @@ pub async fn scoring_flow( action = "scoringFlow", "Intelligent routing not triggered due to 1 gateway eligible for merchant {:?} and for txn Id {:?}", Utils::get_m_id(merchant.merchantId.clone()), - txn_detail.txnId + txn_detail.txn_id ); } else { - let pmt = decider_flow.get().dpTxnCardInfo.paymentMethodType.clone(); - let pm = decider_flow.get().dpTxnCardInfo.paymentMethod.clone(); - let maybe_source_object = decider_flow.get().dpTxnDetail.sourceObject.clone(); + let pmt = decider_flow.get().dpTxnCardInfo.payment_method_type.clone(); + let pm = decider_flow.get().dpTxnCardInfo.payment_method.clone(); + let maybe_source_object = decider_flow.get().dpTxnDetail.source_object.clone(); let pmt_str = pmt.clone(); let pm_str = Utils::get_payment_method( @@ -240,7 +240,7 @@ pub async fn scoring_flow( action = "scoringFlow", "Deciding Gateway based on SR V3 Routing for merchant {:?} and for txn Id {:?}", Utils::get_m_id(merchant.merchantId.clone()), - txn_detail.txnId.clone() + txn_detail.txn_id.clone() ); let merchant_sr_v3_input_config = findByNameFromRedis( @@ -266,13 +266,13 @@ pub async fn scoring_flow( let sr_routing_dimesions = SrRoutingDimensions { card_network: txn_card_info - .cardSwitchProvider + .card_switch_provider .as_ref() .map(|s| s.peek().to_string()), card_isin: txn_card_info.card_isin.clone(), currency: Some(decider_flow.get().dpOrder.currency.to_string()), country: txn_detail.country.as_ref().map(|a| a.to_string()), - auth_type: txn_card_info.authType.as_ref().map(|a| a.to_string()), + auth_type: txn_card_info.auth_type.as_ref().map(|a| a.to_string()), }; let hedging_percent = Utils::get_sr_v3_hedging_percent( @@ -329,7 +329,7 @@ pub async fn scoring_flow( tag = "scoringFlow", action = "scoringFlow", "Gateway Scores based on SR V3 Routing for txn id : {:?} is {:?}", - txn_detail.txnId.clone(), + txn_detail.txn_id.clone(), initial_sr_gw_scores_list ); @@ -340,7 +340,7 @@ pub async fn scoring_flow( tag = "scoringFlow", action = "scoringFlow", "Considering Gateway Scores based on SR V3 for txn id : {:?}", - txn_detail.txnId.clone() + txn_detail.txn_id.clone() ); if should_explore { @@ -389,7 +389,7 @@ pub async fn scoring_flow( // Utils::add_txn_to_hash_map_if_debug_mode( // is_debug_mode_enabled, - // Utils::get_m_id(&merchant.merchant_id), + // Utils::get_m_id(&merchant.merchantId), // txn_detail.clone(), // ); } @@ -400,7 +400,7 @@ pub async fn scoring_flow( tag="scoringFlow", action = "scoringFlow", "Gateway Scores based on SR V3 for txn id : {:?} and for merchant : {:?} is null, So falling back to priorityLogic", - txn_detail.txnId.clone(), + txn_detail.txn_id.clone(), Utils::get_m_id(merchant.merchantId.clone()) ); @@ -426,7 +426,7 @@ pub async fn scoring_flow( action = "scoringFlow", "Ordering gateways available based on PRIORITY for merchant {:?} and for txn Id {:?}", Utils::get_m_id(merchant.merchantId.clone()), - txn_detail.txnId.clone() + txn_detail.txn_id.clone() ); set_decider_approach(decider_flow, GatewayDeciderApproach::PriorityLogic); let gateway_score = @@ -437,7 +437,7 @@ pub async fn scoring_flow( tag = "scoringFlow", action = "scoringFlow", "Gateway scores after considering priority for {:?} : {:?}", - txn_detail.txnId.clone(), + txn_detail.txn_id.clone(), toListOfGatewayScore(gateway_score.clone()) ); // update_score_for_issuer(decider_flow); @@ -449,7 +449,7 @@ pub async fn scoring_flow( action = "scoringFlow", "skipped priority for merchant {:?} and for txn Id {:?}", Utils::get_m_id(merchant.merchantId.clone()), - txn_detail.txnId.clone() + txn_detail.txn_id.clone() ); } @@ -481,7 +481,7 @@ pub async fn get_cached_scores_based_on_srv3( gateway_scoring_data: GatewayScoringData, ) -> GatewayScoreMap { let merchant = decider_flow.get().dpMerchantAccount.clone(); - let pmt = decider_flow.get().dpTxnCardInfo.paymentMethodType.clone(); + let pmt = decider_flow.get().dpTxnCardInfo.payment_method_type.clone(); let order_ref = decider_flow.get().dpOrder.clone(); let pmt_str = pmt; let functional_gateways = getGws(decider_flow); @@ -509,7 +509,7 @@ pub async fn get_cached_scores_based_on_srv3( let sr_routing_dimesions = SrRoutingDimensions { card_network: txn_card_info - .cardSwitchProvider + .card_switch_provider .as_ref() .map(|s| s.peek().to_string()), card_isin: txn_card_info.card_isin, @@ -520,7 +520,7 @@ pub async fn get_cached_scores_based_on_srv3( .country .as_ref() .map(|a| a.to_string()), - auth_type: txn_card_info.authType.as_ref().map(|a| a.to_string()), + auth_type: txn_card_info.auth_type.as_ref().map(|a| a.to_string()), }; let merchant_bucket_size = Utils::get_sr_v3_bucket_size( @@ -1030,8 +1030,8 @@ pub async fn update_score_for_outage(decider_flow: &mut DeciderFlow<'_>) -> Gate logger::debug!("updated score for outage filtered {:?}", out_gws); logger::debug!( "updated score for outage info: {:?}, {:?}, {:?}", - txn_detail.txnObjectType, - txn_detail.sourceObject, + txn_detail.txn_object_type, + txn_detail.source_object, Utils::fetch_juspay_bank_code(&txn_card_info) ); @@ -1052,11 +1052,11 @@ pub async fn update_score_for_outage(decider_flow: &mut DeciderFlow<'_>) -> Gate // checkScheduledOutage :: ETTD.TxnDetail -> TxnCardInfo -> ETM.MerchantId -> Maybe ETJ.JuspayBankCode -> ETGO.GatewayOutage -> Bool // checkScheduledOutage txnDetail txnCardInfo merchantId juspayBankCode scheduledOutage = -// (scheduleEqualTo (==) (Just merchantId) scheduledOutage.merchantId) -// && (if (txnCardInfo.paymentMethod == UPI) -// then (scheduleEqualTo (==) txnDetail.sourceObject scheduledOutage.paymentMethod) -// else scheduleEqualTo (==) (Just txnCardInfo.paymentMethod) scheduledOutage.paymentMethod) -// && (scheduleEqualTo (==) (Just txnCardInfo.paymentMethodType) scheduledOutage.paymentMethodType) +// (scheduleEqualTo (==) (Just merchantId) scheduledOutage.merchant_id) +// && (if (txnCardInfo.payment_method == UPI) +// then (scheduleEqualTo (==) txnDetail.source_object scheduledOutage.payment_method) +// else scheduleEqualTo (==) (Just txnCardInfo.payment_method) scheduledOutage.payment_method) +// && (scheduleEqualTo (==) (Just txnCardInfo.payment_method_type) scheduledOutage.payment_method_type) // && (scheduleEqualTo (\jbc outageBank -> jbc.bankCode == outageBank || jbc.bankName == outageBank ) juspayBankCode scheduledOutage.bank) // && (checkScheduledOutageMetadata txnDetail txnCardInfo scheduledOutage.metadata) @@ -1089,21 +1089,21 @@ fn check_scheduled_outtage( |x: ETM::id::MerchantId, y: ETM::id::MerchantId| x == y, Some(merchant_id.clone()), scheduled_outage.merchantId.clone(), - ) && if txn_card_info.paymentMethodType == UPI { + ) && if txn_card_info.payment_method_type == UPI { schedule_equal_to( |x, y| x == y, - txn_detail.sourceObject.clone(), + txn_detail.source_object.clone(), scheduled_outage.paymentMethod.clone(), ) } else { schedule_equal_to( |x, y| x == y, - Some(txn_card_info.paymentMethod.clone()), + Some(txn_card_info.payment_method.clone()), scheduled_outage.paymentMethod.clone(), ) } && schedule_equal_to( |x, y| x == y, - Some(txn_card_info.paymentMethodType.clone()), + Some(txn_card_info.payment_method_type.clone()), scheduled_outage.paymentMethodType.clone(), ) && schedule_equal_to( |jbc, outage_bank| { @@ -1125,15 +1125,15 @@ fn check_scheduled_outtage( // checkScheduledOutageMetadata :: ETTD.TxnDetail -> TxnCardInfo -> Maybe ETGO.ScheduledOutageMetadata -> Bool // checkScheduledOutageMetadata _ _ Nothing = True // checkScheduledOutageMetadata txnDetail txnCardInfo (Just scheduledOutageMetadata) = -// (scheduleEqualTo (==) (Just txnDetail.txnObjectType) scheduledOutageMetadata.txnObjectType) -// && (scheduleEqualTo (==) txnDetail.sourceObject scheduledOutageMetadata.sourceObject) +// (scheduleEqualTo (==) (Just txnDetail.txn_object_type) scheduledOutageMetadata.txn_object_type) +// && (scheduleEqualTo (==) txnDetail.source_object scheduledOutageMetadata.source_object) // && (scheduleEqualTo (==) Nothing scheduledOutageMetadata.flowType) -// && (case txnCardInfo.paymentMethodType of +// && (case txnCardInfo.payment_method_type of // ETP.Card -> scheduleEqualTo (==) txnCardInfo.cardType scheduledOutageMetadata.cardType // ETP.UPI -> maybe False (\paymentSource -> bool // (scheduleEqualTo (==) (Just paymentSource) scheduledOutageMetadata.app) // (scheduleEqualTo (==) (Just paymentSource) scheduledOutageMetadata.handle) -// (T.any (== '@') paymentSource)) txnCardInfo.paymentSource +// (T.any (== '@') paymentSource)) txnCardInfo.payment_source // _ -> True) // getScheduledOutage scheduledOutageValidationDuration = do // currentTime <- getCurrentTimeUTC @@ -1160,24 +1160,24 @@ fn check_scheduled_outage_metadata( Some(scheduled_outage_metadata) => { schedule_equal_to( |x, y| x == y, - txn_detail.txnObjectType.clone(), + txn_detail.txn_object_type.clone(), scheduled_outage_metadata.txnObjectType.clone(), ) && schedule_equal_to( |x, y| x == y, - txn_detail.sourceObject.clone(), + txn_detail.source_object.clone(), scheduled_outage_metadata.sourceObject.clone(), ) && schedule_equal_to( |x: _, y| x == Some(y), Some(None), scheduled_outage_metadata.flowType.clone(), - ) && match txn_card_info.paymentMethodType.as_str() { + ) && match txn_card_info.payment_method_type.as_str() { CARD => schedule_equal_to( |x, y| x == y, txn_card_info.card_type.clone(), scheduled_outage_metadata.cardType.clone(), ), UPI => txn_card_info - .paymentSource + .payment_source .as_ref() .map_or(false, |payment_source| { if payment_source.contains('@') { @@ -1411,7 +1411,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( ) { let gateway_score = get_gwsm(decider_flow); let txn_detail = decider_flow.get().dpTxnDetail.clone(); - let merchant_id = txn_detail.merchantId.clone(); + let merchant_id = txn_detail.merchant_id.clone(); let (global_elimination_occurred, global_elimination_gateway_score_map) = match check_sr_global_routing_defaults( @@ -1436,7 +1436,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( tag = "scoringFlow", action = "scoringFlow", "Gateway Success Rate Inputs for Global SR based elimination for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, gateway_success_rate_inputs ); @@ -1454,7 +1454,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( tag = "scoringFlow", action = "scoringFlow", "Gateway Redis Key Map for Global SR based elimination for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, gateway_redis_key_map ); @@ -1470,7 +1470,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( tag = "scoringFlow", action = "scoringFlow", "Global Elimination Gateway Score for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, global_elimination_gateway_score ); match global_elimination_gateway_score { @@ -1488,7 +1488,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( logger::info!( action = "global_gateway_score", "Global Elimination Gateway Score for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, new_gsri ); upd_gateway_success_rate_inputs.push(new_gsri); @@ -1556,7 +1556,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( let new_gateway_score = filtered_gateway_success_rate_inputs .iter() .fold(gateway_score.clone(), |acc, x| { - penalize_gsr(txn_detail.txnId.clone(), acc, x.clone()) + penalize_gsr(txn_detail.txn_id.clone(), acc, x.clone()) }); set_gwsm(decider_flow, new_gateway_score.clone()); let old_sr_metric_log_data = decider_flow.writer.srMetricLogData.clone(); @@ -1575,7 +1575,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( tag="scoringFlow", action = "scoringFlow", "No gateways are eligible for penalties & fallback {:?} based on global score", - txn_detail.txnId + txn_detail.txn_id ); let old_sr_metric_log_data = decider_flow.writer.srMetricLogData.clone(); set_metric_log_data( @@ -1621,7 +1621,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( action = "scoringFlow", "Global scores not available for {:?} {:?}", merchant_id, - txn_detail.txnId + txn_detail.txn_id ); } @@ -1629,7 +1629,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( tag = "scoringFlow", action = "scoringFlow", "Gateway scores after considering global SR based elimination for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, global_gateway_scores ); @@ -1650,7 +1650,7 @@ pub async fn update_gateway_score_based_on_global_success_rate( action = "scoringFlow", "Global SR routing not enabled for merchant {:?} txn {:?}", merchant_id, - txn_detail.txnId + txn_detail.txn_id ); (false, None) } @@ -1927,7 +1927,7 @@ async fn get_elimination_v2_threshold( m_pmt.unwrap_or_else(|| "Nothing".to_string()), m_pm.unwrap_or_else(|| "Nothing".to_string()), m_txn_object_type.unwrap_or_else(|| "Nothing".to_string()), - txn_detail.sourceObject.as_ref().unwrap_or(&"Nothing".to_string()) + txn_detail.source_object.as_ref().unwrap_or(&"Nothing".to_string()) ); logger::info!( @@ -1945,10 +1945,10 @@ async fn get_elimination_v2_threshold( tag="scoringFlow", action = "scoringFlow", "Elimination V2 values not found: Threshold: PMT: {:?} PM: {:?} TxnObjectType: {:?} SourceObject: {:?}", - txn_card_info.paymentMethodType, - txn_card_info.paymentMethod, - txn_detail.txnObjectType, - txn_detail.sourceObject.as_ref().unwrap_or(&"Nothing".to_string()) + txn_card_info.payment_method_type, + txn_card_info.payment_method, + txn_detail.txn_object_type, + txn_detail.source_object.as_ref().unwrap_or(&"Nothing".to_string()) ); // .await; @@ -1972,19 +1972,19 @@ pub async fn get_sr1_and_sr2_and_n( )> { if let Some(gateway_success_rate_merchant_input) = m_gateway_success_rate_merchant_input { if let Some(inputs) = gateway_success_rate_merchant_input.eliminationV2SuccessRateInputs { - let pmt = &txn_card_info.paymentMethodType; - let source_obj = if txn_card_info.paymentMethod == UPI { - txn_detail.sourceObject.clone() + let pmt = &txn_card_info.payment_method_type; + let source_obj = if txn_card_info.payment_method == UPI { + txn_detail.source_object.clone() } else { - Some(txn_card_info.paymentMethod.clone()) + Some(txn_card_info.payment_method.clone()) }; - let pm = if txn_card_info.paymentMethodType == UPI { + let pm = if txn_card_info.payment_method_type == UPI { source_obj.clone() } else { - Some(txn_card_info.paymentMethod.clone()) + Some(txn_card_info.payment_method.clone()) }; let txn_obj_type = txn_detail - .txnObjectType + .txn_object_type .map(|t| t.to_string()) .unwrap_or_default(); @@ -2112,9 +2112,9 @@ pub fn filter_inputs_upto( // sr1, // input.success_rate, // n, -// Some(input.payment_method_type), -// input.payment_method.clone(), -// input.txn_object_type.clone(), +// Some(input.paymentMethodType), +// input.paymentMethod.clone(), +// input.txnObjectType.clone(), // ConfigSource::Redis, // )), // _ => None, @@ -2251,7 +2251,9 @@ fn filter_configs_upto_payment_method_type( configs .iter() .find(|x| { - x.paymentMethodType == *pmt && x.paymentMethod.is_none() && x.txnObjectType.is_none() + x.paymentMethodType == *pmt + && x.paymentMethod.is_none() + && x.txnObjectType.is_none() }) .cloned() } @@ -2376,7 +2378,7 @@ pub async fn update_gateway_score_based_on_success_rate( let is_reset_score_enabled_for_merchant = isFeatureEnabled( C::GatewayResetScoreEnabled.get_key(), - Utils::get_m_id(txn_detail.merchantId.clone()), + Utils::get_m_id(txn_detail.merchant_id.clone()), "kv_redis".to_string(), ) .await; @@ -2390,7 +2392,7 @@ pub async fn update_gateway_score_based_on_success_rate( let payment_method_type = if Utils::is_card_transaction(&txn_card_info) { CARD } else { - txn_card_info.paymentMethodType.as_str() + txn_card_info.payment_method_type.as_str() }; let enabled_payment_method_types = gateway_success_rate_merchant_input @@ -2407,7 +2409,7 @@ pub async fn update_gateway_score_based_on_success_rate( tag="scoringFlow", action = "scoringFlow", "Transaction {:?} with payment method types {:?} not enabled by {:?} for SR based routing", - txn_detail.txnId, + txn_detail.txn_id, payment_method_type, merchant_acc.merchantId ); @@ -2428,7 +2430,7 @@ pub async fn update_gateway_score_based_on_success_rate( tag = "scoringFlow", action = "scoringFlow", "Gateway scores input for merchant wise SR based evaluation for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, gateway_score_global_sr, ); @@ -2509,7 +2511,7 @@ pub async fn update_gateway_score_based_on_success_rate( let new_sm = filtered_gateway_success_rate_inputs.iter().fold( gateway_score_global_sr.clone(), |acc, input| { - update_score_with_log(txn_detail.txnId.clone(), acc, input.clone()) + update_score_with_log(txn_detail.txn_id.clone(), acc, input.clone()) }, ); @@ -2550,7 +2552,7 @@ pub async fn update_gateway_score_based_on_success_rate( tag = "scoringFlow", action = "scoringFlow", "No gateways are eligible for penalties & fallback : {:?}", - txn_detail.txnId + txn_detail.txn_id ); } @@ -2652,7 +2654,7 @@ pub async fn update_gateway_score_based_on_success_rate( { let optimization_during_downtime_enabled = isFeatureEnabled( C::EnableOptimizationDuringDowntime.get_key(), - Utils::get_m_id(txn_detail.merchantId.clone()), + Utils::get_m_id(txn_detail.merchant_id.clone()), "kv_redis".to_string(), ) .await; @@ -2663,7 +2665,7 @@ pub async fn update_gateway_score_based_on_success_rate( tag="scoringFlow", action = "scoringFlow", "Overriding priority with SR Scores during downtime for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, new_gateway_score, ); @@ -2671,7 +2673,7 @@ pub async fn update_gateway_score_based_on_success_rate( } else { logger::info!( "Overriding priority with PL during downtime for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, initial_gw_scores, ); @@ -2682,7 +2684,7 @@ pub async fn update_gateway_score_based_on_success_rate( tag="scoringFlow", action = "scoringFlow", "Overriding priority with SR Scores during downtime is not enabled for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, new_gateway_score, ); @@ -2739,7 +2741,7 @@ pub async fn update_gateway_score_based_on_success_rate( tag = "GW_Scoring", action = "GW_Scoring", "Gateway scores after considering SR based elimination for {:?} : {:?}", - txn_detail.txnId, + txn_detail.txn_id, toListOfGatewayScore(gateway_score_sr_based), ); @@ -2801,7 +2803,7 @@ pub async fn update_current_score( tag = "scoringFlow", action = "scoringFlow", "Current score for {:?} {:?} : {:?} with elimination level {:?} threshold {:?}", - txn_detail.txnId, + txn_detail.txn_id, i.gateway, m_score.as_ref().map(|score| score.score), i.eliminationLevel, @@ -2856,7 +2858,7 @@ pub async fn evaluate_reset_gateway_score( tag = "evaluateResetGatewayScore", action = "evaluateResetGatewayScore", "Evaluating Reset Logic for Gateways for {:?}", - txnDetail.txnId + txnDetail.txn_id ); let current_time: i64 = SystemTime::now() @@ -2876,7 +2878,7 @@ pub async fn evaluate_reset_gateway_score( action = "evaluateResetGatewayScore", "Adding gateway {} to reset Request for {:?} for level {:?}", it.gateway, - txnDetail.txnId, + txnDetail.txn_id, it.eliminationLevel ); acc.push(it.gateway.clone()); @@ -2906,8 +2908,8 @@ pub async fn trigger_reset_gateway_score( tag = "scoringFlow", action = "scoringFlow", "Reset Gateway Scores is enabled for {:?} and merchantId {:?}", - txn_detail.txnId, - Utils::get_m_id(txn_detail.clone().merchantId) + txn_detail.txn_id, + Utils::get_m_id(txn_detail.clone().merchant_id) ); let mut reset_gateway_sr_list = Vec::new(); for it in &reset_gateway_list { @@ -2916,7 +2918,7 @@ pub async fn trigger_reset_gateway_score( action = "scoringFlow", "Adding gateway {:?} to resetAPI Request for {:?}", it, - txn_detail.txnId + txn_detail.txn_id ); let m_sr_input = get_gateway_success_rate_input(it, &gateway_success_rate_inputs); @@ -2959,7 +2961,7 @@ pub async fn trigger_reset_gateway_score( action = "scoringFlow", "No SR Input for {:?} and {:?}", it, - txn_detail.txnId + txn_detail.txn_id ); } } @@ -2984,7 +2986,7 @@ pub async fn trigger_reset_gateway_score( tag = "scoringFlow", action = "scoringFlow", "Reset Gateway List for {:?} is {:?}", - txn_detail.txnId, + txn_detail.txn_id, reset_gateway_sr_list ); } else { @@ -2992,8 +2994,8 @@ pub async fn trigger_reset_gateway_score( tag = "scoringFlow", action = "scoringFlow", "Reset Gateway Scores is not enabled for {:?} and merchantId {:?}", - txn_detail.txnId, - Utils::get_m_id(txn_detail.clone().merchantId) + txn_detail.txn_id, + Utils::get_m_id(txn_detail.clone().merchant_id) ); } } @@ -3091,7 +3093,7 @@ pub async fn reset_gateway_score( tag = "scoringFlow", action = "scoringFlow", "Resetting Gateway Score for {:?} with new score {:?}", - txn_detail.txnId, + txn_detail.txn_id, reset_cached_gateway_score ); } else { @@ -3099,7 +3101,7 @@ pub async fn reset_gateway_score( tag = "scoringFlow", action = "scoringFlow", "Gateway Score is not eligible for reset for {:?}", - txn_detail.txnId + txn_detail.txn_id ); } } @@ -3108,7 +3110,7 @@ pub async fn reset_gateway_score( tag = "scoringFlow", action = "scoringFlow", "Failed to reset Gateway Score for {:?} with error: {:?}", - txn_detail.txnId, + txn_detail.txn_id, e ); } @@ -3119,8 +3121,8 @@ pub async fn reset_gateway_score( tag = "scoringFlow", action = "scoringFlow", "Reset Gateway Score is not enabled for {:?} and merchantId {:?}", - txn_detail.txnId, - Utils::get_m_id(txn_detail.clone().merchantId) + txn_detail.txn_id, + Utils::get_m_id(txn_detail.clone().merchant_id) ); } } diff --git a/src/decider/gatewaydecider/runner.rs b/src/decider/gatewaydecider/runner.rs index 8b12e5e7..d20b7df2 100644 --- a/src/decider/gatewaydecider/runner.rs +++ b/src/decider/gatewaydecider/runner.rs @@ -123,11 +123,11 @@ pub fn filter_order(order: Order, metaData: Option) -> FilteredOrderInfo FilteredOrderInfo { amount: Money::to_double(&order.amount) / 10000.0, currency: order.currency, - customerId: order.customerId, - orderId: order.orderId, - productId: order.productId, + customerId: order.customer_id, + orderId: order.order_id, + productId: order.product_id, description: order.description, - preferredGateway: order.preferredGateway, + preferredGateway: order.preferred_gateway, udf1: get_udf(&order.udfs, 0).cloned(), udf2: get_udf(&order.udfs, 1).cloned(), udf3: get_udf(&order.udfs, 2).cloned(), @@ -156,19 +156,19 @@ pub struct FilteredTxnInfo { pub fn filter_txn(detail: TxnDetail) -> FilteredTxnInfo { FilteredTxnInfo { - isEmi: detail.isEmi.unwrap_or(false), - emiBank: detail.emiBank, - emiTenure: detail.emiTenure, - txnId: detail.txnId, - addToLocker: detail.addToLocker.unwrap_or(false), - expressCheckout: detail.expressCheckout.unwrap_or(false), - sourceObject: detail.sourceObject, - txnObjectType: detail.txnObjectType.unwrap_or(TxnObjectType::Unknown), + isEmi: detail.is_emi.unwrap_or(false), + emiBank: detail.emi_bank, + emiTenure: detail.emi_tenure, + txnId: detail.txn_id, + addToLocker: detail.add_to_locker.unwrap_or(false), + expressCheckout: detail.express_checkout.unwrap_or(false), + sourceObject: detail.source_object, + txnObjectType: detail.txn_object_type.unwrap_or(TxnObjectType::Unknown), } } pub fn fetch_emi_type(txnCardInfo: TxnCardInfo) -> Result> { - match txnCardInfo.paymentSource { + match txnCardInfo.payment_source { None => Err(vec![]), Some(ps) => { if ps.contains("emi_type") { @@ -236,13 +236,13 @@ pub fn make_payment_info( .card_type .as_ref() .map(|ct| card_type_to_text(&ct)) - .or_else(|| Some(txnCardInfo.paymentMethodType)), + .or_else(|| Some(txnCardInfo.payment_method_type)), paymentMethod: txnCardInfo - .cardIssuerBankName + .card_issuer_bank_name .clone() - .or_else(|| Some(txnCardInfo.paymentMethod)), - paymentSource: txnCardInfo.paymentSource, - cardIssuer: txnCardInfo.cardIssuerBankName, + .or_else(|| Some(txnCardInfo.payment_method)), + paymentSource: txnCardInfo.payment_source, + cardIssuer: txnCardInfo.card_issuer_bank_name, cardType: txnCardInfo.card_type.map(|c| card_type_to_text(&c)), cardBin: None, extendedCardBin: None, @@ -315,12 +315,12 @@ fn go_card_isin( FilteredPaymentInfo { paymentMethodType: Some(CARD.to_string()), paymentMethod: txnCardInfo - .cardSwitchProvider + .card_switch_provider .clone() .map(|csp| csp.peek().to_uppercase()), paymentSource: None, cardIssuer: txnCardInfo - .cardIssuerBankName + .card_issuer_bank_name .clone() .map(|ci| ci.to_uppercase()), cardType: cloned_txn_card_info @@ -330,7 +330,7 @@ fn go_card_isin( cardBin: Some(cardIsin.chars().take(6).collect()), extendedCardBin: extended_card_bin, cardBrand: cloned_txn_card_info - .cardSwitchProvider + .card_switch_provider .clone() .map(|csp| csp.peek().to_uppercase()), cardIssuerCountry: mCardInfo @@ -338,7 +338,7 @@ fn go_card_isin( .and_then(|ci| ci.card_issuer_country.clone().map(|c| c.to_uppercase())) .or_else(|| Some("".to_string())), authType: txnCardInfo - .authType + .auth_type .clone() .map(|at| auth_type_to_text(&at)), emiType: fetch_emi_type(txnCardInfo.clone()) @@ -491,7 +491,7 @@ pub async fn execute_priority_logic( ) -> DeciderTypes::GatewayPriorityLogicOutput { let internal_metadata: Option = req .txnDetail - .internalMetadata + .internal_metadata .as_ref() .and_then(|im| serde_json::from_str(im.peek()).ok()); let order_metadata = req.orderMetadata.metadata.clone(); diff --git a/src/decider/gatewaydecider/types.rs b/src/decider/gatewaydecider/types.rs index 70427836..0d9ad689 100644 --- a/src/decider/gatewaydecider/types.rs +++ b/src/decider/gatewaydecider/types.rs @@ -890,21 +890,22 @@ pub struct ApiTxnCardInfo { // } #[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] pub struct DomainDeciderRequest { - pub orderReference: ETO::Order, - pub orderMetadata: ETOMV2::OrderMetadataV2, - pub txnDetail: ETTD::TxnDetail, - pub txnOfferDetails: Option>, - pub txnCardInfo: ETCa::txn_card_info::TxnCardInfo, - pub merchantAccount: ETM::merchant_account::MerchantAccount, - pub cardToken: Option, - pub txnType: Option, - pub shouldCreateMandate: Option, - pub enforceGatewayList: Option>, - pub priorityLogicOutput: Option, - pub priorityLogicScript: Option, - pub isEdccApplied: Option, - pub shouldConsumeResult: Option, + pub order_reference: ETO::Order, + pub order_metadata: ETOMV2::OrderMetadataV2, + pub txn_detail: ETTD::TxnDetail, + pub txn_offer_details: Option>, + pub txn_card_info: ETCa::txn_card_info::TxnCardInfo, + pub merchant_account: ETM::merchant_account::MerchantAccount, + pub card_token: Option, + pub txn_type: Option, + pub should_create_mandate: Option, + pub enforce_gateway_list: Option>, + pub priority_logic_output: Option, + pub priority_logic_script: Option, + pub is_edcc_applied: Option, + pub should_consume_result: Option, } // impl Given for DomainDeciderRequest {} @@ -949,31 +950,31 @@ pub struct PaymentInfo { impl DomainDeciderRequestForApiCallV2 { pub async fn to_domain_decider_request(&self) -> DomainDeciderRequest { DomainDeciderRequest { - orderReference: ETO::Order { + order_reference: ETO::Order { id: ETO::id::to_order_prim_id(1), amount: ETMo::Money::from_double(self.payment_info.amount), currency: self.payment_info.currency.clone(), - dateCreated: OffsetDateTime::now_utc(), - merchantId: ETM::id::to_merchant_id(self.merchant_id.clone()), - orderId: ETO::id::to_order_id(self.payment_info.payment_id.clone()), + date_created: OffsetDateTime::now_utc(), + merchant_id: ETM::id::to_merchant_id(self.merchant_id.clone()), + order_id: ETO::id::to_order_id(self.payment_info.payment_id.clone()), status: ETO::OrderStatus::Created, description: None, - customerId: self.payment_info.customer_id.clone(), + customer_id: self.payment_info.customer_id.clone(), udfs: self .payment_info .udfs .clone() .unwrap_or(UDFs(HashMap::new())), - preferredGateway: self.payment_info.preferred_gateway.clone(), - productId: None, - orderType: ETO::OrderType::from_txn_object_type( + preferred_gateway: self.payment_info.preferred_gateway.clone(), + product_id: None, + order_type: ETO::OrderType::from_txn_object_type( self.payment_info.payment_type.clone(), ), metadata: self.payment_info.metadata.clone(), - internalMetadata: self.payment_info.internal_metadata.clone(), + internal_metadata: self.payment_info.internal_metadata.clone(), }, - shouldConsumeResult: None, - orderMetadata: ETOMV2::OrderMetadataV2 { + should_consume_result: None, + order_metadata: ETOMV2::OrderMetadataV2 { id: ETOMV2::to_order_metadata_v2_pid(1), date_created: OffsetDateTime::now_utc(), last_updated: OffsetDateTime::now_utc(), @@ -982,65 +983,65 @@ impl DomainDeciderRequestForApiCallV2 { ip_address: None, partition_key: None, }, - txnDetail: ETTD::TxnDetail { + txn_detail: ETTD::TxnDetail { id: ETTD::to_txn_detail_id(1), - orderId: ETO::id::to_order_id(self.payment_info.payment_id.clone()), + order_id: ETO::id::to_order_id(self.payment_info.payment_id.clone()), status: ETTD::TxnStatus::Started, - txnId: ETId::to_transaction_id(self.payment_info.payment_id.clone()), - txnType: Some("NOT_DEFINED".to_string()), - dateCreated: OffsetDateTime::now_utc(), - addToLocker: Some(false), - merchantId: ETM::id::to_merchant_id(self.merchant_id.clone()), + txn_id: ETId::to_transaction_id(self.payment_info.payment_id.clone()), + txn_type: Some("NOT_DEFINED".to_string()), + date_created: OffsetDateTime::now_utc(), + add_to_locker: Some(false), + merchant_id: ETM::id::to_merchant_id(self.merchant_id.clone()), gateway: None, - expressCheckout: Some(false), - isEmi: Some(self.payment_info.is_emi.clone().unwrap_or(false)), - emiBank: self.payment_info.emi_bank.clone(), - emiTenure: self.payment_info.emi_tenure.clone(), - txnUuid: self.payment_info.payment_id.clone(), - merchantGatewayAccountId: None, - txnAmount: Some(ETMo::Money::from_double(self.payment_info.amount)), - txnObjectType: Some(self.payment_info.payment_type.clone()), - sourceObject: Some(self.payment_info.payment_method.clone()), - sourceObjectId: None, + express_checkout: Some(false), + is_emi: Some(self.payment_info.is_emi.clone().unwrap_or(false)), + emi_bank: self.payment_info.emi_bank.clone(), + emi_tenure: self.payment_info.emi_tenure.clone(), + txn_uuid: self.payment_info.payment_id.clone(), + merchant_gateway_account_id: None, + txn_amount: Some(ETMo::Money::from_double(self.payment_info.amount)), + txn_object_type: Some(self.payment_info.payment_type.clone()), + source_object: Some(self.payment_info.payment_method.clone()), + source_object_id: None, currency: self.payment_info.currency.clone(), country: self.payment_info.country.clone(), - netAmount: Some(ETMo::Money::from_double(self.payment_info.amount)), - surchargeAmount: None, - taxAmount: None, - internalMetadata: self.payment_info.internal_metadata.clone().map(Secret::new), + net_amount: Some(ETMo::Money::from_double(self.payment_info.amount)), + surcharge_amount: None, + tax_amount: None, + internal_metadata: self.payment_info.internal_metadata.clone().map(Secret::new), metadata: self.payment_info.metadata.clone().map(Secret::new), - offerDeductionAmount: None, - internalTrackingInfo: None, - partitionKey: None, - txnAmountBreakup: None, + offer_deduction_amount: None, + internal_tracking_info: None, + partition_key: None, + txn_amount_breakup: None, }, - txnOfferDetails: None, - txnCardInfo: ETCa::txn_card_info::TxnCardInfo { + txn_offer_details: None, + txn_card_info: ETCa::txn_card_info::TxnCardInfo { id: ETCa::txn_card_info::to_txn_card_info_pid(1), card_isin: self.payment_info.card_isin.clone(), - cardIssuerBankName: self.payment_info.card_issuer_bank_name.clone(), - cardSwitchProvider: self.payment_info.card_switch_provider.clone(), + card_issuer_bank_name: self.payment_info.card_issuer_bank_name.clone(), + card_switch_provider: self.payment_info.card_switch_provider.clone(), card_type: self.payment_info.card_type.clone(), - nameOnCard: None, - dateCreated: OffsetDateTime::now_utc(), - paymentMethodType: self.payment_info.payment_method_type.to_string(), - paymentMethod: self.payment_info.payment_method.clone(), - paymentSource: self.payment_info.payment_source.clone(), - authType: self.payment_info.auth_type.clone(), - partitionKey: None, + name_on_card: None, + date_created: OffsetDateTime::now_utc(), + payment_method_type: self.payment_info.payment_method_type.to_string(), + payment_method: self.payment_info.payment_method.clone(), + payment_source: self.payment_info.payment_source.clone(), + auth_type: self.payment_info.auth_type.clone(), + partition_key: None, }, - merchantAccount: ETM::merchant_account::load_merchant_by_merchant_id( + merchant_account: ETM::merchant_account::load_merchant_by_merchant_id( self.merchant_id.clone(), ) .await .expect("Merchant account not found"), - cardToken: None, - txnType: None, - shouldCreateMandate: None, - enforceGatewayList: None, - priorityLogicOutput: None, - priorityLogicScript: None, - isEdccApplied: Some(false), + card_token: None, + txn_type: None, + should_create_mandate: None, + enforce_gateway_list: None, + priority_logic_output: None, + priority_logic_script: None, + is_edcc_applied: Some(false), } } } diff --git a/src/decider/gatewaydecider/utils.rs b/src/decider/gatewaydecider/utils.rs index 57fb6b47..f0b21ec9 100644 --- a/src/decider/gatewaydecider/utils.rs +++ b/src/decider/gatewaydecider/utils.rs @@ -146,21 +146,21 @@ pub fn check_no_or_low_cost_emi(txn_card_info: &ETCa::txn_card_info::TxnCardInfo pub fn fetch_emi_type(txn_card_info: &ETCa::txn_card_info::TxnCardInfo) -> Option { txn_card_info - .paymentSource + .payment_source .as_ref() .and_then(|source| get_value("emi_type", source)) } pub fn fetch_extended_card_bin(txn_card_info: &ETCa::txn_card_info::TxnCardInfo) -> Option { txn_card_info - .paymentSource + .payment_source .as_ref() .and_then(|source| get_value("extended_card_bin", source)) } pub fn fetch_juspay_bank_code(txn_card_info: &ETCa::txn_card_info::TxnCardInfo) -> Option { txn_card_info - .paymentSource + .payment_source .as_ref() .and_then(|source| get_value("juspay_bank_code", source)) } @@ -191,14 +191,14 @@ pub fn is_emandate_supported_payment_method( txn_card_info: &ETCa::txn_card_info::TxnCardInfo, ) -> bool { matches!( - txn_card_info.paymentMethodType.as_str(), + txn_card_info.payment_method_type.as_str(), CARD | NB | WALLET | UPI | AADHAAR | PAPERNACH | PAN | RTP ) } pub fn is_emandate_transaction(txn_detail: &ETTD::TxnDetail) -> bool { matches!( - txn_detail.txnObjectType, + txn_detail.txn_object_type, Some(ETTD::TxnObjectType::EmandateRegister) | Some(ETTD::TxnObjectType::TpvEmandateRegister) | Some(ETTD::TxnObjectType::EmandatePayment) @@ -208,14 +208,14 @@ pub fn is_emandate_transaction(txn_detail: &ETTD::TxnDetail) -> bool { pub fn is_emandate_payment_transaction(txn_detail: &ETTD::TxnDetail) -> bool { matches!( - txn_detail.txnObjectType, + txn_detail.txn_object_type, Some(ETTD::TxnObjectType::EmandatePayment) | Some(ETTD::TxnObjectType::TpvEmandatePayment) ) } pub fn is_reccuring_payment_transaction(txn_detail: &ETTD::TxnDetail) -> bool { matches!( - txn_detail.txnObjectType, + txn_detail.txn_object_type, Some(ETTD::TxnObjectType::EmandatePayment) | Some(ETTD::TxnObjectType::TpvEmandatePayment) | Some(ETTD::TxnObjectType::MandatePayment) @@ -225,13 +225,13 @@ pub fn is_reccuring_payment_transaction(txn_detail: &ETTD::TxnDetail) -> bool { pub fn is_tpv_transaction(txn_detail: &ETTD::TxnDetail) -> bool { matches!( - txn_detail.txnObjectType, + txn_detail.txn_object_type, Some(ETTD::TxnObjectType::TpvPayment) ) } pub fn is_tpv_mandate_transaction(txn_detail: &ETTD::TxnDetail) -> bool { - txn_detail.txnObjectType == Some(ETTD::TxnObjectType::TpvEmandateRegister) + txn_detail.txn_object_type == Some(ETTD::TxnObjectType::TpvEmandateRegister) } pub fn get_merchant_wise_si_bin_key(gw: &String) -> String { @@ -251,7 +251,7 @@ fn get_merchant_gateway_card_info_feature_name( pub fn is_mandate_transaction(txn: &ETTD::TxnDetail) -> bool { matches!( - txn.txnObjectType, + txn.txn_object_type, Some(ETTD::TxnObjectType::MandateRegister) | Some(ETTD::TxnObjectType::MandatePayment) ) } @@ -548,7 +548,7 @@ pub fn get_gateway_reference_id( pub async fn effective_amount_with_txn_amount(txn_detail: ETTD::TxnDetail) -> Money { let def_amount = Money::from_double(0.0); - let amount_txn = txn_detail.txnAmount.as_ref().unwrap_or(&def_amount); + let amount_txn = txn_detail.txn_amount.as_ref().unwrap_or(&def_amount); let offers = ETTO::getOffers(&txn_detail.id).await; let discount_sum: Money = Money::from_double( offers @@ -560,8 +560,8 @@ pub async fn effective_amount_with_txn_amount(txn_detail: ETTD::TxnDetail) -> Mo amount_txn .m_sub(&discount_sum) - .m_add(&txn_detail.surchargeAmount.unwrap_or(def_amount.clone())) - .m_add(&txn_detail.taxAmount.unwrap_or(def_amount)) + .m_add(&txn_detail.surcharge_amount.unwrap_or(def_amount.clone())) + .m_add(&txn_detail.tax_amount.unwrap_or(def_amount)) } pub fn filter_gateway_card_info_for_max_register_amount( @@ -590,13 +590,13 @@ pub fn is_emandate_amount_filter_needed( ) -> bool { is_emandate_register_transaction(txn_detail) && matches!( - txn_card_info.paymentMethodType.as_str(), + txn_card_info.payment_method_type.as_str(), CARD | NB | AADHAAR | PAN ) } pub fn is_emandate_register_transaction(txn_detail: &ETTD::TxnDetail) -> bool { - txn_detail.txnObjectType == Some(ETTD::TxnObjectType::EmandateRegister) + txn_detail.txn_object_type == Some(ETTD::TxnObjectType::EmandateRegister) } pub async fn get_card_brand(decider_flow: &mut DeciderFlow<'_>) -> Option { @@ -731,31 +731,31 @@ pub fn get_metric_log_format(decider_flow: &mut DeciderFlow<'_>, stage: &str) -> let order_reference = decider_flow.get().dpOrder.clone(); let x_req_id = decider_flow.logger.get("x-request-id"); let payment_source_m = txn_card_info - .paymentSource + .payment_source .as_ref() .and_then(|ps| last(split("@", ps))); MessageFormat { model: txn_detail - .txnObjectType + .txn_object_type .map(|t| t.to_string()) .unwrap_or_default(), log_type: "APP_EVENT".to_string(), - payment_method: txn_card_info.paymentMethod.clone(), - payment_method_type: txn_card_info.paymentMethodType.clone(), + payment_method: txn_card_info.payment_method.clone(), + payment_method_type: txn_card_info.payment_method_type.clone(), payment_source: payment_source_m, - source_object: txn_detail.sourceObject.clone(), + source_object: txn_detail.source_object.clone(), txn_detail_id: txn_detail.id.clone(), stage: stage.to_string(), - merchant_id: merchant_id_to_text(order_reference.merchantId.clone()), - txn_uuid: txn_detail.txnUuid.clone(), - order_id: order_reference.orderId.0.clone(), + merchant_id: merchant_id_to_text(order_reference.merchant_id.clone()), + txn_uuid: txn_detail.txn_uuid.clone(), + order_id: order_reference.order_id.0.clone(), card_type: txn_card_info .card_type .as_ref() .map(|ct| ct.to_string()) .unwrap_or_default(), - auth_type: txn_card_info.authType.as_ref().map(|at| at.to_string()), + auth_type: txn_card_info.auth_type.as_ref().map(|at| at.to_string()), bank_code: fetch_juspay_bank_code(&txn_card_info), x_request_id: x_req_id.cloned(), log_data: serde_json::to_value(mp).unwrap(), @@ -778,7 +778,7 @@ pub async fn log_gateway_decider_approach( let order_reference = decider_flow.get().dpOrder.clone(); let txn_card_info = decider_flow.get().dpTxnCardInfo.clone(); let x_req_id = decider_flow.logger.get("x-request-id").cloned(); - let txn_creation_time = txn_detail.dateCreated.to_string(); // Assuming dateCreated is a DateTime field + let txn_creation_time = txn_detail.date_created.to_string(); // Assuming dateCreated is a DateTime field let mp = types::DeciderApproachLogData { decided_gateway: m_decided_gateway, @@ -792,7 +792,7 @@ pub async fn log_gateway_decider_approach( }; let payment_source_m = txn_card_info - .paymentSource + .payment_source .as_ref() .and_then(|ps| ps.split('@').next_back().map(String::from)); @@ -801,25 +801,25 @@ pub async fn log_gateway_decider_approach( "DECIDER", MessageFormat { model: txn_detail - .txnObjectType + .txn_object_type .map(|t| t.to_string()) .unwrap_or_default(), log_type: "APP_EVENT".to_string(), - payment_method: txn_card_info.clone().paymentMethod, - payment_method_type: txn_card_info.clone().paymentMethodType.to_string(), + payment_method: txn_card_info.clone().payment_method, + payment_method_type: txn_card_info.clone().payment_method_type.to_string(), payment_source: payment_source_m, - source_object: txn_detail.sourceObject, + source_object: txn_detail.source_object, txn_detail_id: txn_detail.id, stage: "GATEWAY_DECIDER_APPROACH".to_string(), - merchant_id: merchant_id_to_text(order_reference.merchantId), - txn_uuid: txn_detail.txnUuid, - order_id: order_reference.orderId.0, + merchant_id: merchant_id_to_text(order_reference.merchant_id), + txn_uuid: txn_detail.txn_uuid, + order_id: order_reference.order_id.0, card_type: txn_card_info .card_type .clone() .map(|ct| ct.to_string()) .unwrap_or_default(), - auth_type: txn_card_info.authType.clone().map(|at| at.to_string()), + auth_type: txn_card_info.auth_type.clone().map(|at| at.to_string()), bank_code: fetch_juspay_bank_code(&txn_card_info), x_request_id: x_req_id, log_data: serde_json::to_value(mp).unwrap(), @@ -934,7 +934,7 @@ pub async fn get_token_supported_gateways( ) -> Option> { let token_type = get_stored_card_vault_provider(m_internal_meta.clone()); let brand = txn_card_info - .cardSwitchProvider + .card_switch_provider .as_ref() .map_or("DEFAULT".to_string(), |secret| secret.peek().to_string()); let token_provider = get_token_provider(m_internal_meta, &txn_card_info, &brand); @@ -1154,7 +1154,7 @@ fn get_int_isin(isin: &ETCa::isin::Isin) -> i32 { pub fn get_payment_flow_list_from_txn_detail(txn_detail: &ETTD::TxnDetail) -> Vec { match txn_detail - .internalTrackingInfo + .internal_tracking_info .as_ref() .and_then(|info| either_decode_t(info).ok()) { @@ -1297,7 +1297,7 @@ pub fn modify_gateway_decider_approach( } pub fn get_juspay_bank_code_from_internal_metadata(txn_detail: &ETTD::TxnDetail) -> Option { - txn_detail.internalMetadata.as_ref().and_then(|metadata| { + txn_detail.internal_metadata.as_ref().and_then(|metadata| { from_str::(metadata.peek()).ok().and_then(|json| { json.get("juspayBankCode") .and_then(|v| v.as_str().map(|s| s.to_string())) @@ -1925,14 +1925,14 @@ pub async fn get_gateway_scoring_data( .await; let merchant_id = merchant_id_to_text(merchant.merchantId.clone()); let order_type = txn_detail - .txnObjectType + .txn_object_type .map(|t| t.to_string()) .unwrap_or_default(); - let payment_method_type = txn_card_info.paymentMethodType.to_uppercase(); - let m_source_object = if txn_card_info.paymentMethod == UPI { - txn_detail.sourceObject.clone().unwrap_or_default() + let payment_method_type = txn_card_info.payment_method_type.to_uppercase(); + let m_source_object = if txn_card_info.payment_method == UPI { + txn_detail.source_object.clone().unwrap_or_default() } else { - txn_card_info.paymentMethod.clone() + txn_card_info.payment_method.clone() }; let is_performing_experiment = isFeatureEnabled( C::MerchantEnabledForRoutingExperiment.get_key(), @@ -1959,19 +1959,19 @@ pub async fn get_gateway_scoring_data( m_source_object, is_gri_enabled_for_elimination, is_gri_enabled_for_sr_routing, - decider_flow.get().dpTxnDetail.dateCreated.clone(), + decider_flow.get().dpTxnDetail.date_created.clone(), decider_flow.get().dpTxnCardInfo.card_isin.clone(), - decider_flow.get().dpTxnCardInfo.cardSwitchProvider.clone(), + decider_flow.get().dpTxnCardInfo.card_switch_provider.clone(), Some(decider_flow.get().dpOrder.currency.clone()), decider_flow.get().dpTxnDetail.country.clone(), decider_flow .get() .dpTxnCardInfo - .authType + .auth_type .as_ref() .map(|a| a.to_string()), ); - let updated_gateway_scoring_data = match txn_card_info.paymentMethodType.as_str() { + let updated_gateway_scoring_data = match txn_card_info.payment_method_type.as_str() { UPI => { let handle_and_package_based_routing = isFeatureEnabled( C::HandlePackageBasedRoutingCutover.get_key(), @@ -1980,11 +1980,11 @@ pub async fn get_gateway_scoring_data( ) .await; if is_performing_experiment && handle_and_package_based_routing { - let experiment_tag = get_experiment_tag(txn_detail.dateCreated, "HANDLE_PSP").await; + let experiment_tag = get_experiment_tag(txn_detail.date_created, "HANDLE_PSP").await; set_is_experiment_tag(decider_flow, experiment_tag); } - let payment_source = get_true_string(txn_card_info.paymentSource.clone()) + let payment_source = get_true_string(txn_card_info.payment_source.clone()) .map(|source| source.split("@").last().unwrap_or_default().to_uppercase()) .unwrap_or_default(); default_gateway_scoring_data.paymentSource = Some(payment_source); @@ -2008,11 +2008,11 @@ pub async fn get_gateway_scoring_data( if is_performing_experiment { if sr_evaluation_at_auth_level { let experiment_tag = - get_experiment_tag(txn_detail.dateCreated, "AUTH_TYPE").await; + get_experiment_tag(txn_detail.date_created, "AUTH_TYPE").await; set_is_experiment_tag(decider_flow, experiment_tag); } else if sr_evaluation_at_bank_level { let experiment_tag = - get_experiment_tag(txn_detail.dateCreated, "BANK_TYPE").await; + get_experiment_tag(txn_detail.date_created, "BANK_TYPE").await; set_is_experiment_tag(decider_flow, experiment_tag); } } @@ -2022,7 +2022,7 @@ pub async fn get_gateway_scoring_data( .map(|card| card_type_to_text(&card).to_uppercase()) .unwrap_or_default(); let auth_type = txn_card_info - .authType + .auth_type .clone() .map(|auth| auth_type_to_text(&auth).to_uppercase()) .unwrap_or_default(); @@ -2049,15 +2049,15 @@ pub async fn get_gateway_scoring_data( if is_performing_experiment && is_gri_enabled_for_elimination { let experiment_tag = - get_experiment_tag(txn_detail.dateCreated, "GRI_BASED_ELIMINATION").await; + get_experiment_tag(txn_detail.date_created, "GRI_BASED_ELIMINATION").await; set_is_experiment_tag(decider_flow, experiment_tag); } if is_performing_experiment && is_gri_enabled_for_sr_routing { let experiment_tag = - get_experiment_tag(txn_detail.dateCreated, "GRI_BASED_SR_ROUTING").await; + get_experiment_tag(txn_detail.date_created, "GRI_BASED_SR_ROUTING").await; set_is_experiment_tag(decider_flow, experiment_tag); } - let key = [C::GATEWAY_SCORING_DATA, &txn_detail.txnUuid.clone()].concat(); + let key = [C::GATEWAY_SCORING_DATA, &txn_detail.txn_uuid.clone()].concat(); updated_gateway_scoring_data } diff --git a/src/decider/gatewaydecider/validators.rs b/src/decider/gatewaydecider/validators.rs index 902deaba..ccf7a2f3 100644 --- a/src/decider/gatewaydecider/validators.rs +++ b/src/decider/gatewaydecider/validators.rs @@ -65,17 +65,17 @@ pub fn parse_from_api_order_reference(apiType: T::ApiOrderReference) -> Option Option().ok()) .map(ETTD::to_txn_detail_id)?, - dateCreated: apiType.dateCreated?, - orderId: ETOID::to_order_id(apiType.orderId), + date_created: apiType.dateCreated?, + order_id: ETOID::to_order_id(apiType.orderId), status: ETTD::TxnStatus::from_text(apiType.status)?, - txnId: ETTID::to_transaction_id(apiType.txnId), - txnType: Some(apiType.txnType), - addToLocker: Some(apiType.addToLocker.unwrap_or(false)), - merchantId: apiType.merchantId.map(to_merchant_id)?, + txn_id: ETTID::to_transaction_id(apiType.txnId), + txn_type: Some(apiType.txnType), + add_to_locker: Some(apiType.addToLocker.unwrap_or(false)), + merchant_id: apiType.merchantId.map(to_merchant_id)?, gateway: apiType.gateway, - expressCheckout: Some(apiType.expressCheckout.unwrap_or(false)), - isEmi: Some(apiType.isEmi.unwrap_or(false)), - emiBank: apiType.emiBank, - emiTenure: apiType.emiTenure, - txnUuid: apiType.txnUuid.unwrap_or_default(), - merchantGatewayAccountId: apiType + express_checkout: Some(apiType.expressCheckout.unwrap_or(false)), + is_emi: Some(apiType.isEmi.unwrap_or(false)), + emi_bank: apiType.emiBank, + emi_tenure: apiType.emiTenure, + txn_uuid: apiType.txnUuid.unwrap_or_default(), + merchant_gateway_account_id: apiType .merchantGatewayAccountId .map(ETMGA::to_merchant_gw_acc_id), - netAmount: apiType.netAmount.map(Money::from_double), - txnAmount: apiType.txnAmount.map(Money::from_double), - txnObjectType: apiType + net_amount: apiType.netAmount.map(Money::from_double), + txn_amount: apiType.txnAmount.map(Money::from_double), + txn_object_type: apiType .txnObjectType .and_then(ETTD::TxnObjectType::from_text), - sourceObject: apiType.sourceObject, - sourceObjectId: apiType.sourceObjectId.map(SO::to_source_object_id), + source_object: apiType.sourceObject, + source_object_id: apiType.sourceObjectId.map(SO::to_source_object_id), currency: apiType .currency .as_deref() @@ -237,14 +237,14 @@ pub fn parse_from_api_txn_detail(apiType: T::ApiTxnDetail) -> Option>(breakup_str).ok() }), }) @@ -258,25 +258,25 @@ pub fn parse_from_api_txn_card_info(apiType: T::ApiTxnCardInfo) -> Option().ok()).map(ETTD::to_txn_detail_id)?, - dateCreated: apiType.dateCreated?, - paymentMethodType: apiType.paymentMethodType?, - paymentMethod: apiType.paymentMethod?, + date_created: apiType.dateCreated?, + payment_method_type: apiType.paymentMethodType?, + payment_method: apiType.paymentMethod?, // cardGlobalFingerprint: apiType.cardGlobalFingerprint, - paymentSource: apiType.paymentSource, - authType: apiType + payment_source: apiType.paymentSource, + auth_type: apiType .authType .as_deref() .map(ETCa::text_to_auth_type)? .ok(), - partitionKey: apiType.partitionKey, + partition_key: apiType.partitionKey, }) } diff --git a/src/decider/storage/utils/merchant_gateway_card_info.rs b/src/decider/storage/utils/merchant_gateway_card_info.rs index 198891d6..85454627 100644 --- a/src/decider/storage/utils/merchant_gateway_card_info.rs +++ b/src/decider/storage/utils/merchant_gateway_card_info.rs @@ -47,8 +47,8 @@ pub async fn filter_gateways_for_payment_method_and_validation_type( .map(|acc| merchant_gw_acc_id_to_id(acc.id.clone())) .collect(); - let given_payment_method = txn_card_info.paymentMethod.clone(); - let given_payment_method_type = txn_card_info.paymentMethodType; + let given_payment_method = txn_card_info.payment_method.clone(); + let given_payment_method_type = txn_card_info.payment_method_type; // Step 1: Fetch Juspay Bank Codes let jpbc_records: Vec = match crate::generics::generic_find_all::< diff --git a/src/decider/storage/utils/txn_card_info.rs b/src/decider/storage/utils/txn_card_info.rs index 9e9a2ad9..a6020201 100644 --- a/src/decider/storage/utils/txn_card_info.rs +++ b/src/decider/storage/utils/txn_card_info.rs @@ -10,5 +10,5 @@ use crate::types::card::txn_card_info::TxnCardInfo; use crate::types::payment::payment_method_type_const::*; pub fn is_google_pay_txn(tci: TxnCardInfo) -> bool { - tci.paymentMethodType == WALLET && tci.paymentMethod == "GOOGLEPAY" + tci.payment_method_type == WALLET && tci.payment_method == "GOOGLEPAY" } diff --git a/src/feedback/gateway_elimination_scoring/flow.rs b/src/feedback/gateway_elimination_scoring/flow.rs index a0685627..bcf48882 100644 --- a/src/feedback/gateway_elimination_scoring/flow.rs +++ b/src/feedback/gateway_elimination_scoring/flow.rs @@ -85,7 +85,7 @@ pub async fn updateKeyScoreForKeysFromConsumer( mer_acc: MerchantAccount, gateway_scoring_key: (ScoreKeyType, Option), ) -> Option<((ScoreKeyType, String), CachedGatewayScore)> { - let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchantId.clone()); + let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchant_id.clone()); let (score_key_type, m_key) = gateway_scoring_key; match m_key { Some(key) => { @@ -429,7 +429,7 @@ pub async fn getUpdatedMerchantDetailsForGlobalKey( txn_detail: TxnDetail, txn_card_info: TxnCardInfo, ) -> Option> { - let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchantId.clone()); + let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchant_id.clone()); if isGlobalKey(score_key_type) { match cached_gateway_score.merchants { Some(merchant_details_array) => { @@ -478,7 +478,7 @@ pub async fn replaceTransactionCount( gateway_scoring_type: GatewayScoreType, score_key_type: ScoreKeyType, ) -> MerchantScoringDetails { - let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchantId.clone()); + let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchant_id.clone()); if merchant_scoring_details.merchantId == merchant_id { let updated_score = updateKeyScoreForTxnStatus( txn_detail, @@ -512,7 +512,7 @@ pub fn getNewCachedGatewayScore( txn_detail: TxnDetail, txn_card_info: TxnCardInfo, ) -> CachedGatewayScore { - let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchantId); + let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchant_id); let current_date: u128 = CUTILS::get_current_date_in_millis(); if isGlobalKey(score_key_type) { let merchant_scoring_details = @@ -561,7 +561,7 @@ pub async fn getAllUnifiedKeys( gateway_scoring_data: GatewayScoringData, gateway_reference_id: Option, ) -> Vec<(ScoreKeyType, Option)> { - let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchantId.clone()); + let merchant_id = Merchant::merchant_id_to_text(txn_detail.merchant_id.clone()); let is_key_enabled_for_global_gateway_scoring = isFeatureEnabled( C::GlobalGatewayScoringEnabledMerchants.get_key(), merchant_id.clone(), @@ -768,7 +768,7 @@ pub async fn eliminationV2RewardFactor( txn_detail: &TxnDetail, ) -> Option { let merch_acc: MerchantAccount = - MA::load_merchant_by_merchant_id(MID::merchant_id_to_text(txn_detail.clone().merchantId)) + MA::load_merchant_by_merchant_id(MID::merchant_id_to_text(txn_detail.clone().merchant_id)) .await .expect("Merchant account not found"); @@ -813,10 +813,10 @@ pub async fn eliminationV2RewardFactor( } None => { logger::info!("ELIMINATION_V2_VALUES_NOT_FOUND:ALPHA:PMT_PM_TXNOBJECTTYPE_SOURCEOBJECT {:?} {:?} {:?} {:?}", - txn_card_info.paymentMethodType, - if txn_card_info.paymentMethod.is_empty() { "Nothing".to_string() } else { txn_card_info.paymentMethod.clone() }, - txn_detail.txnObjectType, - txn_detail.sourceObject.as_ref().map_or_else(|| "Nothing".to_string(), |s| s.clone()), + txn_card_info.payment_method_type, + if txn_card_info.payment_method.is_empty() { "Nothing".to_string() } else { txn_card_info.payment_method.clone() }, + txn_detail.txn_object_type, + txn_detail.source_object.as_ref().map_or_else(|| "Nothing".to_string(), |s| s.clone()), ); None } @@ -892,7 +892,7 @@ pub fn isKeyOutage(scoreKeyType: ScoreKeyType) -> bool { // downThreshold: None, // eliminationMaxCount: None, // dimension: None, -// merchantId: txn_detail.merchantId, +// merchantId: txn_detail.merchant_id, // gateway: txn_detail.gateway.unwrap_or_else(|| "".to_string()), // authType: None, // cardBin: None, diff --git a/src/feedback/gateway_scoring_service.rs b/src/feedback/gateway_scoring_service.rs index 3935154c..c6976563 100644 --- a/src/feedback/gateway_scoring_service.rs +++ b/src/feedback/gateway_scoring_service.rs @@ -294,29 +294,29 @@ pub async fn getGatewayScoringType( } let txn_status = txn_detail.status.clone(); - let merchant_id = txn_detail.merchantId.clone(); + let merchant_id = txn_detail.merchant_id.clone(); let is_success = isTransactionSuccess(txn_status.clone()); let is_failure = isTransactionFailure(txn_status.clone()); let time_difference = getTimeFromTxnCreatedInMills(txn_detail.clone()); let merchant_sr_v3_input_config = findByNameFromRedis(SrV3InputConfig(get_m_id(merchant_id)).get_key()).await; - let pmt = txn_card_info.paymentMethodType; + let pmt = txn_card_info.payment_method_type; let pm = get_payment_method( pmt.to_string(), - txn_card_info.paymentMethod, - txn_detail.sourceObject.unwrap_or_default(), + txn_card_info.payment_method, + txn_detail.source_object.unwrap_or_default(), ); // Extract the new parameters from txn_card_info let sr_routing_dimesions = SrRoutingDimensions { card_network: txn_card_info - .cardSwitchProvider + .card_switch_provider .as_ref() .map(|s| s.peek().to_string()), card_isin: txn_card_info.card_isin.clone(), currency: Some(txn_detail.currency.to_string()), country: txn_detail.country.as_ref().map(|c| c.to_string()), - auth_type: txn_card_info.authType.as_ref().map(|a| a.to_string()), + auth_type: txn_card_info.auth_type.as_ref().map(|a| a.to_string()), }; let maybe_latency_threshold = get_sr_v3_latency_threshold( @@ -488,7 +488,7 @@ pub async fn check_and_update_gateway_score( // Create update score lock key let update_score_lock_key = updateGatewayScoreLock( gateway_scoring_type.clone(), - txn_detail.txnUuid.clone(), // This is Maybe type in haskell and here it is not Option + txn_detail.txn_uuid.clone(), // This is Maybe type in haskell and here it is not Option gateway_in_string, // Convert Option to String ); @@ -502,7 +502,7 @@ pub async fn check_and_update_gateway_score( // Check if feature is enabled for merchant let feature_enabled = isFeatureEnabled( UpdateScoreLockFeatureEnabledMerchant.get_key(), - get_m_id(txn_detail.merchantId.clone()), + get_m_id(txn_detail.merchant_id.clone()), "kv_redis".to_string(), ) .await; @@ -558,7 +558,7 @@ pub async fn updateGatewayScore( txn_latency: Option, ) -> () { let mer_acc: MerchantAccount = - MA::load_merchant_by_merchant_id(MID::merchant_id_to_text(txn_detail.clone().merchantId)) + MA::load_merchant_by_merchant_id(MID::merchant_id_to_text(txn_detail.clone().merchant_id)) .await .expect("Merchant account not found"); @@ -579,7 +579,7 @@ pub async fn updateGatewayScore( true }; - //let is_pm_and_pmt_present = Fbu::isTrueString(txn_card_info.paymentMethod) && txn_card_info.paymentMethodType.is_some(); + //let is_pm_and_pmt_present = Fbu::isTrueString(txn_card_info.payment_method) && txn_card_info.payment_method_type.is_some(); let should_update_srv3_gateway_score = if gateway_scoring_type.clone() == GST::Penalise { false } else { @@ -597,7 +597,7 @@ pub async fn updateGatewayScore( let should_isolate_srv3_producer = if Cutover::isFeatureEnabled( C::SrV3ProducerIsolation.get_key(), - MID::merchant_id_to_text(txn_detail.clone().merchantId), + MID::merchant_id_to_text(txn_detail.clone().merchant_id), C::kvRedis(), ) .await @@ -612,9 +612,9 @@ pub async fn updateGatewayScore( }; let should_update_explore_txn = if Cutover::isFeatureEnabled( - DC::EnableExploreAndExploitOnSrv3(txn_card_info.clone().paymentMethodType.to_string()) + DC::EnableExploreAndExploitOnSrv3(txn_card_info.clone().payment_method_type.to_string()) .get_key(), - MID::merchant_id_to_text(txn_detail.clone().merchantId), + MID::merchant_id_to_text(txn_detail.clone().merchant_id), C::kvRedis(), ) .await @@ -628,7 +628,7 @@ pub async fn updateGatewayScore( true }; - let redis_key = format!("{}{}", C::GATEWAY_SCORING_DATA, txn_detail.clone().txnUuid); + let redis_key = format!("{}{}", C::GATEWAY_SCORING_DATA, txn_detail.clone().txn_uuid); let redis_gateway_score_data = if should_update_srv3_gateway_score && is_update_within_window && should_isolate_srv3_producer @@ -762,7 +762,7 @@ pub fn getRoutingApproach(txnDetail: TxnDetail) -> Option { // Original Haskell function: getValueFromMetaData pub fn getValueFromMetaData(txn_detail: &TxnDetail) -> Option { - let metadata = txn_detail.internalMetadata.clone()?; + let metadata = txn_detail.internal_metadata.clone()?; serde_json::from_str(metadata.peek()).ok() } @@ -827,12 +827,12 @@ pub async fn isUpdateWithinLatencyWindow( // Cutover::findByNameFromRedis(C.gatewayScoreLatencyCheckInMins) // .await // .unwrap_or(C.defaultGatewayScoreLatencyCheckInMins); - let merchant_id = MID::merchant_id_to_text(txn_detail.merchantId.clone()); - let pmt = txn_card_info.paymentMethodType; + let merchant_id = MID::merchant_id_to_text(txn_detail.merchant_id.clone()); + let pmt = txn_card_info.payment_method_type; let pm = GU::get_payment_method( pmt, - txn_card_info.paymentMethod, - txn_detail.sourceObject.clone().unwrap_or_default(), + txn_card_info.payment_method, + txn_detail.source_object.clone().unwrap_or_default(), ); let gw_score_update_latency = Fbu::getTimeFromTxnCreatedInMills(txn_detail.clone()); @@ -855,8 +855,8 @@ pub async fn isUpdateWithinLatencyWindow( } async fn checkExemptIfMandateTxn(txn_detail: &TxnDetail, txn_card_info: &TxnCardInfo) -> bool { - let is_recurring = isRecurringTxn(txn_detail.txnObjectType.clone()); - let is_nb_pmt = txn_card_info.paymentMethodType == (NB); + let is_recurring = isRecurringTxn(txn_detail.txn_object_type.clone()); + let is_nb_pmt = txn_card_info.payment_method_type == (NB); let is_penny_reg_txn = isPennyMandateRegTxn(txn_detail.clone()); is_recurring || (is_nb_pmt && is_penny_reg_txn) } diff --git a/src/feedback/gateway_selection_scoring_v3/flow.rs b/src/feedback/gateway_selection_scoring_v3/flow.rs index d3a8d2f0..7b89bbba 100644 --- a/src/feedback/gateway_selection_scoring_v3/flow.rs +++ b/src/feedback/gateway_selection_scoring_v3/flow.rs @@ -85,7 +85,7 @@ pub async fn updateSrV3Score( .await; let key_for_gateway_selection = unified_sr_v3_key.clone().unwrap_or_else(|| "".to_string()); - let payment_method_type = txn_card_info.paymentMethodType.clone(); + let payment_method_type = txn_card_info.payment_method_type.clone(); let key_for_gateway_selection_queue = format!("{}_{}queue", key_for_gateway_selection, "}"); let key_for_gateway_selection_score = @@ -193,7 +193,7 @@ pub async fn updateScoreAndQueue( }; // let is_debug_mode_enabled = isFeatureEnabled( // DC::enableDebugModeOnSrV3.get_key(), - // MID::merchant_id_to_text(txn_detail.merchantId), + // MID::merchant_id_to_text(txn_detail.merchant_id), // C::kvRedis(), // ).await; // if is_debug_mode_enabled { @@ -202,7 +202,7 @@ pub async fn updateScoreAndQueue( // &format!( // "{}{}", // C::pendingTxnsKeyPrefix, - // txn_detail.merchantId.clone() + // txn_detail.merchant_id.clone() // ), // &[txn_detail.txnUuid.clone()], // ); @@ -214,7 +214,7 @@ pub async fn updateScoreAndQueue( // .delete_key(&[format!( // "{}{}", // C::pendingTxnsKeyPrefix, - // txn_detail.merchantId.clone() + // txn_detail.merchant_id.clone() // )]) // .await // { @@ -232,7 +232,7 @@ pub async fn updateScoreAndQueue( // } let current_ist_time = getCurrentIstDateWithFormat("YYYY-MM-DD HH:mm:SS.sss".to_string()); let date_created = dateInIST( - txn_detail.clone().dateCreated.to_string(), + txn_detail.clone().date_created.to_string(), "YYYY-MM-DD HH:mm:SS.sss".to_string(), ) .unwrap_or_default(); @@ -286,26 +286,26 @@ pub async fn updateScoreAndQueue( //Original Haskell function: getSrV3MerchantBucketSize pub async fn getSrV3MerchantBucketSize(txn_detail: TxnDetail, txn_card_info: TxnCardInfo) -> i32 { let merchant_sr_v3_input_config: Option = findByNameFromRedis( - C::SrV3InputConfig(MID::merchant_id_to_text(txn_detail.merchantId)).get_key(), + C::SrV3InputConfig(MID::merchant_id_to_text(txn_detail.merchant_id)).get_key(), ) .await; - let pmt = txn_card_info.paymentMethodType; + let pmt = txn_card_info.payment_method_type; let pm = GU::get_payment_method( (&pmt).to_string(), - txn_card_info.paymentMethod, - txn_detail.sourceObject.unwrap_or_default(), + txn_card_info.payment_method, + txn_detail.source_object.unwrap_or_default(), ); // Extract the new parameters from txn_card_info let sr_routing_dimesions = SrRoutingDimensions { card_network: txn_card_info - .cardSwitchProvider + .card_switch_provider .as_ref() .map(|s| s.peek().to_string()), card_isin: txn_card_info.card_isin, currency: Some(txn_detail.currency.to_string()), country: txn_detail.country.as_ref().map(|c| c.to_string()), - auth_type: txn_card_info.authType.as_ref().map(|a| a.to_string()), + auth_type: txn_card_info.auth_type.as_ref().map(|a| a.to_string()), }; let maybe_bucket_size = GU::get_sr_v3_bucket_size( diff --git a/src/feedback/utils.rs b/src/feedback/utils.rs index e91e3a2e..d25aaaa3 100644 --- a/src/feedback/utils.rs +++ b/src/feedback/utils.rs @@ -163,35 +163,35 @@ pub fn getTxnDetailFromApiPayload( ) -> Result { let txn_detail = ETTD::TxnDetail { id: ETTD::to_txn_detail_id(1), - dateCreated: gateway_scoring_data.dateCreated, - orderId: ETO::id::to_order_id(apiPayload.paymentId.clone()), + date_created: gateway_scoring_data.dateCreated, + order_id: ETO::id::to_order_id(apiPayload.paymentId.clone()), status: apiPayload.status.clone(), - txnId: ETId::to_transaction_id(apiPayload.paymentId.clone()), - txnType: Some("NOT_DEFINED".to_string()), - addToLocker: Some(false), - merchantId: ETM::id::to_merchant_id(apiPayload.merchantId.clone()), + txn_id: ETId::to_transaction_id(apiPayload.paymentId.clone()), + txn_type: Some("NOT_DEFINED".to_string()), + add_to_locker: Some(false), + merchant_id: ETM::id::to_merchant_id(apiPayload.merchantId.clone()), gateway: Some(apiPayload.gateway), - expressCheckout: Some(false), - isEmi: Some(false), - emiBank: None, - emiTenure: None, - txnUuid: apiPayload.paymentId.clone(), - merchantGatewayAccountId: None, - txnAmount: Some(ETMo::Money::from_double(0.0)), - txnObjectType: Some( + express_checkout: Some(false), + is_emi: Some(false), + emi_bank: None, + emi_tenure: None, + txn_uuid: apiPayload.paymentId.clone(), + merchant_gateway_account_id: None, + txn_amount: Some(ETMo::Money::from_double(0.0)), + txn_object_type: Some( ETTD::TxnObjectType::from_text(gateway_scoring_data.orderType.clone()) .unwrap_or_else(|| ETTD::TxnObjectType::OrderPayment), ), - sourceObject: Some(gateway_scoring_data.paymentMethod.clone()), - sourceObjectId: None, + source_object: Some(gateway_scoring_data.paymentMethod.clone()), + source_object_id: None, currency: gateway_scoring_data .currency .clone() .ok_or(crate::error::ApiError::MissingRequiredField("currency"))?, country: gateway_scoring_data.country.clone(), - surchargeAmount: None, - taxAmount: None, - internalMetadata: Some(Secret::new( + surcharge_amount: None, + tax_amount: None, + internal_metadata: Some(Secret::new( serde_json::to_string(&InternalMetadata { internal_tracking_info: InternalTrackingInfo { routing_approach: gateway_scoring_data.routingApproach.unwrap_or_default(), @@ -199,12 +199,12 @@ pub fn getTxnDetailFromApiPayload( }) .unwrap(), )), - netAmount: Some(ETMo::Money::from_double(0.0)), + net_amount: Some(ETMo::Money::from_double(0.0)), metadata: None, - offerDeductionAmount: None, - internalTrackingInfo: None, - partitionKey: None, - txnAmountBreakup: None, + offer_deduction_amount: None, + internal_tracking_info: None, + partition_key: None, + txn_amount_breakup: None, }; Ok(txn_detail) } @@ -216,21 +216,21 @@ pub fn getTxnCardInfoFromApiPayload( let txnCardInfo = ETCa::txn_card_info::TxnCardInfo { id: ETCa::txn_card_info::to_txn_card_info_pid(1), card_isin: None, - cardIssuerBankName: None, - cardSwitchProvider: None, + card_issuer_bank_name: None, + card_switch_provider: None, card_type: None, - nameOnCard: None, - dateCreated: gateway_scoring_data.dateCreated, - paymentMethodType: gateway_scoring_data.paymentMethodType.clone(), - paymentMethod: gateway_scoring_data.paymentMethod.clone(), - paymentSource: gateway_scoring_data.paymentSource.clone(), - authType: gateway_scoring_data + name_on_card: None, + date_created: gateway_scoring_data.dateCreated, + payment_method_type: gateway_scoring_data.paymentMethodType.clone(), + payment_method: gateway_scoring_data.paymentMethod.clone(), + payment_source: gateway_scoring_data.paymentSource.clone(), + auth_type: gateway_scoring_data .authType .clone() .and_then(|auth_type_text| { ETCa::txn_card_info::text_to_auth_type(&auth_type_text).ok() }), - partitionKey: None, + partition_key: None, }; txnCardInfo } @@ -687,7 +687,7 @@ pub fn logGatewayScoreType( }; let txn_creation_time = txn_detail - .dateCreated + .date_created .to_string() .replace(" ", "T") .replace(" UTC", "Z"); @@ -853,7 +853,7 @@ pub fn mandateRegisterTxnObjectTypes() -> Vec { } pub fn isPennyMandateRegTxn(txn_detail: TxnDetail) -> bool { - if let Some(txn_object_type) = txn_detail.clone().txnObjectType { + if let Some(txn_object_type) = txn_detail.clone().txn_object_type { if isMandateRegTxn(txn_object_type) { isPennyTxnType(txn_detail.clone()) } else { @@ -891,7 +891,7 @@ pub fn isMandateRegTxn(txn_object_type: TxnObjectType) -> bool { // Original Haskell function: isPennyTxnType pub fn isPennyTxnType(txn_detail: TxnDetail) -> bool { - let mandate = getTxnTypeFromInternalMetadata(txn_detail.internalMetadata); + let mandate = getTxnTypeFromInternalMetadata(txn_detail.internal_metadata); match mandate { MandateTxnType::Register => true, _ => false, @@ -917,7 +917,7 @@ pub fn isRecurringTxn(txn_object_type: Option) -> bool { // Original Haskell function: getTimeFromTxnCreatedInMills pub fn getTimeFromTxnCreatedInMills(txn: TxnDetail) -> u128 { - let dateCreated = txn.dateCreated.unix_timestamp_nanos() as u128 / 1_000_000; + let dateCreated = txn.date_created.unix_timestamp_nanos() as u128 / 1_000_000; let currentTime = EU::get_current_date_in_millis(); currentTime.saturating_sub(dateCreated) } diff --git a/src/routes/decision_gateway.rs b/src/routes/decision_gateway.rs index 31f6fb74..ca1f5270 100644 --- a/src/routes/decision_gateway.rs +++ b/src/routes/decision_gateway.rs @@ -128,16 +128,16 @@ where let api_decider_request: Result = serde_json::from_slice(&body); match api_decider_request { Ok(payload) => { - let merchant_id = payload.orderReference.merchantId.clone(); + let merchant_id = payload.order_reference.merchant_id.clone(); let merchant_id_txt = crate::types::merchant::id::merchant_id_to_text(merchant_id); tracing::Span::current().record("merchant_id", merchant_id_txt.clone()); - tracing::Span::current().record("udf_txn_uuid", payload.txnDetail.txnUuid.clone()); - tracing::Span::current().record("txn_uuid", payload.txnDetail.txnUuid.clone()); + tracing::Span::current().record("udf_txn_uuid", payload.txn_detail.txn_uuid.clone()); + tracing::Span::current().record("txn_uuid", payload.txn_detail.txn_uuid.clone()); tracing::Span::current() - .record("udf_order_id", payload.orderReference.orderId.0.as_str()); + .record("udf_order_id", payload.order_reference.order_id.0.as_str()); tracing::Span::current().record( "is_audit_trail_log", - payload.shouldConsumeResult.unwrap_or(false), + payload.should_consume_result.unwrap_or(false), ); jemalloc_ctl::epoch::advance().unwrap(); let allocated_before = jemalloc_ctl::stats::allocated::read().unwrap_or(0); diff --git a/src/types/card/txn_card_info.rs b/src/types/card/txn_card_info.rs index e70ad730..0e02fd27 100644 --- a/src/types/card/txn_card_info.rs +++ b/src/types/card/txn_card_info.rs @@ -135,29 +135,29 @@ pub struct TxnCardInfo { #[serde(rename = "cardIsin")] pub card_isin: Option, #[serde(rename = "cardIssuerBankName")] - pub cardIssuerBankName: Option, + pub card_issuer_bank_name: Option, #[serde(rename = "cardSwitchProvider")] - pub cardSwitchProvider: Option>, + pub card_switch_provider: Option>, #[serde(rename = "cardType")] pub card_type: Option, #[serde(rename = "nameOnCard")] - pub nameOnCard: Option>, + pub name_on_card: Option>, // #[serde(rename = "txnDetailId")] // pub txnDetailId: TxnDetailId, #[serde(with = "time::serde::iso8601")] #[serde(rename = "dateCreated")] - pub dateCreated: OffsetDateTime, + pub date_created: OffsetDateTime, #[serde(rename = "paymentMethodType")] - pub paymentMethodType: String, + pub payment_method_type: String, #[serde(rename = "paymentMethod")] - pub paymentMethod: String, + pub payment_method: String, #[serde(rename = "paymentSource")] - pub paymentSource: Option, + pub payment_source: Option, #[serde(rename = "authType")] - pub authType: Option, + pub auth_type: Option, #[serde(rename = "partitionKey")] #[serde(deserialize_with = "deserialize_optional_primitive_datetime")] - pub partitionKey: Option, + pub partition_key: Option, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] @@ -201,17 +201,17 @@ pub fn convert_safe_to_txn_card_info( Ok(TxnCardInfo { id: TxnCardInfoPId(id_i64), card_isin: safe_info.card_isin, - cardIssuerBankName: safe_info.cardIssuerBankName, - cardSwitchProvider: safe_info.cardSwitchProvider, + card_issuer_bank_name: safe_info.cardIssuerBankName, + card_switch_provider: safe_info.cardSwitchProvider, card_type: safe_info.card_type, - nameOnCard: safe_info.nameOnCard, - dateCreated: safe_info.dateCreated, - paymentMethodType: safe_info.paymentMethodType, - paymentMethod: safe_info.paymentMethod, - paymentSource: safe_info.paymentSource, - authType: safe_info + name_on_card: safe_info.nameOnCard, + date_created: safe_info.dateCreated, + payment_method_type: safe_info.paymentMethodType, + payment_method: safe_info.paymentMethod, + payment_source: safe_info.paymentSource, + auth_type: safe_info .authType .and_then(|auth| text_to_auth_type(&auth).ok()), - partitionKey: safe_info.partitionKey, + partition_key: safe_info.partitionKey, }) } diff --git a/src/types/order.rs b/src/types/order.rs index da2574e2..0a24c789 100644 --- a/src/types/order.rs +++ b/src/types/order.rs @@ -213,24 +213,25 @@ where } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct Order { pub id: OrderPrimId, pub amount: Money, pub currency: Currency, #[serde(with = "time::serde::iso8601")] - pub dateCreated: OffsetDateTime, - pub merchantId: MerchantId, - pub orderId: OrderId, + pub date_created: OffsetDateTime, + pub merchant_id: MerchantId, + pub order_id: OrderId, pub status: OrderStatus, - pub customerId: Option, + pub customer_id: Option, pub description: Option, #[serde(deserialize_with = "deserialize_udfs_to_hashmap")] pub udfs: UDFs, - pub preferredGateway: Option, - pub productId: Option, - pub orderType: OrderType, + pub preferred_gateway: Option, + pub product_id: Option, + pub order_type: OrderType, pub metadata: Option, - pub internalMetadata: Option, + pub internal_metadata: Option, } // #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] diff --git a/src/types/txn_details/types.rs b/src/types/txn_details/types.rs index f4db7327..010ae219 100644 --- a/src/types/txn_details/types.rs +++ b/src/types/txn_details/types.rs @@ -560,112 +560,83 @@ pub fn convert_safe_txn_detail_to_txn_detail( .and_then(|s| s.parse::().ok()) .map(to_txn_detail_id) .unwrap(), - dateCreated: safe_detail + date_created: safe_detail .dateCreated .unwrap_or_else(|| OffsetDateTime::now_utc()), - orderId: safe_detail.orderId, + order_id: safe_detail.orderId, status: TxnStatus::from_text(safe_detail.status).unwrap_or(TxnStatus::Failure), - txnId: safe_detail.txnId, - txnType: Some(safe_detail.txnType), - addToLocker: safe_detail.addToLocker, - merchantId: safe_detail.merchantId, + txn_id: safe_detail.txnId, + txn_type: Some(safe_detail.txnType), + add_to_locker: safe_detail.addToLocker, + merchant_id: safe_detail.merchantId, gateway: safe_detail.gateway, - expressCheckout: safe_detail.expressCheckout, - isEmi: safe_detail.isEmi, - emiBank: safe_detail.emiBank, - emiTenure: safe_detail.emiTenure.map(|t| t as i32), - txnUuid: safe_detail.txnUuid, - merchantGatewayAccountId: safe_detail + express_checkout: safe_detail.expressCheckout, + is_emi: safe_detail.isEmi, + emi_bank: safe_detail.emiBank, + emi_tenure: safe_detail.emiTenure.map(|t| t as i32), + txn_uuid: safe_detail.txnUuid, + merchant_gateway_account_id: safe_detail .merchantGatewayAccountId .map(|id| MerchantGwAccId { merchantGwAccId: id, }), - netAmount: safe_detail.netAmount, - txnAmount: safe_detail.txnAmount, - txnObjectType: safe_detail + net_amount: safe_detail.netAmount, + txn_amount: safe_detail.txnAmount, + txn_object_type: safe_detail .txnObjectType .and_then(|s| TxnObjectType::from_text(s)), - sourceObject: safe_detail.sourceObject, - sourceObjectId: safe_detail.sourceObjectId.map(to_source_object_id), + source_object: safe_detail.sourceObject, + source_object_id: safe_detail.sourceObjectId.map(to_source_object_id), currency: safe_detail .currency .and_then(|s| Currency::text_to_curr(&s).ok()) .ok_or(crate::error::ApiError::MissingRequiredField("currency"))?, country: None, - surchargeAmount: safe_detail.surchargeAmount, - taxAmount: safe_detail.taxAmount, - internalMetadata: safe_detail.internalMetadata, + surcharge_amount: safe_detail.surchargeAmount, + tax_amount: safe_detail.taxAmount, + internal_metadata: safe_detail.internalMetadata, metadata: safe_detail.metadata, - offerDeductionAmount: safe_detail.offerDeductionAmount, - internalTrackingInfo: safe_detail.internalTrackingInfo, - partitionKey: safe_detail.partitionKey, - txnAmountBreakup: safe_detail.txnAmountBreakup, + offer_deduction_amount: safe_detail.offerDeductionAmount, + internal_tracking_info: safe_detail.internalTrackingInfo, + partition_key: safe_detail.partitionKey, + txn_amount_breakup: safe_detail.txnAmountBreakup, }) } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct TxnDetail { - #[serde(rename = "id")] pub id: TxnDetailId, #[serde(with = "time::serde::iso8601")] - #[serde(rename = "dateCreated")] - pub dateCreated: OffsetDateTime, - #[serde(rename = "orderId")] - pub orderId: OrderId, - #[serde(rename = "status")] + pub date_created: OffsetDateTime, + pub order_id: OrderId, pub status: TxnStatus, - #[serde(rename = "txnId")] - pub txnId: TransactionId, - #[serde(rename = "txnType")] - pub txnType: Option, - #[serde(rename = "addToLocker")] - pub addToLocker: Option, - #[serde(rename = "merchantId")] - pub merchantId: MerchantId, - #[serde(rename = "gateway")] + pub txn_id: TransactionId, + pub txn_type: Option, + pub add_to_locker: Option, + pub merchant_id: MerchantId, pub gateway: Option, - #[serde(rename = "expressCheckout")] - pub expressCheckout: Option, - #[serde(rename = "isEmi")] - pub isEmi: Option, - #[serde(rename = "emiBank")] - pub emiBank: Option, - #[serde(rename = "emiTenure")] - pub emiTenure: Option, - #[serde(rename = "txnUuid")] - pub txnUuid: String, - #[serde(rename = "merchantGatewayAccountId")] - pub merchantGatewayAccountId: Option, - #[serde(rename = "netAmount")] - pub netAmount: Option, - #[serde(rename = "txnAmount")] - pub txnAmount: Option, - #[serde(rename = "txnObjectType")] - pub txnObjectType: Option, - #[serde(rename = "sourceObject")] - pub sourceObject: Option, - #[serde(rename = "sourceObjectId")] - pub sourceObjectId: Option, - #[serde(rename = "currency")] + pub express_checkout: Option, + pub is_emi: Option, + pub emi_bank: Option, + pub emi_tenure: Option, + pub txn_uuid: String, + pub merchant_gateway_account_id: Option, + pub net_amount: Option, + pub txn_amount: Option, + pub txn_object_type: Option, + pub source_object: Option, + pub source_object_id: Option, pub currency: Currency, - #[serde(rename = "country")] pub country: Option, - #[serde(rename = "surchargeAmount")] - pub surchargeAmount: Option, - #[serde(rename = "taxAmount")] - pub taxAmount: Option, - #[serde(rename = "internalMetadata")] - pub internalMetadata: Option>, - #[serde(rename = "metadata")] + pub surcharge_amount: Option, + pub tax_amount: Option, + pub internal_metadata: Option>, pub metadata: Option>, - #[serde(rename = "offerDeductionAmount")] - pub offerDeductionAmount: Option, - #[serde(rename = "internalTrackingInfo")] - pub internalTrackingInfo: Option, + pub offer_deduction_amount: Option, + pub internal_tracking_info: Option, #[serde(deserialize_with = "deserialize_optional_primitive_datetime")] - #[serde(rename = "partitionKey")] - pub partitionKey: Option, - #[serde(rename = "txnAmountBreakup")] - pub txnAmountBreakup: Option>, + pub partition_key: Option, + pub txn_amount_breakup: Option>, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] diff --git a/src/types/txn_offer_detail.rs b/src/types/txn_offer_detail.rs index 6f3504b9..0bf04e0a 100644 --- a/src/types/txn_offer_detail.rs +++ b/src/types/txn_offer_detail.rs @@ -41,24 +41,24 @@ pub struct TxnOfferDetail { #[serde(rename = "id")] pub id: TxnOfferDetailId, #[serde(rename = "txnDetailId")] - pub txnDetailId: TxnDetailId, + pub txn_detail_id: TxnDetailId, #[serde(rename = "offerId")] - pub offerId: String, + pub offer_id: String, #[serde(rename = "status")] pub status: TxnOfferDetailStatus, #[serde(rename = "dateCreated")] #[serde(with = "time::serde::iso8601::option")] - pub dateCreated: Option, + pub date_created: Option, #[serde(rename = "lastUpdated")] #[serde(with = "time::serde::iso8601::option")] - pub lastUpdated: Option, + pub last_updated: Option, #[serde(rename = "gatewayInfo")] - pub gatewayInfo: Option, + pub gateway_info: Option, #[serde(rename = "internalMetadata")] - pub internalMetadata: Option, + pub internal_metadata: Option, #[serde(rename = "partitionKey")] #[serde(deserialize_with = "deserialize_optional_primitive_datetime")] - pub partitionKey: Option, + pub partition_key: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]