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): add flag to wait for post message in `threeDSMethodData` for `three_ds_invoke` next action in Payments Confirm (#9454)
Sai Harsha Vardhan0b263179af1b
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex c0d580edc8..55640e8191 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -32016,7 +32016,7 @@"type": "object","required": ["three_ds_method_data_submission",- "three_ds_method_key"+ "consume_post_message_for_three_ds_method_completion"],"properties": {"three_ds_method_data_submission": {@@ -32034,17 +32034,27 @@"nullable": true},"three_ds_method_key": {- "type": "string",- "enum": [- "threeDSMethodData"- ]+ "allOf": [+ {+ "$ref": "#/components/schemas/ThreeDsMethodKey"+ }+ ],+ "nullable": true+ },+ "consume_post_message_for_three_ds_method_completion": {+ "type": "boolean",+ "description": "Indicates whethere to wait for Post message after 3DS method data submission"}}}- ],- "discriminator": {- "propertyName": "three_ds_method_key"- }+ ]+ },+ "ThreeDsMethodKey": {+ "type": "string",+ "enum": [+ "threeDSMethodData",+ "JWT"+ ]},"TimeRange": {"type": "object",diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 07b6c0a6db..6bdb7e6fed 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -25648,7 +25648,7 @@"type": "object","required": ["three_ds_method_data_submission",- "three_ds_method_key"+ "consume_post_message_for_three_ds_method_completion"],"properties": {"three_ds_method_data_submission": {@@ -25666,17 +25666,27 @@"nullable": true},"three_ds_method_key": {- "type": "string",- "enum": [- "threeDSMethodData"- ]+ "allOf": [+ {+ "$ref": "#/components/schemas/ThreeDsMethodKey"+ }+ ],+ "nullable": true+ },+ "consume_post_message_for_three_ds_method_completion": {+ "type": "boolean",+ "description": "Indicates whethere to wait for Post message after 3DS method data submission"}}}- ],- "discriminator": {- "propertyName": "three_ds_method_key"- }+ ]+ },+ "ThreeDsMethodKey": {+ "type": "string",+ "enum": [+ "threeDSMethodData",+ "JWT"+ ]},"TimeRange": {"type": "object",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 2158b8be12..8c8052b14d 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -5002,9 +5002,8 @@ pub struct ThreeDsData {}#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]-#[serde(tag = "three_ds_method_key")]+#[serde(untagged)]pub enum ThreeDsMethodData {- #[serde(rename = "threeDSMethodData")]AcsThreeDsMethodData {/// Whether ThreeDS method data submission is requiredthree_ds_method_data_submission: bool,@@ -5012,9 +5011,21 @@ pub enum ThreeDsMethodData {three_ds_method_data: Option<String>,/// ThreeDS method urlthree_ds_method_url: Option<String>,+ /// Three DS Method Key+ three_ds_method_key: Option<ThreeDsMethodKey>,+ /// Indicates whethere to wait for Post message after 3DS method data submission+ consume_post_message_for_three_ds_method_completion: bool,},}+#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]+pub enum ThreeDsMethodKey {+ #[serde(rename = "threeDSMethodData")]+ ThreeDsMethodData,+ #[serde(rename = "JWT")]+ JWT,+}+#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]pub struct PollConfigResponse {/// Poll Iddiff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 296f60f8d4..581858a85d 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -8083,6 +8083,19 @@ impl AuthenticationConnectors {Self::Gpayments => true,}}++ pub fn is_jwt_flow(&self) -> bool {+ match self {+ Self::Threedsecureio+ | Self::Netcetera+ | Self::CtpMastercard+ | Self::UnifiedAuthenticationService+ | Self::Juspaythreedsserver+ | Self::CtpVisa+ | Self::Gpayments => false,+ Self::Cardinal => true,+ }+ }}#[derive(diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rsindex 0a621e6d61..4075612178 100644--- a/crates/diesel_models/src/authentication.rs+++ b/crates/diesel_models/src/authentication.rs@@ -1,5 +1,12 @@-use common_utils::{encryption::Encryption, pii};+use std::str::FromStr;++use common_utils::{+ encryption::Encryption,+ errors::{CustomResult, ValidationError},+ pii,+};use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};+use error_stack::ResultExt;use serde::{self, Deserialize, Serialize};use serde_json;@@ -74,6 +81,22 @@ impl Authentication {.as_ref().is_some_and(|version| version.get_major() == 2)}++ // get authentication_connector from authentication record and check if it is jwt flow+ pub fn is_jwt_flow(&self) -> CustomResult<bool, ValidationError> {+ Ok(self+ .authentication_connector+ .clone()+ .map(|connector| {+ common_enums::AuthenticationConnectors::from_str(&connector)+ .change_context(ValidationError::InvalidValue {+ message: "failed to parse authentication_connector".to_string(),+ })+ .map(|connector_enum| connector_enum.is_jwt_flow())+ })+ .transpose()?+ .unwrap_or(false))+ }}#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Insertable)]diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex a95f4fa9a0..8b2a3300a3 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -597,6 +597,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::PaymentCreatePaymentLinkConfig,api_models::payments::ThreeDsData,api_models::payments::ThreeDsMethodData,+ api_models::payments::ThreeDsMethodKey,api_models::payments::PollConfigResponse,api_models::payments::PollConfig,api_models::payments::ExternalAuthenticationDetailsResponse,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex 3942d01abf..eb172cf0cf 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -566,6 +566,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::PaymentCreatePaymentLinkConfig,api_models::payments::ThreeDsData,api_models::payments::ThreeDsMethodData,+ api_models::payments::ThreeDsMethodKey,api_models::payments::PollConfigResponse,api_models::payments::PollConfig,api_models::payments::ExternalAuthenticationDetailsResponse,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex c479b01999..51a315bee8 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -3173,6 +3173,9 @@ wherelet payment_connector_name = payment_attempt.connector.as_ref().get_required_value("connector")?;+ let is_jwt_flow = authentication.is_jwt_flow()+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Failed to determine if the authentication is JWT flow")?;Some(api_models::payments::NextActionData::ThreeDsInvoke {three_ds_data: api_models::payments::ThreeDsData {three_ds_authentication_url: helpers::create_authentication_url(base_url, &payment_attempt),@@ -3186,11 +3189,20 @@ wherethree_ds_method_data_submission: true,three_ds_method_data: Some(three_ds_method_data.clone()),three_ds_method_url: Some(three_ds_method_url.to_owned()),+ three_ds_method_key: if is_jwt_flow {+ Some(api_models::payments::ThreeDsMethodKey::JWT)+ } else {+ Some(api_models::payments::ThreeDsMethodKey::ThreeDsMethodData)+ },+ // In JWT flow, we need to wait for post message to get the result+ consume_post_message_for_three_ds_method_completion: is_jwt_flow,}}).unwrap_or(api_models::payments::ThreeDsMethodData::AcsThreeDsMethodData {three_ds_method_data_submission: false,three_ds_method_data: None,three_ds_method_url: None,+ three_ds_method_key: None,+ consume_post_message_for_three_ds_method_completion: false,}),poll_config: api_models::payments::PollConfigResponse {poll_id: request_poll_id, delay_in_secs: poll_config.delay_in_secs, frequency: poll_config.frequency},message_version: authentication.message_version.as_ref()