text stringlengths 70 351k | source stringclasses 4 values |
|---|---|
// file: hyperswitch/crates/router/src/core/payments/customers.rs | crate: router
use common_utils::pii;
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
payments,
},
logger,
routes::{metrics, SessionState},
services,
types::{self, api, domain, storage},
};
pub async fn update_connector_customer_in_customers(
connector_label: &str,
customer: Option<&domain::Customer>,
connector_customer_id: Option<String>,
) -> Option<storage::CustomerUpdate> {
let mut connector_customer_map = customer
.and_then(|customer| customer.connector_customer.clone().expose_option())
.and_then(|connector_customer| connector_customer.as_object().cloned())
.unwrap_or_default();
let updated_connector_customer_map = connector_customer_id.map(|connector_customer_id| {
let connector_customer_value = serde_json::Value::String(connector_customer_id);
connector_customer_map.insert(connector_label.to_string(), connector_customer_value);
connector_customer_map
});
updated_connector_customer_map
.map(serde_json::Value::Object)
.map(
|connector_customer_value| storage::CustomerUpdate::ConnectorCustomer {
connector_customer: Some(pii::SecretSerdeValue::new(connector_customer_value)),
},
)
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/customers.rs | crate: router
use common_utils::pii;
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
payments,
},
logger,
routes::{metrics, SessionState},
services,
types::{self, api, domain, storage},
};
pub fn should_call_connector_create_customer<'a>(
state: &SessionState,
connector: &api::ConnectorData,
customer: &'a Option<domain::Customer>,
merchant_connector_id: &common_utils::id_type::MerchantConnectorAccountId,
) -> (bool, Option<&'a str>) {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/customers.rs | crate: router
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
payments,
},
logger,
routes::{metrics, SessionState},
services,
types::{self, api, domain, storage},
};
pub fn should_call_connector_create_customer<'a>(
state: &SessionState,
connector: &api::ConnectorData,
customer: &'a Option<domain::Customer>,
connector_label: &str,
) -> (bool, Option<&'a str>) {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use external_services::grpc_client::dynamic_routing::{
contract_routing_client::ContractBasedDynamicRouting,
success_rate_client::{CalSuccessRateResponse, SuccessBasedDynamicRouting},
DynamicRoutingError,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_dynamic_routing(
state: &SessionState,
routable_connectors: Vec<api_routing::RoutableConnectorChoice>,
profile: &domain::Profile,
dynamic_routing_config_params_interpolator: routing::helpers::DynamicRoutingConfigParamsInterpolator,
) -> RoutingResult<Vec<api_routing::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use hyperswitch_domain_models::address::Address;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn make_dsl_input_for_surcharge(
payment_attempt: &oss_storage::PaymentAttempt,
payment_intent: &oss_storage::PaymentIntent,
billing_address: Option<Address>,
) -> RoutingResult<dsl_inputs::BackendInput> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use crate::core::admin;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
async fn perform_session_routing_for_pm_type<'a>(
state: &'a SessionState,
key_store: &'a domain::MerchantKeyStore,
session_pm_input: &SessionRoutingPmTypeInput<'_>,
transaction_type: &api_enums::TransactionType,
business_profile: &domain::Profile,
) -> RoutingResult<Option<Vec<api_models::routing::RoutableConnectorChoice>>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use crate::core::admin;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
async fn get_chosen_connectors<'a>(
state: &'a SessionState,
key_store: &'a domain::MerchantKeyStore,
session_pm_input: &SessionRoutingPmTypeInput<'_>,
transaction_type: &api_enums::TransactionType,
profile_wrapper: &admin::ProfileWrapper,
) -> RoutingResult<Vec<api_models::routing::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
async fn perform_session_routing_for_pm_type(
session_pm_input: &SessionRoutingPmTypeInput<'_>,
transaction_type: &api_enums::TransactionType,
_business_profile: &domain::Profile,
) -> RoutingResult<Option<Vec<api_models::routing::RoutableConnectorChoice>>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_eligibility_analysis_with_fallback(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
chosen: Vec<routing_types::RoutableConnectorChoice>,
transaction_data: &routing::TransactionData<'_>,
eligible_connectors: Option<Vec<api_enums::RoutableConnectors>>,
business_profile: &domain::Profile,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use crate::core::admin;
use crate::core::payouts;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_fallback_routing(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
transaction_data: &routing::TransactionData<'_>,
eligible_connectors: Option<&Vec<api_enums::RoutableConnectors>>,
business_profile: &domain::Profile,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_cgraph_filtering(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
chosen: Vec<routing_types::RoutableConnectorChoice>,
backend_input: dsl_inputs::BackendInput,
eligible_connectors: Option<&Vec<api_enums::RoutableConnectors>>,
profile_id: &common_utils::id_type::ProfileId,
transaction_type: &api_enums::TransactionType,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use std::{collections::HashMap, str::FromStr, sync::Arc};
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use storage_impl::redis::cache::{CacheKey, CGRAPH_CACHE, ROUTING_CACHE};
use crate::core::payouts;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn get_merchant_cgraph(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
transaction_type: &api_enums::TransactionType,
) -> RoutingResult<Arc<hyperswitch_constraint_graph::ConstraintGraph<euclid_dir::DirValue>>> {
{
api_enums::TransactionType::Payment => {
format!(
"cgraph_{}_{}",
merchant_id.get_string_repr(),
profile_id.get_string_repr()
)
}<|fim_suffix|>
<|fim_middle|>
#[cfg(feature = "payouts")]
api_enums::TransactionType::Payout => {
format!(
"cgraph_po_{}_{}",
merchant_id.get_string_repr(),
profile_id.get_string_repr()
)
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use std::collections::hash_map;
use std::hash::{Hash, Hasher};
use std::{collections::HashMap, str::FromStr, sync::Arc};
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use rand::distributions::{self, Distribution};
use rand::SeedableRng;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn perform_dynamic_routing_volume_split(
splits: Vec<api_models::routing::RoutingVolumeSplit>,
rng_seed: Option<&str>,
) -> RoutingResult<api_models::routing::RoutingVolumeSplit> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use std::{collections::HashMap, str::FromStr, sync::Arc};
use common_utils::ext_traits::AsyncExt;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use storage_impl::redis::cache::{CacheKey, CGRAPH_CACHE, ROUTING_CACHE};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn refresh_routing_cache_v1(
state: &SessionState,
key: String,
algorithm_id: &common_utils::id_type::RoutingId,
profile_id: &common_utils::id_type::ProfileId,
) -> RoutingResult<Arc<CachedAlgorithm>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use std::{collections::HashMap, str::FromStr, sync::Arc};
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use storage_impl::redis::cache::{CacheKey, CGRAPH_CACHE, ROUTING_CACHE};
use crate::core::payouts;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
async fn ensure_algorithm_cached_v1(
state: &SessionState,
merchant_id: &common_utils::id_type::MerchantId,
algorithm_id: &common_utils::id_type::RoutingId,
profile_id: &common_utils::id_type::ProfileId,
transaction_type: &api_enums::TransactionType,
) -> RoutingResult<Arc<CachedAlgorithm>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use crate::core::admin;
use crate::core::payouts;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_static_routing_v1(
state: &SessionState,
merchant_id: &common_utils::id_type::MerchantId,
algorithm_id: Option<&common_utils::id_type::RoutingId>,
business_profile: &domain::Profile,
transaction_data: &routing::TransactionData<'_>,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use crate::core::payouts;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn make_dsl_input_for_payouts(
payout_data: &payouts::PayoutData,
) -> RoutingResult<dsl_inputs::BackendInput> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
.ok()
.flatten()
.unwrap_or(routable_connectors)
}
};
Ok(connector_list)
}
/// success based dynamic routing
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
#[instrument(skip_all)]
pub async fn perform_success_based_routing(
state: &SessionState,
routable_connectors: Vec<api_routing::RoutableConnectorChoice>,
profile_id: &common_utils::id_type::ProfileId,
success_based_routing_config_params_interpolator: routing::helpers::DynamicRoutingConfigParamsInterpolator,
success_based_algo_ref: api_routing::SuccessBasedAlgorithm,
) -> RoutingResult<Vec<api_routing::RoutableConnectorChoice>> {
if success_based_algo_ref.enabled_feature
== api_routing::DynamicRoutingFeatures::DynamicConnectorSelection
{
logger::debug!(
"performing success_based_routing for profile {}",
profile_id.get_string_repr()
pub async fn perform_success_based_routing(
state: &SessionState,
routable_connectors: Vec<api_routing::RoutableConnectorChoice>,
profile_id: &common_utils::id_type::ProfileId,
success_based_routing_config_params_interpolator: routing::helpers::DynamicRoutingConfigParamsInterpolator,
success_based_algo_ref: api_routing::SuccessBasedAlgorithm,
) -> RoutingResult<Vec<api_routing::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
)
.await?;
}
if final_selection.is_empty() {
Ok(None)
} else {
Ok(Some(final_selection))
}
}
#[cfg(feature = "v2")]
async fn get_chosen_connectors<'a>(
state: &'a SessionState,
key_store: &'a domain::MerchantKeyStore,
session_pm_input: &SessionRoutingPmTypeInput<'_>,
transaction_type: &api_enums::TransactionType,
profile_wrapper: &admin::ProfileWrapper,
) -> RoutingResult<Vec<api_models::routing::RoutableConnectorChoice>> {
let merchant_id = &key_store.merchant_id;
let MerchantAccountRoutingAlgorithm::V1(algorithm_id) = session_pm_input.routing_algorithm;
let chosen_connectors = if let Some(ref algorithm_id) = algorithm_id {
let cached_algorithm = ensure_algorithm_cached_v1(
async fn get_chosen_connectors<'a>(
state: &'a SessionState,
key_store: &'a domain::MerchantKeyStore,
session_pm_input: &SessionRoutingPmTypeInput<'_>,
transaction_type: &api_enums::TransactionType,
profile_wrapper: &admin::ProfileWrapper,
) -> RoutingResult<Vec<api_models::routing::RoutableConnectorChoice>> {
{
CachedAlgorithm::Single(conn) => vec![(**conn).clone()],<|fim_suffix|>
<|fim_middle|>
CachedAlgorithm::Advanced(interpreter) => execute_dsl_and_get_connector_v1(
session_pm_input.backend_input.clone(),
interpreter,
)?,
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use hyperswitch_domain_models::address::Address;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn make_dsl_input_for_surcharge(
_payment_attempt: &oss_storage::PaymentAttempt,
_payment_intent: &oss_storage::PaymentIntent,
_billing_address: Option<Address>,
) -> RoutingResult<dsl_inputs::BackendInput> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use crate::core::payouts;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_eligibility_analysis(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
chosen: Vec<routing_types::RoutableConnectorChoice>,
transaction_data: &routing::TransactionData<'_>,
eligible_connectors: Option<&Vec<api_enums::RoutableConnectors>>,
profile_id: &common_utils::id_type::ProfileId,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use rand::distributions::{self, Distribution};
use rand::SeedableRng;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn perform_volume_split(
mut splits: Vec<routing_types::ConnectorVolumeSplit>,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use diesel_models::enums as storage_enums;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use kgraph_utils::{
mca as mca_graph,
transformers::{IntoContext, IntoDirValue},
types::CountryCurrencyFilter,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
fn execute_dsl_and_get_connector_v1(
backend_input: dsl_inputs::BackendInput,
interpreter: &backend::VirInterpreterBackend<ConnectorSelection>,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use diesel_models::enums as storage_enums;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use kgraph_utils::{
mca as mca_graph,
transformers::{IntoContext, IntoDirValue},
types::CountryCurrencyFilter,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn perform_routing_for_single_straight_through_algorithm(
algorithm: &routing_types::StraightThroughAlgorithm,
) -> RoutingResult<Vec<routing_types::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use std::{collections::HashMap, str::FromStr, sync::Arc};
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn perform_straight_through_routing(
algorithm: &routing_types::StraightThroughAlgorithm,
creds_identifier: Option<&str>,
) -> RoutingResult<(Vec<routing_types::RoutableConnectorChoice>, bool)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use external_services::grpc_client::dynamic_routing::{
contract_routing_client::ContractBasedDynamicRouting,
success_rate_client::{CalSuccessRateResponse, SuccessBasedDynamicRouting},
DynamicRoutingError,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_contract_based_routing(
state: &SessionState,
routable_connectors: Vec<api_routing::RoutableConnectorChoice>,
profile_id: &common_utils::id_type::ProfileId,
_dynamic_routing_config_params_interpolator: routing::helpers::DynamicRoutingConfigParamsInterpolator,
contract_based_algo_ref: api_routing::ContractRoutingAlgorithm,
) -> RoutingResult<Vec<api_routing::RoutableConnectorChoice>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use external_services::grpc_client::dynamic_routing::{
contract_routing_client::ContractBasedDynamicRouting,
success_rate_client::{CalSuccessRateResponse, SuccessBasedDynamicRouting},
DynamicRoutingError,
};
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_success_based_routing(
state: &SessionState,
routable_connectors: Vec<api_routing::RoutableConnectorChoice>,
profile_id: &common_utils::id_type::ProfileId,
success_based_routing_config_params_interpolator: routing::helpers::DynamicRoutingConfigParamsInterpolator,
success_based_algo_ref: api_routing::SuccessBasedAlgorithm,
) -> RoutingResult<Vec<api_routing::RoutableConnectorChoice>> {
if success_based_algo_ref.enabled_feature
== api_routing::DynamicRoutingFeatures::DynamicConnectorSelection
{
logger::debug!(
"performing success_based_routing for profile {}",
profile_id.get_string_repr()
);
let client = state
.grpc_client
.dynamic_routing
.success_rate_client
.as_ref()
.ok_or(errors::RoutingError::SuccessRateClientInitializationError)
.attach_printable("success_rate gRPC client not found")?;
let success_based_routing_configs = routing::helpers::fetch_dynamic_routing_configs::<
api_routing::SuccessBasedRoutingConfig,
>(
state,
profile_id,
success_based_algo_ref
.algorithm_id_with_timestamp
.algorithm_id
.ok_or(errors::RoutingError::GenericNotFoundError {
field: "success_based_routing_algorithm_id".to_string(),
})
.attach_printable("success_based_routing_algorithm_id not found in profile_id")?,
)
.await
.change_context(errors::RoutingError::SuccessBasedRoutingConfigError)
.attach_printable("unable to fetch success_rate based dynamic routing configs")?;
let success_based_routing_config_params = success_based_routing_config_params_interpolator
.get_string_val(
success_based_routing_configs
.params
.as_ref()
.ok_or(errors::RoutingError::SuccessBasedRoutingParamsNotFoundError)?,
);
let success_based_connectors: CalSuccessRateResponse = client
.calculate_success_rate(
profile_id.get_string_repr().into(),
success_based_routing_configs,
success_based_routing_config_params,
routable_connectors,
state.get_grpc_headers(),
)
.await
.change_context(errors::RoutingError::SuccessRateCalculationError)
.attach_printable(
"unable to calculate/fetch success rate from dynamic routing service",
)?;
let mut connectors = Vec::with_capacity(success_based_connectors.labels_with_score.len());
for label_with_score in success_based_connectors.labels_with_score {
let (connector, merchant_connector_id) = label_with_score.label
.split_once(':')
.ok_or(errors::RoutingError::InvalidSuccessBasedConnectorLabel(label_with_score.label.to_string()))
.attach_printable(
"unable to split connector_name and mca_id from the label obtained by the dynamic routing service",
)?;
connectors.push(api_routing::RoutableConnectorChoice {
choice_kind: api_routing::RoutableChoiceKind::FullStruct,
connector: common_enums::RoutableConnectors::from_str(connector)
.change_context(errors::RoutingError::GenericConversionError {
from: "String".to_string(),
to: "RoutableConnectors".to_string(),
})
.attach_printable("unable to convert String to RoutableConnectors")?,
merchant_connector_id: Some(
common_utils::id_type::MerchantConnectorAccountId::wrap(
merchant_connector_id.to_string(),
)
.change_context(errors::RoutingError::GenericConversionError {
from: "String".to_string(),
to: "MerchantConnectorAccountId".to_string(),
})
.attach_printable("unable to convert MerchantConnectorAccountId from string")?,
),
});
}
logger::debug!(success_based_routing_connectors=?connectors);
Ok(connectors)
} else {
Ok(routable_connectors)
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use diesel_models::enums as storage_enums;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use rustc_hash::FxHashMap;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_session_flow_routing(
session_input: SessionFlowRoutingInput<'_>,
business_profile: &domain::Profile,
transaction_type: &api_enums::TransactionType,
) -> RoutingResult<FxHashMap<api_enums::PaymentMethodType, Vec<routing_types::SessionRoutingChoice>>>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use diesel_models::enums as storage_enums;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use rustc_hash::FxHashMap;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn perform_session_flow_routing<'a>(
state: &'a SessionState,
key_store: &'a domain::MerchantKeyStore,
session_input: SessionFlowRoutingInput<'_>,
business_profile: &domain::Profile,
transaction_type: &api_enums::TransactionType,
) -> RoutingResult<FxHashMap<api_enums::PaymentMethodType, Vec<routing_types::SessionRoutingChoice>>>
{
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use std::{collections::HashMap, str::FromStr, sync::Arc};
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use common_utils::ext_traits::AsyncExt;
use diesel_models::enums as storage_enums;
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use kgraph_utils::{
mca as mca_graph,
transformers::{IntoContext, IntoDirValue},
types::CountryCurrencyFilter,
};
use storage_impl::redis::cache::{CacheKey, CGRAPH_CACHE, ROUTING_CACHE};
use crate::core::payouts;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub async fn refresh_cgraph_cache(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
key: String,
profile_id: &common_utils::id_type::ProfileId,
transaction_type: &api_enums::TransactionType,
) -> RoutingResult<Arc<hyperswitch_constraint_graph::ConstraintGraph<euclid_dir::DirValue>>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/routing.rs | crate: router
use api_models::routing as api_routing;
use api_models::{
admin as admin_api,
enums::{self as api_enums, CountryAlpha2},
routing::ConnectorSelection,
};
use euclid::{
backend::{self, inputs as dsl_inputs, EuclidBackend},
dssa::graph::{self as euclid_graph, CgraphExt},
enums as euclid_enums,
frontend::{ast, dir as euclid_dir},
};
use hyperswitch_domain_models::address::Address;
use crate::{
core::{
errors, errors as oss_errors,
routing::{self},
},
logger,
types::{
api::{self, routing as routing_types},
domain, storage as oss_storage,
transformers::{ForeignFrom, ForeignInto, ForeignTryFrom},
},
utils::{OptionExt, ValueExt},
SessionState,
};
type RoutingResult<O> = oss_errors::CustomResult<O, errors::RoutingError>;
pub fn make_dsl_input(
payments_dsl_input: &routing::PaymentsDslInput<'_>,
) -> RoutingResult<dsl_inputs::BackendInput> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_or_create_customer_details<'a>(
&'a self,
state: &SessionState,
payment_data: &mut D,
_request: Option<CustomerDetails>,
merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsCancelRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_or_create_customer_details<'a>(
&'a self,
state: &SessionState,
payment_data: &mut D,
_request: Option<CustomerDetails>,
merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsCaptureRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_or_create_customer_details<'a>(
&'a self,
state: &SessionState,
payment_data: &mut D,
_request: Option<CustomerDetails>,
merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsRetrieveRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedOperation<'a, F, api::PaymentsCaptureRequest, D>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
Ok((Box::new(self), None, None))
}
async fn get_connector<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
state: &SessionState,
_request: &api::PaymentsCaptureRequest,
_payment_intent: &storage::PaymentIntent,
_merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {
helpers::get_connector_default(state, None).await
}
#[instrument(skip_all)]
async fn guard_payment_against_blocklist<'a>(
async fn get_connector<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
state: &SessionState,
_request: &api::PaymentsCaptureRequest,
_payment_intent: &storage::PaymentIntent,
_merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsCaptureRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
todo!()
}
#[instrument(skip_all)]
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut D,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedOperation<'a, F, api::PaymentsCaptureRequest, D>,
Option<domain::PaymentMethodData>,
Option<String>,
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut D,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedOperation<'a, F, api::PaymentsCaptureRequest, D>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_connector<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
state: &SessionState,
_request: &api::PaymentsRejectRequest,
_payment_intent: &storage::PaymentIntent,
_merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut D,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedOperation<'a, F, api::PaymentsRejectRequest, D>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_customer_details<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_merchant_key_store: &domain::MerchantKeyStore,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsRejectRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_or_create_customer_details<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_request: Option<CustomerDetails>,
_merchant_key_store: &domain::MerchantKeyStore,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsRejectRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_connector<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
state: &SessionState,
_request: &api::PaymentsCancelRequest,
_payment_intent: &storage::PaymentIntent,
_merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut D,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedOperation<'a, F, api::PaymentsCancelRequest, D>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_customer_details<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsCancelRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_connector<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
state: &SessionState,
_request: &api::PaymentsCaptureRequest,
_payment_intent: &storage::PaymentIntent,
_merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {
helpers::get_connector_default(state, None).await
} | ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut D,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedOperation<'a, F, api::PaymentsCaptureRequest, D>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
Ok((Box::new(self), None, None))
} | ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_customer_details<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_merchant_key_store: &domain::MerchantKeyStore,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<'a, F, api::PaymentsCaptureRequest, D>,
Option<domain::Customer>,
),
errors::StorageError,
> {
todo!()
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn guard_payment_against_blocklist<'a>(
&'a self,
_state: &SessionState,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_payment_data: &mut D,
) -> CustomResult<bool, errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut D,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedOperation<'a, F, api::PaymentsRetrieveRequest, D>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
Ok((Box::new(self), None, None))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use super::{helpers, CustomerDetails, OperationSessionGetters, OperationSessionSetters};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn get_connector<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
state: &SessionState,
_request: &api::PaymentsRetrieveRequest,
_payment_intent: &storage::PaymentIntent,
_merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn save_pm_and_mandate<'b>(
&self,
_state: &SessionState,
_resp: &types::RouterData<F, R, PaymentsResponseData>,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_payment_data: &mut D,
_business_profile: &domain::Profile,
) -> CustomResult<(), errors::ApiErrorResponse>
where
F: 'b + Clone + Send + Sync,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn store_extended_card_info_temporarily<'a>(
&'a self,
_state: &SessionState,
_payment_id: &common_utils::id_type::PaymentId,
_business_profile: &domain::Profile,
_payment_method_data: Option<&domain::PaymentMethodData>,
) -> CustomResult<(), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn payments_dynamic_tax_calculation<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_connector_call_type: &ConnectorCallType,
_business_profile: &domain::Profile,
_key_store: &domain::MerchantKeyStore,
_merchant_account: &domain::MerchantAccount,
) -> CustomResult<(), errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
use api_models::routing::RoutableConnectorChoice;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn call_unified_authentication_service_if_eligible<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_should_continue_confirm_transaction: &mut bool,
_connector_call_type: &ConnectorCallType,
_business_profile: &domain::Profile,
_key_store: &domain::MerchantKeyStore,
_mandate_type: Option<api_models::payments::MandateTransactionType>,
_do_authorization_confirmation: &bool,
) -> CustomResult<(), errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use api_models::enums::FrmSuggestion;
use api_models::routing::RoutableConnectorChoice;
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn call_external_three_ds_authentication_if_eligible<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_should_continue_confirm_transaction: &mut bool,
_connector_call_type: &ConnectorCallType,
_merchant_account: &domain::Profile,
_key_store: &domain::MerchantKeyStore,
_mandate_type: Option<api_models::payments::MandateTransactionType>,
) -> CustomResult<(), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn populate_payment_data<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut D,
_merchant_account: &domain::MerchantAccount,
_business_profile: &domain::Profile,
_connector_data: &api::ConnectorData,
) -> CustomResult<(), errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn add_task_to_process_tracker<'a>(
&'a self,
_db: &'a SessionState,
_payment_attempt: &storage::PaymentAttempt,
_requeue: bool,
_schedule_time: Option<time::PrimitiveDateTime>,
) -> CustomResult<(), errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
/// This will run the decision manager for the payment
async fn run_decision_manager<'a>(
&'a self,
state: &SessionState,
payment_data: &mut D,
business_profile: &domain::Profile,
) -> CustomResult<(), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
async fn validate_request_with_state(
&self,
_state: &SessionState,
_request: &R,
_payment_data: &mut D,
_business_profile: &domain::Profile,
) -> RouterResult<()> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use error_stack::{report, ResultExt};
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
fn to_post_update_tracker(
&self,
) -> RouterResult<&(dyn PostUpdateTracker<F, Self::Data, T> + Send + Sync)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use error_stack::{report, ResultExt};
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
fn to_update_tracker(
&self,
) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, T> + Send + Sync)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use error_stack::{report, ResultExt};
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
fn to_domain(&self) -> RouterResult<&dyn Domain<F, T, Self::Data>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use error_stack::{report, ResultExt};
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
fn to_get_tracker(&self) -> RouterResult<&(dyn GetTracker<F, Self::Data, T> + Send + Sync)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations.rs | crate: router
use error_stack::{report, ResultExt};
pub use self::payment_get::PaymentGet;
pub use self::payment_get_intent::PaymentGetIntent;
pub use self::payment_response::PaymentResponse;
pub use self::payment_update_intent::PaymentUpdateIntent;
pub use self::{
payment_approve::PaymentApprove, payment_cancel::PaymentCancel,
payment_capture::PaymentCapture, payment_confirm::PaymentConfirm,
payment_create::PaymentCreate, payment_post_session_tokens::PaymentPostSessionTokens,
payment_reject::PaymentReject, payment_session::PaymentSession, payment_start::PaymentStart,
payment_status::PaymentStatus, payment_update::PaymentUpdate,
payments_incremental_authorization::PaymentIncrementalAuthorization,
tax_calculation::PaymentSessionUpdate,
};
pub use self::{
payment_confirm_intent::PaymentIntentConfirm, payment_create_intent::PaymentIntentCreate,
payment_session_intent::PaymentSessionIntent,
};
use crate::{
core::errors::{self, CustomResult, RouterResult},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType},
domain,
storage::{self, enums},
PaymentsResponseData,
},
};
pub type BoxedOperation<'a, F, T, D> = Box<dyn Operation<F, T, Data = D> + Send + Sync + 'a>;
fn to_validate_request(
&self,
) -> RouterResult<&(dyn ValidateRequest<F, T, Self::Data> + Send + Sync)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use diesel_models::enums as storage_enums;
use router_env::{
logger,
tracing::{self, instrument},
};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
fn should_call_gsm(&self) -> bool {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use diesel_models::enums as storage_enums;
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub fn make_new_payment_attempt(
connector: String,
old_payment_attempt: storage::PaymentAttempt,
new_attempt_count: i16,
is_step_up: bool,
) -> storage::PaymentAttemptNew {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use diesel_models::enums as storage_enums;
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn do_retry<F, ApiRequest, FData, D>(
state: &routes::SessionState,
req_state: ReqState,
connector: &api::ConnectorData,
operation: &operations::BoxedOperation<'_, F, ApiRequest, D>,
customer: &Option<domain::Customer>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
payment_data: &mut D,
router_data: types::RouterData<F, FData, types::PaymentsResponseData>,
validate_result: &operations::ValidateResult,
schedule_time: Option<time::PrimitiveDateTime>,
is_step_up: bool,
frm_suggestion: Option<storage_enums::FrmSuggestion>,
business_profile: &domain::Profile,
should_retry_with_pan: bool,
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
where
F: Clone + Send + Sync,
FData: Send + Sync,
payments::PaymentResponse: operations::Operation<F, FData>,
D: payments::OperationSessionGetters<F>
+ payments::OperationSessionSetters<F>
+ Send
+ Sync
+ Clone,
D: ConstructFlowSpecificData<F, FData, types::PaymentsResponseData>,
types::RouterData<F, FData, types::PaymentsResponseData>: Feature<F, FData>,
dyn api::Connector: services::api::ConnectorIntegration<F, FData, types::PaymentsResponseData>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
#[cfg(feature = "v2")]
#[instrument(skip_all)]
pub fn make_new_payment_attempt(
_connector: String,
_old_payment_attempt: storage::PaymentAttempt,
_new_attempt_count: i16,
_is_step_up: bool,
) -> storage::PaymentAttempt {
todo!()
}
#[cfg(feature = "v1")]
pub async fn get_merchant_config_for_gsm(
db: &dyn StorageInterface,
merchant_id: &common_utils::id_type::MerchantId,
) -> bool {
let config = db
.find_config_by_key_unwrap_or(
&merchant_id.get_should_call_gsm_key(),
Some("false".to_string()),
)
.await;
match config {
Ok(conf) => conf.config == "true",
Err(error) => {
pub async fn get_merchant_config_for_gsm(
db: &dyn StorageInterface,
merchant_id: &common_utils::id_type::MerchantId,
) -> bool {
{
Ok(conf) => conf.config == "true",<|fim_suffix|>
<|fim_middle|>
Err(error) => {
logger::error!(?error);
false
}
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn get_retries(
state: &app::SessionState,
retries: Option<i32>,
merchant_id: &common_utils::id_type::MerchantId,
profile: &domain::Profile,
) -> Option<i32> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn config_should_call_gsm(
db: &dyn StorageInterface,
merchant_id: &common_utils::id_type::MerchantId,
profile: &domain::Profile,
) -> bool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use router_env::{
logger,
tracing::{self, instrument},
};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn get_merchant_config_for_gsm(
db: &dyn StorageInterface,
merchant_id: &common_utils::id_type::MerchantId,
) -> bool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub fn make_new_payment_attempt(
_connector: String,
_old_payment_attempt: storage::PaymentAttempt,
_new_attempt_count: i16,
_is_step_up: bool,
) -> storage::PaymentAttempt {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use diesel_models::enums as storage_enums;
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn modify_trackers<F, FData, D>(
state: &routes::SessionState,
connector: String,
payment_data: &mut D,
key_store: &domain::MerchantKeyStore,
storage_scheme: storage_enums::MerchantStorageScheme,
router_data: types::RouterData<F, FData, types::PaymentsResponseData>,
is_step_up: bool,
) -> RouterResult<()>
where
F: Clone + Send,
FData: Send,
D: payments::OperationSessionGetters<F> + payments::OperationSessionSetters<F> + Send + Sync,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use std::{str::FromStr, vec::IntoIter};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
fn get_flow_name<F>() -> RouterResult<String> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use error_stack::{report, ResultExt};
use router_env::{
logger,
tracing::{self, instrument},
};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub fn get_gsm_decision(
option_gsm: Option<storage::gsm::GatewayStatusMap>,
) -> api_models::gsm::GsmDecision {
let option_gsm_decision = option_gsm
.and_then(|gsm| {
api_models::gsm::GsmDecision::from_str(gsm.decision.as_str())
.map_err(|err| {
let api_error = report!(err).change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("gsm decision parsing failed");
logger::warn!(get_gsm_decision_parse_error=?api_error, "error fetching gsm decision");
api_error
})
.ok()
});
if option_gsm_decision.is_some() {
metrics::AUTO_RETRY_GSM_MATCH_COUNT.add(1, &[]);
}
option_gsm_decision.unwrap_or_default()
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn get_gsm<F, FData>(
state: &app::SessionState,
router_data: &types::RouterData<F, FData, types::PaymentsResponseData>,
) -> RouterResult<Option<storage::gsm::GatewayStatusMap>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn get_retries(
state: &app::SessionState,
retries: Option<i32>,
merchant_id: &common_utils::id_type::MerchantId,
profile: &domain::Profile,
) -> Option<i32> {
match retries {
Some(retries) => Some(retries),
None => get_merchant_max_auto_retries_enabled(state.store.as_ref(), merchant_id)
.await
.or(profile.max_auto_retries_enabled.map(i32::from)),
}
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use router_env::{
logger,
tracing::{self, instrument},
};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn get_merchant_max_auto_retries_enabled(
db: &dyn StorageInterface,
merchant_id: &common_utils::id_type::MerchantId,
) -> Option<i32> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use common_utils::{ext_traits::Encode, types::MinorUnit};
use router_env::{
logger,
tracing::{self, instrument},
};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn is_step_up_enabled_for_merchant_connector(
state: &app::SessionState,
merchant_id: &common_utils::id_type::MerchantId,
connector_name: types::Connector,
) -> bool {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/retry.rs | crate: router
use std::{str::FromStr, vec::IntoIter};
use common_utils::{ext_traits::Encode, types::MinorUnit};
use diesel_models::enums as storage_enums;
use error_stack::{report, ResultExt};
use router_env::{
logger,
tracing::{self, instrument},
};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self,
flows::{ConstructFlowSpecificData, Feature},
operations,
},
},
db::StorageInterface,
routes::{
self,
app::{self, ReqState},
metrics,
},
services,
types::{self, api, domain, storage},
};
pub async fn do_gsm_actions<F, ApiRequest, FData, D>(
state: &app::SessionState,
req_state: ReqState,
payment_data: &mut D,
mut connectors: IntoIter<api::ConnectorData>,
original_connector_data: &api::ConnectorData,
mut router_data: types::RouterData<F, FData, types::PaymentsResponseData>,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
operation: &operations::BoxedOperation<'_, F, ApiRequest, D>,
customer: &Option<domain::Customer>,
validate_result: &operations::ValidateResult,
schedule_time: Option<time::PrimitiveDateTime>,
frm_suggestion: Option<storage_enums::FrmSuggestion>,
business_profile: &domain::Profile,
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
where
F: Clone + Send + Sync,
FData: Send + Sync,
payments::PaymentResponse: operations::Operation<F, FData>,
D: payments::OperationSessionGetters<F>
+ payments::OperationSessionSetters<F>
+ Send
+ Sync
+ Clone,
D: ConstructFlowSpecificData<F, FData, types::PaymentsResponseData>,
types::RouterData<F, FData, types::PaymentsResponseData>: Feature<F, FData>,
dyn api::Connector: services::api::ConnectorIntegration<F, FData, types::PaymentsResponseData>,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use async_trait::async_trait;
use common_utils::{ext_traits::Encode, types::keymanager::ToEncryptable};
use error_stack::ResultExt;
use hyperswitch_domain_models::payments::PaymentConfirmData;
use masking::PeekInterface;
use router_env::{instrument, tracing};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
async fn perform_routing<'a>(
&'a self,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
state: &SessionState,
// TODO: do not take the whole payment data here
payment_data: &mut PaymentConfirmData<F>,
mechant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<ConnectorCallType, errors::ApiErrorResponse> {
use crate::core::payments::OperationSessionSetters;
let fallback_config = admin::ProfileWrapper::new(business_profile.clone())
.get_default_fallback_list_of_connector_under_profile()
.change_context(errors::RoutingError::FallbackConfigFetchFailed)
.change_context(errors::ApiErrorResponse::InternalServerError)?;
let first_chosen_connector = fallback_config
.first()
.ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration)?;
let connector_name = first_chosen_connector.connector.to_string();
let merchant_connector_id = first_chosen_connector
.merchant_connector_id
.clone()
.get_required_value("merchant_connector_id")?;
payment_data.set_connector_in_payment_attempt(Some(connector_name.to_string()));
payment_data.set_merchant_connector_id_in_attempt(Some(merchant_connector_id.clone()));
let connector_data = api::ConnectorData::get_connector_by_name(
&state.conf.connectors,
&connector_name,
api::GetToken::Connector,
Some(merchant_connector_id),
)?;
Ok(ConnectorCallType::PreDetermined(connector_data))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use hyperswitch_domain_models::payments::PaymentConfirmData;
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
async fn get_customer_details<'a>(
&'a self,
state: &SessionState,
payment_data: &mut PaymentConfirmData<F>,
merchant_key_store: &domain::MerchantKeyStore,
storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<(BoxedConfirmOperation<'a, F>, Option<domain::Customer>), errors::StorageError>
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedConfirmOperation<'a, F>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
Ok((Box::new(self), None, None))
}
#[cfg(feature = "v2")]
async fn perform_routing<'a>(
&'a self,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
state: &SessionState,
// TODO: do not take the whole payment data here
payment_data: &mut PaymentConfirmData<F>,
mechant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<ConnectorCallType, errors::ApiErrorResponse> {
use crate::core::payments::OperationSessionSetters;
let fallback_config = admin::ProfileWrapper::new(business_profile.clone())
.get_default_fallback_list_of_connector_under_profile()
async fn perform_routing<'a>(
&'a self,
merchant_account: &domain::MerchantAccount,
business_profile: &domain::Profile,
state: &SessionState,
// TODO: do not take the whole payment data here
payment_data: &mut PaymentConfirmData<F>,
mechant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<ConnectorCallType, errors::ApiErrorResponse> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
)?,
None => authentication_type,
};
if let Some(auth_type) = authentication_type {
payment_data.payment_attempt.authentication_type = auth_type;
}
Ok(())
}
#[instrument(skip_all)]
async fn make_pm_data<'a>(
&'a self,
state: &'a SessionState,
payment_data: &mut PaymentConfirmData<F>,
storage_scheme: storage_enums::MerchantStorageScheme,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedConfirmOperation<'a, F>,
Option<domain::PaymentMethodData>,
Option<String>,
async fn make_pm_data<'a>(
&'a self,
state: &'a SessionState,
payment_data: &mut PaymentConfirmData<F>,
storage_scheme: storage_enums::MerchantStorageScheme,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedConfirmOperation<'a, F>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use hyperswitch_domain_models::payments::PaymentConfirmData;
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
async fn make_pm_data<'a>(
&'a self,
state: &'a SessionState,
payment_data: &mut PaymentConfirmData<F>,
storage_scheme: storage_enums::MerchantStorageScheme,
key_store: &domain::MerchantKeyStore,
customer: &Option<domain::Customer>,
business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
BoxedConfirmOperation<'a, F>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
Ok((Box::new(self), None, None))
} | ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use hyperswitch_domain_models::payments::PaymentConfirmData;
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
async fn run_decision_manager<'a>(
&'a self,
state: &SessionState,
payment_data: &mut PaymentConfirmData<F>,
business_profile: &domain::Profile,
) -> CustomResult<(), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
fn validate_request<'a, 'b>(
&'b self,
request: &PaymentsConfirmIntentRequest,
merchant_account: &'a domain::MerchantAccount,
) -> RouterResult<operations::ValidateResult> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
fn to_update_tracker(
&self,
) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsConfirmIntentRequest> + Send + Sync)>
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
fn to_domain(&self) -> RouterResult<&dyn Domain<F, PaymentsConfirmIntentRequest, Self::Data>> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
fn to_get_tracker(
&self,
) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsConfirmIntentRequest> + Send + Sync)>
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
fn to_validate_request(
&self,
) -> RouterResult<
&(dyn ValidateRequest<F, PaymentsConfirmIntentRequest, Self::Data> + Send + Sync),
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
/// Validate if the current operation can be performed on the current status of the payment intent
fn validate_status_for_operation(
&self,
intent_status: common_enums::IntentStatus,
) -> Result<(), errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use hyperswitch_domain_models::payments::PaymentConfirmData;
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
async fn update_trackers<'b>(
&'b self,
state: &'b SessionState,
req_state: ReqState,
mut payment_data: PaymentConfirmData<F>,
customer: Option<domain::Customer>,
storage_scheme: storage_enums::MerchantStorageScheme,
updated_customer: Option<storage::CustomerUpdate>,
key_store: &domain::MerchantKeyStore,
frm_suggestion: Option<FrmSuggestion>,
header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>
where
F: 'b + Send,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payment_confirm_intent.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsConfirmIntentRequest};
use common_utils::{ext_traits::Encode, types::keymanager::ToEncryptable};
use hyperswitch_domain_models::payments::PaymentConfirmData;
use masking::PeekInterface;
use crate::{
core::{
admin,
errors::{self, CustomResult, RouterResult, StorageErrorExt},
payments::{
self, call_decision_manager, helpers,
operations::{self, ValidateStatusForOperation},
populate_surcharge_details, CustomerDetails, OperationSessionSetters, PaymentAddress,
PaymentData,
},
utils as core_utils,
},
routes::{app::ReqState, SessionState},
services,
types::{
self,
api::{self, ConnectorCallType, PaymentIdTypeExt},
domain::{self, types as domain_types},
storage::{self, enums as storage_enums},
},
utils::{self, OptionExt},
};
type BoxedConfirmOperation<'b, F> =
super::BoxedOperation<'b, F, PaymentsConfirmIntentRequest, PaymentConfirmData<F>>;
async fn get_trackers<'a>(
&'a self,
state: &'a SessionState,
payment_id: &common_utils::id_type::GlobalPaymentId,
request: &PaymentsConfirmIntentRequest,
merchant_account: &domain::MerchantAccount,
profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
_platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<operations::GetTrackerResponse<PaymentConfirmData<F>>> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payments_incremental_authorization.rs | crate: router
#[operation(operations = "all", flow = "incremental_authorization")]
pub struct PaymentIncrementalAuthorization;
type PaymentIncrementalAuthorizationOperation<'b, F> =
BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>;
#[async_trait]
impl<F: Send + Clone + Sync>
GetTracker<F, payments::PaymentData<F>, PaymentsIncrementalAuthorizationRequest>
for PaymentIncrementalAuthorization
{
#[instrument(skip_all)]
async fn get_trackers<'a>(
&'a self,
state: &'a SessionState,
payment_id: &api::PaymentIdType,
request: &PaymentsIncrementalAuthorizationRequest,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
_auth_flow: services::AuthFlow,
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<
operations::GetTrackerResponse<
'a,
async fn get_trackers<'a>(
&'a self,
state: &'a SessionState,
payment_id: &api::PaymentIdType,
request: &PaymentsIncrementalAuthorizationRequest,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
_auth_flow: services::AuthFlow,
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
platform_merchant_account: Option<&domain::MerchantAccount>,
) -> RouterResult<
operations::GetTrackerResponse<
'a,
F,
PaymentsIncrementalAuthorizationRequest,
payments::PaymentData<F>,
>,
> {
{let db = &*state.store;<|fim_suffix|>
<|fim_middle|>
Ok(get_trackers_response)}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payments_incremental_authorization.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsIncrementalAuthorizationRequest};
use common_utils::errors::CustomResult;
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails,
PaymentAddress,
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums},
},
utils::OptionExt,
};
type PaymentIncrementalAuthorizationOperation<'b, F> =
BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>;
async fn guard_payment_against_blocklist<'a>(
&'a self,
_state: &SessionState,
_merchant_account: &domain::MerchantAccount,
_key_store: &domain::MerchantKeyStore,
_payment_data: &mut payments::PaymentData<F>,
) -> CustomResult<bool, errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payments_incremental_authorization.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsIncrementalAuthorizationRequest};
use common_utils::errors::CustomResult;
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails,
PaymentAddress,
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums},
},
utils::OptionExt,
};
type PaymentIncrementalAuthorizationOperation<'b, F> =
BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>;
async fn get_connector<'a>(
&'a self,
_merchant_account: &domain::MerchantAccount,
state: &SessionState,
_request: &PaymentsIncrementalAuthorizationRequest,
_payment_intent: &storage::PaymentIntent,
_merchant_key_store: &domain::MerchantKeyStore,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payments_incremental_authorization.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsIncrementalAuthorizationRequest};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails,
PaymentAddress,
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums},
},
utils::OptionExt,
};
type PaymentIncrementalAuthorizationOperation<'b, F> =
BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>;
async fn make_pm_data<'a>(
&'a self,
_state: &'a SessionState,
_payment_data: &mut payments::PaymentData<F>,
_storage_scheme: enums::MerchantStorageScheme,
_merchant_key_store: &domain::MerchantKeyStore,
_customer: &Option<domain::Customer>,
_business_profile: &domain::Profile,
_should_retry_with_pan: bool,
) -> RouterResult<(
PaymentIncrementalAuthorizationOperation<'a, F>,
Option<domain::PaymentMethodData>,
Option<String>,
)> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payments_incremental_authorization.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsIncrementalAuthorizationRequest};
use common_utils::errors::CustomResult;
use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails,
PaymentAddress,
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums},
},
utils::OptionExt,
};
type PaymentIncrementalAuthorizationOperation<'b, F> =
BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>;
async fn get_or_create_customer_details<'a>(
&'a self,
_state: &SessionState,
_payment_data: &mut payments::PaymentData<F>,
_request: Option<CustomerDetails>,
_merchant_key_store: &domain::MerchantKeyStore,
_storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<
(
BoxedOperation<
'a,
F,
PaymentsIncrementalAuthorizationRequest,
payments::PaymentData<F>,
>,
Option<domain::Customer>,
),
errors::StorageError,
> {
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payments_incremental_authorization.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsIncrementalAuthorizationRequest};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails,
PaymentAddress,
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums},
},
utils::OptionExt,
};
type PaymentIncrementalAuthorizationOperation<'b, F> =
BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>;
fn validate_request<'a, 'b>(
&'b self,
request: &PaymentsIncrementalAuthorizationRequest,
merchant_account: &'a domain::MerchantAccount,
) -> RouterResult<(
PaymentIncrementalAuthorizationOperation<'b, F>,
operations::ValidateResult,
)> {
{<|fim_suffix|>
<|fim_middle|>
}}
| ast_fragments |
<|fim_prefix|>
// file: hyperswitch/crates/router/src/core/payments/operations/payments_incremental_authorization.rs | crate: router
use api_models::{enums::FrmSuggestion, payments::PaymentsIncrementalAuthorizationRequest};
use common_utils::errors::CustomResult;
use diesel_models::authorization::AuthorizationNew;
use error_stack::{report, ResultExt};
use crate::{
core::{
errors::{self, RouterResult, StorageErrorExt},
payments::{
self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails,
PaymentAddress,
},
utils::ValidatePlatformMerchant,
},
routes::{app::ReqState, SessionState},
services,
types::{
api::{self, PaymentIdTypeExt},
domain,
storage::{self, enums},
},
utils::OptionExt,
};
type PaymentIncrementalAuthorizationOperation<'b, F> =
BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>;
async fn update_trackers<'b>(
&'b self,
state: &'b SessionState,
_req_state: ReqState,
mut payment_data: payments::PaymentData<F>,
_customer: Option<domain::Customer>,
storage_scheme: enums::MerchantStorageScheme,
_updated_customer: Option<storage::CustomerUpdate>,
key_store: &domain::MerchantKeyStore,
_frm_suggestion: Option<FrmSuggestion>,
_header_payload: hyperswitch_domain_models::payments::HeaderPayload,
) -> RouterResult<(
PaymentIncrementalAuthorizationOperation<'b, F>,
payments::PaymentData<F>,
)>
where
F: 'b + Send,
{
<|fim_suffix|>
<|fim_middle|>
}
| ast_fragments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.