mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
feat(payouts): add payout types in euclid crate (#3862)
Co-authored-by: Kashif <mohammed.kashif@juspay.in>
This commit is contained in:
@ -714,6 +714,7 @@ pub async fn retrieve_linked_routing_config(
|
||||
state: AppState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
#[cfg(feature = "business_profile_routing")] query_params: RoutingRetrieveLinkQuery,
|
||||
#[cfg(feature = "business_profile_routing")] transaction_type: &enums::TransactionType,
|
||||
) -> RouterResponse<routing_types::LinkedRoutingConfigRetrieveResponse> {
|
||||
metrics::ROUTING_RETRIEVE_LINK_CONFIG.add(&metrics::CONTEXT, 1, &[]);
|
||||
let db = state.store.as_ref();
|
||||
@ -739,16 +740,17 @@ pub async fn retrieve_linked_routing_config(
|
||||
let mut active_algorithms = Vec::new();
|
||||
|
||||
for business_profile in business_profiles {
|
||||
let routing_ref: routing_types::RoutingAlgorithmRef = business_profile
|
||||
.routing_algorithm
|
||||
.clone()
|
||||
.map(|val| val.parse_value("RoutingAlgorithmRef"))
|
||||
.transpose()
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable(
|
||||
"unable to deserialize routing algorithm ref from merchant account",
|
||||
)?
|
||||
.unwrap_or_default();
|
||||
let routing_ref: routing_types::RoutingAlgorithmRef = match transaction_type {
|
||||
enums::TransactionType::Payment => business_profile.routing_algorithm,
|
||||
#[cfg(feature = "payouts")]
|
||||
enums::TransactionType::Payout => business_profile.payout_routing_algorithm,
|
||||
}
|
||||
.clone()
|
||||
.map(|val| val.parse_value("RoutingAlgorithmRef"))
|
||||
.transpose()
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("unable to deserialize routing algorithm ref from merchant account")?
|
||||
.unwrap_or_default();
|
||||
|
||||
if let Some(algorithm_id) = routing_ref.algorithm_id {
|
||||
let record = db
|
||||
|
||||
@ -401,10 +401,18 @@ impl Routing {
|
||||
#[allow(unused_mut)]
|
||||
let mut route = web::scope("/routing")
|
||||
.app_data(web::Data::new(state.clone()))
|
||||
.service(
|
||||
web::resource("/active")
|
||||
.route(web::get().to(cloud_routing::routing_retrieve_linked_config)),
|
||||
)
|
||||
.service(web::resource("/active").route(web::get().to(
|
||||
|state, req, #[cfg(feature = "business_profile_routing")] query_params| {
|
||||
cloud_routing::routing_retrieve_linked_config(
|
||||
state,
|
||||
req,
|
||||
#[cfg(feature = "business_profile_routing")]
|
||||
query_params,
|
||||
#[cfg(feature = "business_profile_routing")]
|
||||
&TransactionType::Payment,
|
||||
)
|
||||
},
|
||||
)))
|
||||
.service(
|
||||
web::resource("")
|
||||
.route(
|
||||
@ -524,6 +532,18 @@ impl Routing {
|
||||
)
|
||||
})),
|
||||
)
|
||||
.service(web::resource("/payouts/active").route(web::get().to(
|
||||
|state, req, #[cfg(feature = "business_profile_routing")] query_params| {
|
||||
cloud_routing::routing_retrieve_linked_config(
|
||||
state,
|
||||
req,
|
||||
#[cfg(feature = "business_profile_routing")]
|
||||
query_params,
|
||||
#[cfg(feature = "business_profile_routing")]
|
||||
&TransactionType::Payout,
|
||||
)
|
||||
},
|
||||
)))
|
||||
.service(
|
||||
web::resource("/payouts/default")
|
||||
.route(web::get().to(|state, req| {
|
||||
|
||||
@ -509,6 +509,7 @@ pub async fn routing_retrieve_linked_config(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
#[cfg(feature = "business_profile_routing")] query: web::Query<RoutingRetrieveLinkQuery>,
|
||||
#[cfg(feature = "business_profile_routing")] transaction_type: &enums::TransactionType,
|
||||
) -> impl Responder {
|
||||
#[cfg(feature = "business_profile_routing")]
|
||||
{
|
||||
@ -520,7 +521,12 @@ pub async fn routing_retrieve_linked_config(
|
||||
&req,
|
||||
query.into_inner(),
|
||||
|state, auth: AuthenticationData, query_params| {
|
||||
routing::retrieve_linked_routing_config(state, auth.merchant_account, query_params)
|
||||
routing::retrieve_linked_routing_config(
|
||||
state,
|
||||
auth.merchant_account,
|
||||
query_params,
|
||||
transaction_type,
|
||||
)
|
||||
},
|
||||
#[cfg(not(feature = "release"))]
|
||||
auth::auth_type(
|
||||
|
||||
Reference in New Issue
Block a user