@@ -939,7 +939,7 @@ pub async fn authentication_eligibility_core(
939
939
let notification_url = match authentication_connector {
940
940
common_enums:: AuthenticationConnectors :: Juspaythreedsserver => {
941
941
Some ( url:: Url :: parse ( & format ! (
942
- "{base_url}/{merchant_id}/{authentication_id}/sync" ,
942
+ "{base_url}/authentication/ {merchant_id}/{authentication_id}/sync" ,
943
943
base_url = state. base_url,
944
944
merchant_id = merchant_id. get_string_repr( ) ,
945
945
authentication_id = authentication_id. get_string_repr( )
@@ -1416,29 +1416,6 @@ pub async fn authentication_sync_core(
1416
1416
id : profile_id. get_string_repr ( ) . to_owned ( ) ,
1417
1417
} ) ?;
1418
1418
1419
- let ( authentication_value, eci) = match auth_flow {
1420
- AuthFlow :: Client => ( None , None ) ,
1421
- AuthFlow :: Merchant => {
1422
- if let Some ( common_enums:: TransactionStatus :: Success ) = authentication. trans_status {
1423
- let tokenised_data = crate :: core:: payment_methods:: vault:: get_tokenized_data (
1424
- & state,
1425
- authentication_id. get_string_repr ( ) ,
1426
- false ,
1427
- merchant_context. get_merchant_key_store ( ) . key . get_inner ( ) ,
1428
- )
1429
- . await
1430
- . inspect_err ( |err| router_env:: logger:: error!( tokenized_data_result=?err) )
1431
- . attach_printable ( "cavv not present after authentication status is success" ) ?;
1432
- (
1433
- Some ( masking:: Secret :: new ( tokenised_data. value1 ) ) ,
1434
- authentication. eci . clone ( ) ,
1435
- )
1436
- } else {
1437
- ( None , None )
1438
- }
1439
- }
1440
- } ;
1441
-
1442
1419
let ( authentication_connector, three_ds_connector_account) =
1443
1420
auth_utils:: get_authentication_connector_data (
1444
1421
& state,
@@ -1448,21 +1425,20 @@ pub async fn authentication_sync_core(
1448
1425
)
1449
1426
. await ?;
1450
1427
1451
- if let Some ( trans_status) = authentication. trans_status . clone ( ) {
1452
- if trans_status. is_pending ( ) {
1453
- let post_auth_response =
1454
- <ExternalAuthentication as UnifiedAuthenticationService >:: post_authentication (
1455
- & state,
1456
- & business_profile,
1457
- None ,
1458
- & three_ds_connector_account,
1459
- & authentication_connector. to_string ( ) ,
1460
- & authentication_id,
1461
- common_enums:: PaymentMethod :: Card ,
1462
- merchant_id,
1463
- Some ( & authentication) ,
1464
- )
1465
- . await ?;
1428
+ let updated_authentication = match authentication. trans_status . clone ( ) {
1429
+ Some ( trans_status) if trans_status. clone ( ) . is_pending ( ) => {
1430
+ let post_auth_response = ExternalAuthentication :: post_authentication (
1431
+ & state,
1432
+ & business_profile,
1433
+ None ,
1434
+ & three_ds_connector_account,
1435
+ & authentication_connector. to_string ( ) ,
1436
+ & authentication_id,
1437
+ common_enums:: PaymentMethod :: Card ,
1438
+ merchant_id,
1439
+ Some ( & authentication) ,
1440
+ )
1441
+ . await ?;
1466
1442
1467
1443
utils:: external_authentication_update_trackers (
1468
1444
& state,
@@ -1475,14 +1451,41 @@ pub async fn authentication_sync_core(
1475
1451
None ,
1476
1452
None ,
1477
1453
)
1478
- . await ?;
1454
+ . await ?
1479
1455
}
1480
- }
1456
+
1457
+ _ => authentication,
1458
+ } ;
1459
+
1460
+ let ( authentication_value, eci) = match auth_flow {
1461
+ AuthFlow :: Client => ( None , None ) ,
1462
+ AuthFlow :: Merchant => {
1463
+ if let Some ( common_enums:: TransactionStatus :: Success ) =
1464
+ updated_authentication. trans_status
1465
+ {
1466
+ let tokenised_data = crate :: core:: payment_methods:: vault:: get_tokenized_data (
1467
+ & state,
1468
+ authentication_id. get_string_repr ( ) ,
1469
+ false ,
1470
+ merchant_context. get_merchant_key_store ( ) . key . get_inner ( ) ,
1471
+ )
1472
+ . await
1473
+ . inspect_err ( |err| router_env:: logger:: error!( tokenized_data_result=?err) )
1474
+ . attach_printable ( "cavv not present after authentication status is success" ) ?;
1475
+ (
1476
+ Some ( masking:: Secret :: new ( tokenised_data. value1 ) ) ,
1477
+ updated_authentication. eci . clone ( ) ,
1478
+ )
1479
+ } else {
1480
+ ( None , None )
1481
+ }
1482
+ }
1483
+ } ;
1481
1484
1482
1485
let acquirer_details = Some ( AcquirerDetails {
1483
- acquirer_bin : authentication . acquirer_bin . clone ( ) ,
1484
- acquirer_merchant_id : authentication . acquirer_merchant_id . clone ( ) ,
1485
- merchant_country_code : authentication . acquirer_country_code . clone ( ) ,
1486
+ acquirer_bin : updated_authentication . acquirer_bin . clone ( ) ,
1487
+ acquirer_merchant_id : updated_authentication . acquirer_merchant_id . clone ( ) ,
1488
+ merchant_country_code : updated_authentication . acquirer_country_code . clone ( ) ,
1486
1489
} ) ;
1487
1490
1488
1491
let encrypted_data = domain:: types:: crypto_operation (
@@ -1491,8 +1494,8 @@ pub async fn authentication_sync_core(
1491
1494
domain:: types:: CryptoOperation :: BatchDecrypt (
1492
1495
hyperswitch_domain_models:: authentication:: EncryptedAuthentication :: to_encryptable (
1493
1496
hyperswitch_domain_models:: authentication:: EncryptedAuthentication {
1494
- billing_address : authentication . billing_address ,
1495
- shipping_address : authentication . shipping_address ,
1497
+ billing_address : updated_authentication . billing_address ,
1498
+ shipping_address : updated_authentication . shipping_address ,
1496
1499
} ,
1497
1500
) ,
1498
1501
) ,
@@ -1513,7 +1516,7 @@ pub async fn authentication_sync_core(
1513
1516
. change_context ( ApiErrorResponse :: InternalServerError )
1514
1517
. attach_printable ( "Unable to get encrypted data for authentication after encryption" ) ?;
1515
1518
1516
- let email_decrypted = authentication
1519
+ let email_decrypted = updated_authentication
1517
1520
. email
1518
1521
. clone ( )
1519
1522
. async_lift ( |inner| async {
@@ -1536,7 +1539,7 @@ pub async fn authentication_sync_core(
1536
1539
. change_context ( ApiErrorResponse :: InternalServerError )
1537
1540
. attach_printable ( "Unable to encrypt email" ) ?;
1538
1541
1539
- let browser_info = authentication
1542
+ let browser_info = updated_authentication
1540
1543
. browser_info
1541
1544
. clone ( )
1542
1545
. map ( |browser_info| {
@@ -1545,16 +1548,16 @@ pub async fn authentication_sync_core(
1545
1548
. transpose ( )
1546
1549
. change_context ( ApiErrorResponse :: InternalServerError ) ?;
1547
1550
1548
- let amount = authentication
1551
+ let amount = updated_authentication
1549
1552
. amount
1550
1553
. ok_or ( ApiErrorResponse :: InternalServerError )
1551
1554
. attach_printable ( "amount failed to get amount from authentication table" ) ?;
1552
- let currency = authentication
1555
+ let currency = updated_authentication
1553
1556
. currency
1554
1557
. ok_or ( ApiErrorResponse :: InternalServerError )
1555
1558
. attach_printable ( "currency failed to get currency from authentication table" ) ?;
1556
1559
1557
- let authentication_connector = authentication
1560
+ let authentication_connector = updated_authentication
1558
1561
. authentication_connector
1559
1562
. map ( |connector| common_enums:: AuthenticationConnectors :: from_str ( & connector) )
1560
1563
. transpose ( )
@@ -1588,51 +1591,50 @@ pub async fn authentication_sync_core(
1588
1591
let response = AuthenticationSyncResponse {
1589
1592
authentication_id : authentication_id. clone ( ) ,
1590
1593
merchant_id : merchant_id. clone ( ) ,
1591
- status : authentication . authentication_status ,
1592
- client_secret : authentication
1594
+ status : updated_authentication . authentication_status ,
1595
+ client_secret : updated_authentication
1593
1596
. authentication_client_secret
1594
1597
. map ( masking:: Secret :: new) ,
1595
1598
amount,
1596
1599
currency,
1597
1600
authentication_connector,
1598
- force_3ds_challenge : authentication . force_3ds_challenge ,
1599
- return_url : authentication . return_url . clone ( ) ,
1600
- created_at : authentication . created_at ,
1601
- profile_id : authentication . profile_id . clone ( ) ,
1602
- psd2_sca_exemption_type : authentication . psd2_sca_exemption_type ,
1601
+ force_3ds_challenge : updated_authentication . force_3ds_challenge ,
1602
+ return_url : updated_authentication . return_url . clone ( ) ,
1603
+ created_at : updated_authentication . created_at ,
1604
+ profile_id : updated_authentication . profile_id . clone ( ) ,
1605
+ psd2_sca_exemption_type : updated_authentication . psd2_sca_exemption_type ,
1603
1606
acquirer_details,
1604
- error_message : authentication . error_message . clone ( ) ,
1605
- error_code : authentication . error_code . clone ( ) ,
1607
+ error_message : updated_authentication . error_message . clone ( ) ,
1608
+ error_code : updated_authentication . error_code . clone ( ) ,
1606
1609
authentication_value,
1607
- threeds_server_transaction_id : authentication . threeds_server_transaction_id . clone ( ) ,
1608
- maximum_supported_3ds_version : authentication . maximum_supported_version . clone ( ) ,
1609
- connector_authentication_id : authentication . connector_authentication_id . clone ( ) ,
1610
- three_ds_method_data : authentication . three_ds_method_data . clone ( ) ,
1611
- three_ds_method_url : authentication . three_ds_method_url . clone ( ) ,
1612
- message_version : authentication . message_version . clone ( ) ,
1613
- connector_metadata : authentication . connector_metadata . clone ( ) ,
1614
- directory_server_id : authentication . directory_server_id . clone ( ) ,
1610
+ threeds_server_transaction_id : updated_authentication . threeds_server_transaction_id . clone ( ) ,
1611
+ maximum_supported_3ds_version : updated_authentication . maximum_supported_version . clone ( ) ,
1612
+ connector_authentication_id : updated_authentication . connector_authentication_id . clone ( ) ,
1613
+ three_ds_method_data : updated_authentication . three_ds_method_data . clone ( ) ,
1614
+ three_ds_method_url : updated_authentication . three_ds_method_url . clone ( ) ,
1615
+ message_version : updated_authentication . message_version . clone ( ) ,
1616
+ connector_metadata : updated_authentication . connector_metadata . clone ( ) ,
1617
+ directory_server_id : updated_authentication . directory_server_id . clone ( ) ,
1615
1618
billing,
1616
1619
shipping,
1617
1620
browser_information : browser_info,
1618
1621
email : email_decrypted,
1619
- transaction_status : authentication . trans_status . clone ( ) ,
1620
- acs_url : authentication . acs_url . clone ( ) ,
1621
- challenge_request : authentication . challenge_request . clone ( ) ,
1622
- acs_reference_number : authentication . acs_reference_number . clone ( ) ,
1623
- acs_trans_id : authentication . acs_trans_id . clone ( ) ,
1624
- acs_signed_content : authentication . acs_signed_content ,
1622
+ transaction_status : updated_authentication . trans_status . clone ( ) ,
1623
+ acs_url : updated_authentication . acs_url . clone ( ) ,
1624
+ challenge_request : updated_authentication . challenge_request . clone ( ) ,
1625
+ acs_reference_number : updated_authentication . acs_reference_number . clone ( ) ,
1626
+ acs_trans_id : updated_authentication . acs_trans_id . clone ( ) ,
1627
+ acs_signed_content : updated_authentication . acs_signed_content ,
1625
1628
three_ds_requestor_url : business_profile
1626
1629
. authentication_connector_details
1627
1630
. clone ( )
1628
1631
. map ( |details| details. three_ds_requestor_url ) ,
1629
1632
three_ds_requestor_app_url : business_profile
1630
1633
. authentication_connector_details
1631
1634
. and_then ( |details| details. three_ds_requestor_app_url ) ,
1632
- profile_acquirer_id : authentication . profile_acquirer_id . clone ( ) ,
1635
+ profile_acquirer_id : updated_authentication . profile_acquirer_id . clone ( ) ,
1633
1636
eci,
1634
1637
} ;
1635
-
1636
1638
Ok ( hyperswitch_domain_models:: api:: ApplicationResponse :: Json (
1637
1639
response,
1638
1640
) )
0 commit comments