Skip to content

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

feat(authentication): Added eligibility flow for modular authentication (#8431)

Sahkal Poddar82eb3ca7b4b0
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 96b8f60def..de49d53ada 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -7576,7 +7576,8 @@
"type": "object",
"required": [
"amount",
- "currency"
+ "currency",
+ "profile_acquirer_id"
],
"properties": {
"authentication_id": {
@@ -7590,25 +7591,25 @@
"description": "The business profile that is associated with this authentication",
"nullable": true
},
- "authentication_connector": {
+ "customer": {
"allOf": [
{
- "$ref": "#/components/schemas/AuthenticationConnectors"
+ "$ref": "#/components/schemas/CustomerDetails"
}
],
"nullable": true
},
- "customer": {
+ "amount": {
+ "$ref": "#/components/schemas/MinorUnit"
+ },
+ "authentication_connector": {
"allOf": [
{
- "$ref": "#/components/schemas/CustomerDetails"
+ "$ref": "#/components/schemas/AuthenticationConnectors"
}
],
"nullable": true
},
- "amount": {
- "$ref": "#/components/schemas/MinorUnit"
- },
"currency": {
"$ref": "#/components/schemas/Currency"
},
@@ -7638,6 +7639,149 @@
}
],
"nullable": true
+ },
+ "profile_acquirer_id": {
+ "type": "string",
+ "description": "Profile Acquirer ID get from profile acquirer configuration"
+ }
+ }
+ },
+ "AuthenticationEligibilityRequest": {
+ "type": "object",
+ "required": [
+ "payment_method_data",
+ "payment_method"
+ ],
+ "properties": {
+ "payment_method_data": {
+ "$ref": "#/components/schemas/PaymentMethodData"
+ },
+ "payment_method": {
+ "$ref": "#/components/schemas/PaymentMethod"
+ },
+ "client_secret": {
+ "type": "string",
+ "description": "Optional secret value used to identify and authorize the client making the request.\nThis can help ensure that the payment session is secure and valid.",
+ "nullable": true
+ },
+ "profile_id": {
+ "type": "string",
+ "description": "Optional identifier for the business profile associated with the payment.\nThis determines which configurations, rules, and branding are applied to the transaction.",
+ "nullable": true
+ },
+ "billing": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Address"
+ }
+ ],
+ "nullable": true
+ },
+ "shipping": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Address"
+ }
+ ],
+ "nullable": true
+ },
+ "browser_information": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/BrowserInformation"
+ }
+ ],
+ "nullable": true
+ },
+ "email": {
+ "type": "string",
+ "description": "Optional email address of the customer.\nUsed for customer identification, communication, and possibly for 3DS or fraud checks.",
+ "nullable": true
+ }
+ }
+ },
+ "AuthenticationEligibilityResponse": {
+ "type": "object",
+ "required": [
+ "authentication_id",
+ "next_action",
+ "status",
+ "connector_metadata",
+ "profile_id"
+ ],
+ "properties": {
+ "authentication_id": {
+ "type": "string",
+ "description": "The unique identifier for this authentication.",
+ "example": "auth_mbabizu24mvu3mela5njyhpit4"
+ },
+ "next_action": {
+ "$ref": "#/components/schemas/NextAction"
+ },
+ "status": {
+ "$ref": "#/components/schemas/AuthenticationStatus"
+ },
+ "eligibility_response_params": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/EligibilityResponseParams"
+ }
+ ],
+ "nullable": true
+ },
+ "connector_metadata": {
+ "description": "The metadata for this authentication."
+ },
+ "profile_id": {
+ "type": "string",
+ "description": "The unique identifier for this authentication."
+ },
+ "error_message": {
+ "type": "string",
+ "description": "The error message for this authentication.",
+ "nullable": true
+ },
+ "error_code": {
+ "type": "string",
+ "description": "The error code for this authentication.",
+ "nullable": true
+ },
+ "authentication_connector": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/AuthenticationConnectors"
+ }
+ ],
+ "nullable": true
+ },
+ "billing": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Address"
+ }
+ ],
+ "nullable": true
+ },
+ "shipping": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Address"
+ }
+ ],
+ "nullable": true
+ },
+ "browser_information": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/BrowserInformation"
+ }
+ ],
+ "nullable": true
+ },
+ "email": {
+ "type": "string",
+ "description": "Email",
+ "nullable": true
}
}
},
@@ -7648,7 +7792,8 @@
"merchant_id",
"status",
"amount",
- "currency"
+ "currency",
+ "profile_acquirer_id"
],
"properties": {
"authentication_id": {
@@ -7676,11 +7821,6 @@
"currency": {
"$ref": "#/components/schemas/Currency"
},
- "force_3ds_challenge": {
- "type": "boolean",
- "description": "Whether 3DS challenge was forced.",
- "nullable": true
- },
"authentication_connector": {
"allOf": [
{
@@ -7689,6 +7829,11 @@
],
"nullable": true
},
+ "force_3ds_challenge": {
+ "type": "boolean",
+ "description": "Whether 3DS challenge was forced.",
+ "nullable": true
+ },
"return_url": {
"type": "string",
"description": "The URL to which the user should be redirected after authentication, if provided.",
@@ -7731,6 +7876,10 @@
}
],
"nullable": true
+ },
+ "profile_acquirer_id": {
+ "type": "string",
+ "description": "Profile Acquirer ID get from profile acquirer configuration"
}
}
},
@@ -13515,6 +13664,21 @@
}
]
},
+ "EligibilityResponseParams": {
+ "oneOf": [
+ {
+ "type": "object",
+ "required": [
+ "ThreeDsData"
+ ],
+ "properties": {
+ "ThreeDsData": {
+ "$ref": "#/components/schemas/ThreeDsData"
+ }
+ }
+ }
+ ]
+ },
"EliminationAnalyserConfig": {
"type": "object",
"properties": {
@@ -17637,6 +17801,16 @@
}
}
},
+ "Method": {
+ "type": "string",
+ "enum": [
+ "GET",
+ "POST",
+ "PUT",
+ "DELETE",
+ "PATCH"
+ ]
+ },
"MifinityData": {
"type": "object",
"required": [
@@ -17827,6 +18001,22 @@
}
}
},
+ "NextAction": {
+ "type": "object",
+ "required": [
+ "url",
+ "http_method"
+ ],
+ "properties": {
+ "url": {
+ "type": "string",
+ "description": "The URL for authenticatating the user."
+ },
+ "http_method": {
+ "$ref": "#/components/schemas/Method"
+ }
+ }
+ },
"NextActionCall": {
"type": "string",
"enum": [
@@ -29638,35 +29828,43 @@
"ThreeDsData": {
"type": "object",
"required": [
- "three_ds_authentication_url",
- "three_ds_authorize_url",
- "three_ds_method_details",
- "poll_config"
+ "threeds_server_transaction_id",
+ "maximum_supported_3ds_version",
+ "connector_authentication_id",
+ "three_ds_method_data",
+ "three_ds_method_url",
+ "message_version",
+ "directory_server_id"
],
"properties": {
- "three_ds_authentication_url": {
+ "threeds_server_transaction_id": {
"type": "string",
- "description": "ThreeDS authentication url - to initiate authentication"
+ "description": "The unique identifier for this authentication from the 3DS server."
},
- "three_ds_authorize_url": {
+ "maximum_supported_3ds_version": {
"type": "string",
- "description": "ThreeDS authorize url - to complete the payment authorization after authentication"
+ "description": "The maximum supported 3DS version."
},
- "three_ds_method_details": {
- "$ref": "#/components/schemas/ThreeDsMethodData"
+ "connector_authentication_id": {
+ "type": "string",
+ "description": "The unique identifier for this authentication from the connector."
},
- "poll_config": {
- "$ref": "#/components/schemas/PollConfigResponse"
+ "three_ds_method_data": {
+ "type": "string",
+ "description": "The data required to perform the 3DS method."
+ },
+ "three_ds_method_url": {
+ "type": "string",
+ "description": "The URL to which the user should be redirected after authentication.",
+ "example": "https://example.com/redirect"
},
"message_version": {
"type": "string",
- "description": "Message Version",
- "nullable": true
+ "description": "The version of the message."
},
"directory_server_id": {
"type": "string",
- "description": "Directory Server ID",
- "nullable": true
+ "description": "The unique identifier for this authentication."
}
}
},
diff --git a/config/development.toml b/config/development.toml
index 9f8a1a8f2a..ccc9d7af32 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -343,7 +343,7 @@ worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymen
xendit.base_url = "https://api.xendit.co"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
tsys.base_url = "https://stagegw.transnox.com/"
-unified_authentication_service.base_url = "http://localhost:8080/"
+unified_authentication_service.base_url = "http://localhost:8000/"
vgs.base_url = "https://sandbox.vault-api.verygoodvault.com"
volt.base_url = "https://api.sandbox.volt.io/"
wellsfargo.base_url = "https://apitest.cybersource.com/"
diff --git a/crates/api_models/src/authentication.rs b/crates/api_models/src/authentication.rs
index af7b59925b..d8891170d0 100644
--- a/crates/api_models/src/authentication.rs
+++ b/crates/api_models/src/authentication.rs
@@ -1,13 +1,19 @@
use common_enums::{enums, AuthenticationConnectors};
+#[cfg(feature = "v1")]
+use common_utils::errors::{self, CustomResult};
use common_utils::{
events::{ApiEventMetric, ApiEventsType},
id_type,
};
+#[cfg(feature = "v1")]
+use error_stack::ResultExt;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use utoipa::ToSchema;
use crate::payments::CustomerDetails;
+#[cfg(feature = "v1")]
+use crate::payments::{Address, BrowserInformation, PaymentMethodData};
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct AuthenticationCreateRequest {
@@ -19,10 +25,6 @@ pub struct AuthenticationCreateRequest {
#[schema(value_type = Option<String>)]
pub profile_id: Option<id_type::ProfileId>,
- /// The connector to be used for authentication, if known.
- #[schema(value_type = Option<AuthenticationConnectors>, example = "netcetera")]
- pub authentication_connector: Option<AuthenticationConnectors>,
-
/// Customer details.
#[schema(value_type = Option<CustomerDetails>)]
pub customer: Option<CustomerDetails>,
@@ -31,6 +33,10 @@ pub struct AuthenticationCreateRequest {
#[schema(value_type = MinorUnit, example = 1000)]
pub amount: common_utils::types::MinorUnit,
+ /// The connector to be used for authentication, if known.
+ #[schema(value_type = Option<AuthenticationConnectors>, example = "netcetera")]
+ pub authentication_connector: Option<AuthenticationConnectors>,
+
/// The currency for the transaction, required.
#[schema(value_type = Currency)]
pub currency: common_enums::Currency,
@@ -50,6 +56,10 @@ pub struct AuthenticationCreateRequest {
/// Choose what kind of sca exemption is required for this payment
#[schema(value_type = Option<ScaExemptionType>)]
pub psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
+
+ /// Profile Acquirer ID get from profile acquirer configuration
+ #[schema(value_type = String)]
+ pub profile_acquirer_id: id_type::ProfileAcquirerId,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
@@ -92,13 +102,13 @@ pub struct AuthenticationResponse {
#[schema(value_type = Currency)]
pub currency: enums::Currency,
+ /// The connector to be used for authentication, if known.
+ #[schema(value_type = Option<AuthenticationConnectors>, example = "netcetera")]
+ pub authentication_connector: Option<AuthenticationConnectors>,
+
/// Whether 3DS challenge was forced.
pub force_3ds_challenge: Option<bool>,
- /// The connector to be used for authentication, if specified in request.
- #[schema(value_type = Option<AuthenticationConnectors>)]
- pub authentication_connector: Option<String>,
-
/// The URL to which the user should be redirected after authentication, if provided.
pub return_url: Option<String>,
@@ -124,6 +134,10 @@ pub struct AuthenticationResponse {
/// Acquirer details information
#[schema(value_type = Option<AcquirerDetails>)]
pub acquirer_details: Option<AcquirerDetails>,
+
+ /// Profile Acquirer ID get from profile acquirer configuration
+ #[schema(value_type = String)]
+ pub profile_acquirer_id: id_type::ProfileAcquirerId,
}
impl ApiEventMetric for AuthenticationCreateRequest {
@@ -135,6 +149,7 @@ impl ApiEventMetric for AuthenticationCreateRequest {
})
}
}
+
impl ApiEventMetric for AuthenticationResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Authentication {
@@ -142,3 +157,174 @@ impl ApiEventMetric for AuthenticationResponse {
})
}
}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct AuthenticationEligibilityRequest {
+ /// Payment method-specific data such as card details, wallet info, etc.
+ /// This holds the raw information required to process the payment method.
+ #[schema(value_type = PaymentMethodData)]
+ pub payment_method_data: PaymentMethodData,
+
+ /// Enum representing the type of payment method being used
+ /// (e.g., Card, Wallet, UPI, BankTransfer, etc.).
+ #[schema(value_type = PaymentMethod)]
+ pub payment_method: common_enums::PaymentMethod,
+
+ /// Optional secret value used to identify and authorize the client making the request.
+ /// This can help ensure that the payment session is secure and valid.
+ #[schema(value_type = Option<String>)]
+ pub client_secret: Option<masking::Secret<String>>,
+
+ /// Optional identifier for the business profile associated with the payment.
+ /// This determines which configurations, rules, and branding are applied to the transaction.
+ #[schema(value_type = Option<String>)]
+ pub profile_id: Option<id_type::ProfileId>,
+
+ /// Optional billing address of the customer.
+ /// This can be used for fraud detection, authentication, or compliance purposes.
+ #[schema(value_type = Option<Address>)]
+ pub billing: Option<Address>,
+
+ /// Optional shipping address of the customer.
+ /// This can be useful for logistics, verification, or additional risk checks.
+ #[schema(value_type = Option<Address>)]
+ pub shipping: Option<Address>,
+
+ /// Optional information about the customer's browser (user-agent, language, etc.).
+ /// This is typically used to support 3DS authentication flows and improve risk assessment.
+ #[schema(value_type = Option<BrowserInformation>)]
+ pub browser_information: Option<BrowserInformation>,
+
+ /// Optional email address of the customer.
+ /// Used for customer identification, communication, and possibly for 3DS or fraud checks.
+ #[schema(value_type = Option<String>)]
+ pub email: Option<common_utils::pii::Email>,
+}
+
+#[cfg(feature = "v1")]
+impl AuthenticationEligibilityRequest {
+ pub fn get_next_action_api(
+ &self,
+ base_url: String,
+ authentication_id: String,
+ ) -> CustomResult<NextAction, errors::ParsingError> {
+ let url = format!("{base_url}/authentication/{authentication_id}/authenticate");
+ Ok(NextAction {
+ url: url::Url::parse(&url).change_context(errors::ParsingError::UrlParsingError)?,
+ http_method: common_utils::request::Method::Post,
+ })
+ }
+
+ pub fn get_billing_address(&self) -> Option<Address> {
+ self.billing.clone()
+ }
+
+ pub fn get_shipping_address(&self) -> Option<Address> {
+ self.shipping.clone()
+ }
+
+ pub fn get_browser_information(&self) -> Option<BrowserInformation> {
+ self.browser_information.clone()
+ }
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, ToSchema)]
+pub struct AuthenticationEligibilityResponse {
+ /// The unique identifier for this authentication.
+ #[schema(value_type = String, example = "auth_mbabizu24mvu3mela5njyhpit4")]
+ pub authentication_id: id_type::AuthenticationId,
+ /// The URL to which the user should be redirected after authentication.
+ #[schema(value_type = NextAction)]
+ pub next_action: NextAction,
+ /// The current status of the authentication (e.g., Started).
+ #[schema(value_type = AuthenticationStatus)]
+ pub status: common_enums::AuthenticationStatus,
+ /// The 3DS data for this authentication.
+ #[schema(value_type = Option<EligibilityResponseParams>)]
+ pub eligibility_response_params: Option<EligibilityResponseParams>,
+ /// The metadata for this authentication.
+ #[schema(value_type = serde_json::Value)]
+ pub connector_metadata: Option<serde_json::Value>,
+ /// The unique identifier for this authentication.
+ #[schema(value_type = String)]
+ pub profile_id: id_type::ProfileId,
+ /// The error message for this authentication.
+ #[schema(value_type = Option<String>)]
+ pub error_message: Option<String>,
+ /// The error code for this authentication.
+ #[schema(value_type = Option<String>)]
+ pub error_code: Option<String>,
+ /// The connector used for this authentication.
+ #[schema(value_type = Option<AuthenticationConnectors>)]
+ pub authentication_connector: Option<AuthenticationConnectors>,
+ /// Billing address
+ #[schema(value_type = Option<Address>)]
+ pub billing: Option<Address>,
+ /// Shipping address
+ #[schema(value_type = Option<Address>)]
+ pub shipping: Option<Address>,
+ /// Browser information
+ #[schema(value_type = Option<BrowserInformation>)]
+ pub browser_information: Option<BrowserInformation>,
+ /// Email
+ #[schema(value_type = Option<String>)]
+ pub email: common_utils::crypto::OptionalEncryptableEmail,
+}
+
+#[derive(Debug, Serialize, ToSchema)]
+pub enum EligibilityResponseParams {
+ ThreeDsData(ThreeDsData),
+}
+
+#[derive(Debug, Serialize, ToSchema)]
+pub struct ThreeDsData {
+ /// The unique identifier for this authentication from the 3DS server.
+ #[schema(value_type = String)]
+ pub threeds_server_transaction_id: Option<String>,
+ /// The maximum supported 3DS version.
+ #[schema(value_type = String)]
+ pub maximum_supported_3ds_version: Option<common_utils::types::SemanticVersion>,
+ /// The unique identifier for this authentication from the connector.
+ #[schema(value_type = String)]
+ pub connector_authentication_id: Option<String>,
+ /// The data required to perform the 3DS method.
+ #[schema(value_type = String)]
+ pub three_ds_method_data: Option<String>,
+ /// The URL to which the user should be redirected after authentication.
+ #[schema(value_type = String, example = "https://example.com/redirect")]
+ pub three_ds_method_url: Option<url::Url>,
+ /// The version of the message.
+ #[schema(value_type = String)]
+ pub message_version: Option<common_utils::types::SemanticVersion>,
+ /// The unique identifier for this authentication.
+ #[schema(value_type = String)]
+ pub directory_server_id: Option<String>,
+}
+
+#[derive(Debug, Serialize, ToSchema)]
+pub struct NextAction {
+ /// The URL for authenticatating the user.
+ #[schema(value_type = String)]
+ pub url: url::Url,
+ /// The HTTP method to use for the request.
+ #[schema(value_type = Method)]
+ pub http_method: common_utils::request::Method,
+}
+
+#[cfg(feature = "v1")]
+impl ApiEventMetric for AuthenticationEligibilityRequest {
+ fn get_api_event_type(&self) -> Option<ApiEventsType> {
+ None
+ }
+}
+
+#[cfg(feature = "v1")]
+impl ApiEventMetric for AuthenticationEligibilityResponse {
+ fn get_api_event_type(&self) -> Option<ApiEventsType> {
+ Some(ApiEventsType::Authentication {
+ authentication_id: self.authentication_id.clone(),
+ })
+ }
+}
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index cef094a98d..d1e0403752 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -1423,7 +1423,7 @@ pub struct RequestSurchargeDetails {
// for v2 use the type from common_utils::types
#[cfg(feature = "v1")]
/// Browser information to be used for 3DS 2.0
-#[derive(ToSchema, Debug, serde::Deserialize, serde::Serialize)]
+#[derive(ToSchema, Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct BrowserInformation {
/// Color depth supported by the browser
pub color_depth: Option<u8>,
diff --git a/crates/common_utils/src/errors.rs b/crates/common_utils/src/errors.rs
index c2cddf41bc..8dd7ac43a8 100644
--- a/crates/common_utils/src/errors.rs
+++ b/crates/common_utils/src/errors.rs
@@ -52,6 +52,9 @@ pub enum ParsingError {
/// Failed to convert the given integer because of integer overflow error
#[error("Integer Overflow error")]
IntegerOverflow,
+ /// Failed to parse url
+ #[error("Failed to parse url")]
+ UrlParsingError,
}
/// Validation errors.
diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rs
index d8329e3765..915d661bad 100644
--- a/crates/diesel_models/src/authentication.rs
+++ b/crates/diesel_models/src/authentication.rs
@@ -1,3 +1,4 @@
+use common_utils::encryption::Encryption;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};
use serde::{self, Deserialize, Serialize};
use serde_json;
@@ -55,6 +56,11 @@ pub struct Authentication {
pub return_url: Option<String>,
pub amount: Option<common_utils::types::MinorUnit>,
pub currency: Option<common_enums::Currency>,
+ pub billing_address: Option<Encryption>,
+ pub shipping_address: Option<Encryption>,
+ pub browser_info: Option<serde_json::Value>,
+ pub email: Option<Encryption>,
+ pub profile_acquirer_id: Option<common_utils::id_type::ProfileAcquirerId>,
}
impl Authentication {
@@ -110,6 +116,11 @@ pub struct AuthenticationNew {
pub return_url: Option<String>,
pub amount: Option<common_utils::types::MinorUnit>,
pub currency: Option<common_enums::Currency>,
+ pub billing_address: Option<Encryption>,
+ pub shipping_address: Option<Encryption>,
+ pub browser_info: Option<serde_json::Value>,
+ pub email: Option<Encryption>,
+ pub profile_acquirer_id: Option<common_utils::id_type::ProfileAcquirerId>,
}
#[derive(Debug)]
@@ -139,6 +150,10 @@ pub enum AuthenticationUpdate {
acquirer_merchant_id: Option<String>,
directory_server_id: Option<String>,
acquirer_country_code: Option<String>,
+ billing_address: Option<Encryption>,
+ shipping_address: Option<Encryption>,
+ browser_info: Box<Option<serde_json::Value>>,
+ email: Option<Encryption>,
},
AuthenticationUpdate {
trans_status: common_enums::TransactionStatus,
@@ -207,6 +222,11 @@ pub struct AuthenticationUpdateInternal {
pub service_details: Option<serde_json::Value>,
pub force_3ds_challenge: Option<bool>,
pub psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
+ pub billing_address: Option<Encryption>,
+ pub shipping_address: Option<Encryption>,
+ pub browser_info: Option<serde_json::Value>,
+ pub email: Option<Encryption>,
+ pub profile_acquirer_id: Option<common_utils::id_type::ProfileAcquirerId>,
}
impl Default for AuthenticationUpdateInternal {
@@ -242,6 +262,11 @@ impl Default for AuthenticationUpdateInternal {
service_details: Default::default(),
force_3ds_challenge: Default::default(),
psd2_sca_exemption_type: Default::default(),
+ billing_address: Default::default(),
+ shipping_address: Default::default(),
+ browser_info: Default::default(),
+ email: Default::default(),
+ profile_acquirer_id: Default::default(),
}
}
}
@@ -279,6 +304,11 @@ impl AuthenticationUpdateInternal {
service_details,
force_3ds_challenge,
psd2_sca_exemption_type,
+ billing_address,
+ shipping_address,
+ browser_info,
+ email,
+ profile_acquirer_id,
} = self;
Authentication {
connector_authentication_id: connector_authentication_id
@@ -315,6 +345,11 @@ impl AuthenticationUpdateInternal {
service_details: service_details.or(source.service_details),
force_3ds_challenge: force_3ds_challenge.or(source.force_3ds_challenge),
psd2_sca_exemption_type: psd2_sca_exemption_type.or(source.psd2_sca_exemption_type),
+ billing_address: billing_address.or(source.billing_address),
+ shipping_address: shipping_address.or(source.shipping_address),
+ browser_info: browser_info.or(source.browser_info),
+ email: email.or(source.email),
+ profile_acquirer_id: profile_acquirer_id.or(source.profile_acquirer_id),
..source
}
}
@@ -368,6 +403,10 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {
acquirer_merchant_id,
directory_server_id,
acquirer_country_code,
+ billing_address,
+ shipping_address,
+ browser_info,
+ email,
} => Self {
threeds_server_transaction_id: Some(threeds_server_transaction_id),
maximum_supported_version: Some(maximum_supported_3ds_version),
@@ -381,6 +420,10 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {
acquirer_merchant_id,
directory_server_id,
acquirer_country_code,
+ billing_address,
+ shipping_address,
+ browser_info: *browser_info,
+ email,
..Default::default()
},
AuthenticationUpdate::AuthenticationUpdate {
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index d0cd33228f..0cf2f2decc 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -131,6 +131,12 @@ diesel::table! {
return_url -> Nullable<Varchar>,
amount -> Nullable<Int8>,
currency -> Nullable<Currency>,
+ billing_address -> Nullable<Bytea>,
+ shipping_address -> Nullable<Bytea>,
+ browser_info -> Nullable<Jsonb>,
+ email -> Nullable<Bytea>,
+ #[max_length = 128]
+ profile_acquirer_id -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index d8a3728d64..b461741d42 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -131,6 +131,12 @@ diesel::table! {
return_url -> Nullable<Varchar>,
amount -> Nullable<Int8>,
currency -> Nullable<Currency>,
+ billing_address -> Nullable<Bytea>,
+ shipping_address -> Nullable<Bytea>,
+ browser_info -> Nullable<Jsonb>,
+ email -> Nullable<Bytea>,
+ #[max_length = 128]
+ profile_acquirer_id -> Nullable<Varchar>,
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
index 0bf6c9db87..1fa353949a 100644
--- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
+++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
@@ -310,34 +310,38 @@ impl
req: &UasPreAuthenticationRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let transaction_details = req.request.transaction_details.clone().ok_or(
- errors::ConnectorError::MissingRequiredField {
- field_name: "transaction_details",
- },
- )?;
- let amount = utils::convert_amount(
- self.amount_converter,
- transaction_details
- .amount
- .ok_or(errors::ConnectorError::MissingRequiredField {
- field_name: "amount",
- })?,
- transaction_details
- .currency
- .ok_or(errors::ConnectorError::MissingRequiredField {
- field_name: "currency",
- })?,
- )?;
-
- let connector_router_data =
- unified_authentication_service::UnifiedAuthenticationServiceRouterData::from((
- amount, req,
- ));
-
- let connector_req = unified_authentication_service::UnifiedAuthenticationServicePreAuthenticateRequest::try_from(
- &connector_router_data,
- )?;
+ let connector_req = if req.request.service_details.is_some() {
+ let transaction_details = req.request.transaction_details.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "transaction_details",
+ },
+ )?;
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ transaction_details
+ .amount
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "amount",
+ })?,
+ transaction_details.currency.ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ },
+ )?,
+ )?;
+ let connector_router_data =
+ unified_authentication_service::UnifiedAuthenticationServiceRouterData::from((
+ amount, req,
+ ));
+ unified_authentication_service::UnifiedAuthenticationServicePreAuthenticateRequest::try_from(
+ &connector_router_data,
+ )?
+ } else {
+ unified_authentication_service::UnifiedAuthenticationServicePreAuthenticateRequest::try_from(
+ req,
+ )?
+ };
Ok(RequestContent::Json(Box::new(connector_req)))
}
diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
index b283306c2d..eb3eac1412 100644
--- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
@@ -1,4 +1,5 @@
-use common_enums::enums;
+use common_enums::{enums, MerchantCategoryCode};
+use common_types::payments::MerchantCountryCode;
use common_utils::types::FloatMajorUnit;
use hyperswitch_domain_models::{
router_data::{ConnectorAuthType, RouterData},
@@ -42,15 +43,17 @@ pub struct UnifiedAuthenticationServicePreAuthenticateRequest {
pub service_details: Option<CtpServiceDetails>,
pub customer_details: Option<CustomerDetails>,
pub pmt_details: Option<PaymentDetails>,
- pub auth_creds: ConnectorAuthType,
+ pub auth_creds: UnifiedAuthenticationServiceAuthType,
pub transaction_details: Option<TransactionDetails>,
+ pub acquirer_details: Option<Acquirer>,
+ pub billing_address: Option<Address>,
}
#[derive(Debug, Serialize)]
pub struct UnifiedAuthenticationServiceAuthenticateConfirmationRequest {
pub authenticate_by: String,
pub source_authentication_id: common_utils::id_type::AuthenticationId,
- pub auth_creds: ConnectorAuthType,
+ pub auth_creds: UnifiedAuthenticationServiceAuthType,
pub x_src_flow_id: Option<String>,
pub transaction_amount: Option<FloatMajorUnit>,
pub transaction_currency: Option<enums::Currency>,
@@ -102,13 +105,14 @@ pub struct PaymentDetails {
pub digital_card_id: Option<String>,
pub payment_data_type: Option<String>,
pub encrypted_src_card_details: Option<String>,
- pub card_expiry_date: Secret<String>,
- pub cardholder_name: Secret<String>,
+ pub card_expiry_month: Secret<String>,
+ pub card_expiry_year: Secret<String>,
+ pub cardholder_name: Option<Secret<String>>,
pub card_token_number: Secret<String>,
- pub account_type: u8,
+ pub account_type: Option<common_enums::PaymentMethodType>,
}
-#[derive(Default, Debug, Serialize, PartialEq)]
+#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TransactionDetails {
pub amount: FloatMajorUnit,
pub currency: enums::Currency,
@@ -119,34 +123,44 @@ pub struct TransactionDetails {
pub transaction_type: Option<String>,
pub otp_value: Option<String>,
pub three_ds_data: Option<ThreeDSData>,
+ pub message_category: Option<MessageCategory>,
}
-#[derive(Default, Debug, Serialize, PartialEq)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum MessageCategory {
+ Payment,
+ NonPayment,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ThreeDSData {
- pub browser: BrowserInfo,
- pub acquirer: Acquirer,
+ pub preferred_protocol_version: Option<common_utils::types::SemanticVersion>,
}
-#[derive(Default, Debug, Serialize, PartialEq)]
+#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Acquirer {
- pub merchant_id: String,
- pub bin: u32,
+ pub acquirer_merchant_id: Option<String>,
+ pub acquirer_bin: Option<String>,
+ pub acquirer_country_code: Option<String>,
}
-#[derive(Default, Debug, Serialize, PartialEq)]
+#[derive(Default, Debug, Serialize, PartialEq, Clone, Deserialize)]
pub struct BrowserInfo {
- pub accept_header: String,
- pub screen_width: u32,
- pub screen_height: u32,
- pub java_enabled: bool,
- pub javascript_enabled: bool,
- pub language: String,
- pub user_agent: String,
- pub color_depth: u32,
- pub ip: String,
- pub tz: i32,
- pub time_zone: i8,
- pub challenge_window_size: String,
+ pub color_depth: Option<u8>,
+ pub java_enabled: Option<bool>,
+ pub java_script_enabled: Option<bool>,
+ pub language: Option<String>,
+ pub screen_height: Option<u32>,
+ pub screen_width: Option<u32>,
+ pub time_zone: Option<i32>,
+ pub ip_address: Option<std::net::IpAddr>,
+ pub accept_header: Option<String>,
+ pub user_agent: Option<String>,
+ pub os_type: Option<String>,
+ pub os_version: Option<String>,
+ pub device_model: Option<String>,
+ pub accept_language: Option<String>,
}
#[derive(Default, Debug, Serialize, PartialEq)]
@@ -167,30 +181,29 @@ pub struct ServiceSessionIds {
#[derive(Default, Debug, Serialize, PartialEq)]
pub struct MerchantDetails {
- pub merchant_id: String,
- pub merchant_name: String,
- pub mcc: String,
- pub country_code: String,
- pub name: String,
- pub requestor_id: String,
- pub requestor_name: String,
- pub configuration_id: String,
- pub merchant_country: String,
- pub merchant_category_code: u32,
+ pub merchant_id: Option<String>,
+ pub merchant_name: Option<String>,
+ pub merchant_category_code: Option<MerchantCategoryCode>,
+ pub configuration_id: Option<String>,
+ pub endpoint_prefix: Option<String>,
+ pub three_ds_requestor_url: Option<String>,
+ pub three_ds_requestor_id: Option<String>,
+ pub three_ds_requestor_name: Option<String>,
+ pub merchant_country_code: Option<MerchantCountryCode>,
}
-#[derive(Default, Debug, Serialize, PartialEq)]
+#[derive(Default, Clone, Debug, Serialize, PartialEq, Deserialize)]
pub struct Address {
- pub city: String,
- pub country: String,
- pub line1: Secret<String>,
- pub line2: Secret<String>,
+ pub city: Option<String>,
+ pub country: Option<common_enums::CountryAlpha2>,
+ pub line1: Option<Secret<String>>,
+ pub line2: Option<Secret<String>>,
pub line3: Option<Secret<String>>,
- pub post_code: Secret<String>,
- pub state: Secret<String>,
+ pub post_code: Option<Secret<String>>,
+ pub state: Option<Secret<String>>,
}
-#[derive(Default, Debug, Serialize, PartialEq)]
+#[derive(Default, Clone, Debug, Serialize, PartialEq, Deserialize)]
pub struct CustomerDetails {
pub name: Secret<String>,
pub email: Option<Secret<String>>,
@@ -228,6 +241,8 @@ impl TryFrom<&UnifiedAuthenticationServiceRouterData<&UasPreAuthenticationRouter
},
)?;
let authentication_info = item.router_data.request.authentication_info.clone();
+ let auth_type =
+ UnifiedAuthenticationServiceAuthType::try_from(&item.router_data.connector_auth_type)?;
Ok(Self {
authenticate_by: item.router_data.connector.clone(),
session_id: authentication_id.clone(),
@@ -259,7 +274,9 @@ impl TryFrom<&UnifiedAuthenticationServiceRouterData<&UasPreAuthenticationRouter
}),
customer_details: None,
pmt_details: None,
- auth_creds: item.router_data.connector_auth_type.clone(),
+ auth_creds: auth_type,
+ acquirer_details: None,
+ billing_address: None,
transaction_details: Some(TransactionDetails {
amount: item.amount,
currency: item
@@ -281,6 +298,7 @@ impl TryFrom<&UnifiedAuthenticationServiceRouterData<&UasPreAuthenticationRouter
transaction_type: None,
otp_value: None,
three_ds_data: None,
+ message_category: None,
}),
})
}
@@ -296,6 +314,7 @@ pub enum UnifiedAuthenticationServicePreAuthenticateStatus {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UnifiedAuthenticationServicePreAuthenticateResponse {
status: UnifiedAuthenticationServicePreAuthenticateStatus,
+ pub eligibility: Option<Eligibility>,
}
impl<F, T>
@@ -317,17 +336,47 @@ impl<F, T>
UasAuthenticationResponseData,
>,
) -> Result<Self, Self::Error> {
+ let three_ds_eligibility_response = if let Some(Eligibility::ThreeDsEligibilityResponse {
+ three_ds_eligibility_response,
+ }) = item.response.eligibility
+ {
+ Some(three_ds_eligibility_response)
+ } else {
+ None
+ };
+ let max_acs_protocol_version = three_ds_eligibility_response
+ .as_ref()
+ .and_then(|response| response.get_max_acs_protocol_version_if_available());
+ let maximum_supported_3ds_version = max_acs_protocol_version
+ .as_ref()
+ .map(|acs_protocol_version| acs_protocol_version.version.clone());
+ let three_ds_method_data =
+ three_ds_eligibility_response
+ .as_ref()
+ .and_then(|three_ds_eligibility_response| {
+ three_ds_eligibility_response
+ .three_ds_method_data_form
+ .three_ds_method_data
+ .clone()
+ });
+ let three_ds_method_url = max_acs_protocol_version
+ .and_then(|acs_protocol_version| acs_protocol_version.three_ds_method_url);
Ok(Self {
response: Ok(UasAuthenticationResponseData::PreAuthentication {
authentication_details: PreAuthenticationDetails {
- threeds_server_transaction_id: None,
- maximum_supported_3ds_version: None,
- connector_authentication_id: None,
- three_ds_method_data: None,
- three_ds_method_url: None,
- message_version: None,
+ threeds_server_transaction_id: three_ds_eligibility_response
+ .as_ref()
+ .map(|response| response.three_ds_server_trans_id.clone()),
+ maximum_supported_3ds_version: maximum_supported_3ds_version.clone(),
+ connector_authentication_id: three_ds_eligibility_response
+ .as_ref()
+ .map(|response| response.three_ds_server_trans_id.clone()),
+ three_ds_method_data,
+ three_ds_method_url,
+ message_version: maximum_supported_3ds_version,
connector_metadata: None,
- directory_server_id: None,
+ directory_server_id: three_ds_eligibility_response
+ .and_then(|response| response.directory_server_id),
},
}),
..item.data
@@ -449,7 +498,7 @@ impl<F, T>
}
//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
+#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)]
pub struct UnifiedAuthenticationServiceErrorResponse {
pub error: String,
}
@@ -466,9 +515,12 @@ impl TryFrom<&UnifiedAuthenticationServiceRouterData<&UasAuthenticationConfirmat
field_name: "authentication_id",
},
)?;
+ let auth_type =
+ UnifiedAuthenticationServiceAuthType::try_from(&item.router_data.connector_auth_type)?;
+
Ok(Self {
authenticate_by: item.router_data.connector.clone(),
- auth_creds: item.router_data.connector_auth_type.clone(),
+ auth_creds: auth_type,
source_authentication_id: authentication_id,
x_src_flow_id: item.router_data.request.x_src_flow_id.clone(),
transaction_amount: Some(item.amount),
@@ -489,3 +541,237 @@ impl TryFrom<&UnifiedAuthenticationServiceRouterData<&UasAuthenticationConfirmat
})
}
}
+
+impl TryFrom<&UasPreAuthenticationRouterData>
+ for UnifiedAuthenticationServicePreAuthenticateRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &UasPreAuthenticationRouterData) -> Result<Self, Self::Error> {
+ let auth_type = UnifiedAuthenticationServiceAuthType::try_from(&item.connector_auth_type)?;
+ let authentication_id =
+ item.authentication_id
+ .clone()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "authentication_id",
+ })?;
+
+ let merchant_data = item.request.merchant_details.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "merchant_details",
+ },
+ )?;
+
+ let merchant_details = MerchantDetails {
+ merchant_id: merchant_data.merchant_id,
+ merchant_name: merchant_data.merchant_name,
+ merchant_category_code: merchant_data.merchant_category_code,
+ merchant_country_code: merchant_data.merchant_country_code.clone(),
+ endpoint_prefix: merchant_data.endpoint_prefix,
+ three_ds_requestor_url: merchant_data.three_ds_requestor_url,
+ three_ds_requestor_id: merchant_data.three_ds_requestor_id,
+ three_ds_requestor_name: merchant_data.three_ds_requestor_name,
+ configuration_id: None,
+ };
+
+ let acquirer = Acquirer {
+ acquirer_bin: item.request.acquirer_bin.clone(),
+ acquirer_merchant_id: item.request.acquirer_merchant_id.clone(),
+ acquirer_country_code: merchant_data
+ .merchant_country_code
+ .map(|code| code.get_country_code()),
+ };
+
+ let service_details = Some(CtpServiceDetails {
+ service_session_ids: None,
+ merchant_details: Some(merchant_details),
+ });
+
+ let billing_address = item
+ .request
+ .billing_address
+ .clone()
+ .map(|address_wrap| Address {
+ city: address_wrap
+ .address
+ .clone()
+ .and_then(|address| address.city),
+ country: address_wrap
+ .address
+ .clone()
+ .and_then(|address| address.country),
+ line1: address_wrap
+ .address
+ .clone()
+ .and_then(|address| address.line1),
+ line2: address_wrap
+ .address
+ .clone()
+ .and_then(|address| address.line2),
+ line3: address_wrap
+ .address
+ .clone()
+ .and_then(|address| address.line3),
+ post_code: address_wrap.address.clone().and_then(|address| address.zip),
+ state: address_wrap.address.and_then(|address| address.state),
+ });
+
+ Ok(Self {
+ authenticate_by: item.connector.clone(),
+ session_id: authentication_id.clone(),
+ source_authentication_id: authentication_id,
+ authentication_info: None,
+ service_details,
+ customer_details: None,
+ pmt_details: item
+ .request
+ .payment_details
+ .clone()
+ .map(|details| PaymentDetails {
+ pan: details.pan,
+ digital_card_id: details.digital_card_id,
+ payment_data_type: details.payment_data_type,
+ encrypted_src_card_details: details.encrypted_src_card_details,
+ cardholder_name: details.cardholder_name,
+ card_token_number: details.card_token_number,
+ account_type: details.account_type,
+ card_expiry_month: details.card_expiry_month,
+ card_expiry_year: details.card_expiry_year,
+ }),
+ auth_creds: auth_type,
+ transaction_details: None,
+ acquirer_details: Some(acquirer),
+ billing_address,
+ })
+ }
+}
+
+#[derive(Debug, Serialize, PartialEq)]
+#[serde(tag = "auth_type")]
+pub enum UnifiedAuthenticationServiceAuthType {
+ HeaderKey {
+ api_key: Secret<String>,
+ },
+ CertificateAuth {
+ certificate: Secret<String>,
+ private_key: Secret<String>,
+ },
+}
+
+impl TryFrom<&ConnectorAuthType> for UnifiedAuthenticationServiceAuthType {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
+ match auth_type {
+ ConnectorAuthType::HeaderKey { api_key } => Ok(Self::HeaderKey {
+ api_key: api_key.clone(),
+ }),
+ ConnectorAuthType::CertificateAuth {
+ certificate,
+ private_key,
+ } => Ok(Self::CertificateAuth {
+ certificate: certificate.clone(),
+ private_key: private_key.clone(),
+ }),
+ _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
+ }
+ }
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+#[serde(tag = "eligibility")]
+pub enum Eligibility {
+ None,
+ TokenEligibilityResponse {
+ token_eligibility_response: Box<TokenEligibilityResponse>,
+ },
+ ThreeDsEligibilityResponse {
+ three_ds_eligibility_response: Box<ThreeDsEligibilityResponse>,
+ },
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct TokenEligibilityResponse {
+ pub network_request_id: Option<String>,
+ pub network_client_id: Option<String>,
+ pub nonce: Option<String>,
+ pub payment_method_details: Option<PaymentMethodDetails>,
+ pub network_pan_enrollment_id: Option<String>,
+ pub ignore_00_field: Option<String>,
+ pub token_details: Option<TokenDetails>,
+ pub network_provisioned_token_id: Option<String>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct PaymentMethodDetails {
+ pub ignore_01_field: String,
+ pub cvv2_printed_ind: String,
+ pub last4: String,
+ pub exp_date_printed_ind: String,
+ pub payment_account_reference: String,
+ pub exp_year: String,
+ pub exp_month: String,
+ pub verification_results: VerificationResults,
+ pub enabled_services: EnabledServices,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct VerificationResults {
+ pub address_verification_code: String,
+ pub cvv2_verification_code: String,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct EnabledServices {
+ pub merchant_presented_qr: String,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct ThreeDsEligibilityResponse {
+ pub three_ds_server_trans_id: String,
+ pub scheme_id: Option<String>,
+ pub acs_protocol_versions: Option<Vec<AcsProtocolVersion>>,
+ pub ds_protocol_versions: Option<Vec<String>>,
+ pub three_ds_method_data_form: ThreeDsMethodDataForm,
+ pub three_ds_method_data: Option<ThreeDsMethodData>,
+ pub error_details: Option<String>,
+ pub is_card_found_in_2x_ranges: bool,
+ pub directory_server_id: Option<String>,
+}
+
+impl ThreeDsEligibilityResponse {
+ pub fn get_max_acs_protocol_version_if_available(&self) -> Option<AcsProtocolVersion> {
+ let max_acs_version =
+ self.acs_protocol_versions
+ .as_ref()
+ .and_then(|acs_protocol_versions| {
+ acs_protocol_versions
+ .iter()
+ .max_by_key(|acs_protocol_versions| acs_protocol_versions.version.clone())
+ });
+ max_acs_version.cloned()
+ }
+}
+
+#[derive(Clone, Serialize, Deserialize, Debug)]
+pub struct AcsProtocolVersion {
+ pub version: common_utils::types::SemanticVersion,
+ pub acs_info_ind: Vec<String>,
+ pub three_ds_method_url: Option<String>,
+ pub supported_msg_ext: Option<Vec<SupportedMsgExt>>,
+}
+
+#[derive(Clone, Serialize, Deserialize, Debug)]
+pub struct SupportedMsgExt {
+ pub id: String,
+ pub version: String,
+}
+
+#[derive(Clone, Serialize, Deserialize, Debug, Default)]
+pub struct ThreeDsMethodDataForm {
+ pub three_ds_method_data: Option<String>,
+}
+
+#[derive(Default, Clone, Serialize, Deserialize, Debug)]
+pub struct ThreeDsMethodData {
+ pub three_ds_method_notification_url: String,
+ pub server_transaction_id: String,
+}
diff --git a/crates/hyperswitch_domain_models/src/authentication.rs b/crates/hyperswitch_domain_models/src/authentication.rs
new file mode 100644
index 0000000000..3f46d81e22
--- /dev/null
+++ b/crates/hyperswitch_domain_models/src/authentication.rs
@@ -0,0 +1,64 @@
+use common_utils::{
+ crypto::Encryptable, encryption::Encryption, errors::CustomResult, pii,
+ types::keymanager::ToEncryptable,
+};
+use masking::Secret;
+use rustc_hash::FxHashMap;
+use serde_json::Value;
+
+#[cfg(feature = "v1")]
+#[derive(Clone, Debug, router_derive::ToEncryption, serde::Serialize)]
+pub struct Authentication {
+ pub authentication_id: common_utils::id_type::AuthenticationId,
+ pub merchant_id: common_utils::id_type::MerchantId,
+ pub authentication_connector: Option<String>,
+ pub connector_authentication_id: Option<String>,
+ pub authentication_data: Option<Value>,
+ pub payment_method_id: String,
+ pub authentication_type: Option<common_enums::DecoupledAuthenticationType>,
+ pub authentication_status: common_enums::AuthenticationStatus,
+ pub authentication_lifecycle_status: common_enums::AuthenticationLifecycleStatus,
+ #[serde(with = "common_utils::custom_serde::iso8601")]
+ pub created_at: time::PrimitiveDateTime,
+ #[serde(with = "common_utils::custom_serde::iso8601")]
+ pub modified_at: time::PrimitiveDateTime,
+ pub error_message: Option<String>,
+ pub error_code: Option<String>,
+ pub connector_metadata: Option<Value>,
+ pub maximum_supported_version: Option<common_utils::types::SemanticVersion>,
+ pub threeds_server_transaction_id: Option<String>,
+ pub cavv: Option<String>,
+ pub authentication_flow_type: Option<String>,
+ pub message_version: Option<common_utils::types::SemanticVersion>,
+ pub eci: Option<String>,
+ pub trans_status: Option<common_enums::TransactionStatus>,
+ pub acquirer_bin: Option<String>,
+ pub acquirer_merchant_id: Option<String>,
+ pub three_ds_method_data: Option<String>,
+ pub three_ds_method_url: Option<String>,
+ pub acs_url: Option<String>,
+ pub challenge_request: Option<String>,
+ pub acs_reference_number: Option<String>,
+ pub acs_trans_id: Option<String>,
+ pub acs_signed_content: Option<String>,
+ pub profile_id: common_utils::id_type::ProfileId,
+ pub payment_id: Option<common_utils::id_type::PaymentId>,
+ pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
+ pub ds_trans_id: Option<String>,
+ pub directory_server_id: Option<String>,
+ pub acquirer_country_code: Option<String>,
+ pub service_details: Option<Value>,
+ pub organization_id: common_utils::id_type::OrganizationId,
+ pub authentication_client_secret: Option<String>,
+ pub force_3ds_challenge: Option<bool>,
+ pub psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
+ pub return_url: Option<String>,
+ pub amount: Option<common_utils::types::MinorUnit>,
+ pub currency: Option<common_enums::Currency>,
+ #[encrypt]
+ pub billing_address: Option<Encryptable<Secret<Value>>>,
+ #[encrypt]
+ pub shipping_address: Option<Encryptable<Secret<Value>>>,
+ pub browser_info: Option<Value>,
+ pub email: Option<Encryptable<Secret<String, pii::EmailStrategy>>>,
+}
diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs
index efa6505491..1f9dee6863 100644
--- a/crates/hyperswitch_domain_models/src/lib.rs
+++ b/crates/hyperswitch_domain_models/src/lib.rs
@@ -1,5 +1,6 @@
pub mod address;
pub mod api;
+pub mod authentication;
pub mod behaviour;
pub mod bulk_tokenization;
pub mod business_profile;
diff --git a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs
index 6939a18595..8c7f2c3248 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs
@@ -1,4 +1,6 @@
use api_models::payments::DeviceChannel;
+use common_enums::MerchantCategoryCode;
+use common_types::payments::MerchantCountryCode;
use common_utils::types::MinorUnit;
use masking::Secret;
use time::PrimitiveDateTime;
@@ -11,6 +13,22 @@ pub struct UasPreAuthenticationRequestData {
pub transaction_details: Option<TransactionDetails>,
pub payment_details: Option<PaymentDetails>,
pub authentication_info: Option<AuthenticationInfo>,
+ pub merchant_details: Option<MerchantDetails>,
+ pub billing_address: Option<Address>,
+ pub acquirer_bin: Option<String>,
+ pub acquirer_merchant_id: Option<String>,
+}
+
+#[derive(Debug, Clone)]
+pub struct MerchantDetails {
+ pub merchant_id: Option<String>,
+ pub merchant_name: Option<String>,
+ pub merchant_category_code: Option<MerchantCategoryCode>,
+ pub merchant_country_code: Option<MerchantCountryCode>,
+ pub endpoint_prefix: Option<String>,
+ pub three_ds_requestor_url: Option<String>,
+ pub three_ds_requestor_id: Option<String>,
+ pub three_ds_requestor_name: Option<String>,
}
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
@@ -51,10 +69,11 @@ pub struct PaymentDetails {
pub digital_card_id: Option<String>,
pub payment_data_type: Option<String>,
pub encrypted_src_card_details: Option<String>,
- pub card_expiry_date: Secret<String>,
+ pub card_expiry_month: Secret<String>,
+ pub card_expiry_year: Secret<String>,
pub cardholder_name: Option<Secret<String>>,
pub card_token_number: Secret<String>,
- pub account_type: Option<common_enums::CardNetwork>,
+ pub account_type: Option<common_enums::PaymentMethodType>,
}
#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]
@@ -154,3 +173,14 @@ pub struct UasConfirmationRequestData {
pub correlation_id: Option<String>,
pub merchant_transaction_id: Option<String>,
}
+
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+pub struct ThreeDsMetaData {
+ pub merchant_category_code: Option<MerchantCategoryCode>,
+ pub merchant_country_code: Option<MerchantCountryCode>,
+ pub merchant_name: Option<String>,
+ pub endpoint_prefix: String,
+ pub three_ds_requestor_name: Option<String>,
+ pub three_ds_requestor_id: Option<String>,
+ pub merchant_configuration_id: Option<String>,
+}
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 387be8ec75..4a8f2ac9c2 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -799,6 +799,12 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::authentication::AuthenticationCreateRequest,
api_models::authentication::AuthenticationResponse,
api_models::authentication::AcquirerDetails,
+ api_models::authentication::NextAction,
+ common_utils::request::Method,
+ api_models::authentication::EligibilityResponseParams,
+ api_models::authentication::ThreeDsData,
+ api_models::authentication::AuthenticationEligibilityRequest,
+ api_models::authentication::AuthenticationEligibilityResponse,
)),
modifiers(&SecurityAddon)
)]
diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs
index cc1db79444..a38b7d841c 100644
--- a/crates/router/src/core/authentication.rs
+++ b/crates/router/src/core/authentication.rs
@@ -110,7 +110,7 @@ pub async fn perform_post_authentication(
ApiErrorResponse,
> {
let (authentication_connector, three_ds_connector_account) =
- utils::get_authentication_connector_data(state, key_store, &business_profile).await?;
+ utils::get_authentication_connector_data(state, key_store, &business_profile, None).await?;
let is_pull_mechanism_enabled =
check_if_pull_mechanism_for_external_3ds_enabled_from_connector_metadata(
three_ds_connector_account
@@ -191,7 +191,7 @@ pub async fn perform_pre_authentication(
ApiErrorResponse,
> {
let (authentication_connector, three_ds_connector_account) =
- utils::get_authentication_connector_data(state, key_store, business_profile).await?;
+ utils::get_authentication_connector_data(state, key_store, business_profile, None).await?;
let authentication_connector_name = authentication_connector.to_string();
let authentication = utils::create_new_authentication(
state,
diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rs
index 0466205ca0..b6c304168c 100644
--- a/crates/router/src/core/authentication/utils.rs
+++ b/crates/router/src/core/authentication/utils.rs
@@ -88,6 +88,10 @@ pub async fn update_trackers<F: Clone, Req>(
acquirer_country_code: acquirer_details
.and_then(|acquirer_details| acquirer_details.acquirer_country_code),
directory_server_id,
+ billing_address: None,
+ shipping_address: None,
+ browser_info: Box::new(None),
+ email: None,
},
AuthenticationResponseData::AuthNResponse {
authn_flow_type,
@@ -275,6 +279,11 @@ pub async fn create_new_authentication(
return_url: None,
amount: None,
currency: None,
+ billing_address: None,
+ shipping_address: None,
+ browser_info: None,
+ email: None,
+ profile_acquirer_id: None,
};
state
.store
@@ -325,31 +334,46 @@ pub async fn get_authentication_connector_data(
state: &SessionState,
key_store: &domain::MerchantKeyStore,
business_profile: &domain::Profile,
+ authentication_connector: Option<String>,
) -> RouterResult<(
common_enums::AuthenticationConnectors,
payments::helpers::MerchantConnectorAccountType,
)> {
- let authentication_details = business_profile
- .authentication_connector_details
- .clone()
- .get_required_value("authentication_details")
- .change_context(errors::ApiErrorResponse::UnprocessableEntity {
- message: "authentication_connector_details is not available in business profile".into(),
- })
- .attach_printable("authentication_connector_details not configured by the merchant")?;
- let authentication_connector = authentication_details
- .authentication_connectors
- .first()
- .ok_or(errors::ApiErrorResponse::UnprocessableEntity {
- message: format!(
- "No authentication_connector found for profile_id {:?}",
- business_profile.get_id()
+ let authentication_connector = if let Some(authentication_connector) = authentication_connector
+ {
+ api_models::enums::convert_authentication_connector(&authentication_connector).ok_or(
+ errors::ApiErrorResponse::UnprocessableEntity {
+ message: format!(
+ "Invalid authentication_connector found in request : {authentication_connector}",
),
- })
- .attach_printable(
- "No authentication_connector found from merchant_account.authentication_details",
+ },
)?
- .to_owned();
+ } else {
+ let authentication_details = business_profile
+ .authentication_connector_details
+ .clone()
+ .get_required_value("authentication_details")
+ .change_context(errors::ApiErrorResponse::UnprocessableEntity {
+ message: "authentication_connector_details is not available in business profile"
+ .into(),
+ })
+ .attach_printable("authentication_connector_details not configured by the merchant")?;
+
+ authentication_details
+ .authentication_connectors
+ .first()
+ .ok_or(errors::ApiErrorResponse::UnprocessableEntity {
+ message: format!(
+ "No authentication_connector found for profile_id {:?}",
+ business_profile.get_id()
+ ),
+ })
+ .attach_printable(
+ "No authentication_connector found from merchant_account.authentication_details",
+ )?
+ .to_owned()
+ };
+
let profile_id = business_profile.get_id();
let authentication_connector_mca = payments::helpers::get_merchant_connector_account(
state,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 3eb1d335a1..0ed5dc0609 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -9242,6 +9242,10 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
authentication.clone(),
None,
merchant_context.get_merchant_key_store(),
+ None,
+ None,
+ None,
+ None,
)
.await?;
authentication::AuthenticationResponse::try_from(authentication)?
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index abbdc1f5c7..a6d1047e6d 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1288,6 +1288,10 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
payment_data.payment_intent.amount,
payment_data.payment_intent.currency,
payment_data.service_details.clone(),
+ None,
+ None,
+ None,
+ None
)
.await?;
@@ -1361,6 +1365,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
None,
None,
None,
+ None,
None
)
.await?;
@@ -1430,7 +1435,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
..
} => {
let (authentication_connector, three_ds_connector_account) =
- authentication::utils::get_authentication_connector_data(state, key_store, business_profile).await?;
+ authentication::utils::get_authentication_connector_data(state, key_store, business_profile, None).await?;
let authentication_connector_name = authentication_connector.to_string();
let authentication = authentication::utils::create_new_authentication(
state,
@@ -1462,14 +1467,22 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
).attach_printable("payment_method not found in payment_attempt")?,
payment_data.payment_intent.amount,
payment_data.payment_intent.currency,
- payment_data.service_details.clone()
+ payment_data.service_details.clone(),
+ None,
+ None,
+ None,
+ None
).await?;
let updated_authentication = uas_utils::utils::external_authentication_update_trackers(
state,
pre_auth_response,
authentication.clone(),
acquirer_details,
- key_store
+ key_store,
+ None,
+ None,
+ None,
+ None,
).await?;
let authentication_store = hyperswitch_domain_models::router_request_types::authentication::AuthenticationStore {
cavv: None, // since in case of pre_authentication cavv is not present
@@ -1513,7 +1526,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
},
helpers::UnifiedAuthenticationServiceFlow::ExternalAuthenticationPostAuthenticate {authentication_id} => {
let (authentication_connector, three_ds_connector_account) =
- authentication::utils::get_authentication_connector_data(state, key_store, business_profile).await?;
+ authentication::utils::get_authentication_connector_data(state, key_store, business_profile, None).await?;
let is_pull_mechanism_enabled =
utils::check_if_pull_mechanism_for_external_3ds_enabled_from_connector_metadata(
three_ds_connector_account
@@ -1548,7 +1561,11 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
post_auth_response,
authentication,
None,
- key_store
+ key_store,
+ None,
+ None,
+ None,
+ None,
).await?
} else {
authentication
diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs
index caba69331b..94c0e7a673 100644
--- a/crates/router/src/core/unified_authentication_service.rs
+++ b/crates/router/src/core/unified_authentication_service.rs
@@ -1,10 +1,17 @@
pub mod types;
-pub mod utils;
+use std::str::FromStr;
+pub mod utils;
+#[cfg(feature = "v1")]
+use api_models::authentication::{
+ AuthenticationEligibilityRequest, AuthenticationEligibilityResponse,
+};
use api_models::{
authentication::{AcquirerDetails, AuthenticationCreateRequest, AuthenticationResponse},
payments,
};
+#[cfg(feature = "v1")]
+use common_utils::{ext_traits::ValueExt, types::keymanager::ToEncryptable};
use diesel_models::authentication::{Authentication, AuthenticationNew};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
@@ -13,8 +20,8 @@ use hyperswitch_domain_models::{
router_request_types::{
authentication::{MessageCategory, PreAuthenticationData},
unified_authentication_service::{
- AuthenticationInfo, PaymentDetails, ServiceSessionIds, TransactionDetails,
- UasAuthenticationRequestData, UasConfirmationRequestData,
+ AuthenticationInfo, PaymentDetails, ServiceSessionIds, ThreeDsMetaData,
+ TransactionDetails, UasAuthenticationRequestData, UasConfirmationRequestData,
UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
},
BrowserInformation,
@@ -24,6 +31,7 @@ use hyperswitch_domain_models::{
UasPreAuthenticationRouterData,
},
};
+use masking::{ExposeInterface, PeekInterface};
use super::{
errors::{RouterResponse, RouterResult},
@@ -32,6 +40,7 @@ use super::{
use crate::{
consts,
core::{
+ authentication::utils as auth_utils,
errors::utils::StorageErrorExt,
unified_authentication_service::types::{
ClickToPay, ExternalAuthentication, UnifiedAuthenticationService,
@@ -41,7 +50,7 @@ use crate::{
},
db::domain,
routes::SessionState,
- types::transformers::ForeignFrom,
+ types::{domain::types::AsyncLift, transformers::ForeignTryFrom},
};
#[cfg(feature = "v1")]
@@ -52,6 +61,10 @@ impl UnifiedAuthenticationService for ClickToPay {
service_details: Option<payments::CtpServiceDetails>,
amount: common_utils::types::MinorUnit,
currency: Option<common_enums::Currency>,
+ merchant_details: Option<&hyperswitch_domain_models::router_request_types::unified_authentication_service::MerchantDetails>,
+ billing_address: Option<&hyperswitch_domain_models::address::Address>,
+ acquirer_bin: Option<String>,
+ acquirer_merchant_id: Option<String>,
) -> RouterResult<UasPreAuthenticationRequestData> {
let domain_service_details = hyperswitch_domain_models::router_request_types::unified_authentication_service::CtpServiceDetails {
service_session_ids: Some(ServiceSessionIds {
@@ -91,6 +104,10 @@ impl UnifiedAuthenticationService for ClickToPay {
transaction_details: Some(transaction_details),
payment_details: None,
authentication_info,
+ merchant_details: merchant_details.cloned(),
+ billing_address: billing_address.cloned(),
+ acquirer_bin,
+ acquirer_merchant_id,
})
}
@@ -106,12 +123,20 @@ impl UnifiedAuthenticationService for ClickToPay {
amount: common_utils::types::MinorUnit,
currency: Option<common_enums::Currency>,
service_details: Option<payments::CtpServiceDetails>,
+ merchant_details: Option<&hyperswitch_domain_models::router_request_types::unified_authentication_service::MerchantDetails>,
+ billing_address: Option<&hyperswitch_domain_models::address::Address>,
+ acquirer_bin: Option<String>,
+ acquirer_merchant_id: Option<String>,
) -> RouterResult<UasPreAuthenticationRouterData> {
let pre_authentication_data = Self::get_pre_authentication_request_data(
payment_method_data,
service_details,
amount,
currency,
+ merchant_details,
+ billing_address,
+ acquirer_bin,
+ acquirer_merchant_id,
)?;
let pre_auth_router_data: UasPreAuthenticationRouterData =
@@ -127,11 +152,11 @@ impl UnifiedAuthenticationService for ClickToPay {
payment_id.cloned(),
)?;
- utils::do_auth_connector_call(
+ Box::pin(utils::do_auth_connector_call(
state,
UNIFIED_AUTHENTICATION_SERVICE.to_string(),
pre_auth_router_data,
- )
+ ))
.await
}
@@ -253,8 +278,12 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
fn get_pre_authentication_request_data(
payment_method_data: Option<&domain::PaymentMethodData>,
_service_details: Option<payments::CtpServiceDetails>,
- _amount: common_utils::types::MinorUnit,
- _currency: Option<common_enums::Currency>,
+ amount: common_utils::types::MinorUnit,
+ currency: Option<common_enums::Currency>,
+ merchant_details: Option<&hyperswitch_domain_models::router_request_types::unified_authentication_service::MerchantDetails>,
+ billing_address: Option<&hyperswitch_domain_models::address::Address>,
+ acquirer_bin: Option<String>,
+ acquirer_merchant_id: Option<String>,
) -> RouterResult<UasPreAuthenticationRequestData> {
let payment_method_data = payment_method_data
.ok_or(ApiErrorResponse::InternalServerError)
@@ -266,19 +295,30 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
digital_card_id: None,
payment_data_type: None,
encrypted_src_card_details: None,
- card_expiry_date: card.card_exp_year.clone(),
+ card_expiry_month: card.card_exp_month.clone(),
+ card_expiry_year: card.card_exp_year.clone(),
cardholder_name: card.card_holder_name.clone(),
card_token_number: card.card_cvc.clone(),
- account_type: card.card_network.clone(),
+ account_type: None,
})
} else {
None
};
+ let transaction_details = TransactionDetails {
+ amount: Some(amount),
+ currency,
+ device_channel: None,
+ message_category: None,
+ };
Ok(UasPreAuthenticationRequestData {
service_details: None,
- transaction_details: None,
+ transaction_details: Some(transaction_details),
payment_details,
authentication_info: None,
+ merchant_details: merchant_details.cloned(),
+ billing_address: billing_address.cloned(),
+ acquirer_bin,
+ acquirer_merchant_id,
})
}
@@ -295,12 +335,20 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
amount: common_utils::types::MinorUnit,
currency: Option<common_enums::Currency>,
service_details: Option<payments::CtpServiceDetails>,
+ merchant_details: Option<&hyperswitch_domain_models::router_request_types::unified_authentication_service::MerchantDetails>,
+ billing_address: Option<&hyperswitch_domain_models::address::Address>,
+ acquirer_bin: Option<String>,
+ acquirer_merchant_id: Option<String>,
) -> RouterResult<UasPreAuthenticationRouterData> {
let pre_authentication_data = Self::get_pre_authentication_request_data(
payment_method_data,
service_details,
amount,
currency,
+ merchant_details,
+ billing_address,
+ acquirer_bin,
+ acquirer_merchant_id,
)?;
let pre_auth_router_data: UasPreAuthenticationRouterData =
@@ -316,11 +364,11 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
payment_id.cloned(),
)?;
- utils::do_auth_connector_call(
+ Box::pin(utils::do_auth_connector_call(
state,
UNIFIED_AUTHENTICATION_SERVICE.to_string(),
pre_auth_router_data,
- )
+ ))
.await
}
@@ -511,6 +559,7 @@ pub async fn create_new_authentication(
amount: Option<common_utils::types::MinorUnit>,
currency: Option<common_enums::Currency>,
return_url: Option<String>,
+ profile_acquirer_id: Option<common_utils::id_type::ProfileAcquirerId>,
) -> RouterResult<Authentication> {
let service_details_value = service_details
.map(serde_json::to_value)
@@ -565,6 +614,11 @@ pub async fn create_new_authentication(
return_url,
amount,
currency,
+ billing_address: None,
+ shipping_address: None,
+ browser_info: None,
+ email: None,
+ profile_acquirer_id,
};
state
.store
@@ -647,6 +701,7 @@ pub async fn authentication_create_core(
Some(req.amount),
Some(req.currency),
req.return_url,
+ Some(req.profile_acquirer_id),
)
.await?;
@@ -665,13 +720,20 @@ pub async fn authentication_create_core(
.ok_or(ApiErrorResponse::InternalServerError)
.attach_printable("currency failed to get currency from authentication table")?;
- let response = AuthenticationResponse::foreign_from((
+ let profile_acquirer_id = new_authentication
+ .profile_acquirer_id
+ .clone()
+ .ok_or(ApiErrorResponse::InternalServerError)
+ .attach_printable("failed to get profile_acquirer_id from authentication table")?;
+
+ let response = AuthenticationResponse::foreign_try_from((
new_authentication,
amount,
currency,
profile_id,
acquirer_details,
- ));
+ profile_acquirer_id,
+ ))?;
Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(
response,
@@ -679,24 +741,33 @@ pub async fn authentication_create_core(
}
impl
- ForeignFrom<(
+ ForeignTryFrom<(
Authentication,
common_utils::types::MinorUnit,
common_enums::Currency,
common_utils::id_type::ProfileId,
Option<AcquirerDetails>,
+ common_utils::id_type::ProfileAcquirerId,
)> for AuthenticationResponse
{
- fn foreign_from(
- (authentication, amount, currency, profile_id, acquirer_details): (
+ type Error = error_stack::Report<ApiErrorResponse>;
+ fn foreign_try_from(
+ (authentication, amount, currency, profile_id, acquirer_details, profile_acquirer_id): (
Authentication,
common_utils::types::MinorUnit,
common_enums::Currency,
common_utils::id_type::ProfileId,
Option<AcquirerDetails>,
+ common_utils::id_type::ProfileAcquirerId,
),
- ) -> Self {
- Self {
+ ) -> Result<Self, Self::Error> {
+ let authentication_connector = authentication
+ .authentication_connector
+ .map(|connector| common_enums::AuthenticationConnectors::from_str(&connector))
+ .transpose()
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Incorrect authentication connector stored in table")?;
+ Ok(Self {
authentication_id: authentication.authentication_id,
client_secret: authentication
.authentication_client_secret
@@ -706,7 +777,7 @@ impl
force_3ds_challenge: authentication.force_3ds_challenge,
merchant_id: authentication.merchant_id,
status: authentication.authentication_status,
- authentication_connector: authentication.authentication_connector,
+ authentication_connector,
return_url: authentication.return_url,
created_at: Some(authentication.created_at),
error_code: authentication.error_code,
@@ -714,6 +785,323 @@ impl
profile_id: Some(profile_id),
psd2_sca_exemption_type: authentication.psd2_sca_exemption_type,
acquirer_details,
- }
+ profile_acquirer_id,
+ })
+ }
+}
+
+#[cfg(feature = "v1")]
+impl
+ ForeignTryFrom<(
+ Authentication,
+ api_models::authentication::NextAction,
+ common_utils::id_type::ProfileId,
+ Option<payments::Address>,
+ Option<payments::Address>,
+ Option<payments::BrowserInformation>,
+ common_utils::crypto::OptionalEncryptableEmail,
+ )> for AuthenticationEligibilityResponse
+{
+ type Error = error_stack::Report<ApiErrorResponse>;
+ fn foreign_try_from(
+ (authentication, next_action, profile_id, billing, shipping, browser_information, email): (
+ Authentication,
+ api_models::authentication::NextAction,
+ common_utils::id_type::ProfileId,
+ Option<payments::Address>,
+ Option<payments::Address>,
+ Option<payments::BrowserInformation>,
+ common_utils::crypto::OptionalEncryptableEmail,
+ ),
+ ) -> Result<Self, Self::Error> {
+ let authentication_connector = authentication
+ .authentication_connector
+ .map(|connector| common_enums::AuthenticationConnectors::from_str(&connector))
+ .transpose()
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Incorrect authentication connector stored in table")?;
+ let three_ds_method_url = authentication
+ .three_ds_method_url
+ .map(|url| url::Url::parse(&url))
+ .transpose()
+ .map_err(error_stack::Report::from)
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to parse three_ds_method_url")?;
+
+ let three_ds_data = Some(api_models::authentication::ThreeDsData {
+ threeds_server_transaction_id: authentication.threeds_server_transaction_id,
+ maximum_supported_3ds_version: authentication.maximum_supported_version,
+ connector_authentication_id: authentication.connector_authentication_id,
+ three_ds_method_data: authentication.three_ds_method_data,
+ three_ds_method_url,
+ message_version: authentication.message_version,
+ directory_server_id: authentication.directory_server_id,
+ });
+ Ok(Self {
+ authentication_id: authentication.authentication_id,
+ next_action,
+ status: authentication.authentication_status,
+ eligibility_response_params: three_ds_data
+ .map(api_models::authentication::EligibilityResponseParams::ThreeDsData),
+ connector_metadata: authentication.connector_metadata,
+ profile_id,
+ error_message: authentication.error_message,
+ error_code: authentication.error_code,
+ billing,
+ shipping,
+ authentication_connector,
+ browser_information,
+ email,
+ })
}
}
+
+#[cfg(feature = "v1")]
+pub async fn authentication_eligibility_core(
+ state: SessionState,
+ merchant_context: domain::MerchantContext,
+ req: AuthenticationEligibilityRequest,
+ authentication_id: common_utils::id_type::AuthenticationId,
+) -> RouterResponse<AuthenticationEligibilityResponse> {
+ let merchant_account = merchant_context.get_merchant_account();
+ let merchant_id = merchant_account.get_id();
+ let db = &*state.store;
+ let authentication = db
+ .find_authentication_by_merchant_id_authentication_id(merchant_id, &authentication_id)
+ .await
+ .to_not_found_response(ApiErrorResponse::AuthenticationNotFound {
+ id: authentication_id.get_string_repr().to_owned(),
+ })?;
+
+ if let Some(client_secret) = &req.client_secret {
+ let is_client_secret_expired =
+ utils::authenticate_authentication_client_secret_and_check_expiry(
+ client_secret.peek(),
+ &authentication,
+ )?;
+
+ if is_client_secret_expired {
+ return Err(ApiErrorResponse::ClientSecretExpired.into());
+ };
+ };
+ let key_manager_state = (&state).into();
+
+ let profile_id = core_utils::get_profile_id_from_business_details(
+ &key_manager_state,
+ None,
+ None,
+ &merchant_context,
+ None,
+ db,
+ true,
+ )
+ .await?;
+
+ let business_profile = db
+ .find_business_profile_by_profile_id(
+ &key_manager_state,
+ merchant_context.get_merchant_key_store(),
+ &profile_id,
+ )
+ .await
+ .to_not_found_response(ApiErrorResponse::ProfileNotFound {
+ id: profile_id.get_string_repr().to_owned(),
+ })?;
+
+ let (authentication_connector, three_ds_connector_account) =
+ auth_utils::get_authentication_connector_data(
+ &state,
+ merchant_context.get_merchant_key_store(),
+ &business_profile,
+ authentication.authentication_connector.clone(),
+ )
+ .await?;
+
+ let authentication_connector_name = authentication_connector.to_string();
+
+ let payment_method_data = domain::PaymentMethodData::from(req.payment_method_data.clone());
+
+ let amount = authentication
+ .amount
+ .ok_or(ApiErrorResponse::InternalServerError)
+ .attach_printable("no amount found in authentication table")?;
+
+ let acquirer_details = authentication
+ .profile_acquirer_id
+ .clone()
+ .and_then(|acquirer_id| {
+ business_profile
+ .acquirer_config_map
+ .and_then(|acquirer_config_map| acquirer_config_map.0.get(&acquirer_id).cloned())
+ });
+
+ let metadata: Option<ThreeDsMetaData> = three_ds_connector_account
+ .get_metadata()
+ .map(|metadata| {
+ metadata.expose().parse_value("ThreeDsMetaData").inspect_err(|err| {
+ router_env::logger::warn!(parsing_error=?err,"Error while parsing ThreeDsMetaData");
+ })
+ })
+ .transpose()
+ .change_context(ApiErrorResponse::InternalServerError)?;
+
+ let merchant_country_code = business_profile.merchant_country_code.or(metadata
+ .clone()
+ .and_then(|metadata| metadata.merchant_country_code.clone()));
+
+ let merchant_details = Some(hyperswitch_domain_models::router_request_types::unified_authentication_service::MerchantDetails {
+ merchant_id: Some(authentication.merchant_id.get_string_repr().to_string()),
+ merchant_name: acquirer_details.clone().map(|detail| detail.merchant_name.clone()).or(metadata.clone().and_then(|metadata| metadata.merchant_name)),
+ merchant_category_code: business_profile.merchant_category_code.or(metadata.clone().and_then(|metadata| metadata.merchant_category_code)),
+ endpoint_prefix: metadata.clone().map(|metadata| metadata.endpoint_prefix),
+ three_ds_requestor_url: business_profile.authentication_connector_details.map(|details| details.three_ds_requestor_url),
+ three_ds_requestor_id: metadata.clone().and_then(|metadata| metadata.three_ds_requestor_id),
+ three_ds_requestor_name: metadata.clone().and_then(|metadata| metadata.three_ds_requestor_name),
+ merchant_country_code,
+ });
+
+ let domain_address = req
+ .billing
+ .clone()
+ .map(hyperswitch_domain_models::address::Address::from);
+
+ let pre_auth_response =
+ <ExternalAuthentication as UnifiedAuthenticationService>::pre_authentication(
+ &state,
+ merchant_id,
+ None,
+ Some(&payment_method_data),
+ &three_ds_connector_account,
+ &authentication_connector_name,
+ &authentication_id,
+ req.payment_method,
+ amount,
+ authentication.currency,
+ None,
+ merchant_details.as_ref(),
+ domain_address.as_ref(),
+ acquirer_details.clone().map(|detail| detail.acquirer_bin),
+ acquirer_details.map(|detail| detail.acquirer_assigned_merchant_id),
+ )
+ .await?;
+
+ let billing_details_encoded = req
+ .billing
+ .clone()
+ .map(|billing| {
+ common_utils::ext_traits::Encode::encode_to_value(&billing)
+ .map(masking::Secret::<serde_json::Value>::new)
+ })
+ .transpose()
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encode billing details to serde_json::Value")?;
+
+ let shipping_details_encoded = req
+ .shipping
+ .clone()
+ .map(|shipping| {
+ common_utils::ext_traits::Encode::encode_to_value(&shipping)
+ .map(masking::Secret::<serde_json::Value>::new)
+ })
+ .transpose()
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encode shipping details to serde_json::Value")?;
+
+ let encrypted_data = domain::types::crypto_operation(
+ &key_manager_state,
+ common_utils::type_name!(hyperswitch_domain_models::authentication::Authentication),
+ domain::types::CryptoOperation::BatchEncrypt(
+ hyperswitch_domain_models::authentication::UpdateEncryptableAuthentication::to_encryptable(
+ hyperswitch_domain_models::authentication::UpdateEncryptableAuthentication {
+ billing_address: billing_details_encoded,
+ shipping_address: shipping_details_encoded,
+ },
+ ),
+ ),
+ common_utils::types::keymanager::Identifier::Merchant(
+ merchant_context
+ .get_merchant_key_store()
+ .merchant_id
+ .clone(),
+ ),
+ merchant_context.get_merchant_key_store().key.peek(),
+ )
+ .await
+ .and_then(|val| val.try_into_batchoperation())
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encrypt authentication data".to_string())?;
+
+ let encrypted_data = hyperswitch_domain_models::authentication::FromRequestEncryptableAuthentication::from_encryptable(encrypted_data)
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to get encrypted data for authentication after encryption")?;
+
+ let email_encrypted = req
+ .email
+ .clone()
+ .async_lift(|inner| async {
+ domain::types::crypto_operation(
+ &key_manager_state,
+ common_utils::type_name!(Authentication),
+ domain::types::CryptoOperation::EncryptOptional(inner.map(|inner| inner.expose())),
+ common_utils::types::keymanager::Identifier::Merchant(
+ merchant_context
+ .get_merchant_key_store()
+ .merchant_id
+ .clone(),
+ ),
+ merchant_context.get_merchant_key_store().key.peek(),
+ )
+ .await
+ .and_then(|val| val.try_into_optionaloperation())
+ })
+ .await
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to encrypt email")?;
+
+ let browser_info = req
+ .browser_information
+ .as_ref()
+ .map(common_utils::ext_traits::Encode::encode_to_value)
+ .transpose()
+ .change_context(ApiErrorResponse::InvalidDataValue {
+ field_name: "browser_information",
+ })?;
+
+ let updated_authentication = utils::external_authentication_update_trackers(
+ &state,
+ pre_auth_response,
+ authentication.clone(),
+ None,
+ merchant_context.get_merchant_key_store(),
+ encrypted_data
+ .billing_address
+ .map(common_utils::encryption::Encryption::from),
+ encrypted_data
+ .shipping_address
+ .map(common_utils::encryption::Encryption::from),
+ email_encrypted
+ .clone()
+ .map(common_utils::encryption::Encryption::from),
+ browser_info,
+ )
+ .await?;
+
+ let response = AuthenticationEligibilityResponse::foreign_try_from((
+ updated_authentication,
+ req.get_next_action_api(
+ state.base_url,
+ authentication_id.get_string_repr().to_string(),
+ )
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Unable to get next action api")?,
+ profile_id,
+ req.get_billing_address(),
+ req.get_shipping_address(),
+ req.get_browser_information(),
+ email_encrypted,
+ ))?;
+
+ Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(
+ response,
+ ))
+}
diff --git a/crates/router/src/core/unified_authentication_service/types.rs b/crates/router/src/core/unified_authentication_service/types.rs
index 12b385327c..6006976044 100644
--- a/crates/router/src/core/unified_authentication_service/types.rs
+++ b/crates/router/src/core/unified_authentication_service/types.rs
@@ -33,11 +33,16 @@ pub struct ExternalAuthentication;
#[async_trait::async_trait]
pub trait UnifiedAuthenticationService {
+ #[allow(clippy::too_many_arguments)]
fn get_pre_authentication_request_data(
_payment_method_data: Option<&domain::PaymentMethodData>,
_service_details: Option<payments::CtpServiceDetails>,
_amount: common_utils::types::MinorUnit,
_currency: Option<common_enums::Currency>,
+ _merchant_details: Option<&hyperswitch_domain_models::router_request_types::unified_authentication_service::MerchantDetails>,
+ _billing_address: Option<&hyperswitch_domain_models::address::Address>,
+ _acquirer_bin: Option<String>,
+ _acquirer_merchant_id: Option<String>,
) -> RouterResult<UasPreAuthenticationRequestData> {
Err(errors::ApiErrorResponse::NotImplemented {
message: NotImplementedMessage::Reason(
@@ -60,6 +65,10 @@ pub trait UnifiedAuthenticationService {
_amount: common_utils::types::MinorUnit,
_currency: Option<common_enums::Currency>,
_service_details: Option<payments::CtpServiceDetails>,
+ _merchant_details: Option<&hyperswitch_domain_models::router_request_types::unified_authentication_service::MerchantDetails>,
+ _billing_address: Option<&hyperswitch_domain_models::address::Address>,
+ _acquirer_bin: Option<String>,
+ _acquirer_merchant_id: Option<String>,
) -> RouterResult<hyperswitch_domain_models::types::UasPreAuthenticationRouterData> {
Err(errors::ApiErrorResponse::NotImplemented {
message: NotImplementedMessage::Reason("pre_authentication".to_string()),
diff --git a/crates/router/src/core/unified_authentication_service/utils.rs b/crates/router/src/core/unified_authentication_service/utils.rs
index 89b6c05909..99cbd3af2f 100644
--- a/crates/router/src/core/unified_authentication_service/utils.rs
+++ b/crates/router/src/core/unified_authentication_service/utils.rs
@@ -2,9 +2,10 @@ use std::marker::PhantomData;
use common_enums::enums::PaymentMethod;
use common_utils::ext_traits::{AsyncExt, ValueExt};
-use error_stack::ResultExt;
+use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
errors::api_error_response::ApiErrorResponse,
+ ext_traits::OptionExt,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse, RouterData},
router_data_v2::UasFlowData,
@@ -17,6 +18,7 @@ use super::types::{
IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_AUTHENTICATION_FLOW,
};
use crate::{
+ consts::DEFAULT_SESSION_EXPIRY,
core::{
errors::{utils::ConnectorErrorExt, RouterResult},
payments,
@@ -129,6 +131,7 @@ pub fn construct_uas_router_data<F: Clone, Req, Res>(
})
}
+#[allow(clippy::too_many_arguments)]
pub async fn external_authentication_update_trackers<F: Clone, Req>(
state: &SessionState,
router_data: RouterData<F, Req, UasAuthenticationResponseData>,
@@ -137,6 +140,10 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
hyperswitch_domain_models::router_request_types::authentication::AcquirerDetails,
>,
merchant_key_store: &hyperswitch_domain_models::merchant_key_store::MerchantKeyStore,
+ billing_address: Option<common_utils::encryption::Encryption>,
+ shipping_address: Option<common_utils::encryption::Encryption>,
+ email: Option<common_utils::encryption::Encryption>,
+ browser_info: Option<serde_json::Value>,
) -> RouterResult<diesel_models::authentication::Authentication> {
let authentication_update = match router_data.response {
Ok(response) => match response {
@@ -179,6 +186,10 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
acquirer_country_code: acquirer_details
.and_then(|acquirer_details| acquirer_details.acquirer_country_code),
directory_server_id: authentication_details.directory_server_id,
+ browser_info: Box::new(browser_info),
+ email,
+ billing_address,
+ shipping_address,
},
),
UasAuthenticationResponseData::Authentication {
@@ -309,3 +320,30 @@ pub fn get_checkout_event_status_and_reason(
),
}
}
+
+pub fn authenticate_authentication_client_secret_and_check_expiry(
+ req_client_secret: &String,
+ authentication: &diesel_models::authentication::Authentication,
+) -> RouterResult<bool> {
+ let stored_client_secret = authentication
+ .authentication_client_secret
+ .clone()
+ .get_required_value("authentication_client_secret")
+ .change_context(ApiErrorResponse::MissingRequiredField {
+ field_name: "client_secret",
+ })
+ .attach_printable("client secret not found in db")?;
+
+ if req_client_secret != &stored_client_secret {
+ Err(report!(ApiErrorResponse::ClientSecretInvalid))
+ } else {
+ let current_timestamp = common_utils::date_time::now();
+ let session_expiry = authentication
+ .created_at
+ .saturating_add(time::Duration::seconds(DEFAULT_SESSION_EXPIRY));
+
+ let expired = current_timestamp > session_expiry;
+
+ Ok(expired)
+ }
+}
diff --git a/crates/router/src/db/authentication.rs b/crates/router/src/db/authentication.rs
index 0c31e70fe2..cc892cc513 100644
--- a/crates/router/src/db/authentication.rs
+++ b/crates/router/src/db/authentication.rs
@@ -163,6 +163,11 @@ impl AuthenticationInterface for MockDb {
return_url: authentication.return_url,
amount: authentication.amount,
currency: authentication.currency,
+ billing_address: authentication.billing_address,
+ shipping_address: authentication.shipping_address,
+ browser_info: authentication.browser_info,
+ email: authentication.email,
+ profile_acquirer_id: authentication.profile_acquirer_id,
};
authentications.push(authentication.clone());
Ok(authentication)
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index cd132f0da6..1c904a7c6a 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -2707,6 +2707,10 @@ impl Authentication {
web::scope("/authentication")
.app_data(web::Data::new(state))
.service(web::resource("").route(web::post().to(authentication::authentication_create)))
+ .service(
+ web::resource("/{authentication_id}/eligibility")
+ .route(web::post().to(authentication::authentication_eligibility)),
+ )
}
}
diff --git a/crates/router/src/routes/authentication.rs b/crates/router/src/routes/authentication.rs
index 776a591e18..ce74daaa7c 100644
--- a/crates/router/src/routes/authentication.rs
+++ b/crates/router/src/routes/authentication.rs
@@ -1,5 +1,7 @@
use actix_web::{web, HttpRequest, Responder};
use api_models::authentication::AuthenticationCreateRequest;
+#[cfg(feature = "v1")]
+use api_models::authentication::AuthenticationEligibilityRequest;
use router_env::{instrument, tracing, Flow};
use crate::{
@@ -37,3 +39,45 @@ pub async fn authentication_create(
))
.await
}
+
+#[cfg(feature = "v1")]
+#[instrument(skip_all, fields(flow = ?Flow::AuthenticationEligibility))]
+pub async fn authentication_eligibility(
+ state: web::Data<app::AppState>,
+ req: HttpRequest,
+ json_payload: web::Json<AuthenticationEligibilityRequest>,
+ path: web::Path<common_utils::id_type::AuthenticationId>,
+) -> impl Responder {
+ let flow = Flow::AuthenticationEligibility;
+
+ let api_auth = auth::ApiKeyAuth::default();
+ let payload = json_payload.into_inner();
+
+ let (auth, _) = match auth::check_client_secret_and_get_auth(req.headers(), &payload, api_auth)
+ {
+ Ok((auth, _auth_flow)) => (auth, _auth_flow),
+ Err(e) => return api::log_and_return_error_response(e),
+ };
+
+ let authentication_id = path.into_inner();
+ Box::pin(api::server_wrap(
+ flow,
+ state,
+ &req,
+ payload,
+ |state, auth: auth::AuthenticationData, req, _| {
+ let merchant_context = domain::MerchantContext::NormalMerchant(Box::new(
+ domain::Context(auth.merchant_account, auth.key_store),
+ ));
+ unified_authentication_service::authentication_eligibility_core(
+ state,
+ merchant_context,
+ req,
+ authentication_id.clone(),
+ )
+ },
+ &*auth,
+ api_locking::LockAction::NotApplicable,
+ ))
+ .await
+}
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index fda52ad9b0..2d6dfb49aa 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -353,7 +353,7 @@ impl From<Flow> for ApiIdentifier {
Flow::RevenueRecoveryRetrieve => Self::ProcessTracker,
- Flow::AuthenticationCreate => Self::Authentication,
+ Flow::AuthenticationCreate | Flow::AuthenticationEligibility => Self::Authentication,
Flow::Proxy => Self::Proxy,
Flow::ProfileAcquirerCreate | Flow::ProfileAcquirerUpdate => Self::ProfileAcquirer,
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index 564c9f9d3e..aec5ce8270 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -4218,6 +4218,15 @@ impl ClientSecretFetch for api_models::payment_methods::PaymentMethodUpdate {
}
}
+#[cfg(feature = "v1")]
+impl ClientSecretFetch for api_models::authentication::AuthenticationEligibilityRequest {
+ fn get_client_secret(&self) -> Option<&String> {
+ self.client_secret
+ .as_ref()
+ .map(|client_secret| client_secret.peek())
+ }
+}
+
pub fn get_auth_type_and_flow<A: SessionStateInfo + Sync + Send>(
headers: &HeaderMap,
api_auth: ApiKeyAuth,
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index 155c522337..bad490dddf 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -602,6 +602,8 @@ pub enum Flow {
CloneConnector,
/// Authentication Create flow
AuthenticationCreate,
+ /// Authentication Eligibility flow
+ AuthenticationEligibility,
///Proxy Flow
Proxy,
/// Profile Acquirer Create flow
diff --git a/migrations/2025-06-24-172453_add_new_fields_to_authentication_table/down.sql b/migrations/2025-06-24-172453_add_new_fields_to_authentication_table/down.sql
new file mode 100644
index 0000000000..eddf0495a6
--- /dev/null
+++ b/migrations/2025-06-24-172453_add_new_fields_to_authentication_table/down.sql
@@ -0,0 +1,9 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE authentication
+DROP COLUMN IF EXISTS billing_address,
+DROP COLUMN IF EXISTS shipping_address,
+DROP COLUMN IF EXISTS browser_info,
+DROP COLUMN IF EXISTS email,
+DROP COLUMN IF EXISTS amount,
+DROP COLUMN IF EXISTS currency,
+DROP COLUMN IF EXISTS profile_acquirer_id;
diff --git a/migrations/2025-06-24-172453_add_new_fields_to_authentication_table/up.sql b/migrations/2025-06-24-172453_add_new_fields_to_authentication_table/up.sql
new file mode 100644
index 0000000000..1ce6817aa6
--- /dev/null
+++ b/migrations/2025-06-24-172453_add_new_fields_to_authentication_table/up.sql
@@ -0,0 +1,9 @@
+-- Your SQL goes here
+ALTER TABLE authentication
+ADD COLUMN IF NOT EXISTS billing_address BYTEA,
+ADD COLUMN IF NOT EXISTS shipping_address BYTEA,
+ADD COLUMN IF NOT EXISTS browser_info JSONB,
+ADD COLUMN IF NOT EXISTS email BYTEA,
+ADD COLUMN IF NOT EXISTS amount bigint,
+ADD COLUMN IF NOT EXISTS currency "Currency",
+ADD COLUMN IF NOT EXISTS profile_acquirer_id VARCHAR(128) NULL;
\ No newline at end of file