Skip to content

Commit 18a779f

Browse files
refactor(authentication): flattened paymentData in authentication trait functions (#8365)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent ad52251 commit 18a779f

File tree

7 files changed

+142
-107
lines changed

7 files changed

+142
-107
lines changed

crates/api_models/src/authentication.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ impl ApiEventMetric for AuthenticationCreateRequest {
135135
})
136136
}
137137
}
138-
139138
impl ApiEventMetric for AuthenticationResponse {
140139
fn get_api_event_type(&self) -> Option<ApiEventsType> {
141140
Some(ApiEventsType::Authentication {

crates/router/src/core/payments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8508,7 +8508,7 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
85088508
.await?
85098509
{
85108510
let auth_response =
8511-
<ExternalAuthentication as UnifiedAuthenticationService<F>>::authentication(
8511+
<ExternalAuthentication as UnifiedAuthenticationService>::authentication(
85128512
&state,
85138513
&business_profile,
85148514
payment_method_details.1,
@@ -8534,7 +8534,7 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
85348534
authentication_details.three_ds_requestor_url.clone(),
85358535
&merchant_connector_account,
85368536
&authentication_connector,
8537-
payment_intent.payment_id,
8537+
Some(payment_intent.payment_id),
85388538
)
85398539
.await?;
85408540
let authentication = external_authentication_update_trackers(

crates/router/src/core/payments/operations/payment_confirm.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,26 +1270,30 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
12701270
)?;
12711271
ClickToPay::pre_authentication(
12721272
state,
1273-
key_store,
1274-
business_profile,
1275-
payment_data,
1273+
&payment_data.payment_attempt.merchant_id,
1274+
Some(&payment_data.payment_intent.payment_id),
1275+
payment_data.payment_method_data.as_ref(),
12761276
&helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
12771277
&connector_mca.connector_name,
12781278
&authentication_id,
12791279
payment_method,
1280+
payment_data.payment_intent.amount,
1281+
payment_data.payment_intent.currency,
1282+
payment_data.service_details.clone(),
12801283
)
12811284
.await?;
12821285

12831286
payment_data.payment_attempt.authentication_id = Some(authentication_id.clone());
12841287
let response = ClickToPay::post_authentication(
12851288
state,
1286-
key_store,
12871289
business_profile,
1288-
payment_data,
1290+
Some(&payment_data.payment_intent.payment_id),
12891291
&helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
12901292
&connector_mca.connector_name,
1293+
&authentication_id,
12911294
payment_method,
1292-
None,
1295+
&payment_data.payment_intent.merchant_id,
1296+
None
12931297
)
12941298
.await?;
12951299
let (network_token, authentication_status) = match response.response.clone() {
@@ -1399,10 +1403,16 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
13991403
state,
14001404
key_store,
14011405
business_profile,
1402-
payment_data,
1406+
payment_data.payment_attempt.authentication_id.as_ref(),
1407+
payment_data.payment_intent.currency,
1408+
payment_data.payment_attempt.status,
1409+
payment_data.service_details.clone(),
14031410
&helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
14041411
&connector_mca.connector_name,
14051412
payment_method,
1413+
payment_data.payment_attempt.net_amount.get_order_amount(),
1414+
Some(&payment_data.payment_intent.payment_id),
1415+
merchant_id,
14061416
)
14071417
.await?
14081418
},
@@ -1433,15 +1443,18 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
14331443

14341444
let pre_auth_response = uas_utils::types::ExternalAuthentication::pre_authentication(
14351445
state,
1436-
key_store,
1437-
business_profile,
1438-
payment_data,
1446+
&payment_data.payment_attempt.merchant_id,
1447+
Some(&payment_data.payment_intent.payment_id),
1448+
payment_data.payment_method_data.as_ref(),
14391449
&three_ds_connector_account,
14401450
&authentication_connector_name,
14411451
&authentication.authentication_id,
14421452
payment_data.payment_attempt.payment_method.ok_or(
14431453
errors::ApiErrorResponse::InternalServerError
14441454
).attach_printable("payment_method not found in payment_attempt")?,
1455+
payment_data.payment_intent.amount,
1456+
payment_data.payment_intent.currency,
1457+
payment_data.service_details.clone()
14451458
).await?;
14461459
let updated_authentication = uas_utils::utils::external_authentication_update_trackers(
14471460
state,
@@ -1511,15 +1524,16 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
15111524
let updated_authentication = if !authentication.authentication_status.is_terminal_status() && is_pull_mechanism_enabled {
15121525
let post_auth_response = uas_utils::types::ExternalAuthentication::post_authentication(
15131526
state,
1514-
key_store,
15151527
business_profile,
1516-
payment_data,
1528+
Some(&payment_data.payment_intent.payment_id),
15171529
&three_ds_connector_account,
15181530
&authentication_connector.to_string(),
1531+
&authentication.authentication_id,
15191532
payment_data.payment_attempt.payment_method.ok_or(
15201533
errors::ApiErrorResponse::InternalServerError
15211534
).attach_printable("payment_method not found in payment_attempt")?,
1522-
Some(authentication.clone()),
1535+
&payment_data.payment_intent.merchant_id,
1536+
Some(&authentication),
15231537
).await?;
15241538
uas_utils::utils::external_authentication_update_trackers(
15251539
state,

0 commit comments

Comments
 (0)