@@ -2274,9 +2274,9 @@ impl behaviour::Conversion for PaymentAttempt {
2274
2274
status,
2275
2275
error_message : error. as_ref ( ) . map ( |details| details. message . clone ( ) ) ,
2276
2276
payment_method_id,
2277
- payment_method_type_v2 : Some ( payment_method_type) ,
2277
+ payment_method_type_v2 : payment_method_type,
2278
2278
connector_payment_id,
2279
- authentication_type : Some ( authentication_type ) ,
2279
+ authentication_type,
2280
2280
created_at,
2281
2281
modified_at,
2282
2282
last_synced,
@@ -2304,7 +2304,7 @@ impl behaviour::Conversion for PaymentAttempt {
2304
2304
unified_message : error
2305
2305
. as_ref ( )
2306
2306
. and_then ( |details| details. unified_message . clone ( ) ) ,
2307
- net_amount : Some ( net_amount ) ,
2307
+ net_amount,
2308
2308
external_three_ds_authentication_attempted,
2309
2309
authentication_connector,
2310
2310
authentication_id,
@@ -2356,10 +2356,11 @@ impl behaviour::Conversion for PaymentAttempt {
2356
2356
where
2357
2357
Self : Sized ,
2358
2358
{
2359
- let connector_payment_id = storage_model
2360
- . get_optional_connector_transaction_id ( )
2361
- . cloned ( ) ;
2362
- let decrypted_data = async {
2359
+ async {
2360
+ let connector_payment_id = storage_model
2361
+ . get_optional_connector_transaction_id ( )
2362
+ . cloned ( ) ;
2363
+
2363
2364
let decrypted_data = crypto_operation (
2364
2365
state,
2365
2366
common_utils:: type_name!( Self :: DstType ) ,
@@ -2375,106 +2376,102 @@ impl behaviour::Conversion for PaymentAttempt {
2375
2376
. await
2376
2377
. and_then ( |val| val. try_into_batchoperation ( ) ) ?;
2377
2378
2378
- EncryptedPaymentAttempt :: from_encryptable ( decrypted_data)
2379
+ let decrypted_data = EncryptedPaymentAttempt :: from_encryptable ( decrypted_data)
2379
2380
. change_context ( common_utils:: errors:: CryptoError :: DecodingFailed )
2380
- . attach_printable ( "Invalid batch operation data" )
2381
+ . attach_printable ( "Invalid batch operation data" ) ?;
2382
+
2383
+ let payment_method_billing_address = decrypted_data
2384
+ . payment_method_billing_address
2385
+ . map ( |billing| {
2386
+ billing. deserialize_inner_value ( |value| value. parse_value ( "Address" ) )
2387
+ } )
2388
+ . transpose ( )
2389
+ . change_context ( common_utils:: errors:: CryptoError :: DecodingFailed )
2390
+ . attach_printable ( "Error while deserializing Address" ) ?;
2391
+
2392
+ let amount_details = AttemptAmountDetails {
2393
+ net_amount : storage_model. net_amount ,
2394
+ tax_on_surcharge : storage_model. tax_on_surcharge ,
2395
+ surcharge_amount : storage_model. surcharge_amount ,
2396
+ order_tax_amount : storage_model. order_tax_amount ,
2397
+ shipping_cost : storage_model. shipping_cost ,
2398
+ amount_capturable : storage_model. amount_capturable ,
2399
+ amount_to_capture : storage_model. amount_to_capture ,
2400
+ } ;
2401
+
2402
+ let error = storage_model
2403
+ . error_code
2404
+ . zip ( storage_model. error_message )
2405
+ . map ( |( error_code, error_message) | ErrorDetails {
2406
+ code : error_code,
2407
+ message : error_message,
2408
+ reason : storage_model. error_reason ,
2409
+ unified_code : storage_model. unified_code ,
2410
+ unified_message : storage_model. unified_message ,
2411
+ network_advice_code : storage_model. network_advice_code ,
2412
+ network_decline_code : storage_model. network_decline_code ,
2413
+ network_error_message : storage_model. network_error_message ,
2414
+ } ) ;
2415
+
2416
+ Ok :: < Self , error_stack:: Report < common_utils:: errors:: CryptoError > > ( Self {
2417
+ payment_id : storage_model. payment_id ,
2418
+ merchant_id : storage_model. merchant_id . clone ( ) ,
2419
+ id : storage_model. id ,
2420
+ status : storage_model. status ,
2421
+ amount_details,
2422
+ error,
2423
+ payment_method_id : storage_model. payment_method_id ,
2424
+ payment_method_type : storage_model. payment_method_type_v2 ,
2425
+ connector_payment_id,
2426
+ authentication_type : storage_model. authentication_type ,
2427
+ created_at : storage_model. created_at ,
2428
+ modified_at : storage_model. modified_at ,
2429
+ last_synced : storage_model. last_synced ,
2430
+ cancellation_reason : storage_model. cancellation_reason ,
2431
+ browser_info : storage_model. browser_info ,
2432
+ payment_token : storage_model. payment_token ,
2433
+ connector_metadata : storage_model. connector_metadata ,
2434
+ payment_experience : storage_model. payment_experience ,
2435
+ payment_method_data : storage_model. payment_method_data ,
2436
+ routing_result : storage_model. routing_result ,
2437
+ preprocessing_step_id : storage_model. preprocessing_step_id ,
2438
+ multiple_capture_count : storage_model. multiple_capture_count ,
2439
+ connector_response_reference_id : storage_model. connector_response_reference_id ,
2440
+ updated_by : storage_model. updated_by ,
2441
+ redirection_data : storage_model. redirection_data . map ( From :: from) ,
2442
+ encoded_data : storage_model. encoded_data ,
2443
+ merchant_connector_id : storage_model. merchant_connector_id ,
2444
+ external_three_ds_authentication_attempted : storage_model
2445
+ . external_three_ds_authentication_attempted ,
2446
+ authentication_connector : storage_model. authentication_connector ,
2447
+ authentication_id : storage_model. authentication_id ,
2448
+ fingerprint_id : storage_model. fingerprint_id ,
2449
+ charges : storage_model. charges ,
2450
+ client_source : storage_model. client_source ,
2451
+ client_version : storage_model. client_version ,
2452
+ customer_acceptance : storage_model. customer_acceptance ,
2453
+ profile_id : storage_model. profile_id ,
2454
+ organization_id : storage_model. organization_id ,
2455
+ payment_method_subtype : storage_model. payment_method_subtype ,
2456
+ authentication_applied : storage_model. authentication_applied ,
2457
+ external_reference_id : storage_model. external_reference_id ,
2458
+ connector : storage_model. connector ,
2459
+ payment_method_billing_address,
2460
+ connector_token_details : storage_model. connector_token_details ,
2461
+ card_discovery : storage_model. card_discovery ,
2462
+ feature_metadata : storage_model. feature_metadata . map ( From :: from) ,
2463
+ processor_merchant_id : storage_model
2464
+ . processor_merchant_id
2465
+ . unwrap_or ( storage_model. merchant_id ) ,
2466
+ created_by : storage_model
2467
+ . created_by
2468
+ . and_then ( |created_by| created_by. parse :: < CreatedBy > ( ) . ok ( ) ) ,
2469
+ connector_request_reference_id : storage_model. connector_request_reference_id ,
2470
+ } )
2381
2471
}
2382
2472
. await
2383
2473
. change_context ( ValidationError :: InvalidValue {
2384
2474
message : "Failed while decrypting payment attempt" . to_string ( ) ,
2385
- } ) ?;
2386
-
2387
- let payment_method_billing_address = decrypted_data
2388
- . payment_method_billing_address
2389
- . map ( |billing| billing. deserialize_inner_value ( |value| value. parse_value ( "Address" ) ) )
2390
- . transpose ( )
2391
- . change_context ( ValidationError :: InvalidValue {
2392
- message : "Failed to deserialize payment_method_billing_address" . to_string ( ) ,
2393
- } )
2394
- . attach_printable ( "Error while deserializing Address" ) ?;
2395
-
2396
- let amount_details = AttemptAmountDetails {
2397
- net_amount : storage_model. net_amount . get_required_value ( "net_amount" ) ?,
2398
- tax_on_surcharge : storage_model. tax_on_surcharge ,
2399
- surcharge_amount : storage_model. surcharge_amount ,
2400
- order_tax_amount : storage_model. order_tax_amount ,
2401
- shipping_cost : storage_model. shipping_cost ,
2402
- amount_capturable : storage_model. amount_capturable ,
2403
- amount_to_capture : storage_model. amount_to_capture ,
2404
- } ;
2405
-
2406
- let error = storage_model
2407
- . error_code
2408
- . zip ( storage_model. error_message )
2409
- . map ( |( error_code, error_message) | ErrorDetails {
2410
- code : error_code,
2411
- message : error_message,
2412
- reason : storage_model. error_reason ,
2413
- unified_code : storage_model. unified_code ,
2414
- unified_message : storage_model. unified_message ,
2415
- network_advice_code : storage_model. network_advice_code ,
2416
- network_decline_code : storage_model. network_decline_code ,
2417
- network_error_message : storage_model. network_error_message ,
2418
- } ) ;
2419
-
2420
- Ok ( Self {
2421
- payment_id : storage_model. payment_id ,
2422
- merchant_id : storage_model. merchant_id . clone ( ) ,
2423
- id : storage_model. id ,
2424
- status : storage_model. status ,
2425
- amount_details,
2426
- error,
2427
- payment_method_id : storage_model. payment_method_id ,
2428
- payment_method_type : storage_model
2429
- . payment_method_type_v2
2430
- . get_required_value ( "payment_method_type" ) ?,
2431
- connector_payment_id,
2432
- authentication_type : storage_model
2433
- . authentication_type
2434
- . get_required_value ( "authentication_type" ) ?,
2435
- created_at : storage_model. created_at ,
2436
- modified_at : storage_model. modified_at ,
2437
- last_synced : storage_model. last_synced ,
2438
- cancellation_reason : storage_model. cancellation_reason ,
2439
- browser_info : storage_model. browser_info ,
2440
- payment_token : storage_model. payment_token ,
2441
- connector_metadata : storage_model. connector_metadata ,
2442
- payment_experience : storage_model. payment_experience ,
2443
- payment_method_data : storage_model. payment_method_data ,
2444
- routing_result : storage_model. routing_result ,
2445
- preprocessing_step_id : storage_model. preprocessing_step_id ,
2446
- multiple_capture_count : storage_model. multiple_capture_count ,
2447
- connector_response_reference_id : storage_model. connector_response_reference_id ,
2448
- updated_by : storage_model. updated_by ,
2449
- redirection_data : storage_model. redirection_data . map ( From :: from) ,
2450
- encoded_data : storage_model. encoded_data ,
2451
- merchant_connector_id : storage_model. merchant_connector_id ,
2452
- external_three_ds_authentication_attempted : storage_model
2453
- . external_three_ds_authentication_attempted ,
2454
- authentication_connector : storage_model. authentication_connector ,
2455
- authentication_id : storage_model. authentication_id ,
2456
- fingerprint_id : storage_model. fingerprint_id ,
2457
- charges : storage_model. charges ,
2458
- client_source : storage_model. client_source ,
2459
- client_version : storage_model. client_version ,
2460
- customer_acceptance : storage_model. customer_acceptance ,
2461
- profile_id : storage_model. profile_id ,
2462
- organization_id : storage_model. organization_id ,
2463
- payment_method_subtype : storage_model. payment_method_subtype ,
2464
- authentication_applied : storage_model. authentication_applied ,
2465
- external_reference_id : storage_model. external_reference_id ,
2466
- connector : storage_model. connector ,
2467
- payment_method_billing_address,
2468
- connector_token_details : storage_model. connector_token_details ,
2469
- card_discovery : storage_model. card_discovery ,
2470
- feature_metadata : storage_model. feature_metadata . map ( From :: from) ,
2471
- processor_merchant_id : storage_model
2472
- . processor_merchant_id
2473
- . unwrap_or ( storage_model. merchant_id ) ,
2474
- created_by : storage_model
2475
- . created_by
2476
- . and_then ( |created_by| created_by. parse :: < CreatedBy > ( ) . ok ( ) ) ,
2477
- connector_request_reference_id : storage_model. connector_request_reference_id ,
2478
2475
} )
2479
2476
}
2480
2477
0 commit comments