@@ -31,9 +31,8 @@ use scheduler::{db::process_tracker::ProcessTrackerExt, errors as sch_errors, ut
31
31
use time;
32
32
33
33
pub use self :: operations:: {
34
- PaymentApprove , PaymentCancel , PaymentCapture , PaymentConfirm , PaymentCreate ,
35
- PaymentMethodValidate , PaymentReject , PaymentResponse , PaymentSession , PaymentStatus ,
36
- PaymentUpdate ,
34
+ PaymentApprove , PaymentCancel , PaymentCapture , PaymentConfirm , PaymentCreate , PaymentReject ,
35
+ PaymentResponse , PaymentSession , PaymentStatus , PaymentUpdate ,
37
36
} ;
38
37
use self :: {
39
38
flows:: { ConstructFlowSpecificData , Feature } ,
@@ -112,7 +111,12 @@ where
112
111
113
112
tracing:: Span :: current ( ) . record ( "payment_id" , & format ! ( "{}" , validate_result. payment_id) ) ;
114
113
115
- let ( operation, mut payment_data, customer_details) = operation
114
+ let operations:: GetTrackerResponse {
115
+ operation,
116
+ customer_details,
117
+ mut payment_data,
118
+ business_profile,
119
+ } = operation
116
120
. to_get_tracker ( ) ?
117
121
. get_trackers (
118
122
state,
@@ -142,6 +146,7 @@ where
142
146
state,
143
147
& req,
144
148
& merchant_account,
149
+ & business_profile,
145
150
& key_store,
146
151
& mut payment_data,
147
152
eligible_connectors,
@@ -1998,11 +2003,13 @@ where
1998
2003
Ok ( ( ) )
1999
2004
}
2000
2005
2006
+ #[ allow( clippy:: too_many_arguments) ]
2001
2007
pub async fn get_connector_choice < F , Req , Ctx > (
2002
2008
operation : & BoxedOperation < ' _ , F , Req , Ctx > ,
2003
2009
state : & AppState ,
2004
2010
req : & Req ,
2005
2011
merchant_account : & domain:: MerchantAccount ,
2012
+ business_profile : & storage:: business_profile:: BusinessProfile ,
2006
2013
key_store : & domain:: MerchantKeyStore ,
2007
2014
payment_data : & mut PaymentData < F > ,
2008
2015
eligible_connectors : Option < Vec < api_models:: enums:: RoutableConnectors > > ,
@@ -2040,6 +2047,7 @@ where
2040
2047
connector_selection (
2041
2048
state,
2042
2049
merchant_account,
2050
+ business_profile,
2043
2051
key_store,
2044
2052
payment_data,
2045
2053
Some ( straight_through) ,
@@ -2052,6 +2060,7 @@ where
2052
2060
connector_selection (
2053
2061
state,
2054
2062
merchant_account,
2063
+ business_profile,
2055
2064
key_store,
2056
2065
payment_data,
2057
2066
None ,
@@ -2075,6 +2084,7 @@ where
2075
2084
pub async fn connector_selection < F > (
2076
2085
state : & AppState ,
2077
2086
merchant_account : & domain:: MerchantAccount ,
2087
+ business_profile : & storage:: business_profile:: BusinessProfile ,
2078
2088
key_store : & domain:: MerchantKeyStore ,
2079
2089
payment_data : & mut PaymentData < F > ,
2080
2090
request_straight_through : Option < serde_json:: Value > ,
@@ -2114,6 +2124,7 @@ where
2114
2124
let decided_connector = decide_connector (
2115
2125
state. clone ( ) ,
2116
2126
merchant_account,
2127
+ business_profile,
2117
2128
key_store,
2118
2129
payment_data,
2119
2130
request_straight_through,
@@ -2141,9 +2152,11 @@ where
2141
2152
Ok ( decided_connector)
2142
2153
}
2143
2154
2155
+ #[ allow( clippy:: too_many_arguments) ]
2144
2156
pub async fn decide_connector < F > (
2145
2157
state : AppState ,
2146
2158
merchant_account : & domain:: MerchantAccount ,
2159
+ business_profile : & storage:: business_profile:: BusinessProfile ,
2147
2160
key_store : & domain:: MerchantKeyStore ,
2148
2161
payment_data : & mut PaymentData < F > ,
2149
2162
request_straight_through : Option < api:: routing:: StraightThroughAlgorithm > ,
@@ -2345,6 +2358,7 @@ where
2345
2358
route_connector_v1 (
2346
2359
& state,
2347
2360
merchant_account,
2361
+ business_profile,
2348
2362
key_store,
2349
2363
payment_data,
2350
2364
routing_data,
@@ -2480,6 +2494,7 @@ where
2480
2494
pub async fn route_connector_v1 < F > (
2481
2495
state : & AppState ,
2482
2496
merchant_account : & domain:: MerchantAccount ,
2497
+ business_profile : & storage:: business_profile:: BusinessProfile ,
2483
2498
key_store : & domain:: MerchantKeyStore ,
2484
2499
payment_data : & mut PaymentData < F > ,
2485
2500
routing_data : & mut storage:: RoutingData ,
@@ -2488,44 +2503,19 @@ pub async fn route_connector_v1<F>(
2488
2503
where
2489
2504
F : Send + Clone ,
2490
2505
{
2491
- #[ cfg( not( feature = "business_profile_routing" ) ) ]
2492
- let algorithm_ref: api:: routing:: RoutingAlgorithmRef = merchant_account
2493
- . routing_algorithm
2494
- . clone ( )
2495
- . map ( |ra| ra. parse_value ( "RoutingAlgorithmRef" ) )
2506
+ let routing_algorithm = if cfg ! ( feature = "business_profile_routing" ) {
2507
+ business_profile. routing_algorithm . clone ( )
2508
+ } else {
2509
+ merchant_account. routing_algorithm . clone ( )
2510
+ } ;
2511
+
2512
+ let algorithm_ref = routing_algorithm
2513
+ . map ( |ra| ra. parse_value :: < api:: routing:: RoutingAlgorithmRef > ( "RoutingAlgorithmRef" ) )
2496
2514
. transpose ( )
2497
2515
. change_context ( errors:: ApiErrorResponse :: InternalServerError )
2498
2516
. attach_printable ( "Could not decode merchant routing algorithm ref" ) ?
2499
2517
. unwrap_or_default ( ) ;
2500
2518
2501
- #[ cfg( feature = "business_profile_routing" ) ]
2502
- let algorithm_ref: api:: routing:: RoutingAlgorithmRef = {
2503
- let profile_id = payment_data
2504
- . payment_intent
2505
- . profile_id
2506
- . as_ref ( )
2507
- . get_required_value ( "profile_id" )
2508
- . change_context ( errors:: ApiErrorResponse :: InternalServerError )
2509
- . attach_printable ( "'profile_id' not set in payment intent" ) ?;
2510
-
2511
- let business_profile = state
2512
- . store
2513
- . find_business_profile_by_profile_id ( profile_id)
2514
- . await
2515
- . to_not_found_response ( errors:: ApiErrorResponse :: BusinessProfileNotFound {
2516
- id : profile_id. to_string ( ) ,
2517
- } ) ?;
2518
-
2519
- business_profile
2520
- . routing_algorithm
2521
- . clone ( )
2522
- . map ( |ra| ra. parse_value ( "RoutingAlgorithmRef" ) )
2523
- . transpose ( )
2524
- . change_context ( errors:: ApiErrorResponse :: InternalServerError )
2525
- . attach_printable ( "Could not decode merchant routing algorithm ref" ) ?
2526
- . unwrap_or_default ( )
2527
- } ;
2528
-
2529
2519
let connectors = routing:: perform_static_routing_v1 (
2530
2520
state,
2531
2521
& merchant_account. merchant_id ,
0 commit comments