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(router): add domain types, admin core changes and other prerequisites for 3ds external authentication flow (#3962)

Sai Harsha Vardhan4902c4034525
diff --git a/crates/cards/src/validate.rs b/crates/cards/src/validate.rs
index 0bb07b83dc..ffe96fc13d 100644
--- a/crates/cards/src/validate.rs
+++ b/crates/cards/src/validate.rs
@@ -51,12 +51,13 @@ impl FromStr for CardNumber {
type Err = CCValError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
- match luhn::valid(s) {
- true => {
- let cc_no_whitespace: String = s.split_whitespace().collect();
- Ok(Self(StrongSecret::from_str(&cc_no_whitespace)?))
- }
- false => Err(CCValError),
+ // Valid test cards for threedsecureio
+ let valid_test_cards = ["4000100511112003", "6000100611111203", "3000100811111072"];
+ if luhn::valid(s) || valid_test_cards.contains(&s) {
+ let cc_no_whitespace: String = s.split_whitespace().collect();
+ Ok(Self(StrongSecret::from_str(&cc_no_whitespace)?))
+ } else {
+ Err(CCValError)
}
}
}
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index f04c52042e..9cf138ed33 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -2100,6 +2100,7 @@ pub enum PaymentSource {
Dashboard,
Sdk,
Webhook,
+ ExternalAuthenticator,
}
#[derive(
diff --git a/crates/diesel_models/src/lib.rs b/crates/diesel_models/src/lib.rs
index f7678793bc..44e4d17453 100644
--- a/crates/diesel_models/src/lib.rs
+++ b/crates/diesel_models/src/lib.rs
@@ -6,6 +6,7 @@ pub mod capture;
pub mod cards_info;
pub mod configs;
+pub mod authentication;
pub mod authorization;
pub mod blocklist;
pub mod blocklist_fingerprint;
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index 87a16b73a8..26598493c8 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -96,5 +96,7 @@ pub const MIN_SESSION_EXPIRY: u32 = 60;
pub const LOCKER_HEALTH_CALL_PATH: &str = "/health";
+pub const AUTHENTICATION_ID_PREFIX: &str = "authn";
+
// URL for checking the outgoing call
pub const OUTGOING_CALL_URL: &str = "https://api.stripe.com/healthcheck";
diff --git a/crates/router/src/core.rs b/crates/router/src/core.rs
index 50bae175f6..704ac31b73 100644
--- a/crates/router/src/core.rs
+++ b/crates/router/src/core.rs
@@ -1,6 +1,7 @@
pub mod admin;
pub mod api_keys;
pub mod api_locking;
+pub mod authentication;
pub mod blocklist;
pub mod cache;
pub mod cards_info;
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index c2ed8e1c75..8a12fee5da 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -782,6 +782,8 @@ pub async fn create_payment_connector(
let pm_auth_connector =
api_enums::convert_pm_auth_connector(req.connector_name.to_string().as_str());
+ let authentication_connector =
+ api_enums::convert_authentication_connector(req.connector_name.to_string().as_str());
if pm_auth_connector.is_some() {
if req.connector_type != api_enums::ConnectorType::PaymentMethodAuth {
@@ -790,6 +792,13 @@ pub async fn create_payment_connector(
})
.into_report();
}
+ } else if authentication_connector.is_some() {
+ if req.connector_type != api_enums::ConnectorType::AuthenticationProcessor {
+ return Err(errors::ApiErrorResponse::InvalidRequestData {
+ message: "Invalid connector type given".to_string(),
+ })
+ .into_report();
+ }
} else {
let routable_connector_option = req
.connector_name
@@ -1657,7 +1666,14 @@ pub async fn update_business_profile(
applepay_verified_domains: request.applepay_verified_domains,
payment_link_config,
session_expiry: request.session_expiry.map(i64::from),
- authentication_connector_details: None,
+ authentication_connector_details: request
+ .authentication_connector_details
+ .as_ref()
+ .map(Encode::encode_to_value)
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidDataValue {
+ field_name: "authentication_connector_details",
+ })?,
};
let updated_business_profile = db
diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs
new file mode 100644
index 0000000000..cd408564ea
--- /dev/null
+++ b/crates/router/src/core/authentication.rs
@@ -0,0 +1 @@
+pub mod types;
diff --git a/crates/router/src/core/authentication/types.rs b/crates/router/src/core/authentication/types.rs
new file mode 100644
index 0000000000..c6816bacf8
--- /dev/null
+++ b/crates/router/src/core/authentication/types.rs
@@ -0,0 +1,61 @@
+use cards::CardNumber;
+use serde::{Deserialize, Serialize};
+
+use crate::{
+ core::payments,
+ types::{authentication::AuthNFlowType, storage},
+};
+pub enum PreAuthenthenticationFlowInput<'a, F: Clone> {
+ PaymentAuthNFlow {
+ payment_data: &'a mut payments::PaymentData<F>,
+ should_continue_confirm_transaction: &'a mut bool,
+ card_number: CardNumber,
+ },
+ PaymentMethodAuthNFlow {
+ card_number: CardNumber,
+ other_fields: String, //should be expanded when implementation begins
+ },
+}
+
+pub enum PostAuthenthenticationFlowInput<'a, F: Clone> {
+ PaymentAuthNFlow {
+ payment_data: &'a mut payments::PaymentData<F>,
+ authentication_data: (storage::Authentication, AuthenticationData),
+ should_continue_confirm_transaction: &'a mut bool,
+ },
+ PaymentMethodAuthNFlow {
+ other_fields: String, //should be expanded when implementation begins
+ },
+}
+
+#[derive(Clone, Default, Debug, Serialize, Deserialize)]
+pub struct AuthenticationData {
+ pub maximum_supported_version: (i64, i64, i64),
+ pub threeds_server_transaction_id: String,
+ pub cavv: Option<String>,
+ pub authn_flow_type: Option<AuthNFlowType>,
+ pub three_ds_method_data: ThreeDsMethodData,
+ pub message_version: String,
+ pub eci: Option<String>,
+ pub trans_status: api_models::payments::TransactionStatus,
+ pub acquirer_details: Option<AcquirerDetails>,
+}
+
+impl AuthenticationData {
+ pub fn is_separate_authn_required(&self) -> bool {
+ self.maximum_supported_version.0 == 2
+ }
+}
+
+#[derive(Clone, Default, Debug, Serialize, Deserialize)]
+pub struct ThreeDsMethodData {
+ pub three_ds_method_data_submission: bool,
+ pub three_ds_method_data: String,
+ pub three_ds_method_url: Option<String>,
+}
+
+#[derive(Clone, Default, Debug, Serialize, Deserialize)]
+pub struct AcquirerDetails {
+ pub acquirer_bin: String,
+ pub acquirer_merchant_id: String,
+}
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index d69f668bf9..eac16fa339 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -2271,3 +2271,126 @@ default_imp_for_revoking_mandates!(
connector::Worldpay,
connector::Zen
);
+
+macro_rules! default_imp_for_connector_authentication {
+ ($($path:ident::$connector:ident),*) => {
+ $( impl api::ExternalAuthentication for $path::$connector {}
+ impl api::ConnectorAuthentication for $path::$connector {}
+ impl api::ConnectorPreAuthentication for $path::$connector {}
+ impl api::ConnectorPostAuthentication for $path::$connector {}
+ impl
+ services::ConnectorIntegration<
+ api::Authentication,
+ types::authentication::ConnectorAuthenticationRequestData,
+ types::authentication::AuthenticationResponseData,
+ > for $path::$connector
+ {}
+ impl
+ services::ConnectorIntegration<
+ api::PreAuthentication,
+ types::authentication::PreAuthNRequestData,
+ types::authentication::AuthenticationResponseData,
+ > for $path::$connector
+ {}
+ impl
+ services::ConnectorIntegration<
+ api::PostAuthentication,
+ types::authentication::ConnectorPostAuthenticationRequestData,
+ types::authentication::AuthenticationResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8> api::ExternalAuthentication for connector::DummyConnector<T> {}
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8> api::ConnectorPreAuthentication for connector::DummyConnector<T> {}
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8> api::ConnectorAuthentication for connector::DummyConnector<T> {}
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8> api::ConnectorPostAuthentication for connector::DummyConnector<T> {}
+
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8>
+ services::ConnectorIntegration<
+ api::Authentication,
+ types::authentication::ConnectorAuthenticationRequestData,
+ types::authentication::AuthenticationResponseData,
+ > for connector::DummyConnector<T>
+{
+}
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8>
+ services::ConnectorIntegration<
+ api::PreAuthentication,
+ types::authentication::PreAuthNRequestData,
+ types::authentication::AuthenticationResponseData,
+ > for connector::DummyConnector<T>
+{
+}
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8>
+ services::ConnectorIntegration<
+ api::PostAuthentication,
+ types::authentication::ConnectorPostAuthenticationRequestData,
+ types::authentication::AuthenticationResponseData,
+ > for connector::DummyConnector<T>
+{
+}
+default_imp_for_connector_authentication!(
+ connector::Aci,
+ connector::Adyen,
+ connector::Airwallex,
+ connector::Authorizedotnet,
+ connector::Bambora,
+ connector::Bankofamerica,
+ connector::Bitpay,
+ connector::Bluesnap,
+ connector::Boku,
+ connector::Braintree,
+ connector::Cashtocode,
+ connector::Checkout,
+ connector::Cryptopay,
+ connector::Coinbase,
+ connector::Cybersource,
+ connector::Dlocal,
+ connector::Fiserv,
+ connector::Forte,
+ connector::Globalpay,
+ connector::Globepay,
+ connector::Gocardless,
+ connector::Helcim,
+ connector::Iatapay,
+ connector::Klarna,
+ connector::Mollie,
+ connector::Multisafepay,
+ connector::Nexinets,
+ connector::Nmi,
+ connector::Noon,
+ connector::Nuvei,
+ connector::Opayo,
+ connector::Opennode,
+ connector::Payeezy,
+ connector::Payme,
+ connector::Paypal,
+ connector::Payu,
+ connector::Placetopay,
+ connector::Powertranz,
+ connector::Prophetpay,
+ connector::Rapyd,
+ connector::Riskified,
+ connector::Signifyd,
+ connector::Square,
+ connector::Stax,
+ connector::Stripe,
+ connector::Shift4,
+ connector::Trustpay,
+ connector::Tsys,
+ connector::Volt,
+ connector::Wise,
+ connector::Worldline,
+ connector::Worldpay,
+ connector::Zen
+);
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index bf64d3ceac..983313592a 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -635,6 +635,7 @@ pub async fn refresh_kgraph_cache(
mca.connector_type != storage_enums::ConnectorType::PaymentVas
&& mca.connector_type != storage_enums::ConnectorType::PaymentMethodAuth
&& mca.connector_type != storage_enums::ConnectorType::PayoutProcessor
+ && mca.connector_type != storage_enums::ConnectorType::AuthenticationProcessor
});
}
#[cfg(feature = "payouts")]
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 8ccab155c6..3cb11d1c0e 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -1141,6 +1141,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
| Some(RequestIncrementalAuthorization::Default)
),
metadata: additional_data.payment_data.payment_intent.metadata,
+ authentication_data: None,
customer_acceptance: payment_data.customer_acceptance,
})
}
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index 77151b3a0f..08b250e94b 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -114,7 +114,9 @@ impl From<Flow> for ApiIdentifier {
| Flow::PaymentsStart
| Flow::PaymentsList
| Flow::PaymentsRedirect
- | Flow::PaymentsIncrementalAuthorization => Self::Payments,
+ | Flow::PaymentsIncrementalAuthorization
+ | Flow::PaymentsExternalAuthentication
+ | Flow::PaymentsAuthorize => Self::Payments,
Flow::PayoutsCreate
| Flow::PayoutsRetrieve
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 106872fb43..5b609b072c 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -7,6 +7,7 @@
// Separation of concerns instead of separation of forms.
pub mod api;
+pub mod authentication;
pub mod domain;
#[cfg(feature = "frm")]
pub mod fraud_check;
@@ -35,6 +36,7 @@ pub use crate::core::payments::{CustomerDetails, PaymentAddress};
use crate::core::utils::IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_DISPUTE_FLOW;
use crate::{
core::{
+ authentication as authentication_core,
errors::{self, RouterResult},
payments::{types, PaymentData, RecurringMandatePaymentData},
},
@@ -422,6 +424,7 @@ pub struct PaymentsAuthorizeData {
pub customer_id: Option<String>,
pub request_incremental_authorization: bool,
pub metadata: Option<pii::SecretSerdeValue>,
+ pub authentication_data: Option<authentication_core::types::AuthenticationData>,
}
#[derive(Debug, Clone, Default)]
@@ -1425,6 +1428,7 @@ impl From<&SetupMandateRouterData> for PaymentsAuthorizeData {
surcharge_details: None,
request_incremental_authorization: data.request.request_incremental_authorization,
metadata: None,
+ authentication_data: None,
customer_acceptance: data.request.customer_acceptance.clone(),
}
}
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 009033d534..9b9e242431 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -1,5 +1,6 @@
pub mod admin;
pub mod api_keys;
+pub mod authentication;
pub mod configs;
#[cfg(feature = "olap")]
pub mod connector_onboarding;
@@ -28,8 +29,8 @@ use error_stack::{report, IntoReport, ResultExt};
#[cfg(feature = "frm")]
pub use self::fraud_check::*;
pub use self::{
- admin::*, api_keys::*, configs::*, customers::*, disputes::*, files::*, payment_link::*,
- payment_methods::*, payments::*, payouts::*, refunds::*, webhooks::*,
+ admin::*, api_keys::*, authentication::*, configs::*, customers::*, disputes::*, files::*,
+ payment_link::*, payment_methods::*, payments::*, payouts::*, refunds::*, webhooks::*,
};
use super::ErrorResponse;
use crate::{
@@ -174,6 +175,7 @@ pub trait Connector:
+ ConnectorVerifyWebhookSource
+ FraudCheck
+ ConnectorMandateRevoke
+ + ExternalAuthentication
{
}
@@ -195,7 +197,8 @@ impl<
+ Payouts
+ ConnectorVerifyWebhookSource
+ FraudCheck
- + ConnectorMandateRevoke,
+ + ConnectorMandateRevoke
+ + ExternalAuthentication,
> Connector for T
{
}
diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rs
index dd7f462e1c..b293f85eb1 100644
--- a/crates/router/src/types/api/admin.rs
+++ b/crates/router/src/types/api/admin.rs
@@ -72,7 +72,12 @@ impl ForeignTryFrom<storage::business_profile::BusinessProfile> for BusinessProf
applepay_verified_domains: item.applepay_verified_domains,
payment_link_config: item.payment_link_config,
session_expiry: item.session_expiry,
- authentication_connector_details: None,
+ authentication_connector_details: item
+ .authentication_connector_details
+ .map(|authentication_connector_details| {
+ authentication_connector_details.parse_value("AuthenticationDetails")
+ })
+ .transpose()?,
})
}
}
@@ -158,7 +163,14 @@ impl ForeignTryFrom<(domain::MerchantAccount, BusinessProfileCreate)>
.session_expiry
.map(i64::from)
.or(Some(common_utils::consts::DEFAULT_SESSION_EXPIRY)),
- authentication_connector_details: None,
+ authentication_connector_details: request
+ .authentication_connector_details
+ .as_ref()
+ .map(Encode::encode_to_value)
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidDataValue {
+ field_name: "authentication_connector_details",
+ })?,
})
}
}
diff --git a/crates/router/src/types/api/authentication.rs b/crates/router/src/types/api/authentication.rs
new file mode 100644
index 0000000000..4c662c08fa
--- /dev/null
+++ b/crates/router/src/types/api/authentication.rs
@@ -0,0 +1,84 @@
+use api_models::enums;
+
+use super::BoxedConnector;
+
+#[derive(Debug, Clone)]
+pub struct PreAuthentication;
+
+#[derive(Debug, Clone)]
+pub struct Authentication;
+
+#[derive(Debug, Clone)]
+pub struct PostAuthentication;
+use crate::{services, types};
+
+#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]
+pub struct AcquirerDetails {
+ pub acquirer_bin: String,
+ pub acquirer_merchant_mid: String,
+}
+
+#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]
+pub struct AuthenticationResponse {
+ pub trans_status: api_models::payments::TransactionStatus,
+ pub acs_url: Option<url::Url>,
+ pub challenge_request: Option<String>,
+ pub acs_reference_number: Option<String>,
+ pub acs_trans_id: Option<String>,
+ pub three_dsserver_trans_id: Option<String>,
+ pub acs_signed_content: Option<String>,
+}
+
+#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]
+pub struct PostAuthenticationResponse {
+ pub trans_status: String,
+ pub authentication_value: Option<String>,
+ pub eci: Option<String>,
+}
+
+#[derive(Clone, serde::Deserialize, Debug, serde::Serialize, PartialEq, Eq)]
+pub enum MessageCategory {
+ Payment,
+ NonPayment,
+}
+
+pub trait ConnectorAuthentication:
+ services::ConnectorIntegration<
+ Authentication,
+ types::authentication::ConnectorAuthenticationRequestData,
+ types::authentication::AuthenticationResponseData,
+>
+{
+}
+
+pub trait ConnectorPreAuthentication:
+ services::ConnectorIntegration<
+ PreAuthentication,
+ types::authentication::PreAuthNRequestData,
+ types::authentication::AuthenticationResponseData,
+>
+{
+}
+
+pub trait ConnectorPostAuthentication:
+ services::ConnectorIntegration<
+ PostAuthentication,
+ types::authentication::ConnectorPostAuthenticationRequestData,
+ types::authentication::AuthenticationResponseData,
+>
+{
+}
+
+pub trait ExternalAuthentication:
+ super::ConnectorCommon
+ + ConnectorAuthentication
+ + ConnectorPreAuthentication
+ + ConnectorPostAuthentication
+{
+}
+
+#[derive(Clone, Debug)]
+pub struct AuthenticationConnectorData {
+ pub connector: BoxedConnector,
+ pub connector_name: enums::AuthenticationConnectors,
+}
diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs
index 1204ba79ac..8e13f6c993 100644
--- a/crates/router/src/types/api/payments.rs
+++ b/crates/router/src/types/api/payments.rs
@@ -6,11 +6,12 @@ pub use api_models::payments::{
PaymentListFilters, PaymentListResponse, PaymentListResponseV2, PaymentMethodData,
PaymentMethodDataRequest, PaymentMethodDataResponse, PaymentOp, PaymentRetrieveBody,
PaymentRetrieveBodyWithCredentials, PaymentsApproveRequest, PaymentsCancelRequest,
- PaymentsCaptureRequest, PaymentsIncrementalAuthorizationRequest, PaymentsRedirectRequest,
- PaymentsRedirectionResponse, PaymentsRejectRequest, PaymentsRequest, PaymentsResponse,
- PaymentsResponseForm, PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse,
- PaymentsStartRequest, PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken,
- TimeRange, UrlDetails, VerifyRequest, VerifyResponse, WalletData,
+ PaymentsCaptureRequest, PaymentsExternalAuthenticationRequest,
+ PaymentsIncrementalAuthorizationRequest, PaymentsRedirectRequest, PaymentsRedirectionResponse,
+ PaymentsRejectRequest, PaymentsRequest, PaymentsResponse, PaymentsResponseForm,
+ PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest,
+ PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, TimeRange, UrlDetails,
+ VerifyRequest, VerifyResponse, WalletData,
};
use error_stack::{IntoReport, ResultExt};
diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs
index 4f3d6f7e29..c1d2ebde44 100644
--- a/crates/router/src/types/api/verify_connector.rs
+++ b/crates/router/src/types/api/verify_connector.rs
@@ -50,6 +50,7 @@ impl VerifyConnectorData {
related_transaction_id: None,
statement_descriptor_suffix: None,
request_incremental_authorization: false,
+ authentication_data: None,
customer_acceptance: None,
}
}
diff --git a/crates/router/src/types/authentication.rs b/crates/router/src/types/authentication.rs
new file mode 100644
index 0000000000..dfce745e79
--- /dev/null
+++ b/crates/router/src/types/authentication.rs
@@ -0,0 +1,111 @@
+use api_models::payments;
+use cards::CardNumber;
+use common_utils::pii::Email;
+use serde::{Deserialize, Serialize};
+
+use super::{
+ api::{self, authentication},
+ storage, BrowserInformation, RouterData,
+};
+use crate::services;
+
+#[derive(Debug, Clone)]
+pub enum AuthenticationResponseData {
+ PreAuthNResponse {
+ threeds_server_transaction_id: String,
+ maximum_supported_3ds_version: (i64, i64, i64),
+ connector_authentication_id: String,
+ three_ds_method_data: String,
+ three_ds_method_url: Option<String>,
+ message_version: String,
+ connector_metadata: Option<serde_json::Value>,
+ },
+ AuthNResponse {
+ authn_flow_type: AuthNFlowType,
+ cavv: Option<String>,
+ trans_status: api_models::payments::TransactionStatus,
+ },
+ PostAuthNResponse {
+ trans_status: api_models::payments::TransactionStatus,
+ authentication_value: Option<String>,
+ eci: Option<String>,
+ },
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct ChallengeParams {
+ pub acs_url: Option<url::Url>,
+ pub challenge_request: Option<String>,
+ pub acs_reference_number: Option<String>,
+ pub acs_trans_id: Option<String>,
+ pub three_dsserver_trans_id: Option<String>,
+ pub acs_signed_content: Option<String>,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub enum AuthNFlowType {
+ Challenge(Box<ChallengeParams>),
+ Frictionless,
+}
+
+#[derive(Clone, Default, Debug)]
+pub struct PreAuthNRequestData {
+ // card number
+ pub card_holder_account_number: CardNumber,
+}
+
+#[derive(Clone, Debug)]
+pub struct ConnectorAuthenticationRequestData {
+ pub payment_method_data: payments::PaymentMethodData,
+ pub billing_address: api_models::payments::Address,
+ pub shipping_address: Option<api_models::payments::Address>,
+ pub browser_details: Option<BrowserInformation>,
+ pub amount: Option<i64>,
+ pub currency: Option<common_enums::Currency>,
+ pub message_category: authentication::MessageCategory,
+ pub device_channel: api_models::payments::DeviceChannel,
+ pub authentication_data: (
+ crate::core::authentication::types::AuthenticationData,
+ storage::Authentication,
+ ),
+ pub return_url: Option<String>,
+ pub sdk_information: Option<api_models::payments::SdkInformation>,
+ pub email: Option<Email>,
+ pub threeds_method_comp_ind: api_models::payments::ThreeDsCompletionIndicator,
+ pub three_ds_requestor_url: String,
+}
+
+#[derive(Clone, Debug)]
+pub struct ConnectorPostAuthenticationRequestData {
+ pub authentication_data: crate::core::authentication::types::AuthenticationData,
+}
+
+pub type PreAuthNRouterData =
+ RouterData<api::PreAuthentication, PreAuthNRequestData, AuthenticationResponseData>;
+
+pub type ConnectorAuthenticationRouterData =
+ RouterData<api::Authentication, ConnectorAuthenticationRequestData, AuthenticationResponseData>;
+
+pub type ConnectorPostAuthenticationRouterData = RouterData<
+ api::PostAuthentication,
+ ConnectorPostAuthenticationRequestData,
+ AuthenticationResponseData,
+>;
+
+pub type ConnectorAuthenticationType = dyn services::ConnectorIntegration<
+ api::Authentication,
+ ConnectorAuthenticationRequestData,
+ AuthenticationResponseData,
+>;
+
+pub type ConnectorPostAuthenticationType = dyn services::ConnectorIntegration<
+ api::PostAuthentication,
+ ConnectorPostAuthenticationRequestData,
+ AuthenticationResponseData,
+>;
+
+pub type ConnectorPreAuthenticationType = dyn services::ConnectorIntegration<
+ api::PreAuthentication,
+ PreAuthNRequestData,
+ AuthenticationResponseData,
+>;
diff --git a/crates/router/src/types/storage.rs b/crates/router/src/types/storage.rs
index 3e3d3b5d1f..4baa72c1eb 100644
--- a/crates/router/src/types/storage.rs
+++ b/crates/router/src/types/storage.rs
@@ -1,5 +1,6 @@
pub mod address;
pub mod api_keys;
+pub mod authentication;
pub mod authorization;
pub mod blocklist;
pub mod blocklist_fingerprint;
@@ -49,13 +50,13 @@ pub use diesel_models::{
pub use scheduler::db::process_tracker;
pub use self::{
- address::*, api_keys::*, authorization::*, blocklist::*, blocklist_fingerprint::*,
- blocklist_lookup::*, business_profile::*, capture::*, cards_info::*, configs::*, customers::*,
- dashboard_metadata::*, dispute::*, ephemeral_key::*, events::*, file::*, fraud_check::*,
- gsm::*, locker_mock_up::*, mandate::*, merchant_account::*, merchant_connector_account::*,
- merchant_key_store::*, payment_link::*, payment_method::*, payout_attempt::*, payouts::*,
- process_tracker::*, refund::*, reverse_lookup::*, role::*, routing_algorithm::*, user::*,
- user_role::*,
+ address::*, api_keys::*, authentication::*, authorization::*, blocklist::*,
+ blocklist_fingerprint::*, blocklist_lookup::*, business_profile::*, capture::*, cards_info::*,
+ configs::*, customers::*, dashboard_metadata::*, dispute::*, ephemeral_key::*, events::*,
+ file::*, fraud_check::*, gsm::*, locker_mock_up::*, mandate::*, merchant_account::*,
+ merchant_connector_account::*, merchant_key_store::*, payment_link::*, payment_method::*,
+ payout_attempt::*, payouts::*, process_tracker::*, refund::*, reverse_lookup::*, role::*,
+ routing_algorithm::*, user::*, user_role::*,
};
use crate::types::api::routing;
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 5b2952fe6b..f30682500a 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -13,9 +13,12 @@ use masking::{ExposeInterface, PeekInterface};
use super::domain;
use crate::{
- core::errors,
+ core::{authentication::types::AuthenticationData, errors},
services::authentication::get_header_value_by_key,
- types::{api as api_types, api::routing as routing_types, storage},
+ types::{
+ api::{self as api_types, routing as routing_types},
+ storage,
+ },
};
pub trait ForeignInto<T> {
@@ -713,6 +716,35 @@ impl ForeignFrom<storage::Authorization> for payments::IncrementalAuthorizationR
}
}
+impl ForeignFrom<&(storage::Authentication, AuthenticationData)>
+ for payments::ExternalAuthenticationDetailsResponse
+{
+ fn foreign_from(authn_data: &(storage::Authentication, AuthenticationData)) -> Self {
+ let (ds_transaction_id, version) = if authn_data.0.authentication_data.is_some() {
+ (
+ Some(authn_data.1.threeds_server_transaction_id.clone()),
+ Some(format!(
+ "{}.{}.{}",
+ authn_data.1.maximum_supported_version.0,
+ authn_data.1.maximum_supported_version.1,
+ authn_data.1.maximum_supported_version.2
+ )),
+ )
+ } else {
+ (None, None)
+ };
+ Self {
+ authentication_flow: authn_data.0.authentication_type,
+ electronic_commerce_indicator: authn_data.1.eci.clone(),
+ status: authn_data.0.authentication_status,
+ ds_transaction_id,
+ version,
+ error_code: authn_data.0.error_code.clone(),
+ error_message: authn_data.0.error_message.clone(),
+ }
+ }
+}
+
impl ForeignFrom<storage::Dispute> for api_models::disputes::DisputeResponsePaymentsRetrieve {
fn foreign_from(dispute: storage::Dispute) -> Self {
Self {
diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs
index 5c4660805f..b781ef08f3 100644
--- a/crates/router/tests/connectors/aci.rs
+++ b/crates/router/tests/connectors/aci.rs
@@ -72,6 +72,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
},
response: Err(types::ErrorResponse::default()),
diff --git a/crates/router/tests/connectors/adyen.rs b/crates/router/tests/connectors/adyen.rs
index 55f9f6b4b6..80aa57f911 100644
--- a/crates/router/tests/connectors/adyen.rs
+++ b/crates/router/tests/connectors/adyen.rs
@@ -170,6 +170,7 @@ impl AdyenTest {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
})
}
diff --git a/crates/router/tests/connectors/bitpay.rs b/crates/router/tests/connectors/bitpay.rs
index 93043f37c9..e343cb4775 100644
--- a/crates/router/tests/connectors/bitpay.rs
+++ b/crates/router/tests/connectors/bitpay.rs
@@ -96,6 +96,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
})
}
diff --git a/crates/router/tests/connectors/cashtocode.rs b/crates/router/tests/connectors/cashtocode.rs
index 7dd70d8669..9404641c68 100644
--- a/crates/router/tests/connectors/cashtocode.rs
+++ b/crates/router/tests/connectors/cashtocode.rs
@@ -70,6 +70,7 @@ impl CashtocodeTest {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
})
}
diff --git a/crates/router/tests/connectors/coinbase.rs b/crates/router/tests/connectors/coinbase.rs
index b1fffb302c..2492ed0c93 100644
--- a/crates/router/tests/connectors/coinbase.rs
+++ b/crates/router/tests/connectors/coinbase.rs
@@ -98,6 +98,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
})
}
diff --git a/crates/router/tests/connectors/cryptopay.rs b/crates/router/tests/connectors/cryptopay.rs
index 6eaf514db2..c1bb499ecc 100644
--- a/crates/router/tests/connectors/cryptopay.rs
+++ b/crates/router/tests/connectors/cryptopay.rs
@@ -96,6 +96,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
})
}
diff --git a/crates/router/tests/connectors/opennode.rs b/crates/router/tests/connectors/opennode.rs
index 4702012597..3cae40c91a 100644
--- a/crates/router/tests/connectors/opennode.rs
+++ b/crates/router/tests/connectors/opennode.rs
@@ -97,6 +97,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
})
}
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index 83380f7607..fd19d06322 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -915,6 +915,7 @@ impl Default for PaymentAuthorizeType {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
};
Self(data)
diff --git a/crates/router/tests/connectors/worldline.rs b/crates/router/tests/connectors/worldline.rs
index ba946b296b..39c305849a 100644
--- a/crates/router/tests/connectors/worldline.rs
+++ b/crates/router/tests/connectors/worldline.rs
@@ -106,6 +106,7 @@ impl WorldlineTest {
surcharge_details: None,
request_incremental_authorization: false,
metadata: None,
+ authentication_data: None,
customer_acceptance: None,
})
}
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index 253656a4b1..abf5d1206e 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -376,6 +376,10 @@ pub enum Flow {
UpdateUserAccountDetails,
/// Accept user invitation
AcceptInvitation,
+ /// Initiate external authentication for a payment
+ PaymentsExternalAuthentication,
+ /// Authorize the payment after external 3ds authentication
+ PaymentsAuthorize,
/// Create Role
CreateRole,
/// Update Role
diff --git a/migrations/2024-02-11-092812_add_authentication_processor_enum_to_ConnectorType/down.sql b/migrations/2024-02-11-092812_add_authentication_processor_enum_to_ConnectorType/down.sql
new file mode 100644
index 0000000000..c7c9cbeb40
--- /dev/null
+++ b/migrations/2024-02-11-092812_add_authentication_processor_enum_to_ConnectorType/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+SELECT 1;
\ No newline at end of file
diff --git a/migrations/2024-02-11-092812_add_authentication_processor_enum_to_ConnectorType/up.sql b/migrations/2024-02-11-092812_add_authentication_processor_enum_to_ConnectorType/up.sql
new file mode 100644
index 0000000000..6105491c4c
--- /dev/null
+++ b/migrations/2024-02-11-092812_add_authentication_processor_enum_to_ConnectorType/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+ALTER TYPE "ConnectorType" ADD VALUE IF NOT EXISTS 'authentication_processor';
diff --git a/migrations/2024-02-27-130532_add_enum_types_to_payment-source_enum/down.sql b/migrations/2024-02-27-130532_add_enum_types_to_payment-source_enum/down.sql
new file mode 100644
index 0000000000..c7c9cbeb40
--- /dev/null
+++ b/migrations/2024-02-27-130532_add_enum_types_to_payment-source_enum/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+SELECT 1;
\ No newline at end of file
diff --git a/migrations/2024-02-27-130532_add_enum_types_to_payment-source_enum/up.sql b/migrations/2024-02-27-130532_add_enum_types_to_payment-source_enum/up.sql
new file mode 100644
index 0000000000..caa80c5234
--- /dev/null
+++ b/migrations/2024-02-27-130532_add_enum_types_to_payment-source_enum/up.sql
@@ -0,0 +1,3 @@
+-- Your SQL goes here
+ALTER TYPE "PaymentSource" ADD VALUE 'webhook';
+ALTER TYPE "PaymentSource" ADD VALUE 'external_authenticator';
\ No newline at end of file