Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(router): handle authorization for frictionless flow in external 3ds flow (#4471)
Sai Harsha Vardhan79d8949413c8
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 2e3157ae6e..e35457974f 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -1160,6 +1160,20 @@ impl<Ctx: PaymentMethodRetrieve> PaymentRedirectFlow<Ctx> for PaymentAuthenticat).await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;+ let authentication_id = payment_attempt+ .authentication_id+ .ok_or(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("missing authentication_id in payment_attempt")?;+ let authentication = state+ .store+ .find_authentication_by_merchant_id_authentication_id(+ merchant_id.clone(),+ authentication_id.clone(),+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::AuthenticationNotFound {+ id: authentication_id,+ })?;// Fetching merchant_connector_account to check if pull_mechanism is enabled for 3ds connectorlet authentication_merchant_connector_account = helpers::get_merchant_connector_account(state,@@ -1183,7 +1197,10 @@ impl<Ctx: PaymentMethodRetrieve> PaymentRedirectFlow<Ctx> for PaymentAuthenticat.get_metadata().map(|metadata| metadata.expose()),);- let response = if is_pull_mechanism_enabled {+ let response = if is_pull_mechanism_enabled+ || authentication.authentication_type+ == Some(common_enums::DecoupledAuthenticationType::Frictionless)+ {let payment_confirm_req = api::PaymentsRequest {payment_id: Some(req.resource_id.clone()),merchant_id: req.merchant_id.clone(),diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rsindex 6e2068422f..eb6faea5c3 100644--- a/crates/router/src/core/webhooks.rs+++ b/crates/router/src/core/webhooks.rs@@ -490,8 +490,10 @@ pub async fn external_authentication_incoming_webhook_flow<Ctx: PaymentMethodRet// Check if it's a payment authentication flow, payment_id would be there only for payment authentication flowsif let Some(payment_id) = updated_authentication.payment_id {let is_pull_mechanism_enabled = helper_utils::check_if_pull_mechanism_for_external_3ds_enabled_from_connector_metadata(merchant_connector_account.metadata.map(|metadata| metadata.expose()));- // Merchant doesn't have pull mechanism enabled, so we have to authorize whenever we receive a ARes webhook+ // Merchant doesn't have pull mechanism enabled and if it's challenge flow, we have to authorize whenever we receive a ARes webhookif !is_pull_mechanism_enabled+ && updated_authentication.authentication_type+ == Some(common_enums::DecoupledAuthenticationType::Challenge)&& event_type == webhooks::IncomingWebhookEvent::ExternalAuthenticationARes{let payment_confirm_req = api::PaymentsRequest {