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(connector): [Nuvei] Add Support for External 3DS Auth (#9468)
awasthi21ba74587e1d7e
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rsindex 9991ba8a27..6f429829f5 100644--- a/crates/common_enums/src/connector_enums.rs+++ b/crates/common_enums/src/connector_enums.rs@@ -497,7 +497,6 @@ impl Connector {| Self::Nomupay| Self::Nordea| Self::Novalnet- | Self::Nuvei| Self::Opennode| Self::Paybox| Self::Payload@@ -554,7 +553,7 @@ impl Connector {| Self::Datatrans| Self::Paytm| Self::Phonepe => false,- Self::Checkout | Self::Nmi |Self::Cybersource | Self::Archipel => true,+ Self::Checkout | Self::Nmi |Self::Cybersource | Self::Archipel | Self::Nuvei => true,}}diff --git a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rsindex 687cc60b81..1329bd0a05 100644--- a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs@@ -28,8 +28,8 @@ use hyperswitch_domain_models::{Authorize, Capture, CompleteAuthorize, PSync, PostCaptureVoid, SetupMandate, Void,},router_request_types::{- authentication::MessageExtensionAttribute, BrowserInformation, PaymentsAuthorizeData,- PaymentsPreProcessingData, ResponseId, SetupMandateRequestData,+ authentication::MessageExtensionAttribute, AuthenticationData, BrowserInformation,+ PaymentsAuthorizeData, PaymentsPreProcessingData, ResponseId, SetupMandateRequestData,},router_response_types::{MandateReference, PaymentsResponseData, RedirectForm, RefundsResponseData,@@ -98,6 +98,11 @@ trait NuveiAuthorizePreprocessingCommon {) -> Result<PaymentMethodData, error_stack::Report<errors::ConnectorError>>;fn get_is_partial_approval(&self) -> Option<PartialApprovalFlag>;fn is_customer_initiated_mandate_payment(&self) -> bool;+ fn get_auth_data(+ &self,+ ) -> Result<Option<AuthenticationData>, error_stack::Report<errors::ConnectorError>> {+ Ok(None)+ }}impl NuveiAuthorizePreprocessingCommon for SetupMandateRequestData {@@ -197,7 +202,11 @@ impl NuveiAuthorizePreprocessingCommon for PaymentsAuthorizeData {_ => None,}}-+ fn get_auth_data(+ &self,+ ) -> Result<Option<AuthenticationData>, error_stack::Report<errors::ConnectorError>> {+ Ok(self.authentication_data.clone())+ }fn get_customer_id_required(&self) -> Option<CustomerId> {self.customer_id.clone()}@@ -792,6 +801,18 @@ pub enum ExternalTokenProvider {ApplePay,}+#[serde_with::skip_serializing_none]+#[derive(Debug, Clone, Default, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ExternalMpi {+ pub eci: Option<String>,+ pub cavv: Secret<String>,+ #[serde(rename = "dsTransID")]+ pub ds_trans_id: Option<String>,+ pub challenge_preference: Option<String>,+ pub exemption_request_reason: Option<String>,+}+#[serde_with::skip_serializing_none]#[derive(Debug, Clone, Default, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]@@ -807,6 +828,7 @@ pub struct ThreeD {pub acs_challenge_mandate: Option<String>,pub c_req: Option<Secret<String>>,pub three_d_flow: Option<String>,+ pub external_mpi: Option<ExternalMpi>,pub external_transaction_id: Option<String>,pub transaction_id: Option<String>,pub three_d_reason_id: Option<String>,@@ -1930,7 +1952,18 @@ whereNone,),};- let three_d = if item.is_three_ds() {+ let three_d = if let Some(auth_data) = item.request.get_auth_data()? {+ Some(ThreeD {+ external_mpi: Some(ExternalMpi {+ eci: auth_data.eci,+ cavv: auth_data.cavv,+ ds_trans_id: auth_data.ds_trans_id,+ challenge_preference: None,+ exemption_request_reason: None,+ }),+ ..Default::default()+ })+ } else if item.is_three_ds() {let browser_details = match &browser_information {Some(browser_info) => Some(BrowserDetails {accept_header: browser_info.get_accept_header()?,diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 56db1b8d08..e7001f1551 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -6621,8 +6621,22 @@ where} else if router_data.auth_type == common_enums::AuthenticationType::ThreeDs&& ((connector.connector_name == router_types::Connector::Nexixpay&& is_operation_complete_authorize(&operation))- || ((connector.connector_name == router_types::Connector::Nuvei- || connector.connector_name == router_types::Connector::Shift4)+ || (((connector.connector_name == router_types::Connector::Nuvei && {+ #[cfg(feature = "v1")]+ {+ payment_data+ .get_payment_intent()+ .request_external_three_ds_authentication+ != Some(true)+ }+ #[cfg(feature = "v2")]+ {+ payment_data+ .get_payment_intent()+ .request_external_three_ds_authentication+ != Some(true).into()+ }+ }) || connector.connector_name == router_types::Connector::Shift4)&& !is_operation_complete_authorize(&operation))){router_data = router_data.preprocessing_steps(state, connector).await?;