mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
refactor: remove configs/pg_agnostic_mit api as it will not be used (#4486)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -299,13 +299,6 @@ impl From<RoutableConnectorChoice> for ast::ConnectorChoice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
|
||||||
pub struct DetailedConnectorChoice {
|
|
||||||
pub enabled: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl common_utils::events::ApiEventMetric for DetailedConnectorChoice {}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, serde::Serialize, serde::Deserialize, strum::Display, ToSchema)]
|
#[derive(Debug, Copy, Clone, serde::Serialize, serde::Deserialize, strum::Display, ToSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[strum(serialize_all = "snake_case")]
|
#[strum(serialize_all = "snake_case")]
|
||||||
|
|||||||
@ -314,6 +314,7 @@ where
|
|||||||
&merchant_account,
|
&merchant_account,
|
||||||
&key_store,
|
&key_store,
|
||||||
&mut payment_data,
|
&mut payment_data,
|
||||||
|
&business_profile,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -415,6 +416,7 @@ where
|
|||||||
&merchant_account,
|
&merchant_account,
|
||||||
&key_store,
|
&key_store,
|
||||||
&mut payment_data,
|
&mut payment_data,
|
||||||
|
&business_profile,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -3320,6 +3322,7 @@ where
|
|||||||
routing_data,
|
routing_data,
|
||||||
connector_data,
|
connector_data,
|
||||||
mandate_type,
|
mandate_type,
|
||||||
|
business_profile.is_connector_agnostic_mit_enabled,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -3377,6 +3380,7 @@ where
|
|||||||
routing_data,
|
routing_data,
|
||||||
connector_data,
|
connector_data,
|
||||||
mandate_type,
|
mandate_type,
|
||||||
|
business_profile.is_connector_agnostic_mit_enabled,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -3400,6 +3404,7 @@ pub async fn decide_multiplex_connector_for_normal_or_recurring_payment<F: Clone
|
|||||||
routing_data: &mut storage::RoutingData,
|
routing_data: &mut storage::RoutingData,
|
||||||
connectors: Vec<api::ConnectorData>,
|
connectors: Vec<api::ConnectorData>,
|
||||||
mandate_type: Option<api::MandateTransactionType>,
|
mandate_type: Option<api::MandateTransactionType>,
|
||||||
|
is_connector_agnostic_mit_enabled: Option<bool>,
|
||||||
) -> RouterResult<ConnectorCallType> {
|
) -> RouterResult<ConnectorCallType> {
|
||||||
match (
|
match (
|
||||||
payment_data.payment_intent.setup_future_usage,
|
payment_data.payment_intent.setup_future_usage,
|
||||||
@ -3442,22 +3447,6 @@ pub async fn decide_multiplex_connector_for_normal_or_recurring_payment<F: Clone
|
|||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
.attach_printable("unable to deserialize connector mandate details")?;
|
.attach_printable("unable to deserialize connector mandate details")?;
|
||||||
|
|
||||||
let profile_id = payment_data
|
|
||||||
.payment_intent
|
|
||||||
.profile_id
|
|
||||||
.as_ref()
|
|
||||||
.ok_or(errors::ApiErrorResponse::ResourceIdNotFound)?;
|
|
||||||
|
|
||||||
let pg_agnostic = state
|
|
||||||
.store
|
|
||||||
.find_config_by_key_unwrap_or(
|
|
||||||
&format!("pg_agnostic_mandate_{}", profile_id),
|
|
||||||
Some("false".to_string()),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("The pg_agnostic config was not found in the DB")?;
|
|
||||||
|
|
||||||
let mut connector_choice = None;
|
let mut connector_choice = None;
|
||||||
|
|
||||||
for connector_data in connectors {
|
for connector_data in connectors {
|
||||||
@ -3468,7 +3457,7 @@ pub async fn decide_multiplex_connector_for_normal_or_recurring_payment<F: Clone
|
|||||||
|
|
||||||
if is_network_transaction_id_flow(
|
if is_network_transaction_id_flow(
|
||||||
state,
|
state,
|
||||||
&pg_agnostic.config,
|
is_connector_agnostic_mit_enabled,
|
||||||
connector_data.connector_name,
|
connector_data.connector_name,
|
||||||
payment_method_info,
|
payment_method_info,
|
||||||
) {
|
) {
|
||||||
@ -3588,7 +3577,7 @@ pub async fn decide_multiplex_connector_for_normal_or_recurring_payment<F: Clone
|
|||||||
|
|
||||||
pub fn is_network_transaction_id_flow(
|
pub fn is_network_transaction_id_flow(
|
||||||
state: &AppState,
|
state: &AppState,
|
||||||
pg_agnostic: &String,
|
is_connector_agnostic_mit_enabled: Option<bool>,
|
||||||
connector: enums::Connector,
|
connector: enums::Connector,
|
||||||
payment_method_info: &storage::PaymentMethod,
|
payment_method_info: &storage::PaymentMethod,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
@ -3597,7 +3586,7 @@ pub fn is_network_transaction_id_flow(
|
|||||||
.network_transaction_id_supported_connectors
|
.network_transaction_id_supported_connectors
|
||||||
.connector_list;
|
.connector_list;
|
||||||
|
|
||||||
pg_agnostic == "true"
|
is_connector_agnostic_mit_enabled == Some(true)
|
||||||
&& payment_method_info.payment_method == Some(storage_enums::PaymentMethod::Card)
|
&& payment_method_info.payment_method == Some(storage_enums::PaymentMethod::Card)
|
||||||
&& ntid_supported_connectors.contains(&connector)
|
&& ntid_supported_connectors.contains(&connector)
|
||||||
&& payment_method_info.network_transaction_id.is_some()
|
&& payment_method_info.network_transaction_id.is_some()
|
||||||
@ -3827,6 +3816,7 @@ where
|
|||||||
routing_data,
|
routing_data,
|
||||||
connector_data,
|
connector_data,
|
||||||
mandate_type,
|
mandate_type,
|
||||||
|
business_profile.is_connector_agnostic_mit_enabled,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -241,6 +241,7 @@ pub trait PostUpdateTracker<F, D, R: Send>: Send {
|
|||||||
_merchant_account: &domain::MerchantAccount,
|
_merchant_account: &domain::MerchantAccount,
|
||||||
_key_store: &domain::MerchantKeyStore,
|
_key_store: &domain::MerchantKeyStore,
|
||||||
_payment_data: &mut PaymentData<F>,
|
_payment_data: &mut PaymentData<F>,
|
||||||
|
_business_profile: &storage::business_profile::BusinessProfile,
|
||||||
) -> CustomResult<(), errors::ApiErrorResponse>
|
) -> CustomResult<(), errors::ApiErrorResponse>
|
||||||
where
|
where
|
||||||
F: 'b + Clone + Send + Sync,
|
F: 'b + Clone + Send + Sync,
|
||||||
|
|||||||
@ -89,13 +89,13 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor
|
|||||||
merchant_account: &domain::MerchantAccount,
|
merchant_account: &domain::MerchantAccount,
|
||||||
key_store: &domain::MerchantKeyStore,
|
key_store: &domain::MerchantKeyStore,
|
||||||
payment_data: &mut PaymentData<F>,
|
payment_data: &mut PaymentData<F>,
|
||||||
|
business_profile: &storage::business_profile::BusinessProfile,
|
||||||
) -> CustomResult<(), errors::ApiErrorResponse>
|
) -> CustomResult<(), errors::ApiErrorResponse>
|
||||||
where
|
where
|
||||||
F: 'b + Clone + Send + Sync,
|
F: 'b + Clone + Send + Sync,
|
||||||
{
|
{
|
||||||
let customer_id = payment_data.payment_intent.customer_id.clone();
|
let customer_id = payment_data.payment_intent.customer_id.clone();
|
||||||
let save_payment_data = tokenization::SavePaymentMethodData::from(resp);
|
let save_payment_data = tokenization::SavePaymentMethodData::from(resp);
|
||||||
let profile_id = payment_data.payment_intent.profile_id.clone();
|
|
||||||
|
|
||||||
let connector_name = payment_data
|
let connector_name = payment_data
|
||||||
.payment_attempt
|
.payment_attempt
|
||||||
@ -125,8 +125,8 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor
|
|||||||
key_store,
|
key_store,
|
||||||
Some(resp.request.amount),
|
Some(resp.request.amount),
|
||||||
Some(resp.request.currency),
|
Some(resp.request.currency),
|
||||||
profile_id,
|
|
||||||
billing_name.clone(),
|
billing_name.clone(),
|
||||||
|
business_profile,
|
||||||
));
|
));
|
||||||
|
|
||||||
let is_connector_mandate = resp.request.customer_acceptance.is_some()
|
let is_connector_mandate = resp.request.customer_acceptance.is_some()
|
||||||
@ -169,11 +169,12 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor
|
|||||||
let key_store = key_store.clone();
|
let key_store = key_store.clone();
|
||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
let customer_id = payment_data.payment_intent.customer_id.clone();
|
let customer_id = payment_data.payment_intent.customer_id.clone();
|
||||||
let profile_id = payment_data.payment_intent.profile_id.clone();
|
|
||||||
|
|
||||||
let merchant_connector_id = payment_data.payment_attempt.merchant_connector_id.clone();
|
let merchant_connector_id = payment_data.payment_attempt.merchant_connector_id.clone();
|
||||||
let payment_attempt = payment_data.payment_attempt.clone();
|
let payment_attempt = payment_data.payment_attempt.clone();
|
||||||
|
|
||||||
|
let business_profile = business_profile.clone();
|
||||||
|
|
||||||
let amount = resp.request.amount;
|
let amount = resp.request.amount;
|
||||||
let currency = resp.request.currency;
|
let currency = resp.request.currency;
|
||||||
let payment_method_type = resp.request.payment_method_type;
|
let payment_method_type = resp.request.payment_method_type;
|
||||||
@ -195,8 +196,8 @@ impl<F: Send + Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsAuthor
|
|||||||
&key_store,
|
&key_store,
|
||||||
Some(amount),
|
Some(amount),
|
||||||
Some(currency),
|
Some(currency),
|
||||||
profile_id,
|
|
||||||
billing_name,
|
billing_name,
|
||||||
|
&business_profile,
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -388,6 +389,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> for
|
|||||||
merchant_account: &domain::MerchantAccount,
|
merchant_account: &domain::MerchantAccount,
|
||||||
_key_store: &domain::MerchantKeyStore,
|
_key_store: &domain::MerchantKeyStore,
|
||||||
payment_data: &mut PaymentData<F>,
|
payment_data: &mut PaymentData<F>,
|
||||||
|
business_profile: &storage::business_profile::BusinessProfile,
|
||||||
) -> CustomResult<(), errors::ApiErrorResponse>
|
) -> CustomResult<(), errors::ApiErrorResponse>
|
||||||
where
|
where
|
||||||
F: 'b + Clone + Send + Sync,
|
F: 'b + Clone + Send + Sync,
|
||||||
@ -398,6 +400,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> for
|
|||||||
resp.status,
|
resp.status,
|
||||||
resp.response.clone(),
|
resp.response.clone(),
|
||||||
merchant_account.storage_scheme,
|
merchant_account.storage_scheme,
|
||||||
|
business_profile.is_connector_agnostic_mit_enabled,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -587,6 +590,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
|
|||||||
merchant_account: &domain::MerchantAccount,
|
merchant_account: &domain::MerchantAccount,
|
||||||
key_store: &domain::MerchantKeyStore,
|
key_store: &domain::MerchantKeyStore,
|
||||||
payment_data: &mut PaymentData<F>,
|
payment_data: &mut PaymentData<F>,
|
||||||
|
business_profile: &storage::business_profile::BusinessProfile,
|
||||||
) -> CustomResult<(), errors::ApiErrorResponse>
|
) -> CustomResult<(), errors::ApiErrorResponse>
|
||||||
where
|
where
|
||||||
F: 'b + Clone + Send + Sync,
|
F: 'b + Clone + Send + Sync,
|
||||||
@ -598,7 +602,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
|
|||||||
.and_then(|address| address.get_optional_full_name());
|
.and_then(|address| address.get_optional_full_name());
|
||||||
let save_payment_data = tokenization::SavePaymentMethodData::from(resp);
|
let save_payment_data = tokenization::SavePaymentMethodData::from(resp);
|
||||||
let customer_id = payment_data.payment_intent.customer_id.clone();
|
let customer_id = payment_data.payment_intent.customer_id.clone();
|
||||||
let profile_id = payment_data.payment_intent.profile_id.clone();
|
|
||||||
let connector_name = payment_data
|
let connector_name = payment_data
|
||||||
.payment_attempt
|
.payment_attempt
|
||||||
.connector
|
.connector
|
||||||
@ -622,8 +625,8 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::SetupMandateRequestDa
|
|||||||
key_store,
|
key_store,
|
||||||
resp.request.amount,
|
resp.request.amount,
|
||||||
Some(resp.request.currency),
|
Some(resp.request.currency),
|
||||||
profile_id,
|
|
||||||
billing_name,
|
billing_name,
|
||||||
|
business_profile,
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -674,6 +677,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
|
|||||||
merchant_account: &domain::MerchantAccount,
|
merchant_account: &domain::MerchantAccount,
|
||||||
_key_store: &domain::MerchantKeyStore,
|
_key_store: &domain::MerchantKeyStore,
|
||||||
payment_data: &mut PaymentData<F>,
|
payment_data: &mut PaymentData<F>,
|
||||||
|
business_profile: &storage::business_profile::BusinessProfile,
|
||||||
) -> CustomResult<(), errors::ApiErrorResponse>
|
) -> CustomResult<(), errors::ApiErrorResponse>
|
||||||
where
|
where
|
||||||
F: 'b + Clone + Send + Sync,
|
F: 'b + Clone + Send + Sync,
|
||||||
@ -684,6 +688,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
|
|||||||
resp.status,
|
resp.status,
|
||||||
resp.response.clone(),
|
resp.response.clone(),
|
||||||
merchant_account.storage_scheme,
|
merchant_account.storage_scheme,
|
||||||
|
business_profile.is_connector_agnostic_mit_enabled,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -1224,6 +1229,7 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
|
|||||||
attempt_status: common_enums::AttemptStatus,
|
attempt_status: common_enums::AttemptStatus,
|
||||||
payment_response: Result<types::PaymentsResponseData, ErrorResponse>,
|
payment_response: Result<types::PaymentsResponseData, ErrorResponse>,
|
||||||
storage_scheme: enums::MerchantStorageScheme,
|
storage_scheme: enums::MerchantStorageScheme,
|
||||||
|
is_connector_agnostic_mit_enabled: Option<bool>,
|
||||||
) -> RouterResult<()> {
|
) -> RouterResult<()> {
|
||||||
if let Some(id) = &payment_data.payment_attempt.payment_method_id {
|
if let Some(id) = &payment_data.payment_attempt.payment_method_id {
|
||||||
let pm = state
|
let pm = state
|
||||||
@ -1244,23 +1250,7 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
|
|||||||
|
|
||||||
let network_transaction_id =
|
let network_transaction_id =
|
||||||
if let Some(network_transaction_id) = pm_resp_network_transaction_id {
|
if let Some(network_transaction_id) = pm_resp_network_transaction_id {
|
||||||
let profile_id = payment_data
|
if is_connector_agnostic_mit_enabled == Some(true)
|
||||||
.payment_intent
|
|
||||||
.profile_id
|
|
||||||
.as_ref()
|
|
||||||
.ok_or(errors::ApiErrorResponse::ResourceIdNotFound)?;
|
|
||||||
|
|
||||||
let pg_agnostic = state
|
|
||||||
.store
|
|
||||||
.find_config_by_key_unwrap_or(
|
|
||||||
&format!("pg_agnostic_mandate_{}", profile_id),
|
|
||||||
Some("false".to_string()),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("The pg_agnostic config was not found in the DB")?;
|
|
||||||
|
|
||||||
if &pg_agnostic.config == "true"
|
|
||||||
&& payment_data.payment_intent.setup_future_usage
|
&& payment_data.payment_intent.setup_future_usage
|
||||||
== Some(diesel_models::enums::FutureUsage::OffSession)
|
== Some(diesel_models::enums::FutureUsage::OffSession)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,8 +64,8 @@ pub async fn save_payment_method<FData>(
|
|||||||
key_store: &domain::MerchantKeyStore,
|
key_store: &domain::MerchantKeyStore,
|
||||||
amount: Option<i64>,
|
amount: Option<i64>,
|
||||||
currency: Option<storage_enums::Currency>,
|
currency: Option<storage_enums::Currency>,
|
||||||
profile_id: Option<String>,
|
|
||||||
billing_name: Option<masking::Secret<String>>,
|
billing_name: Option<masking::Secret<String>>,
|
||||||
|
business_profile: &storage::business_profile::BusinessProfile,
|
||||||
) -> RouterResult<(Option<String>, Option<common_enums::PaymentMethodStatus>)>
|
) -> RouterResult<(Option<String>, Option<common_enums::PaymentMethodStatus>)>
|
||||||
where
|
where
|
||||||
FData: mandate::MandateBehaviour + Clone,
|
FData: mandate::MandateBehaviour + Clone,
|
||||||
@ -91,21 +91,7 @@ where
|
|||||||
|
|
||||||
let network_transaction_id =
|
let network_transaction_id =
|
||||||
if let Some(network_transaction_id) = network_transaction_id {
|
if let Some(network_transaction_id) = network_transaction_id {
|
||||||
let profile_id = profile_id
|
if business_profile.is_connector_agnostic_mit_enabled == Some(true)
|
||||||
.as_ref()
|
|
||||||
.ok_or(errors::ApiErrorResponse::ResourceIdNotFound)?;
|
|
||||||
|
|
||||||
let pg_agnostic = state
|
|
||||||
.store
|
|
||||||
.find_config_by_key_unwrap_or(
|
|
||||||
&format!("pg_agnostic_mandate_{}", profile_id),
|
|
||||||
Some("false".to_string()),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("The pg_agnostic config was not found in the DB")?;
|
|
||||||
|
|
||||||
if &pg_agnostic.config == "true"
|
|
||||||
&& save_payment_method_data.request.get_setup_future_usage()
|
&& save_payment_method_data.request.get_setup_future_usage()
|
||||||
== Some(storage_enums::FutureUsage::OffSession)
|
== Some(storage_enums::FutureUsage::OffSession)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use api_models::{
|
|||||||
};
|
};
|
||||||
#[cfg(not(feature = "business_profile_routing"))]
|
#[cfg(not(feature = "business_profile_routing"))]
|
||||||
use common_utils::ext_traits::{Encode, StringExt};
|
use common_utils::ext_traits::{Encode, StringExt};
|
||||||
|
#[cfg(not(feature = "business_profile_routing"))]
|
||||||
use diesel_models::configs;
|
use diesel_models::configs;
|
||||||
#[cfg(feature = "business_profile_routing")]
|
#[cfg(feature = "business_profile_routing")]
|
||||||
use diesel_models::routing_algorithm::RoutingAlgorithm;
|
use diesel_models::routing_algorithm::RoutingAlgorithm;
|
||||||
@ -806,37 +807,6 @@ pub async fn retrieve_linked_routing_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upsert_connector_agnostic_mandate_config(
|
|
||||||
state: AppState,
|
|
||||||
business_profile_id: &str,
|
|
||||||
mandate_config: routing_types::DetailedConnectorChoice,
|
|
||||||
) -> RouterResponse<routing_types::DetailedConnectorChoice> {
|
|
||||||
let key = helpers::get_pg_agnostic_mandate_config_key(business_profile_id);
|
|
||||||
|
|
||||||
let mandate_config_str = mandate_config.enabled.to_string();
|
|
||||||
|
|
||||||
let find_config = state
|
|
||||||
.store
|
|
||||||
.find_config_by_key_unwrap_or(&key, Some(mandate_config_str.clone()))
|
|
||||||
.await
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("error saving pg agnostic mandate config to db")?;
|
|
||||||
|
|
||||||
if find_config.config != mandate_config_str {
|
|
||||||
let config_update = configs::ConfigUpdate::Update {
|
|
||||||
config: Some(mandate_config_str),
|
|
||||||
};
|
|
||||||
state
|
|
||||||
.store
|
|
||||||
.update_config_by_key(&key, config_update)
|
|
||||||
.await
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("error saving pg agnostic mandate config to db")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(service_api::ApplicationResponse::Json(mandate_config))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn retrieve_default_routing_config_for_profiles(
|
pub async fn retrieve_default_routing_config_for_profiles(
|
||||||
state: AppState,
|
state: AppState,
|
||||||
merchant_account: domain::MerchantAccount,
|
merchant_account: domain::MerchantAccount,
|
||||||
|
|||||||
@ -272,47 +272,6 @@ pub async fn update_business_profile_active_algorithm_ref(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_merchant_connector_agnostic_mandate_config(
|
|
||||||
db: &dyn StorageInterface,
|
|
||||||
business_profile_id: &str,
|
|
||||||
) -> RouterResult<Vec<routing_types::DetailedConnectorChoice>> {
|
|
||||||
let key = get_pg_agnostic_mandate_config_key(business_profile_id);
|
|
||||||
let maybe_config = db.find_config_by_key(&key).await;
|
|
||||||
|
|
||||||
match maybe_config {
|
|
||||||
Ok(config) => config
|
|
||||||
.config
|
|
||||||
.parse_struct("Vec<DetailedConnectorChoice>")
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("pg agnostic mandate config has invalid structure"),
|
|
||||||
|
|
||||||
Err(e) if e.current_context().is_db_not_found() => {
|
|
||||||
let new_mandate_config: Vec<routing_types::DetailedConnectorChoice> = Vec::new();
|
|
||||||
|
|
||||||
let serialized = new_mandate_config
|
|
||||||
.encode_to_string_of_json()
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("error serializing newly created pg agnostic mandate config")?;
|
|
||||||
|
|
||||||
let new_config = configs::ConfigNew {
|
|
||||||
key,
|
|
||||||
config: serialized,
|
|
||||||
};
|
|
||||||
|
|
||||||
db.insert_config(new_config)
|
|
||||||
.await
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("error inserting new pg agnostic mandate config in db")?;
|
|
||||||
|
|
||||||
Ok(new_mandate_config)
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(e) => Err(e)
|
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
|
||||||
.attach_printable("error fetching pg agnostic mandate config for merchant from db"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn validate_connectors_in_routing_config(
|
pub async fn validate_connectors_in_routing_config(
|
||||||
db: &dyn StorageInterface,
|
db: &dyn StorageInterface,
|
||||||
key_store: &domain::MerchantKeyStore,
|
key_store: &domain::MerchantKeyStore,
|
||||||
@ -441,12 +400,6 @@ pub fn get_routing_dictionary_key(merchant_id: &str) -> String {
|
|||||||
format!("routing_dict_{merchant_id}")
|
format!("routing_dict_{merchant_id}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provides the identifier for the specific merchant's agnostic_mandate_config
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn get_pg_agnostic_mandate_config_key(business_profile_id: &str) -> String {
|
|
||||||
format!("pg_agnostic_mandate_{business_profile_id}")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Provides the identifier for the specific merchant's default_config
|
/// Provides the identifier for the specific merchant's default_config
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn get_default_config_key(
|
pub fn get_default_config_key(
|
||||||
|
|||||||
@ -466,10 +466,6 @@ impl Routing {
|
|||||||
)
|
)
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.service(
|
|
||||||
web::resource("/business_profile/{business_profile_id}/configs/pg_agnostic_mit")
|
|
||||||
.route(web::post().to(cloud_routing::upsert_connector_agnostic_mandate_config)),
|
|
||||||
)
|
|
||||||
.service(
|
.service(
|
||||||
web::resource("/default")
|
web::resource("/default")
|
||||||
.route(web::get().to(|state, req| {
|
.route(web::get().to(|state, req| {
|
||||||
|
|||||||
@ -231,7 +231,6 @@ impl From<Flow> for ApiIdentifier {
|
|||||||
| Flow::ReconTokenRequest
|
| Flow::ReconTokenRequest
|
||||||
| Flow::ReconServiceRequest
|
| Flow::ReconServiceRequest
|
||||||
| Flow::ReconVerifyToken => Self::Recon,
|
| Flow::ReconVerifyToken => Self::Recon,
|
||||||
Flow::CreateConnectorAgnosticMandateConfig => Self::Routing,
|
|
||||||
|
|
||||||
Flow::RetrievePollStatus => Self::Poll,
|
Flow::RetrievePollStatus => Self::Poll,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -566,41 +566,6 @@ pub async fn routing_retrieve_linked_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "olap")]
|
|
||||||
#[instrument(skip_all)]
|
|
||||||
pub async fn upsert_connector_agnostic_mandate_config(
|
|
||||||
state: web::Data<AppState>,
|
|
||||||
req: HttpRequest,
|
|
||||||
json_payload: web::Json<routing_types::DetailedConnectorChoice>,
|
|
||||||
path: web::Path<String>,
|
|
||||||
) -> impl Responder {
|
|
||||||
use crate::services::authentication::AuthenticationData;
|
|
||||||
|
|
||||||
let flow = Flow::CreateConnectorAgnosticMandateConfig;
|
|
||||||
let business_profile_id = path.into_inner();
|
|
||||||
|
|
||||||
Box::pin(oss_api::server_wrap(
|
|
||||||
flow,
|
|
||||||
state,
|
|
||||||
&req,
|
|
||||||
json_payload.into_inner(),
|
|
||||||
|state, _auth: AuthenticationData, mandate_config, _| {
|
|
||||||
Box::pin(routing::upsert_connector_agnostic_mandate_config(
|
|
||||||
state,
|
|
||||||
&business_profile_id,
|
|
||||||
mandate_config,
|
|
||||||
))
|
|
||||||
},
|
|
||||||
auth::auth_type(
|
|
||||||
&auth::ApiKeyAuth,
|
|
||||||
&auth::JWTAuth(Permission::RoutingWrite),
|
|
||||||
req.headers(),
|
|
||||||
),
|
|
||||||
api_locking::LockAction::NotApplicable,
|
|
||||||
))
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
pub async fn routing_retrieve_default_config_for_profiles(
|
pub async fn routing_retrieve_default_config_for_profiles(
|
||||||
|
|||||||
@ -3,9 +3,9 @@ pub use api_models::routing::RoutableChoiceKind;
|
|||||||
pub use api_models::{
|
pub use api_models::{
|
||||||
enums as api_enums,
|
enums as api_enums,
|
||||||
routing::{
|
routing::{
|
||||||
ConnectorVolumeSplit, DetailedConnectorChoice, RoutableConnectorChoice, RoutingAlgorithm,
|
ConnectorVolumeSplit, RoutableConnectorChoice, RoutingAlgorithm, RoutingAlgorithmKind,
|
||||||
RoutingAlgorithmKind, RoutingAlgorithmRef, RoutingConfigRequest, RoutingDictionary,
|
RoutingAlgorithmRef, RoutingConfigRequest, RoutingDictionary, RoutingDictionaryRecord,
|
||||||
RoutingDictionaryRecord, StraightThroughAlgorithm,
|
StraightThroughAlgorithm,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -210,8 +210,6 @@ pub enum Flow {
|
|||||||
RoutingRetrieveConfig,
|
RoutingRetrieveConfig,
|
||||||
/// Routing retrieve active config
|
/// Routing retrieve active config
|
||||||
RoutingRetrieveActiveConfig,
|
RoutingRetrieveActiveConfig,
|
||||||
/// Update connector agnostic mandate config
|
|
||||||
CreateConnectorAgnosticMandateConfig,
|
|
||||||
/// Routing retrieve default config
|
/// Routing retrieve default config
|
||||||
RoutingRetrieveDefaultConfig,
|
RoutingRetrieveDefaultConfig,
|
||||||
/// Routing retrieve dictionary
|
/// Routing retrieve dictionary
|
||||||
|
|||||||
Reference in New Issue
Block a user