@@ -34,10 +34,10 @@ use common_utils::{consts::DEFAULT_LOCALE, id_type};
34
34
#[ cfg( all( feature = "v2" , feature = "payment_methods_v2" ) ) ]
35
35
use common_utils:: {
36
36
crypto:: Encryptable ,
37
+ errors,
37
38
ext_traits:: { AsyncExt , Encode , ValueExt } ,
38
39
fp_utils:: when,
39
40
generate_id, types as util_types,
40
- errors,
41
41
} ;
42
42
use diesel_models:: {
43
43
enums, GenericLinkNew , PaymentMethodCollectLink , PaymentMethodCollectLinkData ,
@@ -1890,11 +1890,12 @@ pub async fn retrieve_payment_method(
1890
1890
)
1891
1891
. await
1892
1892
. to_not_found_response ( errors:: ApiErrorResponse :: PaymentMethodNotFound ) ?;
1893
-
1893
+
1894
1894
let payment_method_in_cache = get_single_use_token_from_store (
1895
1895
& state. clone ( ) ,
1896
- payment_method_data:: SingleUseTokenKey :: store_key ( pm_id. clone ( ) . get_string_repr ( ) )
1897
- ) . await
1896
+ payment_method_data:: SingleUseTokenKey :: store_key ( pm_id. clone ( ) . get_string_repr ( ) ) ,
1897
+ )
1898
+ . await
1898
1899
. to_not_found_response ( errors:: ApiErrorResponse :: GenericNotFoundError {
1899
1900
message : "payment methods session does not exist or has expired" . to_string ( ) ,
1900
1901
} )
@@ -2690,11 +2691,12 @@ async fn create_single_use_tokenization_flow(
2690
2691
payment_method_session : & domain:: payment_methods:: PaymentMethodSession ,
2691
2692
) -> RouterResult < ( ) > {
2692
2693
let customer_id = payment_method_create_request. customer_id . to_owned ( ) ;
2693
- let connector_id = payment_method_create_request. get_tokenize_connector_id ( )
2694
- . change_context ( errors:: ApiErrorResponse :: MissingRequiredField {
2695
- field_name : "psp_tokenization.connector_id" ,
2696
- } )
2697
- . attach_printable ( "Failed to get tokenize connector id" ) ?;
2694
+ let connector_id = payment_method_create_request
2695
+ . get_tokenize_connector_id ( )
2696
+ . change_context ( errors:: ApiErrorResponse :: MissingRequiredField {
2697
+ field_name : "psp_tokenization.connector_id" ,
2698
+ } )
2699
+ . attach_printable ( "Failed to get tokenize connector id" ) ?;
2698
2700
2699
2701
let db = & state. store ;
2700
2702
@@ -2717,7 +2719,9 @@ async fn create_single_use_tokenization_flow(
2717
2719
. change_context ( errors:: ApiErrorResponse :: MissingRequiredField {
2718
2720
field_name : "card_cvc" ,
2719
2721
} )
2720
- . attach_printable ( "Failed to convert type from Payment Method Create Data to Payment Method Data" ) ?,
2722
+ . attach_printable (
2723
+ "Failed to convert type from Payment Method Create Data to Payment Method Data" ,
2724
+ ) ?,
2721
2725
browser_info : None ,
2722
2726
currency : api_models:: enums:: Currency :: default ( ) ,
2723
2727
amount : None ,
@@ -2807,17 +2811,17 @@ async fn create_single_use_tokenization_flow(
2807
2811
reason : err. reason ,
2808
2812
} ) ?;
2809
2813
2810
- let token = token_response
2811
- . ok_or ( errors:: ApiErrorResponse :: GenericNotFoundError {
2812
- message : "No token recevied from the PSP" . to_string ( ) ,
2813
- } ) ?;
2814
+ let token = token_response. ok_or ( errors:: ApiErrorResponse :: GenericNotFoundError {
2815
+ message : "No token recevied from the PSP" . to_string ( ) ,
2816
+ } ) ?;
2814
2817
2815
2818
let value = payment_method_data:: PaymentMethodTokenSingleUse :: get_single_use_token_from_payment_method_token (
2816
2819
token. clone ( ) ,
2817
2820
connector_id. clone ( )
2818
2821
) ;
2819
2822
2820
- let key = payment_method_data:: SingleUseTokenKey :: store_key ( payment_method. id . get_string_repr ( ) ) ;
2823
+ let key =
2824
+ payment_method_data:: SingleUseTokenKey :: store_key ( payment_method. id . get_string_repr ( ) ) ;
2821
2825
2822
2826
add_single_use_token_to_store ( & state, key, value) . await ?;
2823
2827
@@ -2852,10 +2856,7 @@ async fn add_single_use_token_to_store(
2852
2856
async fn get_single_use_token_from_store (
2853
2857
state : & SessionState ,
2854
2858
key : payment_method_data:: SingleUseTokenKey ,
2855
- ) -> CustomResult <
2856
- payment_method_data:: PaymentMethodTokenSingleUse ,
2857
- errors:: StorageError ,
2858
- > {
2859
+ ) -> CustomResult < payment_method_data:: PaymentMethodTokenSingleUse , errors:: StorageError > {
2859
2860
let redis_connection = state
2860
2861
. store
2861
2862
. get_redis_conn ( )
@@ -2865,9 +2866,9 @@ async fn get_single_use_token_from_store(
2865
2866
redis_connection
2866
2867
. get_and_deserialize_key :: < payment_method_data:: PaymentMethodTokenSingleUse > (
2867
2868
& payment_method_data:: SingleUseTokenKey :: get_store_key ( & key) . into ( ) ,
2868
- "PaymentMethodTokenSingleUse"
2869
+ "PaymentMethodTokenSingleUse" ,
2869
2870
)
2870
2871
. await
2871
2872
. change_context ( errors:: StorageError :: KVError )
2872
2873
. attach_printable ( "Failed to get payment method token from redis" )
2873
- }
2874
+ }
0 commit comments