@@ -1864,49 +1864,45 @@ pub async fn call_surcharge_decision_management(
1864
1864
billing_address : Option < domain:: Address > ,
1865
1865
response_payment_method_types : & mut [ ResponsePaymentMethodsEnabled ] ,
1866
1866
) -> errors:: RouterResult < api_surcharge_decision_configs:: MerchantSurchargeConfigs > {
1867
- if payment_attempt. surcharge_amount . is_some ( ) {
1868
- Ok ( api_surcharge_decision_configs:: MerchantSurchargeConfigs :: default ( ) )
1869
- } else {
1870
- let algorithm_ref: routing_types:: RoutingAlgorithmRef = merchant_account
1871
- . routing_algorithm
1872
- . clone ( )
1873
- . map ( |val| val. parse_value ( "routing algorithm" ) )
1874
- . transpose ( )
1875
- . change_context ( errors:: ApiErrorResponse :: InternalServerError )
1876
- . attach_printable ( "Could not decode the routing algorithm" ) ?
1877
- . unwrap_or_default ( ) ;
1878
- let ( surcharge_results, merchant_sucharge_configs) =
1879
- perform_surcharge_decision_management_for_payment_method_list (
1880
- & state,
1881
- algorithm_ref,
1882
- payment_attempt,
1883
- & payment_intent,
1884
- billing_address. as_ref ( ) . map ( Into :: into) ,
1885
- response_payment_method_types,
1867
+ let algorithm_ref: routing_types:: RoutingAlgorithmRef = merchant_account
1868
+ . routing_algorithm
1869
+ . clone ( )
1870
+ . map ( |val| val. parse_value ( "routing algorithm" ) )
1871
+ . transpose ( )
1872
+ . change_context ( errors:: ApiErrorResponse :: InternalServerError )
1873
+ . attach_printable ( "Could not decode the routing algorithm" ) ?
1874
+ . unwrap_or_default ( ) ;
1875
+ let ( surcharge_results, merchant_sucharge_configs) =
1876
+ perform_surcharge_decision_management_for_payment_method_list (
1877
+ & state,
1878
+ algorithm_ref,
1879
+ payment_attempt,
1880
+ & payment_intent,
1881
+ billing_address. as_ref ( ) . map ( Into :: into) ,
1882
+ response_payment_method_types,
1883
+ )
1884
+ . await
1885
+ . change_context ( errors:: ApiErrorResponse :: InternalServerError )
1886
+ . attach_printable ( "error performing surcharge decision operation" ) ?;
1887
+ if !surcharge_results. is_empty_result ( ) {
1888
+ surcharge_results
1889
+ . persist_individual_surcharge_details_in_redis ( & state, business_profile)
1890
+ . await ?;
1891
+ let _ = state
1892
+ . store
1893
+ . update_payment_intent (
1894
+ payment_intent,
1895
+ storage:: PaymentIntentUpdate :: SurchargeApplicableUpdate {
1896
+ surcharge_applicable : true ,
1897
+ updated_by : merchant_account. storage_scheme . to_string ( ) ,
1898
+ } ,
1899
+ merchant_account. storage_scheme ,
1886
1900
)
1887
1901
. await
1888
- . change_context ( errors:: ApiErrorResponse :: InternalServerError )
1889
- . attach_printable ( "error performing surcharge decision operation" ) ?;
1890
- if !surcharge_results. is_empty_result ( ) {
1891
- surcharge_results
1892
- . persist_individual_surcharge_details_in_redis ( & state, business_profile)
1893
- . await ?;
1894
- let _ = state
1895
- . store
1896
- . update_payment_intent (
1897
- payment_intent,
1898
- storage:: PaymentIntentUpdate :: SurchargeApplicableUpdate {
1899
- surcharge_applicable : true ,
1900
- updated_by : merchant_account. storage_scheme . to_string ( ) ,
1901
- } ,
1902
- merchant_account. storage_scheme ,
1903
- )
1904
- . await
1905
- . to_not_found_response ( errors:: ApiErrorResponse :: PaymentNotFound )
1906
- . attach_printable ( "Failed to update surcharge_applicable in Payment Intent" ) ;
1907
- }
1908
- Ok ( merchant_sucharge_configs)
1902
+ . to_not_found_response ( errors:: ApiErrorResponse :: PaymentNotFound )
1903
+ . attach_printable ( "Failed to update surcharge_applicable in Payment Intent" ) ;
1909
1904
}
1905
+ Ok ( merchant_sucharge_configs)
1910
1906
}
1911
1907
1912
1908
pub async fn call_surcharge_decision_management_for_saved_card (
@@ -1917,47 +1913,43 @@ pub async fn call_surcharge_decision_management_for_saved_card(
1917
1913
payment_intent : storage:: PaymentIntent ,
1918
1914
customer_payment_method_response : & mut api:: CustomerPaymentMethodsListResponse ,
1919
1915
) -> errors:: RouterResult < ( ) > {
1920
- if payment_attempt. surcharge_amount . is_some ( ) {
1921
- Ok ( ( ) )
1922
- } else {
1923
- let algorithm_ref: routing_types:: RoutingAlgorithmRef = merchant_account
1924
- . routing_algorithm
1925
- . clone ( )
1926
- . map ( |val| val. parse_value ( "routing algorithm" ) )
1927
- . transpose ( )
1928
- . change_context ( errors:: ApiErrorResponse :: InternalServerError )
1929
- . attach_printable ( "Could not decode the routing algorithm" ) ?
1930
- . unwrap_or_default ( ) ;
1931
- let surcharge_results = perform_surcharge_decision_management_for_saved_cards (
1932
- state,
1933
- algorithm_ref,
1934
- payment_attempt,
1935
- & payment_intent,
1936
- & mut customer_payment_method_response. customer_payment_methods ,
1937
- )
1938
- . await
1916
+ let algorithm_ref: routing_types:: RoutingAlgorithmRef = merchant_account
1917
+ . routing_algorithm
1918
+ . clone ( )
1919
+ . map ( |val| val. parse_value ( "routing algorithm" ) )
1920
+ . transpose ( )
1939
1921
. change_context ( errors:: ApiErrorResponse :: InternalServerError )
1940
- . attach_printable ( "error performing surcharge decision operation" ) ?;
1941
- if !surcharge_results. is_empty_result ( ) {
1942
- surcharge_results
1943
- . persist_individual_surcharge_details_in_redis ( state, business_profile)
1944
- . await ?;
1945
- let _ = state
1946
- . store
1947
- . update_payment_intent (
1948
- payment_intent,
1949
- storage:: PaymentIntentUpdate :: SurchargeApplicableUpdate {
1950
- surcharge_applicable : true ,
1951
- updated_by : merchant_account. storage_scheme . to_string ( ) ,
1952
- } ,
1953
- merchant_account. storage_scheme ,
1954
- )
1955
- . await
1956
- . to_not_found_response ( errors:: ApiErrorResponse :: PaymentNotFound )
1957
- . attach_printable ( "Failed to update surcharge_applicable in Payment Intent" ) ;
1958
- }
1959
- Ok ( ( ) )
1922
+ . attach_printable ( "Could not decode the routing algorithm" ) ?
1923
+ . unwrap_or_default ( ) ;
1924
+ let surcharge_results = perform_surcharge_decision_management_for_saved_cards (
1925
+ state,
1926
+ algorithm_ref,
1927
+ payment_attempt,
1928
+ & payment_intent,
1929
+ & mut customer_payment_method_response. customer_payment_methods ,
1930
+ )
1931
+ . await
1932
+ . change_context ( errors:: ApiErrorResponse :: InternalServerError )
1933
+ . attach_printable ( "error performing surcharge decision operation" ) ?;
1934
+ if !surcharge_results. is_empty_result ( ) {
1935
+ surcharge_results
1936
+ . persist_individual_surcharge_details_in_redis ( state, business_profile)
1937
+ . await ?;
1938
+ let _ = state
1939
+ . store
1940
+ . update_payment_intent (
1941
+ payment_intent,
1942
+ storage:: PaymentIntentUpdate :: SurchargeApplicableUpdate {
1943
+ surcharge_applicable : true ,
1944
+ updated_by : merchant_account. storage_scheme . to_string ( ) ,
1945
+ } ,
1946
+ merchant_account. storage_scheme ,
1947
+ )
1948
+ . await
1949
+ . to_not_found_response ( errors:: ApiErrorResponse :: PaymentNotFound )
1950
+ . attach_printable ( "Failed to update surcharge_applicable in Payment Intent" ) ;
1960
1951
}
1952
+ Ok ( ( ) )
1961
1953
}
1962
1954
1963
1955
#[ allow( clippy:: too_many_arguments) ]
0 commit comments