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
refactor(connector): [Nuvei] Fix card 3ds (#8913)
Swangi Kumariba15c0f194e2
diff --git a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rsindex 6d4b27f17e..3e811b7ddd 100644--- a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs@@ -62,6 +62,11 @@ fn to_boolean(string: String) -> bool {}}+// The dimensions of the challenge window for full screen.+const CHALLENGE_WINDOW_SIZE: &str = "05";+// The challenge preference for the challenge flow.+const CHALLENGE_PREFERNCE: &str = "01";+trait NuveiAuthorizePreprocessingCommon {fn get_browser_info(&self) -> Option<BrowserInformation>;fn get_related_transaction_id(&self) -> Option<String>;@@ -527,6 +532,7 @@ pub struct V2AdditionalParams {pub rebill_expiry: Option<String>,/// Recurring Frequency in dayspub rebill_frequency: Option<String>,+ pub challenge_preference: Option<String>,}#[derive(Debug, Clone, Default, Serialize, Deserialize)]@@ -563,7 +569,7 @@ pub struct NuveiACSResponse {pub message_type: String,pub message_version: String,pub trans_status: Option<LiabilityShift>,- pub message_extension: Vec<MessageExtensionAttribute>,+ pub message_extension: Option<Vec<MessageExtensionAttribute>>,pub acs_signed_content: Option<serde_json::Value>,}@@ -1197,11 +1203,22 @@ where),rebill_frequency: Some(mandate_meta.frequency),challenge_window_size: None,+ challenge_preference: None,}),item.request.get_customer_id_required(),)}- _ => (None, None, None),+ // non mandate transactions+ _ => (+ None,+ Some(V2AdditionalParams {+ rebill_expiry: None,+ rebill_frequency: None,+ challenge_window_size: Some(CHALLENGE_WINDOW_SIZE.to_string()),+ challenge_preference: Some(CHALLENGE_PREFERNCE.to_string()),+ }),+ None,+ ),};let three_d = if item.is_three_ds() {let browser_details = match &browser_information {@@ -1277,14 +1294,18 @@ impl TryFrom<(&types::PaymentsCompleteAuthorizeRouterData, Secret<String>)>) -> Result<Self, Self::Error> {let item = data.0;let request_data = match item.request.payment_method_data.clone() {- Some(PaymentMethodData::Card(card)) => Ok(Self {- payment_option: PaymentOption::from(NuveiCardDetails {- card,- three_d: None,- card_holder_name: item.get_optional_billing_full_name(),- }),- ..Default::default()- }),+ Some(PaymentMethodData::Card(card)) => {+ let device_details = DeviceDetails::foreign_try_from(&item.request.browser_info)?;+ Ok(Self {+ payment_option: PaymentOption::from(NuveiCardDetails {+ card,+ three_d: None,+ card_holder_name: item.get_optional_billing_full_name(),+ }),+ device_details,+ ..Default::default()+ })+ }Some(PaymentMethodData::Wallet(..))| Some(PaymentMethodData::PayLater(..))| Some(PaymentMethodData::BankDebit(..))@@ -1319,6 +1340,7 @@ impl TryFrom<(&types::PaymentsCompleteAuthorizeRouterData, Secret<String>)>Ok(Self {related_transaction_id: request_data.related_transaction_id,payment_option: request_data.payment_option,+ device_details: request_data.device_details,..request})}diff --git a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rsindex a26d0c7689..1c6977ac5c 100644--- a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs@@ -75,7 +75,7 @@ pub struct MessageExtensionAttribute {pub id: String,pub name: String,pub criticality_indicator: bool,- pub data: String,+ pub data: serde_json::Value,}#[derive(Clone, Default, Debug)]diff --git a/cypress-tests/cypress/e2e/configs/Payment/Nuvei.js b/cypress-tests/cypress/e2e/configs/Payment/Nuvei.jsindex ed5a964183..fe3d4e870b 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Nuvei.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Nuvei.js@@ -183,7 +183,7 @@ export const connectorDetails = {body: {status: "requires_customer_action",setup_future_usage: "on_session",- payment_method_data: payment_method_data_3ds,+ // we are removing payment_method_data from the response as authentication_data is different every time.},},},