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

chore(barclaycard): Introduce Authentication Flows for Barclaycard (#10810)

Hrithikesh7487ad642b08
diff --git a/config/development.toml b/config/development.toml
index 30b88fd25e..0c138c6a78 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -38,7 +38,7 @@ pool_size = 5
connection_timeout = 10
[preprocessing_flow_config]
-authentication_bloated_connectors = "paypal,nmi,cybersource"
+authentication_bloated_connectors = "paypal,nmi,cybersource,barclaycard"
order_create_bloated_connectors = "trustpay,payme"
[redis]
diff --git a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
index 44340497ec..f63dcb803e 100644
--- a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
+++ b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
@@ -20,10 +20,12 @@ use hyperswitch_domain_models::{
Session, SetupMandate, Void,
},
refunds::{Execute, RSync},
+ Authenticate, PostAuthenticate, PreAuthenticate,
},
router_request_types::{
AccessTokenRequestData, CompleteAuthorizeData, PaymentMethodTokenizationData,
- PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData,
+ PaymentsAuthenticateData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData,
+ PaymentsPostAuthenticateData, PaymentsPreAuthenticateData, PaymentsPreProcessingData,
PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData,
},
router_response_types::{
@@ -31,9 +33,11 @@ use hyperswitch_domain_models::{
SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
- PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
- PaymentsCompleteAuthorizeRouterData, PaymentsPreProcessingRouterData,
- PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
+ PaymentsAuthenticateRouterData, PaymentsAuthorizeRouterData, PaymentsCancelRouterData,
+ PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData,
+ PaymentsPostAuthenticateRouterData, PaymentsPreAuthenticateRouterData,
+ PaymentsPreProcessingRouterData, PaymentsSyncRouterData, RefundSyncRouterData,
+ RefundsRouterData,
},
};
use hyperswitch_interfaces::{
@@ -44,7 +48,10 @@ use hyperswitch_interfaces::{
configs::Connectors,
errors,
events::connector_api_logs::ConnectorEvent,
- types::{self, PaymentsVoidType, Response},
+ types::{
+ self, PaymentsAuthenticateType, PaymentsPostAuthenticateType, PaymentsPreAuthenticateType,
+ PaymentsVoidType, Response,
+ },
webhooks,
};
use masking::{ExposeInterface, Mask, Maskable, PeekInterface};
@@ -126,6 +133,9 @@ impl Barclaycard {
}
impl api::Payment for Barclaycard {}
+impl api::PaymentsAuthenticate for Barclaycard {}
+impl api::PaymentsPreAuthenticate for Barclaycard {}
+impl api::PaymentsPostAuthenticate for Barclaycard {}
impl api::PaymentSession for Barclaycard {}
impl api::PaymentsPreProcessing for Barclaycard {}
impl api::ConnectorAccessToken for Barclaycard {}
@@ -346,6 +356,287 @@ impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsRespons
{
}
+impl ConnectorIntegration<PreAuthenticate, PaymentsPreAuthenticateData, PaymentsResponseData>
+ for Barclaycard
+{
+ fn get_headers(
+ &self,
+ req: &PaymentsPreAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, 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: &PaymentsPreAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!(
+ "{}risk/v1/authentication-setups",
+ ConnectorCommon::base_url(self, connectors)
+ ))
+ }
+ fn get_request_body(
+ &self,
+ req: &PaymentsPreAuthenticateRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let minor_amount = req.request.minor_amount;
+ let currency =
+ req.request
+ .currency
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ })?;
+
+ let amount = convert_amount(self.amount_converter, minor_amount, currency)?;
+
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
+ let connector_req =
+ barclaycard::BarclaycardAuthSetupRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+ fn build_request(
+ &self,
+ req: &PaymentsPreAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ let request = RequestBuilder::new()
+ .method(Method::Post)
+ .url(&PaymentsPreAuthenticateType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(PaymentsPreAuthenticateType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(self.get_request_body(req, connectors)?)
+ .build();
+
+ Ok(Some(request))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsPreAuthenticateRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsPreAuthenticateRouterData, errors::ConnectorError> {
+ let response: barclaycard::BarclaycardAuthSetupResponse = res
+ .response
+ .parse_struct("Barclaycard AuthSetupResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ PaymentsPreAuthenticateRouterData::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<Authenticate, PaymentsAuthenticateData, PaymentsResponseData>
+ for Barclaycard
+{
+ fn get_headers(
+ &self,
+ req: &PaymentsAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, 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: &PaymentsAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!(
+ "{}risk/v1/authentications",
+ self.base_url(connectors)
+ ))
+ }
+ fn get_request_body(
+ &self,
+ req: &PaymentsAuthenticateRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let minor_amount =
+ req.request
+ .minor_amount
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "minor_amount",
+ })?;
+ let currency =
+ req.request
+ .currency
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ })?;
+ let amount = convert_amount(self.amount_converter, minor_amount, currency)?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
+ let connector_req =
+ barclaycard::BarclaycardAuthEnrollmentRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+ fn build_request(
+ &self,
+ req: &PaymentsAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&PaymentsAuthenticateType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(PaymentsAuthenticateType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(PaymentsAuthenticateType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsAuthenticateRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsAuthenticateRouterData, errors::ConnectorError> {
+ let response: barclaycard::BarclaycardAuthenticationResponse = res
+ .response
+ .parse_struct("Barclaycard AuthEnrollmentResponse")
+ .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<PostAuthenticate, PaymentsPostAuthenticateData, PaymentsResponseData>
+ for Barclaycard
+{
+ fn get_headers(
+ &self,
+ req: &PaymentsPostAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, 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: &PaymentsPostAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!(
+ "{}risk/v1/authentication-results",
+ self.base_url(connectors)
+ ))
+ }
+ fn get_request_body(
+ &self,
+ req: &PaymentsPostAuthenticateRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let minor_amount =
+ req.request
+ .minor_amount
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "minor_amount",
+ })?;
+ let currency =
+ req.request
+ .currency
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ })?;
+ let amount = convert_amount(self.amount_converter, minor_amount, currency)?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
+ let connector_req =
+ barclaycard::BarclaycardAuthValidateRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+ fn build_request(
+ &self,
+ req: &PaymentsPostAuthenticateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&PaymentsPostAuthenticateType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(PaymentsPostAuthenticateType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(PaymentsPostAuthenticateType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsPostAuthenticateRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsPostAuthenticateRouterData, errors::ConnectorError> {
+ let response: barclaycard::BarclaycardAuthenticationResponse = res
+ .response
+ .parse_struct("Barclaycard AuthEnrollmentResponse")
+ .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<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>
for Barclaycard
{
@@ -1353,6 +1644,62 @@ static BARCLAYCARD_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
static BARCLAYCARD_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Barclaycard {
+ fn is_pre_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize {
+ request_data,
+ auth_type,
+ } => *auth_type == common_enums::AuthenticationType::ThreeDs && request_data.is_card(),
+ // No alternate flow for complete authorize
+ api::CurrentFlowInfo::CompleteAuthorize { .. } => false,
+ }
+ }
+ /// Check if authentication flow is required
+ fn is_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize { .. } => {
+ // during authorize flow, there is no post_authentication call needed
+ false
+ }
+ api::CurrentFlowInfo::CompleteAuthorize {
+ request_data,
+ payment_method: _,
+ } => {
+ // TODO: add logic before deciding the pre processing flow Authenticate or PostAuthenticate
+ let redirection_params = request_data
+ .redirect_response
+ .as_ref()
+ .and_then(|redirect_response| redirect_response.params.as_ref());
+ match redirection_params {
+ Some(param) if !param.peek().is_empty() => true,
+ Some(_) | None => false,
+ }
+ }
+ }
+ }
+ /// Check if post-authentication flow is required
+ fn is_post_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize { .. } => {
+ // during authorize flow, there is no post_authentication call needed
+ false
+ }
+ api::CurrentFlowInfo::CompleteAuthorize {
+ request_data,
+ payment_method: _,
+ } => {
+ // TODO: add logic before deciding the pre processing flow Authenticate or PostAuthenticate
+ let redirection_params = request_data
+ .redirect_response
+ .as_ref()
+ .and_then(|redirect_response| redirect_response.params.as_ref());
+ match redirection_params {
+ Some(param) if !param.peek().is_empty() => false,
+ Some(_) | None => true,
+ }
+ }
+ }
+ }
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&BARCLAYCARD_CONNECTOR_INFO)
}
diff --git a/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs b/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
index 66ef3de0e3..65f914f5ac 100644
--- a/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
@@ -20,9 +20,10 @@ use hyperswitch_domain_models::{
},
router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
types::{
- PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
- PaymentsCompleteAuthorizeRouterData, PaymentsPreProcessingRouterData,
- PaymentsSyncRouterData, RefundsRouterData,
+ PaymentsAuthenticateRouterData, PaymentsAuthorizeRouterData, PaymentsCancelRouterData,
+ PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData,
+ PaymentsPostAuthenticateRouterData, PaymentsPreAuthenticateRouterData,
+ PaymentsPreProcessingRouterData, PaymentsSyncRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::errors;
@@ -33,9 +34,11 @@ use serde_json::Value;
use crate::{
constants,
types::{
- PaymentsCancelResponseRouterData, PaymentsCaptureResponseRouterData,
- PaymentsPreprocessingResponseRouterData, PaymentsResponseRouterData,
- PaymentsSyncResponseRouterData, RefundsResponseRouterData, ResponseRouterData,
+ PaymentsAuthenticateResponseRouterData, PaymentsCancelResponseRouterData,
+ PaymentsCaptureResponseRouterData, PaymentsPostAuthenticateResponseRouterData,
+ PaymentsPreAuthenticateResponseRouterData, PaymentsPreprocessingResponseRouterData,
+ PaymentsResponseRouterData, PaymentsSyncResponseRouterData, RefundsResponseRouterData,
+ ResponseRouterData,
},
unimplemented_payment_method,
utils::{
@@ -446,6 +449,16 @@ impl
}
}
+impl From<&BarclaycardRouterData<&PaymentsPreAuthenticateRouterData>>
+ for ClientReferenceInformation
+{
+ fn from(item: &BarclaycardRouterData<&PaymentsPreAuthenticateRouterData>) -> Self {
+ Self {
+ code: Some(item.router_data.connector_request_reference_id.clone()),
+ }
+ }
+}
+
impl From<&BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>>
for ClientReferenceInformation
{
@@ -689,6 +702,12 @@ pub enum BarclaycardPreProcessingResponse {
ErrorInformation(Box<BarclaycardErrorInformationResponse>),
}
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub enum BarclaycardAuthenticationResponse {
+ ClientAuthCheckInfo(Box<ClientAuthCheckInfoResponse>),
+ ErrorInformation(Box<BarclaycardErrorInformationResponse>),
+}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BarclaycardAuthSetupRequest {
@@ -757,6 +776,230 @@ pub enum BarclaycardAuthSetupResponse {
ErrorInformation(Box<BarclaycardErrorInformationResponse>),
}
+impl TryFrom<&BarclaycardRouterData<&PaymentsAuthenticateRouterData>>
+ for BarclaycardAuthEnrollmentRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &BarclaycardRouterData<&PaymentsAuthenticateRouterData>,
+ ) -> Result<Self, Self::Error> {
+ let client_reference_information = ClientReferenceInformation {
+ code: Some(item.router_data.connector_request_reference_id.clone()),
+ };
+ let payment_method_data = item.router_data.request.payment_method_data.clone().ok_or(
+ errors::ConnectorError::MissingConnectorRedirectionPayload {
+ field_name: "payment_method_data",
+ },
+ )?;
+ let payment_information = match payment_method_data {
+ PaymentMethodData::Card(ccard) => {
+ let card_type = match ccard
+ .card_network
+ .clone()
+ .and_then(get_barclaycard_card_type)
+ {
+ Some(card_network) => Some(card_network.to_string()),
+ None => ccard.get_card_issuer().ok().map(String::from),
+ };
+
+ Ok(PaymentInformation::Cards(Box::new(
+ CardPaymentInformation {
+ card: Card {
+ number: ccard.card_number,
+ expiration_month: ccard.card_exp_month,
+ expiration_year: ccard.card_exp_year,
+ security_code: ccard.card_cvc,
+ card_type,
+ type_selection_indicator: Some("1".to_owned()),
+ },
+ },
+ )))
+ }
+ PaymentMethodData::Wallet(_)
+ | PaymentMethodData::CardRedirect(_)
+ | PaymentMethodData::PayLater(_)
+ | PaymentMethodData::BankRedirect(_)
+ | PaymentMethodData::BankDebit(_)
+ | PaymentMethodData::BankTransfer(_)
+ | PaymentMethodData::Crypto(_)
+ | PaymentMethodData::MandatePayment
+ | PaymentMethodData::Reward
+ | PaymentMethodData::RealTimePayment(_)
+ | PaymentMethodData::MobilePayment(_)
+ | PaymentMethodData::Upi(_)
+ | PaymentMethodData::Voucher(_)
+ | PaymentMethodData::GiftCard(_)
+ | PaymentMethodData::OpenBanking(_)
+ | PaymentMethodData::CardToken(_)
+ | PaymentMethodData::NetworkToken(_)
+ | PaymentMethodData::CardDetailsForNetworkTransactionId(_)
+ | PaymentMethodData::NetworkTokenDetailsForNetworkTransactionId(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("Barclaycard"),
+ ))
+ }
+ }?;
+
+ let redirect_response = item.router_data.request.redirect_response.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "redirect_response",
+ },
+ )?;
+
+ let amount_details = Amount {
+ total_amount: item.amount.clone(),
+ currency: item.router_data.request.currency.ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ },
+ )?,
+ };
+ let reference_id = redirect_response
+ .params
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "redirect_response.params",
+ })?
+ .clone()
+ .peek()
+ .split_once('=')
+ .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
+ field_name: "request.redirect_response.params.reference_id",
+ })?
+ .1
+ .to_string();
+ let email = item
+ .router_data
+ .get_billing_email()
+ .ok()
+ .or(item.router_data.request.email.clone())
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "email",
+ })?;
+ let bill_to = build_bill_to(item.router_data.get_billing_address()?, email)?;
+ let order_information = OrderInformationWithBill {
+ amount_details,
+ bill_to: Some(bill_to),
+ };
+ let complete_authorize_url = item
+ .router_data
+ .request
+ .complete_authorize_url
+ .clone()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "complete_authorize_url",
+ })?;
+ Ok(Self {
+ payment_information,
+ client_reference_information,
+ consumer_authentication_information: BarclaycardConsumerAuthInformationRequest {
+ return_url: complete_authorize_url,
+ reference_id,
+ },
+ order_information,
+ })
+ }
+}
+
+impl TryFrom<&BarclaycardRouterData<&PaymentsPostAuthenticateRouterData>>
+ for BarclaycardAuthValidateRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &BarclaycardRouterData<&PaymentsPostAuthenticateRouterData>,
+ ) -> Result<Self, Self::Error> {
+ let client_reference_information = ClientReferenceInformation {
+ code: Some(item.router_data.connector_request_reference_id.clone()),
+ };
+ let payment_method_data = item.router_data.request.payment_method_data.clone().ok_or(
+ errors::ConnectorError::MissingConnectorRedirectionPayload {
+ field_name: "payment_method_data",
+ },
+ )?;
+ let payment_information = match payment_method_data {
+ PaymentMethodData::Card(ccard) => {
+ let card_type = match ccard
+ .card_network
+ .clone()
+ .and_then(get_barclaycard_card_type)
+ {
+ Some(card_network) => Some(card_network.to_string()),
+ None => ccard.get_card_issuer().ok().map(String::from),
+ };
+
+ Ok(PaymentInformation::Cards(Box::new(
+ CardPaymentInformation {
+ card: Card {
+ number: ccard.card_number,
+ expiration_month: ccard.card_exp_month,
+ expiration_year: ccard.card_exp_year,
+ security_code: ccard.card_cvc,
+ card_type,
+ type_selection_indicator: Some("1".to_owned()),
+ },
+ },
+ )))
+ }
+ PaymentMethodData::Wallet(_)
+ | PaymentMethodData::CardRedirect(_)
+ | PaymentMethodData::PayLater(_)
+ | PaymentMethodData::BankRedirect(_)
+ | PaymentMethodData::BankDebit(_)
+ | PaymentMethodData::BankTransfer(_)
+ | PaymentMethodData::Crypto(_)
+ | PaymentMethodData::MandatePayment
+ | PaymentMethodData::Reward
+ | PaymentMethodData::RealTimePayment(_)
+ | PaymentMethodData::MobilePayment(_)
+ | PaymentMethodData::Upi(_)
+ | PaymentMethodData::Voucher(_)
+ | PaymentMethodData::GiftCard(_)
+ | PaymentMethodData::OpenBanking(_)
+ | PaymentMethodData::CardToken(_)
+ | PaymentMethodData::NetworkToken(_)
+ | PaymentMethodData::CardDetailsForNetworkTransactionId(_)
+ | PaymentMethodData::NetworkTokenDetailsForNetworkTransactionId(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("Barclaycard"),
+ ))
+ }
+ }?;
+
+ let redirect_response = item.router_data.request.redirect_response.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "redirect_response",
+ },
+ )?;
+
+ let amount_details = Amount {
+ total_amount: item.amount.clone(),
+ currency: item.router_data.request.currency.ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ },
+ )?,
+ };
+ let redirect_payload: BarclaycardRedirectionAuthResponse = redirect_response
+ .payload
+ .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
+ field_name: "request.redirect_response.payload",
+ })?
+ .peek()
+ .clone()
+ .parse_value("BarclaycardRedirectionAuthResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ let order_information = OrderInformation { amount_details };
+ Ok(Self {
+ payment_information,
+ client_reference_information,
+ consumer_authentication_information:
+ BarclaycardConsumerAuthInformationValidateRequest {
+ authentication_transaction_id: redirect_payload.transaction_id,
+ },
+ order_information,
+ })
+ }
+}
+
impl TryFrom<&BarclaycardRouterData<&PaymentsPreProcessingRouterData>>
for BarclaycardPreProcessingRequest
{
@@ -819,81 +1062,441 @@ impl TryFrom<&BarclaycardRouterData<&PaymentsPreProcessingRouterData>>
utils::get_unimplemented_payment_method_error_message("Barclaycard"),
))
}
- }?;
-
- let redirect_response = item.router_data.request.redirect_response.clone().ok_or(
- errors::ConnectorError::MissingRequiredField {
- field_name: "redirect_response",
- },
- )?;
-
- let amount_details = Amount {
- total_amount: item.amount.clone(),
- currency: item.router_data.request.currency.ok_or(
- errors::ConnectorError::MissingRequiredField {
- field_name: "currency",
- },
- )?,
- };
+ }?;
+
+ let redirect_response = item.router_data.request.redirect_response.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "redirect_response",
+ },
+ )?;
+
+ let amount_details = Amount {
+ total_amount: item.amount.clone(),
+ currency: item.router_data.request.currency.ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ },
+ )?,
+ };
+
+ match redirect_response.params {
+ Some(param) if !param.clone().peek().is_empty() => {
+ let reference_id = param
+ .clone()
+ .peek()
+ .split_once('=')
+ .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
+ field_name: "request.redirect_response.params.reference_id",
+ })?
+ .1
+ .to_string();
+ let email = item
+ .router_data
+ .get_billing_email()
+ .or(item.router_data.request.get_email())?;
+ let bill_to = build_bill_to(item.router_data.get_billing_address()?, email)?;
+ let order_information = OrderInformationWithBill {
+ amount_details,
+ bill_to: Some(bill_to),
+ };
+ Ok(Self::AuthEnrollment(Box::new(
+ BarclaycardAuthEnrollmentRequest {
+ payment_information,
+ client_reference_information,
+ consumer_authentication_information:
+ BarclaycardConsumerAuthInformationRequest {
+ return_url: item
+ .router_data
+ .request
+ .get_complete_authorize_url()?,
+ reference_id,
+ },
+ order_information,
+ },
+ )))
+ }
+ Some(_) | None => {
+ let redirect_payload: BarclaycardRedirectionAuthResponse = redirect_response
+ .payload
+ .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
+ field_name: "request.redirect_response.payload",
+ })?
+ .peek()
+ .clone()
+ .parse_value("BarclaycardRedirectionAuthResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ let order_information = OrderInformation { amount_details };
+ Ok(Self::AuthValidate(Box::new(
+ BarclaycardAuthValidateRequest {
+ payment_information,
+ client_reference_information,
+ consumer_authentication_information:
+ BarclaycardConsumerAuthInformationValidateRequest {
+ authentication_transaction_id: redirect_payload.transaction_id,
+ },
+ order_information,
+ },
+ )))
+ }
+ }
+ }
+}
+
+impl TryFrom<PaymentsPreAuthenticateResponseRouterData<BarclaycardPreProcessingResponse>>
+ for PaymentsPreAuthenticateRouterData
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: PaymentsPreAuthenticateResponseRouterData<BarclaycardPreProcessingResponse>,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ BarclaycardPreProcessingResponse::ClientAuthCheckInfo(info_response) => {
+ let status = enums::AttemptStatus::from(info_response.status);
+ let risk_info: Option<ClientRiskInformation> = None;
+ if utils::is_payment_failure(status) {
+ let response = Err(get_error_response(
+ &info_response.error_information,
+ &None,
+ &risk_info,
+ Some(status),
+ item.http_code,
+ info_response.id.clone(),
+ ));
+
+ Ok(Self {
+ status,
+ response,
+ ..item.data
+ })
+ } else {
+ let connector_response_reference_id = Some(
+ info_response
+ .client_reference_information
+ .code
+ .unwrap_or(info_response.id.clone()),
+ );
+
+ let redirection_data = match (
+ info_response
+ .consumer_authentication_information
+ .access_token,
+ info_response
+ .consumer_authentication_information
+ .step_up_url,
+ ) {
+ (Some(token), Some(step_up_url)) => {
+ Some(RedirectForm::BarclaycardConsumerAuth {
+ access_token: token.expose(),
+ step_up_url,
+ })
+ }
+ _ => None,
+ };
+ let three_ds_data = serde_json::to_value(
+ info_response
+ .consumer_authentication_information
+ .validate_response,
+ )
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
+ Ok(Self {
+ status,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Box::new(redirection_data),
+ mandate_reference: Box::new(None),
+ connector_metadata: Some(serde_json::json!({
+ "three_ds_data": three_ds_data
+ })),
+ network_txn_id: None,
+ connector_response_reference_id,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ BarclaycardPreProcessingResponse::ErrorInformation(error_response) => {
+ let detailed_error_info =
+ error_response
+ .error_information
+ .details
+ .to_owned()
+ .map(|details| {
+ details
+ .iter()
+ .map(|details| format!("{} : {}", details.field, details.reason))
+ .collect::<Vec<_>>()
+ .join(", ")
+ });
+
+ let reason = get_error_reason(
+ error_response.error_information.message,
+ detailed_error_info,
+ None,
+ );
+ let error_message = error_response.error_information.reason.to_owned();
+ let response = Err(ErrorResponse {
+ code: error_message
+ .clone()
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
+ message: error_message
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
+ reason,
+ status_code: item.http_code,
+ connector_response_reference_id: None,
+ attempt_status: None,
+ connector_transaction_id: Some(error_response.id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ });
+ Ok(Self {
+ response,
+ status: enums::AttemptStatus::AuthenticationFailed,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+impl TryFrom<PaymentsAuthenticateResponseRouterData<BarclaycardAuthenticationResponse>>
+ for PaymentsAuthenticateRouterData
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: PaymentsAuthenticateResponseRouterData<BarclaycardAuthenticationResponse>,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ BarclaycardAuthenticationResponse::ClientAuthCheckInfo(info_response) => {
+ let status = enums::AttemptStatus::from(info_response.status);
+ let risk_info: Option<ClientRiskInformation> = None;
+ if utils::is_payment_failure(status) {
+ let response = Err(get_error_response(
+ &info_response.error_information,
+ &None,
+ &risk_info,
+ Some(status),
+ item.http_code,
+ info_response.id.clone(),
+ ));
+
+ Ok(Self {
+ status,
+ response,
+ ..item.data
+ })
+ } else {
+ let connector_response_reference_id = Some(
+ info_response
+ .client_reference_information
+ .code
+ .unwrap_or(info_response.id.clone()),
+ );
+
+ let redirection_data = match (
+ info_response
+ .consumer_authentication_information
+ .access_token,
+ info_response
+ .consumer_authentication_information
+ .step_up_url,
+ ) {
+ (Some(token), Some(step_up_url)) => {
+ Some(RedirectForm::BarclaycardConsumerAuth {
+ access_token: token.expose(),
+ step_up_url,
+ })
+ }
+ _ => None,
+ };
+ let three_ds_data = serde_json::to_value(
+ info_response
+ .consumer_authentication_information
+ .validate_response,
+ )
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
+ Ok(Self {
+ status,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Box::new(redirection_data),
+ mandate_reference: Box::new(None),
+ connector_metadata: Some(serde_json::json!({
+ "three_ds_data": three_ds_data
+ })),
+ network_txn_id: None,
+ connector_response_reference_id,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ BarclaycardAuthenticationResponse::ErrorInformation(error_response) => {
+ let detailed_error_info =
+ error_response
+ .error_information
+ .details
+ .to_owned()
+ .map(|details| {
+ details
+ .iter()
+ .map(|details| format!("{} : {}", details.field, details.reason))
+ .collect::<Vec<_>>()
+ .join(", ")
+ });
+
+ let reason = get_error_reason(
+ error_response.error_information.message,
+ detailed_error_info,
+ None,
+ );
+ let error_message = error_response.error_information.reason.to_owned();
+ let response = Err(ErrorResponse {
+ code: error_message
+ .clone()
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
+ message: error_message
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
+ reason,
+ status_code: item.http_code,
+ connector_response_reference_id: None,
+ attempt_status: None,
+ connector_transaction_id: Some(error_response.id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ });
+ Ok(Self {
+ response,
+ status: enums::AttemptStatus::AuthenticationFailed,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+impl TryFrom<PaymentsPostAuthenticateResponseRouterData<BarclaycardAuthenticationResponse>>
+ for PaymentsPostAuthenticateRouterData
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: PaymentsPostAuthenticateResponseRouterData<BarclaycardAuthenticationResponse>,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ BarclaycardAuthenticationResponse::ClientAuthCheckInfo(info_response) => {
+ let status = enums::AttemptStatus::from(info_response.status);
+ let risk_info: Option<ClientRiskInformation> = None;
+ if utils::is_payment_failure(status) {
+ let response = Err(get_error_response(
+ &info_response.error_information,
+ &None,
+ &risk_info,
+ Some(status),
+ item.http_code,
+ info_response.id.clone(),
+ ));
+
+ Ok(Self {
+ status,
+ response,
+ ..item.data
+ })
+ } else {
+ let connector_response_reference_id = Some(
+ info_response
+ .client_reference_information
+ .code
+ .unwrap_or(info_response.id.clone()),
+ );
+
+ let redirection_data = match (
+ info_response
+ .consumer_authentication_information
+ .access_token,
+ info_response
+ .consumer_authentication_information
+ .step_up_url,
+ ) {
+ (Some(token), Some(step_up_url)) => {
+ Some(RedirectForm::BarclaycardConsumerAuth {
+ access_token: token.expose(),
+ step_up_url,
+ })
+ }
+ _ => None,
+ };
+ let three_ds_data = serde_json::to_value(
+ info_response
+ .consumer_authentication_information
+ .validate_response,
+ )
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
+ Ok(Self {
+ status,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Box::new(redirection_data),
+ mandate_reference: Box::new(None),
+ connector_metadata: Some(serde_json::json!({
+ "three_ds_data": three_ds_data
+ })),
+ network_txn_id: None,
+ connector_response_reference_id,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ BarclaycardAuthenticationResponse::ErrorInformation(error_response) => {
+ let detailed_error_info =
+ error_response
+ .error_information
+ .details
+ .to_owned()
+ .map(|details| {
+ details
+ .iter()
+ .map(|details| format!("{} : {}", details.field, details.reason))
+ .collect::<Vec<_>>()
+ .join(", ")
+ });
- match redirect_response.params {
- Some(param) if !param.clone().peek().is_empty() => {
- let reference_id = param
- .clone()
- .peek()
- .split_once('=')
- .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
- field_name: "request.redirect_response.params.reference_id",
- })?
- .1
- .to_string();
- let email = item
- .router_data
- .get_billing_email()
- .or(item.router_data.request.get_email())?;
- let bill_to = build_bill_to(item.router_data.get_billing_address()?, email)?;
- let order_information = OrderInformationWithBill {
- amount_details,
- bill_to: Some(bill_to),
- };
- Ok(Self::AuthEnrollment(Box::new(
- BarclaycardAuthEnrollmentRequest {
- payment_information,
- client_reference_information,
- consumer_authentication_information:
- BarclaycardConsumerAuthInformationRequest {
- return_url: item
- .router_data
- .request
- .get_complete_authorize_url()?,
- reference_id,
- },
- order_information,
- },
- )))
- }
- Some(_) | None => {
- let redirect_payload: BarclaycardRedirectionAuthResponse = redirect_response
- .payload
- .ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
- field_name: "request.redirect_response.payload",
- })?
- .peek()
- .clone()
- .parse_value("BarclaycardRedirectionAuthResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- let order_information = OrderInformation { amount_details };
- Ok(Self::AuthValidate(Box::new(
- BarclaycardAuthValidateRequest {
- payment_information,
- client_reference_information,
- consumer_authentication_information:
- BarclaycardConsumerAuthInformationValidateRequest {
- authentication_transaction_id: redirect_payload.transaction_id,
- },
- order_information,
- },
- )))
+ let reason = get_error_reason(
+ error_response.error_information.message,
+ detailed_error_info,
+ None,
+ );
+ let error_message = error_response.error_information.reason.to_owned();
+ let response = Err(ErrorResponse {
+ code: error_message
+ .clone()
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
+ message: error_message
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
+ reason,
+ status_code: item.http_code,
+ connector_response_reference_id: None,
+ attempt_status: None,
+ connector_transaction_id: Some(error_response.id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ });
+ Ok(Self {
+ response,
+ status: enums::AttemptStatus::AuthenticationFailed,
+ ..item.data
+ })
}
}
}
@@ -1047,6 +1650,69 @@ fn extract_score_id(message_extensions: &[MessageExtensionAttribute]) -> Option<
})
}
+impl TryFrom<&BarclaycardRouterData<&PaymentsPreAuthenticateRouterData>>
+ for BarclaycardAuthSetupRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &BarclaycardRouterData<&PaymentsPreAuthenticateRouterData>,
+ ) -> Result<Self, Self::Error> {
+ match item.router_data.request.payment_method_data.clone() {
+ PaymentMethodData::Card(ccard) => {
+ let card_type = match ccard
+ .card_network
+ .clone()
+ .and_then(get_barclaycard_card_type)
+ {
+ Some(card_network) => Some(card_network.to_string()),
+ None => ccard.get_card_issuer().ok().map(String::from),
+ };
+
+ let payment_information =
+ PaymentInformation::Cards(Box::new(CardPaymentInformation {
+ card: Card {
+ number: ccard.card_number,
+ expiration_month: ccard.card_exp_month,
+ expiration_year: ccard.card_exp_year,
+ security_code: ccard.card_cvc,
+ card_type,
+ type_selection_indicator: Some("1".to_owned()),
+ },
+ }));
+ let client_reference_information = ClientReferenceInformation::from(item);
+ Ok(Self {
+ payment_information,
+ client_reference_information,
+ })
+ }
+ PaymentMethodData::Wallet(_)
+ | PaymentMethodData::CardRedirect(_)
+ | PaymentMethodData::PayLater(_)
+ | PaymentMethodData::BankRedirect(_)
+ | PaymentMethodData::BankDebit(_)
+ | PaymentMethodData::BankTransfer(_)
+ | PaymentMethodData::Crypto(_)
+ | PaymentMethodData::MandatePayment
+ | PaymentMethodData::Reward
+ | PaymentMethodData::RealTimePayment(_)
+ | PaymentMethodData::MobilePayment(_)
+ | PaymentMethodData::Upi(_)
+ | PaymentMethodData::Voucher(_)
+ | PaymentMethodData::GiftCard(_)
+ | PaymentMethodData::OpenBanking(_)
+ | PaymentMethodData::CardToken(_)
+ | PaymentMethodData::NetworkToken(_)
+ | PaymentMethodData::CardDetailsForNetworkTransactionId(_)
+ | PaymentMethodData::NetworkTokenDetailsForNetworkTransactionId(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("Barclaycard"),
+ )
+ .into())
+ }
+ }
+ }
+}
+
impl TryFrom<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for BarclaycardAuthSetupRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
@@ -1584,6 +2250,89 @@ impl TryFrom<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for Barclayca
}
}
+impl TryFrom<PaymentsPreAuthenticateResponseRouterData<BarclaycardAuthSetupResponse>>
+ for PaymentsPreAuthenticateRouterData
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: PaymentsPreAuthenticateResponseRouterData<BarclaycardAuthSetupResponse>,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ BarclaycardAuthSetupResponse::ClientAuthSetupInfo(info_response) => Ok(Self {
+ status: enums::AttemptStatus::AuthenticationPending,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Box::new(Some(RedirectForm::BarclaycardAuthSetup {
+ access_token: info_response
+ .consumer_authentication_information
+ .access_token,
+ ddc_url: info_response
+ .consumer_authentication_information
+ .device_data_collection_url,
+ reference_id: info_response
+ .consumer_authentication_information
+ .reference_id,
+ })),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: Some(
+ info_response
+ .client_reference_information
+ .code
+ .unwrap_or(info_response.id.clone()),
+ ),
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ }),
+ BarclaycardAuthSetupResponse::ErrorInformation(error_response) => {
+ let detailed_error_info =
+ error_response
+ .error_information
+ .details
+ .to_owned()
+ .map(|details| {
+ details
+ .iter()
+ .map(|details| format!("{} : {}", details.field, details.reason))
+ .collect::<Vec<_>>()
+ .join(", ")
+ });
+
+ let reason = get_error_reason(
+ error_response.error_information.message,
+ detailed_error_info,
+ None,
+ );
+ let error_message = error_response.error_information.reason;
+ Ok(Self {
+ response: Err(ErrorResponse {
+ code: error_message
+ .clone()
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
+ message: error_message.unwrap_or(
+ hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string(),
+ ),
+ reason,
+ status_code: item.http_code,
+ connector_response_reference_id: None,
+ attempt_status: None,
+ connector_transaction_id: Some(error_response.id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ status: enums::AttemptStatus::AuthenticationFailed,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
impl TryFrom<PaymentsResponseRouterData<BarclaycardAuthSetupResponse>>
for PaymentsAuthorizeRouterData
{
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 43a22f24e3..78a221723f 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -1949,7 +1949,6 @@ default_imp_for_pre_authenticate_steps!(
connectors::Bambora,
connectors::Bamboraapac,
connectors::Bankofamerica,
- connectors::Barclaycard,
connectors::Billwerk,
connectors::Bitpay,
connectors::Blackhawknetwork,
@@ -2099,7 +2098,6 @@ default_imp_for_authenticate_steps!(
connectors::Bambora,
connectors::Bamboraapac,
connectors::Bankofamerica,
- connectors::Barclaycard,
connectors::Billwerk,
connectors::Bitpay,
connectors::Blackhawknetwork,
@@ -2252,7 +2250,6 @@ default_imp_for_post_authenticate_steps!(
connectors::Bambora,
connectors::Bamboraapac,
connectors::Bankofamerica,
- connectors::Barclaycard,
connectors::Billwerk,
connectors::Bitpay,
connectors::Blackhawknetwork,
diff --git a/crates/hyperswitch_connectors/src/types.rs b/crates/hyperswitch_connectors/src/types.rs
index 1ab0ffbe57..4ac36c931f 100644
--- a/crates/hyperswitch_connectors/src/types.rs
+++ b/crates/hyperswitch_connectors/src/types.rs
@@ -8,7 +8,7 @@ use hyperswitch_domain_models::{
authentication::{
Authentication, PostAuthentication, PreAuthentication, PreAuthenticationVersionCall,
},
- unified_authentication_service::{PostAuthenticate, PreAuthenticate},
+ unified_authentication_service::{Authenticate, PostAuthenticate, PreAuthenticate},
Accept, AccessTokenAuth, Authorize, Capture, CreateOrder, Defend, Dsync, Evidence,
ExtendAuthorization, Fetch, PSync, PostProcessing, PreProcessing, Retrieve, Session,
Upload, Void,
@@ -19,11 +19,12 @@ use hyperswitch_domain_models::{
PreAuthNRequestData,
},
AcceptDisputeRequestData, AccessTokenRequestData, CreateOrderRequestData,
- DefendDisputeRequestData, DisputeSyncData, FetchDisputesRequestData, PaymentsAuthorizeData,
- PaymentsCancelData, PaymentsCaptureData, PaymentsExtendAuthorizationData,
- PaymentsPostAuthenticateData, PaymentsPostProcessingData, PaymentsPreAuthenticateData,
- PaymentsPreProcessingData, PaymentsSessionData, PaymentsSyncData, RefundsData,
- RetrieveFileRequestData, SubmitEvidenceRequestData, UploadFileRequestData,
+ DefendDisputeRequestData, DisputeSyncData, FetchDisputesRequestData,
+ PaymentsAuthenticateData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData,
+ PaymentsExtendAuthorizationData, PaymentsPostAuthenticateData, PaymentsPostProcessingData,
+ PaymentsPreAuthenticateData, PaymentsPreProcessingData, PaymentsSessionData,
+ PaymentsSyncData, RefundsData, RetrieveFileRequestData, SubmitEvidenceRequestData,
+ UploadFileRequestData,
},
router_response_types::{
AcceptDisputeResponse, AuthenticationResponseData, DefendDisputeResponse,
@@ -54,6 +55,8 @@ pub(crate) type RefreshTokenRouterData =
RouterData<AccessTokenAuth, AccessTokenRequestData, AccessToken>;
pub(crate) type PaymentsPostAuthenticateResponseRouterData<R> =
ResponseRouterData<PostAuthenticate, R, PaymentsPostAuthenticateData, PaymentsResponseData>;
+pub(crate) type PaymentsAuthenticateResponseRouterData<R> =
+ ResponseRouterData<Authenticate, R, PaymentsAuthenticateData, PaymentsResponseData>;
pub(crate) type PaymentsCancelResponseRouterData<R> =
ResponseRouterData<Void, R, PaymentsCancelData, PaymentsResponseData>;
pub(crate) type PaymentsPreAuthenticateResponseRouterData<R> =