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(core): add support for confirmation flow for click to pay (#6982)

Sahkal Poddar74bbf4bf271d
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
index b953fa7375..20db1648e9 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
@@ -1270,13 +1270,13 @@ impl
ucaf_collection_indicator: None,
cavv,
ucaf_authentication_data,
- xid: Some(authn_data.threeds_server_transaction_id.clone()),
+ xid: authn_data.threeds_server_transaction_id.clone(),
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
.map(Secret::new),
specification_version: None,
- pa_specification_version: Some(authn_data.message_version.clone()),
+ pa_specification_version: authn_data.message_version.clone(),
veres_enrolled: Some("Y".to_string()),
}
});
@@ -1353,13 +1353,13 @@ impl
ucaf_collection_indicator: None,
cavv,
ucaf_authentication_data,
- xid: Some(authn_data.threeds_server_transaction_id.clone()),
+ xid: authn_data.threeds_server_transaction_id.clone(),
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
.map(Secret::new),
specification_version: None,
- pa_specification_version: Some(authn_data.message_version.clone()),
+ pa_specification_version: authn_data.message_version.clone(),
veres_enrolled: Some("Y".to_string()),
}
});
@@ -1434,13 +1434,13 @@ impl
ucaf_collection_indicator: None,
cavv,
ucaf_authentication_data,
- xid: Some(authn_data.threeds_server_transaction_id.clone()),
+ xid: authn_data.threeds_server_transaction_id.clone(),
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
.map(Secret::new),
specification_version: None,
- pa_specification_version: Some(authn_data.message_version.clone()),
+ pa_specification_version: authn_data.message_version.clone(),
veres_enrolled: Some("Y".to_string()),
}
});
diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
index 8a52433275..e7760c205b 100644
--- a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
@@ -189,12 +189,12 @@ pub enum ThreeDSecureData {
#[serde(rename_all = "camelCase")]
pub struct ThreeDSData {
#[serde(rename = "threeDSTransactionId")]
- pub three_ds_transaction_id: Secret<String>,
+ pub three_ds_transaction_id: Option<Secret<String>>,
pub cavv: Secret<String>,
pub eci: Option<String>,
pub xid: Option<Secret<String>>,
#[serde(rename = "threeDSVersion")]
- pub three_ds_version: String,
+ pub three_ds_version: Option<String>,
#[serde(rename = "authenticationResponse")]
pub authentication_response: String,
}
@@ -452,11 +452,17 @@ fn create_card_details(
if let Some(auth_data) = &item.router_data.request.authentication_data {
details.three_ds = Some(ThreeDSecureData::Authentication(ThreeDSData {
- three_ds_transaction_id: Secret::new(auth_data.threeds_server_transaction_id.clone()),
+ three_ds_transaction_id: auth_data
+ .threeds_server_transaction_id
+ .clone()
+ .map(Secret::new),
cavv: Secret::new(auth_data.cavv.clone()),
eci: auth_data.eci.clone(),
xid: auth_data.ds_trans_id.clone().map(Secret::new),
- three_ds_version: auth_data.message_version.to_string(),
+ three_ds_version: auth_data
+ .message_version
+ .clone()
+ .map(|version| version.to_string()),
authentication_response: "Y".to_string(),
}));
} else if item.router_data.is_three_ds() {
diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
index 55f3528bbc..ac634d58ae 100644
--- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
+++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
@@ -13,19 +13,23 @@ use hyperswitch_domain_models::{
access_token_auth::AccessTokenAuth,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
refunds::{Execute, RSync},
- Authenticate, PostAuthenticate, PreAuthenticate,
+ Authenticate, AuthenticationConfirmation, PostAuthenticate, PreAuthenticate,
},
router_request_types::{
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
- UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
+ UasConfirmationRequestData, UasPostAuthenticationRequestData,
+ UasPreAuthenticationRequestData,
},
AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
RefundsData, SetupMandateRequestData,
},
router_response_types::{PaymentsResponseData, RefundsResponseData},
- types::{UasPostAuthenticationRouterData, UasPreAuthenticationRouterData},
+ types::{
+ UasAuthenticationConfirmationRouterData, UasPostAuthenticationRouterData,
+ UasPreAuthenticationRouterData,
+ },
};
use hyperswitch_interfaces::{
api::{
@@ -71,6 +75,7 @@ impl api::PaymentToken for UnifiedAuthenticationService {}
impl api::UnifiedAuthenticationService for UnifiedAuthenticationService {}
impl api::UasPreAuthentication for UnifiedAuthenticationService {}
impl api::UasPostAuthentication for UnifiedAuthenticationService {}
+impl api::UasAuthenticationConfirmation for UnifiedAuthenticationService {}
impl api::UasAuthentication for UnifiedAuthenticationService {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
@@ -168,6 +173,105 @@ impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsRespons
{
}
+impl
+ ConnectorIntegration<
+ AuthenticationConfirmation,
+ UasConfirmationRequestData,
+ UasAuthenticationResponseData,
+ > for UnifiedAuthenticationService
+{
+ fn get_headers(
+ &self,
+ req: &UasAuthenticationConfirmationRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &UasAuthenticationConfirmationRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!("{}confirmation", self.base_url(connectors)))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &UasAuthenticationConfirmationRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.transaction_amount,
+ req.request.transaction_currency,
+ )?;
+
+ let connector_router_data =
+ unified_authentication_service::UnifiedAuthenticationServiceRouterData::from((
+ amount, req,
+ ));
+ let connector_req =
+ unified_authentication_service::UnifiedAuthenticationServiceAuthenticateConfirmationRequest::try_from(
+ &connector_router_data,
+ )?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &UasAuthenticationConfirmationRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::UasAuthenticationConfirmationType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(types::UasAuthenticationConfirmationType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::UasAuthenticationConfirmationType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &UasAuthenticationConfirmationRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<UasAuthenticationConfirmationRouterData, errors::ConnectorError> {
+ let response: unified_authentication_service::UnifiedAuthenticationServiceAuthenticateConfirmationResponse =
+ res.response
+ .parse_struct("UnifiedAuthenticationService UnifiedAuthenticationServiceAuthenticateConfirmationResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
impl
ConnectorIntegration<
PreAuthenticate,
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 f2ca77d746..c5d0968fd5 100644
--- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
@@ -6,7 +6,10 @@ use hyperswitch_domain_models::{
DynamicData, PostAuthenticationDetails, PreAuthenticationDetails, TokenDetails,
UasAuthenticationResponseData,
},
- types::{UasPostAuthenticationRouterData, UasPreAuthenticationRouterData},
+ types::{
+ UasAuthenticationConfirmationRouterData, UasPostAuthenticationRouterData,
+ UasPreAuthenticationRouterData,
+ },
};
use hyperswitch_interfaces::errors;
use masking::Secret;
@@ -46,6 +49,56 @@ pub struct UnifiedAuthenticationServicePreAuthenticateRequest {
pub transaction_details: Option<TransactionDetails>,
}
+#[derive(Debug, Serialize, PartialEq)]
+pub struct UnifiedAuthenticationServiceAuthenticateConfirmationRequest {
+ pub authenticate_by: String,
+ pub source_authentication_id: String,
+ pub auth_creds: AuthType,
+ pub x_src_flow_id: Option<String>,
+ pub transaction_amount: Option<FloatMajorUnit>,
+ pub transaction_currency: Option<enums::Currency>,
+ pub checkout_event_type: Option<String>,
+ pub checkout_event_status: Option<String>,
+ pub confirmation_status: Option<String>,
+ pub confirmation_reason: Option<String>,
+ pub confirmation_timestamp: Option<PrimitiveDateTime>,
+ pub network_authorization_code: Option<String>,
+ pub network_transaction_identifier: Option<String>,
+ pub correlation_id: Option<String>,
+ pub merchant_transaction_id: Option<String>,
+}
+
+#[derive(Debug, Serialize, PartialEq, Deserialize)]
+pub struct UnifiedAuthenticationServiceAuthenticateConfirmationResponse {
+ status: String,
+}
+
+impl<F, T>
+ TryFrom<
+ ResponseRouterData<
+ F,
+ UnifiedAuthenticationServiceAuthenticateConfirmationResponse,
+ T,
+ UasAuthenticationResponseData,
+ >,
+ > for RouterData<F, T, UasAuthenticationResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ UnifiedAuthenticationServiceAuthenticateConfirmationResponse,
+ T,
+ UasAuthenticationResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(UasAuthenticationResponseData::Confirmation {}),
+ ..item.data
+ })
+ }
+}
+
#[derive(Debug, Serialize, PartialEq)]
#[serde(tag = "auth_type")]
pub enum AuthType {
@@ -443,3 +496,43 @@ impl<F, T>
pub struct UnifiedAuthenticationServiceErrorResponse {
pub error: String,
}
+
+impl TryFrom<&UnifiedAuthenticationServiceRouterData<&UasAuthenticationConfirmationRouterData>>
+ for UnifiedAuthenticationServiceAuthenticateConfirmationRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &UnifiedAuthenticationServiceRouterData<&UasAuthenticationConfirmationRouterData>,
+ ) -> Result<Self, Self::Error> {
+ let auth_type =
+ UnifiedAuthenticationServiceAuthType::try_from(&item.router_data.connector_auth_type)?;
+ let authentication_id = item.router_data.authentication_id.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "authentication_id",
+ },
+ )?;
+ Ok(Self {
+ authenticate_by: item.router_data.connector.clone(),
+ auth_creds: AuthType::HeaderKey {
+ api_key: auth_type.api_key,
+ },
+ source_authentication_id: authentication_id,
+ x_src_flow_id: item.router_data.request.x_src_flow_id.clone(),
+ transaction_amount: Some(item.amount),
+ transaction_currency: Some(item.router_data.request.transaction_currency),
+ checkout_event_type: item.router_data.request.checkout_event_type.clone(),
+ checkout_event_status: item.router_data.request.checkout_event_status.clone(),
+ confirmation_status: item.router_data.request.confirmation_status.clone(),
+ confirmation_reason: item.router_data.request.confirmation_reason.clone(),
+ confirmation_timestamp: item.router_data.request.confirmation_timestamp,
+ network_authorization_code: item.router_data.request.network_authorization_code.clone(),
+ network_transaction_identifier: item
+ .router_data
+ .request
+ .network_transaction_identifier
+ .clone(),
+ correlation_id: item.router_data.request.correlation_id.clone(),
+ merchant_transaction_id: item.router_data.request.merchant_transaction_id.clone(),
+ })
+ }
+}
diff --git a/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs b/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
index f046b8de70..10c381fa85 100644
--- a/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
@@ -941,13 +941,13 @@ impl
ucaf_collection_indicator: None,
cavv,
ucaf_authentication_data,
- xid: Some(authn_data.threeds_server_transaction_id.clone()),
+ xid: authn_data.threeds_server_transaction_id.clone(),
directory_server_transaction_id: authn_data
.ds_trans_id
.clone()
.map(Secret::new),
specification_version: None,
- pa_specification_version: Some(authn_data.message_version.clone()),
+ pa_specification_version: authn_data.message_version.clone(),
veres_enrolled: Some("Y".to_string()),
}
});
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index a88de8331c..cd78cb47f9 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -33,12 +33,13 @@ use hyperswitch_domain_models::{
PreProcessing, Reject, SdkSessionUpdate,
},
webhooks::VerifyWebhookSource,
- Authenticate, PostAuthenticate, PreAuthenticate,
+ Authenticate, AuthenticationConfirmation, PostAuthenticate, PreAuthenticate,
},
router_request_types::{
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
- UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
+ UasConfirmationRequestData, UasPostAuthenticationRequestData,
+ UasPreAuthenticationRequestData,
},
AcceptDisputeRequestData, AuthorizeSessionTokenData, CompleteAuthorizeData,
ConnectorCustomerData, DefendDisputeRequestData, MandateRevokeRequestData,
@@ -75,7 +76,8 @@ use hyperswitch_interfaces::{
PaymentsPreProcessing, TaxCalculation,
},
ConnectorIntegration, ConnectorMandateRevoke, ConnectorRedirectResponse, UasAuthentication,
- UasPostAuthentication, UasPreAuthentication, UnifiedAuthenticationService,
+ UasAuthenticationConfirmation, UasPostAuthentication, UasPreAuthentication,
+ UnifiedAuthenticationService,
},
errors::ConnectorError,
};
@@ -3099,3 +3101,89 @@ default_imp_for_uas_authentication!(
connectors::Zen,
connectors::Zsl
);
+
+macro_rules! default_imp_for_uas_authentication_confirmation {
+ ($($path:ident::$connector:ident),*) => {
+ $( impl UasAuthenticationConfirmation for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ AuthenticationConfirmation,
+ UasConfirmationRequestData,
+ UasAuthenticationResponseData
+
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_uas_authentication_confirmation!(
+ connectors::Aci,
+ connectors::Airwallex,
+ connectors::Amazonpay,
+ connectors::Bambora,
+ connectors::Bamboraapac,
+ connectors::Bankofamerica,
+ connectors::Billwerk,
+ connectors::Bluesnap,
+ connectors::Bitpay,
+ connectors::Braintree,
+ connectors::Boku,
+ connectors::Cashtocode,
+ connectors::Chargebee,
+ connectors::Coinbase,
+ connectors::Coingate,
+ connectors::Cryptopay,
+ connectors::CtpMastercard,
+ connectors::Cybersource,
+ connectors::Datatrans,
+ connectors::Deutschebank,
+ connectors::Digitalvirgo,
+ connectors::Dlocal,
+ connectors::Elavon,
+ connectors::Fiserv,
+ connectors::Fiservemea,
+ connectors::Fiuu,
+ connectors::Forte,
+ connectors::Getnet,
+ connectors::Globalpay,
+ connectors::Globepay,
+ connectors::Gocardless,
+ connectors::Helcim,
+ connectors::Iatapay,
+ connectors::Inespay,
+ connectors::Itaubank,
+ connectors::Jpmorgan,
+ connectors::Klarna,
+ connectors::Nomupay,
+ connectors::Novalnet,
+ connectors::Nexinets,
+ connectors::Nexixpay,
+ connectors::Nuvei,
+ connectors::Payeezy,
+ connectors::Payu,
+ connectors::Powertranz,
+ connectors::Prophetpay,
+ connectors::Mifinity,
+ connectors::Mollie,
+ connectors::Moneris,
+ connectors::Multisafepay,
+ connectors::Paybox,
+ connectors::Placetopay,
+ connectors::Rapyd,
+ connectors::Razorpay,
+ connectors::Redsys,
+ connectors::Shift4,
+ connectors::Stax,
+ connectors::Square,
+ connectors::Taxjar,
+ connectors::Thunes,
+ connectors::Tsys,
+ connectors::Worldline,
+ connectors::Worldpay,
+ connectors::Wellsfargo,
+ connectors::Volt,
+ connectors::Xendit,
+ connectors::Zen,
+ connectors::Zsl
+);
diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/unified_authentication_service.rs b/crates/hyperswitch_domain_models/src/router_flow_types/unified_authentication_service.rs
index ddc56eb2a2..ba851e0506 100644
--- a/crates/hyperswitch_domain_models/src/router_flow_types/unified_authentication_service.rs
+++ b/crates/hyperswitch_domain_models/src/router_flow_types/unified_authentication_service.rs
@@ -4,5 +4,8 @@ pub struct PreAuthenticate;
#[derive(Debug, Clone)]
pub struct PostAuthenticate;
+#[derive(Debug, Clone)]
+pub struct AuthenticationConfirmation;
+
#[derive(Debug, Clone)]
pub struct Authenticate;
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index 13ab97d60d..90f9781609 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -604,8 +604,8 @@ impl
pub struct AuthenticationData {
pub eci: Option<String>,
pub cavv: String,
- pub threeds_server_transaction_id: String,
- pub message_version: common_utils::types::SemanticVersion,
+ pub threeds_server_transaction_id: Option<String>,
+ pub message_version: Option<common_utils::types::SemanticVersion>,
pub ds_trans_id: Option<String>,
}
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 4238c513f4..248fec6f05 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,5 +1,7 @@
use api_models::payments::DeviceChannel;
+use common_utils::types::MinorUnit;
use masking::Secret;
+use time::PrimitiveDateTime;
use crate::{address::Address, payment_method_data::PaymentMethodData};
@@ -53,7 +55,7 @@ pub struct ServiceSessionIds {
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]
pub struct TransactionDetails {
- pub amount: Option<common_utils::types::MinorUnit>,
+ pub amount: Option<MinorUnit>,
pub currency: Option<common_enums::Currency>,
pub device_channel: Option<DeviceChannel>,
pub message_category: Option<super::authentication::MessageCategory>,
@@ -75,6 +77,7 @@ pub enum UasAuthenticationResponseData {
PostAuthentication {
authentication_details: PostAuthenticationDetails,
},
+ Confirmation {},
}
#[derive(Debug, Clone)]
@@ -120,3 +123,22 @@ pub struct DynamicData {
pub dynamic_data_type: Option<String>,
pub ds_trans_id: Option<String>,
}
+
+#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
+pub struct UasConfirmationRequestData {
+ pub x_src_flow_id: Option<String>,
+ pub transaction_amount: MinorUnit,
+ pub transaction_currency: common_enums::Currency,
+ // Type of event associated with the checkout. Valid values are: - 01 - Authorise - 02 - Capture - 03 - Refund - 04 - Cancel - 05 - Fraud - 06 - Chargeback - 07 - Other
+ pub checkout_event_type: Option<String>,
+ pub checkout_event_status: Option<String>,
+ pub confirmation_status: Option<String>,
+ pub confirmation_reason: Option<String>,
+ pub confirmation_timestamp: Option<PrimitiveDateTime>,
+ // Authorisation code associated with an approved transaction.
+ pub network_authorization_code: Option<String>,
+ // The unique authorisation related tracing value assigned by a Payment Network and provided in an authorisation response. Required only when checkoutEventType=01. If checkoutEventType=01 and the value of networkTransactionIdentifier is unknown, please pass UNAVLB
+ pub network_transaction_identifier: Option<String>,
+ pub correlation_id: Option<String>,
+ pub merchant_transaction_id: Option<String>,
+}
diff --git a/crates/hyperswitch_domain_models/src/types.rs b/crates/hyperswitch_domain_models/src/types.rs
index dc64560ead..a774dda3c9 100644
--- a/crates/hyperswitch_domain_models/src/types.rs
+++ b/crates/hyperswitch_domain_models/src/types.rs
@@ -3,15 +3,17 @@ pub use diesel_models::types::OrderDetailsWithAmount;
use crate::{
router_data::{AccessToken, RouterData},
router_flow_types::{
- mandate_revoke::MandateRevoke, AccessTokenAuth, Authenticate, Authorize,
- AuthorizeSessionToken, CalculateTax, Capture, CompleteAuthorize, CreateConnectorCustomer,
- Execute, IncrementalAuthorization, PSync, PaymentMethodToken, PostAuthenticate,
- PostSessionTokens, PreAuthenticate, PreProcessing, RSync, Session, SetupMandate, Void,
+ mandate_revoke::MandateRevoke, AccessTokenAuth, Authenticate, AuthenticationConfirmation,
+ Authorize, AuthorizeSessionToken, CalculateTax, Capture, CompleteAuthorize,
+ CreateConnectorCustomer, Execute, IncrementalAuthorization, PSync, PaymentMethodToken,
+ PostAuthenticate, PostSessionTokens, PreAuthenticate, PreProcessing, RSync, Session,
+ SetupMandate, Void,
},
router_request_types::{
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
- UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
+ UasConfirmationRequestData, UasPostAuthenticationRequestData,
+ UasPreAuthenticationRequestData,
},
AccessTokenRequestData, AuthorizeSessionTokenData, CompleteAuthorizeData,
ConnectorCustomerData, MandateRevokeRequestData, PaymentMethodTokenizationData,
@@ -60,6 +62,12 @@ pub type UasPostAuthenticationRouterData =
pub type UasPreAuthenticationRouterData =
RouterData<PreAuthenticate, UasPreAuthenticationRequestData, UasAuthenticationResponseData>;
+pub type UasAuthenticationConfirmationRouterData = RouterData<
+ AuthenticationConfirmation,
+ UasConfirmationRequestData,
+ UasAuthenticationResponseData,
+>;
+
pub type MandateRevokeRouterData =
RouterData<MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>;
pub type PaymentsIncrementalAuthorizationRouterData = RouterData<
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index ab918b5334..35a3da4633 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -34,13 +34,14 @@ use hyperswitch_domain_models::{
UasFlowData,
},
router_flow_types::{
- mandate_revoke::MandateRevoke, AccessTokenAuth, Authenticate, PostAuthenticate,
- PreAuthenticate, VerifyWebhookSource,
+ mandate_revoke::MandateRevoke, AccessTokenAuth, Authenticate, AuthenticationConfirmation,
+ PostAuthenticate, PreAuthenticate, VerifyWebhookSource,
},
router_request_types::{
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
- UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
+ UasConfirmationRequestData, UasPostAuthenticationRequestData,
+ UasPreAuthenticationRequestData,
},
AccessTokenRequestData, MandateRevokeRequestData, VerifyWebhookSourceRequestData,
},
@@ -371,7 +372,11 @@ pub trait ConnectorVerifyWebhookSourceV2:
/// trait UnifiedAuthenticationService
pub trait UnifiedAuthenticationService:
- ConnectorCommon + UasPreAuthentication + UasPostAuthentication + UasAuthentication
+ ConnectorCommon
+ + UasPreAuthentication
+ + UasPostAuthentication
+ + UasAuthenticationConfirmation
+ + UasAuthentication
{
}
@@ -395,6 +400,16 @@ pub trait UasPostAuthentication:
{
}
+/// trait UasAuthenticationConfirmation
+pub trait UasAuthenticationConfirmation:
+ ConnectorIntegration<
+ AuthenticationConfirmation,
+ UasConfirmationRequestData,
+ UasAuthenticationResponseData,
+>
+{
+}
+
/// trait UasAuthentication
pub trait UasAuthentication:
ConnectorIntegration<Authenticate, UasAuthenticationRequestData, UasAuthenticationResponseData>
@@ -403,7 +418,11 @@ pub trait UasAuthentication:
/// trait UnifiedAuthenticationServiceV2
pub trait UnifiedAuthenticationServiceV2:
- ConnectorCommon + UasPreAuthenticationV2 + UasPostAuthenticationV2 + UasAuthenticationV2
+ ConnectorCommon
+ + UasPreAuthenticationV2
+ + UasPostAuthenticationV2
+ + UasAuthenticationV2
+ + UasAuthenticationConfirmationV2
{
}
@@ -429,6 +448,17 @@ pub trait UasPostAuthenticationV2:
{
}
+/// trait UasAuthenticationConfirmationV2
+pub trait UasAuthenticationConfirmationV2:
+ ConnectorIntegrationV2<
+ AuthenticationConfirmation,
+ UasFlowData,
+ UasConfirmationRequestData,
+ UasAuthenticationResponseData,
+>
+{
+}
+
/// trait UasAuthenticationV2
pub trait UasAuthenticationV2:
ConnectorIntegrationV2<
diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs
index a047e7f00d..d7c7360a2d 100644
--- a/crates/hyperswitch_interfaces/src/types.rs
+++ b/crates/hyperswitch_interfaces/src/types.rs
@@ -14,13 +14,16 @@ use hyperswitch_domain_models::{
Session, SetupMandate, Void,
},
refunds::{Execute, RSync},
- unified_authentication_service::{Authenticate, PostAuthenticate, PreAuthenticate},
+ unified_authentication_service::{
+ Authenticate, AuthenticationConfirmation, PostAuthenticate, PreAuthenticate,
+ },
webhooks::VerifyWebhookSource,
},
router_request_types::{
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
- UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
+ UasConfirmationRequestData, UasPostAuthenticationRequestData,
+ UasPreAuthenticationRequestData,
},
AcceptDisputeRequestData, AccessTokenRequestData, AuthorizeSessionTokenData,
CompleteAuthorizeData, ConnectorCustomerData, DefendDisputeRequestData,
@@ -206,6 +209,13 @@ pub type UasPostAuthenticationType = dyn ConnectorIntegration<
UasAuthenticationResponseData,
>;
+/// Type alias for `ConnectorIntegration<Confirmation, UasConfirmationRequestData, UasAuthenticationResponseData>`
+pub type UasAuthenticationConfirmationType = dyn ConnectorIntegration<
+ AuthenticationConfirmation,
+ UasConfirmationRequestData,
+ UasAuthenticationResponseData,
+>;
+
/// Type alias for `ConnectorIntegration<Authenticate, UasAuthenticationRequestData, UasAuthenticationResponseData>`
pub type UasAuthenticationType = dyn ConnectorIntegration<
Authenticate,
diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rs
index 254c0346e8..4d9f5978b0 100644
--- a/crates/router/src/connector/checkout/transformers.rs
+++ b/crates/router/src/connector/checkout/transformers.rs
@@ -407,8 +407,13 @@ impl TryFrom<&CheckoutRouterData<&types::PaymentsAuthorizeRouterData>> for Payme
force_3ds: true,
eci: authentication_data.and_then(|auth| auth.eci.clone()),
cryptogram: authentication_data.map(|auth| auth.cavv.clone()),
- xid: authentication_data.map(|auth| auth.threeds_server_transaction_id.clone()),
- version: authentication_data.map(|auth| auth.message_version.to_string()),
+ xid: authentication_data
+ .and_then(|auth| auth.threeds_server_transaction_id.clone()),
+ version: authentication_data.and_then(|auth| {
+ auth.message_version
+ .clone()
+ .map(|version| version.to_string())
+ }),
},
enums::AuthenticationType::NoThreeDs => CheckoutThreeDS {
enabled: false,
diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rs
index e70813216d..1e8b745107 100644
--- a/crates/router/src/connector/nmi/transformers.rs
+++ b/crates/router/src/connector/nmi/transformers.rs
@@ -620,8 +620,14 @@ impl TryFrom<(&domain::payments::Card, &types::PaymentsAuthorizeData)> for Payme
cavv: Some(auth_data.cavv.clone()),
eci: auth_data.eci.clone(),
cardholder_auth: None,
- three_ds_version: Some(auth_data.message_version.to_string()),
- directory_server_id: Some(auth_data.threeds_server_transaction_id.clone().into()),
+ three_ds_version: auth_data
+ .message_version
+ .clone()
+ .map(|version| version.to_string()),
+ directory_server_id: auth_data
+ .threeds_server_transaction_id
+ .clone()
+ .map(Secret::new),
};
Ok(Self::CardThreeDs(Box::new(card_3ds_details)))
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 6edd2b7c65..a14d8b14df 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -388,9 +388,12 @@ where
should_continue_capture,
);
- if helpers::is_merchant_eligible_authentication_service(merchant_account.get_id(), state)
- .await?
- {
+ let is_eligible_for_uas =
+ helpers::is_merchant_eligible_authentication_service(merchant_account.get_id(), state)
+ .await?;
+
+ if is_eligible_for_uas {
+ let should_do_uas_confirmation_call = false;
operation
.to_domain()?
.call_unified_authentication_service_if_eligible(
@@ -401,6 +404,7 @@ where
&business_profile,
&key_store,
mandate_type,
+ &should_do_uas_confirmation_call,
)
.await?;
} else {
@@ -459,7 +463,7 @@ where
_ => (),
};
payment_data = match connector_details {
- ConnectorCallType::PreDetermined(connector) => {
+ ConnectorCallType::PreDetermined(ref connector) => {
#[cfg(all(feature = "dynamic_routing", feature = "v1"))]
let routable_connectors =
convert_connector_data_to_routable_connectors(&[connector.clone()])
@@ -500,6 +504,23 @@ where
)
.await?;
+ if is_eligible_for_uas {
+ let should_do_uas_confirmation_call = true;
+ operation
+ .to_domain()?
+ .call_unified_authentication_service_if_eligible(
+ state,
+ &mut payment_data,
+ &mut should_continue_transaction,
+ &connector_details,
+ &business_profile,
+ &key_store,
+ mandate_type,
+ &should_do_uas_confirmation_call,
+ )
+ .await?;
+ }
+
let op_ref = &operation;
let should_trigger_post_processing_flows = is_operation_confirm(&operation);
@@ -545,7 +566,7 @@ where
&key_store,
&customer,
&mca,
- &connector,
+ connector,
&mut payment_data,
op_ref,
Some(header_payload.clone()),
@@ -556,14 +577,14 @@ where
payment_data
}
- ConnectorCallType::Retryable(connectors) => {
+ ConnectorCallType::Retryable(ref connectors) => {
#[cfg(all(feature = "dynamic_routing", feature = "v1"))]
let routable_connectors =
- convert_connector_data_to_routable_connectors(&connectors)
+ convert_connector_data_to_routable_connectors(connectors)
.map_err(|e| logger::error!(routable_connector_error=?e))
.unwrap_or_default();
- let mut connectors = connectors.into_iter();
+ let mut connectors = connectors.clone().into_iter();
let connector_data = get_connector_data(&mut connectors)?;
@@ -641,6 +662,23 @@ where
let op_ref = &operation;
let should_trigger_post_processing_flows = is_operation_confirm(&operation);
+ if is_eligible_for_uas {
+ let should_do_uas_confirmation_call = true;
+ operation
+ .to_domain()?
+ .call_unified_authentication_service_if_eligible(
+ state,
+ &mut payment_data,
+ &mut should_continue_transaction,
+ &connector_details,
+ &business_profile,
+ &key_store,
+ mandate_type,
+ &should_do_uas_confirmation_call,
+ )
+ .await?;
+ }
+
let operation = Box::new(PaymentResponse);
connector_http_status_code = router_data.connector_http_status_code;
external_latency = router_data.external_latency;
diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs
index 03006706e2..1219363b21 100644
--- a/crates/router/src/core/payments/connector_integration_v2_impls.rs
+++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs
@@ -1,9 +1,9 @@
use hyperswitch_domain_models::router_flow_types::{
- Authenticate, PostAuthenticate, PreAuthenticate,
+ Authenticate, AuthenticationConfirmation, PostAuthenticate, PreAuthenticate,
};
use hyperswitch_interfaces::api::{
- UasAuthenticationV2, UasPostAuthenticationV2, UasPreAuthenticationV2,
- UnifiedAuthenticationServiceV2,
+ UasAuthenticationConfirmationV2, UasAuthenticationV2, UasPostAuthenticationV2,
+ UasPreAuthenticationV2, UnifiedAuthenticationServiceV2,
};
#[cfg(feature = "frm")]
@@ -1907,6 +1907,7 @@ macro_rules! default_imp_for_new_connector_integration_uas {
$( impl UnifiedAuthenticationServiceV2 for $path::$connector {}
impl UasPreAuthenticationV2 for $path::$connector {}
impl UasPostAuthenticationV2 for $path::$connector {}
+ impl UasAuthenticationConfirmationV2 for $path::$connector {}
impl UasAuthenticationV2 for $path::$connector {}
impl
services::ConnectorIntegrationV2<
@@ -1926,6 +1927,13 @@ macro_rules! default_imp_for_new_connector_integration_uas {
{}
impl
services::ConnectorIntegrationV2<
+ AuthenticationConfirmation,
+ types::UasFlowData,
+ types::UasConfirmationRequestData,
+ types::UasAuthenticationResponseData,
+ > for $path::$connector
+ {}
+ impl services::ConnectorIntegrationV2<
Authenticate,
types::UasFlowData,
types::UasAuthenticationRequestData,
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index 1aa5ed6629..f55c1f58f6 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -14,12 +14,14 @@ pub mod setup_mandate_flow;
use async_trait::async_trait;
use hyperswitch_domain_models::{
mandates::CustomerAcceptance,
- router_flow_types::{Authenticate, PostAuthenticate, PreAuthenticate},
+ router_flow_types::{
+ Authenticate, AuthenticationConfirmation, PostAuthenticate, PreAuthenticate,
+ },
router_request_types::PaymentsCaptureData,
};
use hyperswitch_interfaces::api::{
- payouts::Payouts, UasAuthentication, UasPostAuthentication, UasPreAuthentication,
- UnifiedAuthenticationService,
+ payouts::Payouts, UasAuthentication, UasAuthenticationConfirmation, UasPostAuthentication,
+ UasPreAuthentication, UnifiedAuthenticationService,
};
#[cfg(feature = "frm")]
@@ -2276,6 +2278,57 @@ default_imp_for_uas_post_authentication!(
connector::Wise
);
+macro_rules! default_imp_for_uas_authentication_confirmation {
+ ($($path:ident::$connector:ident),*) => {
+ $( impl UasAuthenticationConfirmation for $path::$connector {}
+ impl
+ services::ConnectorIntegration<
+ AuthenticationConfirmation,
+ types::UasConfirmationRequestData,
+ types::UasAuthenticationResponseData
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_uas_authentication_confirmation!(
+ connector::Adyenplatform,
+ connector::Adyen,
+ connector::Authorizedotnet,
+ connector::Checkout,
+ connector::Ebanx,
+ connector::Gpayments,
+ connector::Netcetera,
+ connector::Nmi,
+ connector::Noon,
+ connector::Opayo,
+ connector::Opennode,
+ connector::Payme,
+ connector::Payone,
+ connector::Paypal,
+ connector::Plaid,
+ connector::Riskified,
+ connector::Signifyd,
+ connector::Stripe,
+ connector::Threedsecureio,
+ connector::Trustpay,
+ connector::Wellsfargopayout,
+ connector::Wise
+);
+
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8> UasAuthenticationConfirmation for connector::DummyConnector<T> {}
+#[cfg(feature = "dummy_connector")]
+impl<const T: u8>
+ services::ConnectorIntegration<
+ AuthenticationConfirmation,
+ types::UasConfirmationRequestData,
+ types::UasAuthenticationResponseData,
+ > for connector::DummyConnector<T>
+{
+}
+
macro_rules! default_imp_for_uas_authentication {
($($path:ident::$connector:ident),*) => {
$( impl UasAuthentication for $path::$connector {}
@@ -2289,6 +2342,7 @@ macro_rules! default_imp_for_uas_authentication {
)*
};
}
+
#[cfg(feature = "dummy_connector")]
impl<const T: u8> UasAuthentication for connector::DummyConnector<T> {}
#[cfg(feature = "dummy_connector")]
@@ -2325,6 +2379,7 @@ default_imp_for_uas_authentication!(
connector::Wellsfargopayout,
connector::Wise
);
+
/// Determines whether a capture API call should be made for a payment attempt
/// This function evaluates whether an authorized payment should proceed with a capture API call
/// based on various payment parameters. It's primarily used in two-step (auth + capture) payment flows for CaptureMethod SequentialAutomatic
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 6702b94c43..4bfc0db553 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -6546,6 +6546,7 @@ pub enum UnifiedAuthenticationServiceFlow {
ExternalAuthenticationPostAuthenticate {
authentication_id: String,
},
+ ClickToPayConfirmation,
}
#[cfg(feature = "v1")]
@@ -6556,6 +6557,7 @@ pub async fn decide_action_for_unified_authentication_service<F: Clone>(
payment_data: &mut PaymentData<F>,
connector_call_type: &api::ConnectorCallType,
mandate_type: Option<api_models::payments::MandateTransactionType>,
+ do_authorisation_confirmation: &bool,
) -> RouterResult<Option<UnifiedAuthenticationServiceFlow>> {
let external_authentication_flow = get_payment_external_authentication_flow_during_confirm(
state,
@@ -6586,7 +6588,9 @@ pub async fn decide_action_for_unified_authentication_service<F: Clone>(
)
}
None => {
- if let Some(payment_method) = payment_data.payment_attempt.payment_method {
+ if *do_authorisation_confirmation {
+ Some(UnifiedAuthenticationServiceFlow::ClickToPayConfirmation)
+ } else if let Some(payment_method) = payment_data.payment_attempt.payment_method {
if payment_method == storage_enums::PaymentMethod::Card
&& business_profile.is_click_to_pay_enabled
&& payment_data.service_details.is_some()
@@ -6596,6 +6600,11 @@ pub async fn decide_action_for_unified_authentication_service<F: Clone>(
None
}
} else {
+ logger::info!(
+ payment_method=?payment_data.payment_attempt.payment_method,
+ click_to_pay_enabled=?business_profile.is_click_to_pay_enabled,
+ "skipping unified authentication service call since payment conditions are not satisfied"
+ );
None
}
}
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index e345abbf9c..b305370f6c 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -318,9 +318,10 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {
_payment_data: &mut D,
_should_continue_confirm_transaction: &mut bool,
_connector_call_type: &ConnectorCallType,
- _merchant_account: &domain::Profile,
+ _business_profile: &domain::Profile,
_key_store: &domain::MerchantKeyStore,
_mandate_type: Option<api_models::payments::MandateTransactionType>,
+ _do_authorization_confirmation: &bool,
) -> CustomResult<(), errors::ApiErrorResponse> {
Ok(())
}
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 84ff993387..6068eba131 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1050,6 +1050,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
business_profile: &domain::Profile,
key_store: &domain::MerchantKeyStore,
mandate_type: Option<api_models::payments::MandateTransactionType>,
+ do_authorisation_confirmation: &bool,
) -> CustomResult<(), errors::ApiErrorResponse> {
let unified_authentication_service_flow =
helpers::decide_action_for_unified_authentication_service(
@@ -1059,135 +1060,180 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
payment_data,
connector_call_type,
mandate_type,
+ do_authorisation_confirmation,
)
.await?;
+
if let Some(unified_authentication_service_flow) = unified_authentication_service_flow {
match unified_authentication_service_flow {
- helpers::UnifiedAuthenticationServiceFlow::ClickToPayInitiate => {
- let authentication_product_ids = business_profile
- .authentication_product_ids
- .clone()
- .ok_or(errors::ApiErrorResponse::PreconditionFailed {
- message: "authentication_product_ids is not configured in business profile"
- .to_string(),
- })?;
- let click_to_pay_mca_id = authentication_product_ids
- .get_click_to_pay_connector_account_id()
- .change_context(errors::ApiErrorResponse::MissingRequiredField {
- field_name: "authentication_product_ids",
- })?;
-
- let key_manager_state = &(state).into();
- let merchant_id = &business_profile.merchant_id;
-
- let connector_mca = state
- .store
- .find_by_merchant_connector_account_merchant_id_merchant_connector_id(
- key_manager_state,
- merchant_id,
- &click_to_pay_mca_id,
- key_store,
- )
- .await
- .to_not_found_response(
- errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
- id: click_to_pay_mca_id.get_string_repr().to_string(),
- },
- )?;
-
- let authentication_id =
- common_utils::generate_id_with_default_len(consts::AUTHENTICATION_ID_PREFIX);
-
- let payment_method = payment_data.payment_attempt.payment_method.ok_or(
- errors::ApiErrorResponse::MissingRequiredField {
- field_name: "payment_method",
- },
- )?;
-
- ClickToPay::pre_authentication(
- state,
- key_store,
- business_profile,
- payment_data,
- &helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
- &connector_mca.connector_name,
- &authentication_id,
- payment_method,
- )
- .await?;
-
- payment_data.payment_attempt.authentication_id = Some(authentication_id.clone());
+ helpers::UnifiedAuthenticationServiceFlow::ClickToPayInitiate => {
+ let authentication_product_ids = business_profile
+ .authentication_product_ids
+ .clone()
+ .ok_or(errors::ApiErrorResponse::PreconditionFailed {
+ message: "authentication_product_ids is not configured in business profile"
+ .to_string(),
+ })?;
+ let click_to_pay_mca_id = authentication_product_ids
+ .get_click_to_pay_connector_account_id()
+ .change_context(errors::ApiErrorResponse::MissingRequiredField {
+ field_name: "authentication_product_ids",
+ })?;
+ let key_manager_state = &(state).into();
+ let merchant_id = &business_profile.merchant_id;
+ let connector_mca = state
+ .store
+ .find_by_merchant_connector_account_merchant_id_merchant_connector_id(
+ key_manager_state,
+ merchant_id,
+ &click_to_pay_mca_id,
+ key_store,
+ )
+ .await
+ .to_not_found_response(
+ errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
+ id: click_to_pay_mca_id.get_string_repr().to_string(),
+ },
+ )?;
+ let authentication_id =
+ common_utils::generate_id_with_default_len(consts::AUTHENTICATION_ID_PREFIX);
+ let payment_method = payment_data.payment_attempt.payment_method.ok_or(
+ errors::ApiErrorResponse::MissingRequiredField {
+ field_name: "payment_method",
+ },
+ )?;
+ ClickToPay::pre_authentication(
+ state,
+ key_store,
+ business_profile,
+ payment_data,
+ &helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
+ &connector_mca.connector_name,
+ &authentication_id,
+ payment_method,
+ )
+ .await?;
- let response = ClickToPay::post_authentication(
- state,
- key_store,
- business_profile,
- payment_data,
- &helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
- &connector_mca.connector_name,
- payment_method,
- None,
- )
- .await?;
+ payment_data.payment_attempt.authentication_id = Some(authentication_id.clone());
+ let response = ClickToPay::post_authentication(
+ state,
+ key_store,
+ business_profile,
+ payment_data,
+ &helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
+ &connector_mca.connector_name,
+ payment_method,
+ None,
+ )
+ .await?;
+ let (network_token, authentication_status) = match response.response.clone() {
+ Ok(unified_authentication_service::UasAuthenticationResponseData::PostAuthentication {
+ authentication_details,
+ }) => {
+ let token_details = authentication_details.token_details.ok_or(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Missing authentication_details.token_details")?;
+ (Some(
+ hyperswitch_domain_models::payment_method_data::NetworkTokenData {
+ token_number: token_details.payment_token,
+ token_exp_month: token_details
+ .token_expiration_month,
+ token_exp_year: token_details
+ .token_expiration_year,
+ token_cryptogram: authentication_details
+ .dynamic_data_details
+ .and_then(|data| data.dynamic_data_value),
+ card_issuer: None,
+ card_network: None,
+ card_type: None,
+ card_issuing_country: None,
+ bank_code: None,
+ nick_name: None,
+ eci: authentication_details.eci,
+ }),common_enums::AuthenticationStatus::Success)
+ },
- let (network_token, authentication_status) = match response.response.clone() {
- Ok(unified_authentication_service::UasAuthenticationResponseData::PostAuthentication {
- authentication_details,
- }) => {
- let token_details = authentication_details.token_details.ok_or(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Missing authentication_details.token_details")?;
- (Some(
- hyperswitch_domain_models::payment_method_data::NetworkTokenData {
- token_number: token_details.payment_token,
- token_exp_month: token_details
- .token_expiration_month,
- token_exp_year: token_details
- .token_expiration_year,
- token_cryptogram: authentication_details
- .dynamic_data_details
- .and_then(|data| data.dynamic_data_value),
- card_issuer: None,
- card_network: None,
- card_type: None,
- card_issuing_country: None,
- bank_code: None,
- nick_name: None,
- eci: authentication_details.eci,
- }),common_enums::AuthenticationStatus::Success)
- },
- Ok(unified_authentication_service::UasAuthenticationResponseData::Authentication { .. })
- | Ok(unified_authentication_service::UasAuthenticationResponseData::PreAuthentication { .. })
- => Err(errors::ApiErrorResponse::InternalServerError).attach_printable("unexpected response received")?,
- Err(_) => (None, common_enums::AuthenticationStatus::Failed),
- };
+ Ok(unified_authentication_service::UasAuthenticationResponseData::PreAuthentication { .. })
+ | Ok(unified_authentication_service::UasAuthenticationResponseData::Confirmation {})
+ | Ok(unified_authentication_service::UasAuthenticationResponseData::Authentication { .. }) => Err(errors::ApiErrorResponse::InternalServerError).attach_printable("unexpected response received from unified authentication service")?,
+ Err(_) => (None, common_enums::AuthenticationStatus::Failed)
+ };
+ payment_data.payment_attempt.payment_method =
+ Some(common_enums::PaymentMethod::Card);
- payment_data.payment_attempt.payment_method =
- Some(common_enums::PaymentMethod::Card);
+ payment_data.payment_method_data = network_token
+ .clone()
+ .map(domain::PaymentMethodData::NetworkToken);
- payment_data.payment_method_data = network_token
+ let authentication = uas_utils::create_new_authentication(
+ state,
+ payment_data.payment_attempt.merchant_id.clone(),
+ connector_mca.connector_name.to_string(),
+ business_profile.get_id().clone(),
+ Some(payment_data.payment_intent.get_id().clone()),
+ click_to_pay_mca_id.to_owned(),
+ &authentication_id,
+ payment_data.service_details.clone(),
+ authentication_status,
+ network_token,
+ payment_data.payment_attempt.organization_id.clone(),
+ )
+ .await?;
+ payment_data.authentication = Some(authentication);
+ },
+ helpers::UnifiedAuthenticationServiceFlow::ClickToPayConfirmation => {
+ let authentication_product_ids = business_profile
+ .authentication_product_ids
.clone()
- .map(domain::PaymentMethodData::NetworkToken);
+ .ok_or(errors::ApiErrorResponse::PreconditionFailed {
+ message: "authentication_product_ids is not configured in business profile"
+ .to_string(),
+ })?;
+ let click_to_pay_mca_id = authentication_product_ids
+ .get_click_to_pay_connector_account_id()
+ .change_context(errors::ApiErrorResponse::MissingRequiredField {
+ field_name: "click_to_pay_mca_id",
+ })?;
+ let key_manager_state = &(state).into();
+ let merchant_id = &business_profile.merchant_id;
+
+ let connector_mca = state
+ .store
+ .find_by_merchant_connector_account_merchant_id_merchant_connector_id(
+ key_manager_state,
+ merchant_id,
+ &click_to_pay_mca_id,
+ key_store,
+ )
+ .await
+ .to_not_found_response(
+ errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
+ id: click_to_pay_mca_id.get_string_repr().to_string(),
+ },
+ )?;
- uas_utils::create_new_authentication(
- state,
- payment_data.payment_attempt.merchant_id.clone(),
- connector_mca.connector_name.to_string(),
- business_profile.get_id().clone(),
- Some(payment_data.payment_intent.get_id().clone()),
- click_to_pay_mca_id.to_owned(),
- &authentication_id,
- payment_data.service_details.clone(),
- authentication_status,
- payment_data.payment_attempt.organization_id.clone(),
- )
- .await?;
- },
- helpers::UnifiedAuthenticationServiceFlow::ExternalAuthenticationInitiate {
- acquirer_details,
- token,
- ..
- } => {
- let (authentication_connector, three_ds_connector_account) =
+ let payment_method = payment_data.payment_attempt.payment_method.ok_or(
+ errors::ApiErrorResponse::MissingRequiredField {
+ field_name: "payment_method",
+ },
+ )?;
+
+ ClickToPay::confirmation(
+ state,
+ key_store,
+ business_profile,
+ payment_data,
+ &helpers::MerchantConnectorAccountType::DbVal(Box::new(connector_mca.clone())),
+ &connector_mca.connector_name,
+ payment_method,
+ )
+ .await?
+ },
+ helpers::UnifiedAuthenticationServiceFlow::ExternalAuthenticationInitiate {
+ acquirer_details,
+ token,
+ ..
+ } => {
+ let (authentication_connector, three_ds_connector_account) =
authentication::utils::get_authentication_connector_data(state, key_store, business_profile).await?;
let authentication_connector_name = authentication_connector.to_string();
let authentication = authentication::utils::create_new_authentication(
@@ -1252,9 +1298,9 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
.attach_printable("Error while parsing PollConfig")?;
payment_data.poll_config = Some(poll_config)
}
- },
- helpers::UnifiedAuthenticationServiceFlow::ExternalAuthenticationPostAuthenticate {authentication_id} => {
- let (authentication_connector, three_ds_connector_account) =
+ },
+ helpers::UnifiedAuthenticationServiceFlow::ExternalAuthenticationPostAuthenticate {authentication_id} => {
+ let (authentication_connector, three_ds_connector_account) =
authentication::utils::get_authentication_connector_data(state, key_store, business_profile).await?;
let is_pull_mechanism_enabled =
utils::check_if_pull_mechanism_for_external_3ds_enabled_from_connector_metadata(
@@ -1301,8 +1347,9 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
*should_continue_confirm_transaction = false;
}
},
+ }
}
- }
+
Ok(())
}
diff --git a/crates/router/src/core/payments/types.rs b/crates/router/src/core/payments/types.rs
index 13f4de956e..2d147db244 100644
--- a/crates/router/src/core/payments/types.rs
+++ b/crates/router/src/core/payments/types.rs
@@ -370,20 +370,9 @@ impl ForeignTryFrom<&storage::Authentication> for AuthenticationData {
type Error = error_stack::Report<errors::ApiErrorResponse>;
fn foreign_try_from(authentication: &storage::Authentication) -> Result<Self, Self::Error> {
if authentication.authentication_status == common_enums::AuthenticationStatus::Success {
- let threeds_server_transaction_id = authentication
- .threeds_server_transaction_id
- .clone()
- .get_required_value("threeds_server_transaction_id")
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("threeds_server_transaction_id must not be null when authentication_status is success")?;
- let message_version = authentication
- .message_version
- .clone()
- .get_required_value("message_version")
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable(
- "message_version must not be null when authentication_status is success",
- )?;
+ let threeds_server_transaction_id =
+ authentication.threeds_server_transaction_id.clone();
+ let message_version = authentication.message_version.clone();
let cavv = authentication
.cavv
.clone()
diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs
index 28d32f627c..63824a40c9 100644
--- a/crates/router/src/core/unified_authentication_service.rs
+++ b/crates/router/src/core/unified_authentication_service.rs
@@ -11,7 +11,8 @@ use hyperswitch_domain_models::{
authentication::{MessageCategory, PreAuthenticationData},
unified_authentication_service::{
PaymentDetails, ServiceSessionIds, TransactionDetails, UasAuthenticationRequestData,
- UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
+ UasConfirmationRequestData, UasPostAuthenticationRequestData,
+ UasPreAuthenticationRequestData,
},
BrowserInformation,
},
@@ -20,6 +21,7 @@ use hyperswitch_domain_models::{
UasPreAuthenticationRouterData,
},
};
+use masking::ExposeInterface;
use super::{errors::RouterResult, payments::helpers::MerchantConnectorAccountType};
use crate::{
@@ -152,12 +154,76 @@ impl<F: Clone + Sync> UnifiedAuthenticationService<F> for ClickToPay {
.await
}
- fn confirmation(
- _state: &SessionState,
+ async fn confirmation(
+ state: &SessionState,
_key_store: &domain::MerchantKeyStore,
_business_profile: &domain::Profile,
- _merchant_connector_account: &MerchantConnectorAccountType,
+ payment_data: &PaymentData<F>,
+ merchant_connector_account: &MerchantConnectorAccountType,
+ connector_name: &str,
+ payment_method: common_enums::PaymentMethod,
) -> RouterResult<()> {
+ let authentication_id = payment_data
+ .payment_attempt
+ .authentication_id
+ .clone()
+ .ok_or(ApiErrorResponse::InternalServerError)
+ .attach_printable("Missing authentication id in payment attempt")?;
+
+ let currency = payment_data.payment_attempt.currency.ok_or(
+ ApiErrorResponse::MissingRequiredField {
+ field_name: "currency",
+ },
+ )?;
+
+ let current_time = common_utils::date_time::now();
+
+ let payment_attempt_status = payment_data.payment_attempt.status;
+
+ let (checkout_event_status, confirmation_reason) =
+ utils::get_checkout_event_status_and_reason(payment_attempt_status);
+
+ let click_to_pay_details = payment_data.service_details.clone();
+
+ let authentication_confirmation_data = UasConfirmationRequestData {
+ x_src_flow_id: payment_data
+ .service_details
+ .as_ref()
+ .and_then(|details| details.x_src_flow_id.clone()),
+ transaction_amount: payment_data.payment_attempt.net_amount.get_order_amount(),
+ transaction_currency: currency,
+ checkout_event_type: Some("01".to_string()), // hardcoded to '01' since only authorise flow is implemented
+ checkout_event_status: checkout_event_status.clone(),
+ confirmation_status: checkout_event_status.clone(),
+ confirmation_reason,
+ confirmation_timestamp: Some(current_time),
+ network_authorization_code: Some("01".to_string()), // hardcoded to '01' since only authorise flow is implemented
+ network_transaction_identifier: Some("01".to_string()), // hardcoded to '01' since only authorise flow is implemented
+ correlation_id: click_to_pay_details
+ .clone()
+ .and_then(|details| details.correlation_id),
+ merchant_transaction_id: click_to_pay_details
+ .and_then(|details| details.merchant_transaction_id),
+ };
+
+ let authentication_confirmation_router_data : hyperswitch_domain_models::types::UasAuthenticationConfirmationRouterData = utils::construct_uas_router_data(
+ state,
+ connector_name.to_string(),
+ payment_method,
+ payment_data.payment_attempt.merchant_id.clone(),
+ None,
+ authentication_confirmation_data,
+ merchant_connector_account,
+ Some(authentication_id.clone()),
+ )?;
+
+ utils::do_auth_connector_call(
+ state,
+ UNIFIED_AUTHENTICATION_SERVICE.to_string(),
+ authentication_confirmation_router_data,
+ )
+ .await?;
+
Ok(())
}
}
@@ -388,17 +454,12 @@ impl<F: Clone + Sync> UnifiedAuthenticationService<F> for ExternalAuthentication
)
.await
}
-
- fn confirmation(
- _state: &SessionState,
- _key_store: &domain::MerchantKeyStore,
- _business_profile: &domain::Profile,
- _merchant_connector_account: &MerchantConnectorAccountType,
- ) -> RouterResult<()> {
- Ok(())
- }
}
+#[cfg(all(
+ any(feature = "v1", feature = "v2"),
+ not(feature = "payment_methods_v2")
+))]
#[allow(clippy::too_many_arguments)]
pub async fn create_new_authentication(
state: &SessionState,
@@ -410,6 +471,7 @@ pub async fn create_new_authentication(
authentication_id: &str,
service_details: Option<payments::CtpServiceDetails>,
authentication_status: common_enums::AuthenticationStatus,
+ network_token: Option<payment_method_data::NetworkTokenData>,
organization_id: common_utils::id_type::OrganizationId,
) -> RouterResult<Authentication> {
let service_details_value = service_details
@@ -433,10 +495,12 @@ pub async fn create_new_authentication(
connector_metadata: None,
maximum_supported_version: None,
threeds_server_transaction_id: None,
- cavv: None,
+ cavv: network_token
+ .clone()
+ .and_then(|data| data.token_cryptogram.map(|cavv| cavv.expose())),
authentication_flow_type: None,
message_version: None,
- eci: None,
+ eci: network_token.and_then(|data| data.eci),
trans_status: None,
acquirer_bin: None,
acquirer_merchant_id: None,
diff --git a/crates/router/src/core/unified_authentication_service/types.rs b/crates/router/src/core/unified_authentication_service/types.rs
index bb9abdb121..7a1caf2d0e 100644
--- a/crates/router/src/core/unified_authentication_service/types.rs
+++ b/crates/router/src/core/unified_authentication_service/types.rs
@@ -145,11 +145,14 @@ pub trait UnifiedAuthenticationService<F: Clone + Sync> {
.into())
}
- fn confirmation(
+ async fn confirmation(
_state: &SessionState,
_key_store: &domain::MerchantKeyStore,
_business_profile: &domain::Profile,
+ _payment_data: &PaymentData<F>,
_merchant_connector_account: &MerchantConnectorAccountType,
+ _connector_name: &str,
+ _payment_method: common_enums::PaymentMethod,
) -> RouterResult<()> {
Err(errors::ApiErrorResponse::NotImplemented {
message: NotImplementedMessage::Reason("confirmation".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 15ab09e3cd..b74cd4d0c8 100644
--- a/crates/router/src/core/unified_authentication_service/utils.rs
+++ b/crates/router/src/core/unified_authentication_service/utils.rs
@@ -136,70 +136,74 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
Ok(response) => match response {
UasAuthenticationResponseData::PreAuthentication {
authentication_details,
- } => diesel_models::authentication::AuthenticationUpdate::PreAuthenticationUpdate {
- threeds_server_transaction_id: authentication_details
- .threeds_server_transaction_id
- .ok_or(ApiErrorResponse::InternalServerError)
- .attach_printable(
- "missing threeds_server_transaction_id in PreAuthentication Details",
- )?,
- maximum_supported_3ds_version: authentication_details
- .maximum_supported_3ds_version
- .ok_or(ApiErrorResponse::InternalServerError)
- .attach_printable(
- "missing maximum_supported_3ds_version in PreAuthentication Details",
- )?,
- connector_authentication_id: authentication_details
- .connector_authentication_id
- .ok_or(ApiErrorResponse::InternalServerError)
- .attach_printable(
- "missing connector_authentication_id in PreAuthentication Details",
- )?,
- three_ds_method_data: authentication_details.three_ds_method_data,
- three_ds_method_url: authentication_details.three_ds_method_url,
- message_version: authentication_details
- .message_version
- .ok_or(ApiErrorResponse::InternalServerError)
- .attach_printable("missing message_version in PreAuthentication Details")?,
- connector_metadata: authentication_details.connector_metadata,
- authentication_status: common_enums::AuthenticationStatus::Pending,
- acquirer_bin: acquirer_details
- .as_ref()
- .map(|acquirer_details| acquirer_details.acquirer_bin.clone()),
- acquirer_merchant_id: acquirer_details
- .as_ref()
- .map(|acquirer_details| acquirer_details.acquirer_merchant_id.clone()),
- acquirer_country_code: acquirer_details
- .and_then(|acquirer_details| acquirer_details.acquirer_country_code),
- directory_server_id: authentication_details.directory_server_id,
- },
+ } => Ok(
+ diesel_models::authentication::AuthenticationUpdate::PreAuthenticationUpdate {
+ threeds_server_transaction_id: authentication_details
+ .threeds_server_transaction_id
+ .ok_or(ApiErrorResponse::InternalServerError)
+ .attach_printable(
+ "missing threeds_server_transaction_id in PreAuthentication Details",
+ )?,
+ maximum_supported_3ds_version: authentication_details
+ .maximum_supported_3ds_version
+ .ok_or(ApiErrorResponse::InternalServerError)
+ .attach_printable(
+ "missing maximum_supported_3ds_version in PreAuthentication Details",
+ )?,
+ connector_authentication_id: authentication_details
+ .connector_authentication_id
+ .ok_or(ApiErrorResponse::InternalServerError)
+ .attach_printable(
+ "missing connector_authentication_id in PreAuthentication Details",
+ )?,
+ three_ds_method_data: authentication_details.three_ds_method_data,
+ three_ds_method_url: authentication_details.three_ds_method_url,
+ message_version: authentication_details
+ .message_version
+ .ok_or(ApiErrorResponse::InternalServerError)
+ .attach_printable("missing message_version in PreAuthentication Details")?,
+ connector_metadata: authentication_details.connector_metadata,
+ authentication_status: common_enums::AuthenticationStatus::Pending,
+ acquirer_bin: acquirer_details
+ .as_ref()
+ .map(|acquirer_details| acquirer_details.acquirer_bin.clone()),
+ acquirer_merchant_id: acquirer_details
+ .as_ref()
+ .map(|acquirer_details| acquirer_details.acquirer_merchant_id.clone()),
+ acquirer_country_code: acquirer_details
+ .and_then(|acquirer_details| acquirer_details.acquirer_country_code),
+ directory_server_id: authentication_details.directory_server_id,
+ },
+ ),
UasAuthenticationResponseData::Authentication {
authentication_details,
} => {
let authentication_status = common_enums::AuthenticationStatus::foreign_from(
authentication_details.trans_status.clone(),
);
- diesel_models::authentication::AuthenticationUpdate::AuthenticationUpdate {
- authentication_value: authentication_details.authentication_value,
- trans_status: authentication_details.trans_status,
- acs_url: authentication_details.authn_flow_type.get_acs_url(),
- challenge_request: authentication_details
- .authn_flow_type
- .get_challenge_request(),
- acs_reference_number: authentication_details
- .authn_flow_type
- .get_acs_reference_number(),
- acs_trans_id: authentication_details.authn_flow_type.get_acs_trans_id(),
- acs_signed_content: authentication_details
- .authn_flow_type
- .get_acs_signed_content(),
- authentication_type: authentication_details
- .authn_flow_type
- .get_decoupled_authentication_type(),
- authentication_status,
- connector_metadata: authentication_details.connector_metadata,
- ds_trans_id: authentication_details.ds_trans_id,
- }
+ Ok(
+ diesel_models::authentication::AuthenticationUpdate::AuthenticationUpdate {
+ authentication_value: authentication_details.authentication_value,
+ trans_status: authentication_details.trans_status,
+ acs_url: authentication_details.authn_flow_type.get_acs_url(),
+ challenge_request: authentication_details
+ .authn_flow_type
+ .get_challenge_request(),
+ acs_reference_number: authentication_details
+ .authn_flow_type
+ .get_acs_reference_number(),
+ acs_trans_id: authentication_details.authn_flow_type.get_acs_trans_id(),
+ acs_signed_content: authentication_details
+ .authn_flow_type
+ .get_acs_signed_content(),
+ authentication_type: authentication_details
+ .authn_flow_type
+ .get_decoupled_authentication_type(),
+ authentication_status,
+ connector_metadata: authentication_details.connector_metadata,
+ ds_trans_id: authentication_details.ds_trans_id,
+ },
+ )
}
UasAuthenticationResponseData::PostAuthentication {
authentication_details,
@@ -208,29 +212,39 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
.trans_status
.ok_or(ApiErrorResponse::InternalServerError)
.attach_printable("missing trans_status in PostAuthentication Details")?;
- diesel_models::authentication::AuthenticationUpdate::PostAuthenticationUpdate {
- authentication_status: common_enums::AuthenticationStatus::foreign_from(
- trans_status.clone(),
- ),
- trans_status,
- authentication_value: authentication_details
- .dynamic_data_details
- .and_then(|details| details.dynamic_data_value)
- .map(masking::ExposeInterface::expose),
- eci: authentication_details.eci,
- }
+ Ok(
+ diesel_models::authentication::AuthenticationUpdate::PostAuthenticationUpdate {
+ authentication_status: common_enums::AuthenticationStatus::foreign_from(
+ trans_status.clone(),
+ ),
+ trans_status,
+ authentication_value: authentication_details
+ .dynamic_data_details
+ .and_then(|details| details.dynamic_data_value)
+ .map(masking::ExposeInterface::expose),
+ eci: authentication_details.eci,
+ },
+ )
}
+
+ UasAuthenticationResponseData::Confirmation { .. } => Err(
+ ApiErrorResponse::InternalServerError,
+ )
+ .attach_printable("unexpected api confirmation in external authentication flow."),
},
- Err(error) => diesel_models::authentication::AuthenticationUpdate::ErrorUpdate {
- connector_authentication_id: error.connector_transaction_id,
- authentication_status: common_enums::AuthenticationStatus::Failed,
- error_message: error
- .reason
- .map(|reason| format!("message: {}, reason: {}", error.message, reason))
- .or(Some(error.message)),
- error_code: Some(error.code),
- },
- };
+ Err(error) => Ok(
+ diesel_models::authentication::AuthenticationUpdate::ErrorUpdate {
+ connector_authentication_id: error.connector_transaction_id,
+ authentication_status: common_enums::AuthenticationStatus::Failed,
+ error_message: error
+ .reason
+ .map(|reason| format!("message: {}, reason: {}", error.message, reason))
+ .or(Some(error.message)),
+ error_code: Some(error.code),
+ },
+ ),
+ }?;
+
state
.store
.update_authentication_by_merchant_id_authentication_id(
@@ -241,3 +255,18 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Error while updating authentication")
}
+
+pub fn get_checkout_event_status_and_reason(
+ attempt_status: common_enums::AttemptStatus,
+) -> (Option<String>, Option<String>) {
+ match attempt_status {
+ common_enums::AttemptStatus::Charged | common_enums::AttemptStatus::Authorized => (
+ Some("02".to_string()),
+ Some("Approval Code received".to_string()),
+ ),
+ _ => (
+ Some("03".to_string()),
+ Some("No Approval Code received".to_string()),
+ ),
+ }
+}
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index a5bdef9572..7bfbc22d05 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -59,7 +59,8 @@ pub use hyperswitch_domain_models::{
router_request_types::{
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
- UasPostAuthenticationRequestData, UasPreAuthenticationRequestData,
+ UasConfirmationRequestData, UasPostAuthenticationRequestData,
+ UasPreAuthenticationRequestData,
},
AcceptDisputeRequestData, AccessTokenRequestData, AuthorizeSessionTokenData,
BrowserInformation, ChargeRefunds, ChargeRefundsOptions, CompleteAuthorizeData,