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(connector): [barclaycard] Implement 3DS flow for cards (#8936)

Vani Gupta19db2b5cb8eb
diff --git a/config/config.example.toml b/config/config.example.toml
index af9af674a7..ab7f0ebdef 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -491,6 +491,7 @@ adyen = "Star,Pulse,Accel,Nyce" # Debit networks su
stripe = { payment_method = "bank_transfer" }
nuvei = { payment_method = "card" }
shift4 = { payment_method = "card" }
+barclaycard = { payment_method = "card" }
bluesnap = { payment_method = "card" }
bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 40efdcf07d..e1d1b47772 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -778,6 +778,7 @@ shift4.payment_method = "card"
stripe.payment_method = "bank_transfer"
bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
+barclaycard = { payment_method = "card" }
nmi.payment_method = "card"
payme.payment_method = "card"
deutschebank = { payment_method = "bank_debit" }
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 85b8ebbbda..595143f0de 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -788,6 +788,7 @@ shift4.payment_method = "card"
stripe.payment_method = "bank_transfer"
bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
+barclaycard = { payment_method = "card" }
nmi.payment_method = "card"
payme.payment_method = "card"
deutschebank = { payment_method = "bank_debit" }
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index bad07aa9b4..1e8005a6fe 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -795,6 +795,7 @@ shift4.payment_method = "card"
stripe.payment_method = "bank_transfer"
bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
+barclaycard = { payment_method = "card" }
nmi.payment_method = "card"
payme.payment_method = "card"
deutschebank = { payment_method = "bank_debit" }
diff --git a/config/development.toml b/config/development.toml
index c1533620d3..2dae99e621 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -954,6 +954,7 @@ shift4 = { payment_method = "card" }
bluesnap = { payment_method = "card" }
bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
+barclaycard = { payment_method = "card" }
nmi = { payment_method = "card" }
payme = { payment_method = "card" }
deutschebank = { payment_method = "bank_debit" }
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index cf0057d54d..c8cb463238 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -410,6 +410,7 @@ shift4 = { payment_method = "card" }
bluesnap = { payment_method = "card" }
bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
+barclaycard = { payment_method = "card" }
nmi = { payment_method = "card" }
payme = { payment_method = "card" }
deutschebank = { payment_method = "bank_debit" }
diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rs
index 6c80160cc6..9c3b4a56d6 100644
--- a/crates/diesel_models/src/payment_attempt.rs
+++ b/crates/diesel_models/src/payment_attempt.rs
@@ -3819,6 +3819,15 @@ pub enum RedirectForm {
Html {
html_data: String,
},
+ BarclaycardAuthSetup {
+ access_token: String,
+ ddc_url: String,
+ reference_id: String,
+ },
+ BarclaycardConsumerAuth {
+ access_token: String,
+ step_up_url: String,
+ },
BlueSnap {
payment_fields_token: String,
},
diff --git a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
index 86b862bc8c..9327f8ec1f 100644
--- a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
+++ b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
@@ -8,19 +8,23 @@ use common_utils::{
errors::CustomResult,
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
+ types::{AmountConvertor, MinorUnit, StringMajorUnit, StringMajorUnitForConnector},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
- payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
+ payments::{
+ Authorize, Capture, CompleteAuthorize, PSync, PaymentMethodToken, PreProcessing,
+ Session, SetupMandate, Void,
+ },
refunds::{Execute, RSync},
},
router_request_types::{
- AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
- PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
- RefundsData, SetupMandateRequestData,
+ AccessTokenRequestData, CompleteAuthorizeData, PaymentMethodTokenizationData,
+ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData,
+ PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,
@@ -28,6 +32,7 @@ use hyperswitch_domain_models::{
},
types::{
PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsCompleteAuthorizeRouterData, PaymentsPreProcessingRouterData,
PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
},
};
@@ -51,14 +56,26 @@ use url::Url;
use crate::{
constants::{self, headers},
types::ResponseRouterData,
- utils::RefundsRequestData,
+ utils::{
+ convert_amount, PaymentsAuthorizeRequestData, RefundsRequestData,
+ RouterData as OtherRouterData,
+ },
};
pub const V_C_MERCHANT_ID: &str = "v-c-merchant-id";
#[derive(Clone)]
-pub struct Barclaycard;
+pub struct Barclaycard {
+ amount_converter: &'static (dyn AmountConvertor<Output = StringMajorUnit> + Sync),
+}
+impl Barclaycard {
+ pub fn new() -> &'static Self {
+ &Self {
+ amount_converter: &StringMajorUnitForConnector,
+ }
+ }
+}
impl Barclaycard {
pub fn generate_digest(&self, payload: &[u8]) -> String {
let payload_digest = digest::digest(&digest::SHA256, payload);
@@ -110,11 +127,13 @@ impl Barclaycard {
impl api::Payment for Barclaycard {}
impl api::PaymentSession for Barclaycard {}
+impl api::PaymentsPreProcessing for Barclaycard {}
impl api::ConnectorAccessToken for Barclaycard {}
impl api::MandateSetup for Barclaycard {}
impl api::PaymentAuthorize for Barclaycard {}
impl api::PaymentSync for Barclaycard {}
impl api::PaymentCapture for Barclaycard {}
+impl api::PaymentsCompleteAuthorize for Barclaycard {}
impl api::PaymentVoid for Barclaycard {}
impl api::Refund for Barclaycard {}
impl api::RefundExecute for Barclaycard {}
@@ -325,10 +344,12 @@ impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsRespons
{
}
-impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Barclaycard {
+impl ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>
+ for Barclaycard
+{
fn get_headers(
&self,
- req: &PaymentsAuthorizeRouterData,
+ req: &PaymentsPreProcessingRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
@@ -340,47 +361,67 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
fn get_url(
&self,
- _req: &PaymentsAuthorizeRouterData,
+ req: &PaymentsPreProcessingRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Ok(format!(
- "{}pts/v2/payments",
- ConnectorCommon::base_url(self, connectors)
- ))
+ let redirect_response = req.request.redirect_response.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "redirect_response",
+ },
+ )?;
+ match redirect_response.params {
+ Some(param) if !param.clone().peek().is_empty() => Ok(format!(
+ "{}risk/v1/authentications",
+ self.base_url(connectors)
+ )),
+ Some(_) | None => Ok(format!(
+ "{}risk/v1/authentication-results",
+ self.base_url(connectors)
+ )),
+ }
}
fn get_request_body(
&self,
- req: &PaymentsAuthorizeRouterData,
+ req: &PaymentsPreProcessingRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let connector_router_data = barclaycard::BarclaycardRouterData::try_from((
- &self.get_currency_unit(),
- req.request.currency,
- req.request.amount,
- req,
- ))?;
+ let amount_in_minor_unit = MinorUnit::new(req.request.amount.ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "amount",
+ },
+ )?);
+ let amount = convert_amount(
+ self.amount_converter,
+ amount_in_minor_unit,
+ req.request
+ .currency
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "currency",
+ })?,
+ )?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
let connector_req =
- barclaycard::BarclaycardPaymentsRequest::try_from(&connector_router_data)?;
+ barclaycard::BarclaycardPreProcessingRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
- req: &PaymentsAuthorizeRouterData,
+ req: &PaymentsPreProcessingRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
- .url(&types::PaymentsAuthorizeType::get_url(
+ .url(&types::PaymentsPreProcessingType::get_url(
self, req, connectors,
)?)
.attach_default_headers()
- .headers(types::PaymentsAuthorizeType::get_headers(
+ .headers(types::PaymentsPreProcessingType::get_headers(
self, req, connectors,
)?)
- .set_body(types::PaymentsAuthorizeType::get_request_body(
+ .set_body(types::PaymentsPreProcessingType::get_request_body(
self, req, connectors,
)?)
.build(),
@@ -389,13 +430,13 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
fn handle_response(
&self,
- data: &PaymentsAuthorizeRouterData,
+ data: &PaymentsPreProcessingRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
- let response: barclaycard::BarclaycardPaymentsResponse = res
+ ) -> CustomResult<PaymentsPreProcessingRouterData, errors::ConnectorError> {
+ let response: barclaycard::BarclaycardPreProcessingResponse = res
.response
- .parse_struct("Barclaycard PaymentsAuthorizeResponse")
+ .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);
@@ -413,6 +454,125 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
+}
+
+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Barclaycard {
+ fn get_headers(
+ &self,
+ req: &PaymentsAuthorizeRouterData,
+ 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: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ if req.is_three_ds() && req.request.is_card() {
+ Ok(format!(
+ "{}risk/v1/authentication-setups",
+ ConnectorCommon::base_url(self, connectors)
+ ))
+ } else {
+ Ok(format!(
+ "{}pts/v2/payments/",
+ ConnectorCommon::base_url(self, connectors)
+ ))
+ }
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsAuthorizeRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount_in_minor_unit = MinorUnit::new(req.request.amount);
+ let amount = convert_amount(
+ self.amount_converter,
+ amount_in_minor_unit,
+ req.request.currency,
+ )?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
+
+ if req.is_three_ds() && req.request.is_card() {
+ let connector_req =
+ barclaycard::BarclaycardAuthSetupRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ } else {
+ let connector_req =
+ barclaycard::BarclaycardPaymentsRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsAuthorizeType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(types::PaymentsAuthorizeType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::PaymentsAuthorizeType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsAuthorizeRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
+ if data.is_three_ds() && data.request.is_card() {
+ 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);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ } else {
+ let response: barclaycard::BarclaycardPaymentsResponse = res
+ .response
+ .parse_struct("Barclaycard PaymentsAuthorizeResponse")
+ .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)
+ }
fn get_5xx_error_response(
&self,
@@ -559,12 +719,13 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let connector_router_data = barclaycard::BarclaycardRouterData::try_from((
- &self.get_currency_unit(),
+ let amount_in_minor_unit = MinorUnit::new(req.request.amount_to_capture);
+ let amount = convert_amount(
+ self.amount_converter,
+ amount_in_minor_unit,
req.request.currency,
- req.request.amount_to_capture,
- req,
- ))?;
+ )?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
let connector_req =
barclaycard::BarclaycardCaptureRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
@@ -679,20 +840,21 @@ impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Ba
req: &PaymentsCancelRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let connector_router_data = barclaycard::BarclaycardRouterData::try_from((
- &self.get_currency_unit(),
+ let amount_in_minor_unit = MinorUnit::new(req.request.amount.ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "amount",
+ },
+ )?);
+ let amount = convert_amount(
+ self.amount_converter,
+ amount_in_minor_unit,
req.request
.currency
.ok_or(errors::ConnectorError::MissingRequiredField {
- field_name: "Currency",
+ field_name: "currency",
})?,
- req.request
- .amount
- .ok_or(errors::ConnectorError::MissingRequiredField {
- field_name: "Amount",
- })?,
- req,
- ))?;
+ )?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
let connector_req = barclaycard::BarclaycardVoidRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
@@ -803,12 +965,13 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Barclay
req: &RefundsRouterData<Execute>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let connector_router_data = barclaycard::BarclaycardRouterData::try_from((
- &self.get_currency_unit(),
+ let amount_in_minor_unit = MinorUnit::new(req.request.refund_amount);
+ let amount = convert_amount(
+ self.amount_converter,
+ amount_in_minor_unit,
req.request.currency,
- req.request.refund_amount,
- req,
- ))?;
+ )?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
let connector_req =
barclaycard::BarclaycardRefundRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
@@ -936,6 +1099,134 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Barclayca
}
}
+impl ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>
+ for Barclaycard
+{
+ fn get_headers(
+ &self,
+ req: &PaymentsCompleteAuthorizeRouterData,
+ 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: &PaymentsCompleteAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!(
+ "{}pts/v2/payments/",
+ ConnectorCommon::base_url(self, connectors)
+ ))
+ }
+ fn get_request_body(
+ &self,
+ req: &PaymentsCompleteAuthorizeRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount_in_minor_unit = MinorUnit::new(req.request.amount);
+ let amount = convert_amount(
+ self.amount_converter,
+ amount_in_minor_unit,
+ req.request.currency,
+ )?;
+ let connector_router_data = barclaycard::BarclaycardRouterData::try_from((amount, req))?;
+
+ let connector_req =
+ barclaycard::BarclaycardPaymentsRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+ fn build_request(
+ &self,
+ req: &PaymentsCompleteAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsCompleteAuthorizeType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(types::PaymentsCompleteAuthorizeType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::PaymentsCompleteAuthorizeType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsCompleteAuthorizeRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsCompleteAuthorizeRouterData, errors::ConnectorError> {
+ let response: barclaycard::BarclaycardPaymentsResponse = res
+ .response
+ .parse_struct("Barclaycard PaymentResponse")
+ .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)
+ }
+
+ fn get_5xx_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ let response: barclaycard::BarclaycardServerErrorResponse = res
+ .response
+ .parse_struct("BarclaycardServerErrorResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|event| event.set_response_body(&response));
+ router_env::logger::info!(error_response=?response);
+
+ let attempt_status = match response.reason {
+ Some(reason) => match reason {
+ transformers::Reason::SystemError => Some(enums::AttemptStatus::Failure),
+ transformers::Reason::ServerTimeout | transformers::Reason::ServiceTimeout => None,
+ },
+ None => None,
+ };
+ Ok(ErrorResponse {
+ status_code: res.status_code,
+ reason: response.status.clone(),
+ code: response
+ .status
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
+ message: response
+ .message
+ .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
+ attempt_status,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ })
+ }
+}
+
#[async_trait::async_trait]
impl webhooks::IncomingWebhook for Barclaycard {
fn get_webhook_object_reference_id(
@@ -993,7 +1284,7 @@ static BARCLAYCARD_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods>
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
- three_ds: common_enums::FeatureStatus::NotSupported,
+ three_ds: common_enums::FeatureStatus::Supported,
no_three_ds: common_enums::FeatureStatus::Supported,
supported_card_networks: supported_card_network.clone(),
}
@@ -1012,7 +1303,7 @@ static BARCLAYCARD_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods>
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
- three_ds: common_enums::FeatureStatus::NotSupported,
+ three_ds: common_enums::FeatureStatus::Supported,
no_three_ds: common_enums::FeatureStatus::Supported,
supported_card_networks: supported_card_network.clone(),
}
diff --git a/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs b/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
index db96314992..9d78d9de9a 100644
--- a/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
@@ -1,6 +1,11 @@
use base64::Engine;
use common_enums::enums;
-use common_utils::{consts, pii};
+use common_utils::{
+ consts, date_time,
+ ext_traits::ValueExt,
+ pii,
+ types::{SemanticVersion, StringMajorUnit},
+};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::{GooglePayWalletData, PaymentMethodData, WalletData},
@@ -10,17 +15,18 @@ use hyperswitch_domain_models::{
},
router_flow_types::refunds::{Execute, RSync},
router_request_types::{
- PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData,
+ authentication::MessageExtensionAttribute, CompleteAuthorizeData, PaymentsAuthorizeData,
+ PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSyncData,
ResponseId,
},
- router_response_types::{PaymentsResponseData, RefundsResponseData},
+ router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
types::{
PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
- RefundsRouterData,
+ PaymentsCompleteAuthorizeRouterData, PaymentsPreProcessingRouterData, RefundsRouterData,
},
};
-use hyperswitch_interfaces::{api, errors};
-use masking::{ExposeInterface, Secret};
+use hyperswitch_interfaces::errors;
+use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use serde_json::Value;
@@ -28,8 +34,9 @@ use crate::{
constants,
types::{RefundsResponseRouterData, ResponseRouterData},
utils::{
- self, AddressDetailsData, CardData, PaymentsAuthorizeRequestData, PaymentsSyncRequestData,
- RouterData as OtherRouterData,
+ self, AddressDetailsData, CardData, PaymentsAuthorizeRequestData,
+ PaymentsCompleteAuthorizeRequestData, PaymentsPreProcessingRequestData,
+ PaymentsSyncRequestData, RouterData as OtherRouterData,
},
};
pub struct BarclaycardAuthType {
@@ -59,23 +66,13 @@ impl TryFrom<&ConnectorAuthType> for BarclaycardAuthType {
}
pub struct BarclaycardRouterData<T> {
- pub amount: String,
+ pub amount: StringMajorUnit,
pub router_data: T,
}
-impl<T> TryFrom<(&api::CurrencyUnit, api_models::enums::Currency, i64, T)>
- for BarclaycardRouterData<T>
-{
+impl<T> TryFrom<(StringMajorUnit, T)> for BarclaycardRouterData<T> {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(
- (currency_unit, currency, amount, item): (
- &api::CurrencyUnit,
- api_models::enums::Currency,
- i64,
- T,
- ),
- ) -> Result<Self, Self::Error> {
- let amount = utils::get_amount_as_string(currency_unit, amount, currency)?;
+ fn try_from((amount, item): (StringMajorUnit, T)) -> Result<Self, Self::Error> {
Ok(Self {
amount,
router_data: item,
@@ -102,6 +99,7 @@ pub struct ProcessingInformation {
commerce_indicator: String,
capture: Option<bool>,
payment_solution: Option<String>,
+ cavv_algorithm: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -111,15 +109,62 @@ pub struct MerchantDefinedInformation {
value: String,
}
+#[derive(Debug, Serialize)]
+pub enum BarclaycardParesStatus {
+ #[serde(rename = "Y")]
+ AuthenticationSuccessful,
+ #[serde(rename = "A")]
+ AuthenticationAttempted,
+ #[serde(rename = "N")]
+ AuthenticationFailed,
+ #[serde(rename = "U")]
+ AuthenticationNotCompleted,
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BarclaycardConsumerAuthInformation {
ucaf_collection_indicator: Option<String>,
- cavv: Option<String>,
+ cavv: Option<Secret<String>>,
ucaf_authentication_data: Option<Secret<String>>,
xid: Option<String>,
directory_server_transaction_id: Option<Secret<String>>,
- specification_version: Option<String>,
+ specification_version: Option<SemanticVersion>,
+ /// This field specifies the 3ds version
+ pa_specification_version: Option<SemanticVersion>,
+ /// Verification response enrollment status.
+ ///
+ /// This field is supported only on Asia, Middle East, and Africa Gateway.
+ ///
+ /// For external authentication, this field will always be "Y"
+ veres_enrolled: Option<String>,
+ /// Raw electronic commerce indicator (ECI)
+ eci_raw: Option<String>,
+ /// This field is supported only on Asia, Middle East, and Africa Gateway
+ /// Also needed for Credit Mutuel-CIC in France and Mastercard Identity Check transactions
+ /// This field is only applicable for Mastercard and Visa Transactions
+ pares_status: Option<BarclaycardParesStatus>,
+ //This field is used to send the authentication date in yyyyMMDDHHMMSS format
+ authentication_date: Option<String>,
+ /// This field indicates the 3D Secure transaction flow. It is only supported for secure transactions in France.
+ /// The possible values are - CH (Challenge), FD (Frictionless with delegation), FR (Frictionless)
+ effective_authentication_type: Option<EffectiveAuthenticationType>,
+ /// This field indicates the authentication type or challenge presented to the cardholder at checkout.
+ challenge_code: Option<String>,
+ /// This field indicates the reason for payer authentication response status. It is only supported for secure transactions in France.
+ pares_status_reason: Option<String>,
+ /// This field indicates the reason why strong authentication was cancelled. It is only supported for secure transactions in France.
+ challenge_cancel_code: Option<String>,
+ /// This field indicates the score calculated by the 3D Securing platform. It is only supported for secure transactions in France.
+ network_score: Option<u32>,
+ /// This is the transaction ID generated by the access control server. This field is supported only for secure transactions in France.
+ acs_transaction_id: Option<String>,
+}
+
+#[derive(Debug, Serialize)]
+pub enum EffectiveAuthenticationType {
+ CH,
+ FR,
}
#[derive(Debug, Serialize)]
@@ -150,6 +195,7 @@ pub struct Card {
security_code: Secret<String>,
#[serde(rename = "type")]
card_type: Option<String>,
+ type_selection_indicator: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -168,7 +214,7 @@ pub struct OrderInformationWithBill {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Amount {
- total_amount: String,
+ total_amount: StringMajorUnit,
currency: api_models::enums::Currency,
}
@@ -268,7 +314,7 @@ impl
) -> Self {
Self {
amount_details: Amount {
- total_amount: item.amount.to_owned(),
+ total_amount: item.amount.clone(),
currency: item.router_data.request.currency,
},
bill_to,
@@ -293,7 +339,37 @@ impl
),
) -> Result<Self, Self::Error> {
let commerce_indicator = get_commerce_indicator(network);
+ let cavv_algorithm = Some("2".to_string());
+ Ok(Self {
+ capture: Some(matches!(
+ item.router_data.request.capture_method,
+ Some(enums::CaptureMethod::Automatic) | None
+ )),
+ payment_solution: solution.map(String::from),
+ commerce_indicator,
+ cavv_algorithm,
+ })
+ }
+}
+
+impl
+ TryFrom<(
+ &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ Option<PaymentSolution>,
+ Option<String>,
+ )> for ProcessingInformation
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ (item, solution, network): (
+ &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ Option<PaymentSolution>,
+ Option<String>,
+ ),
+ ) -> Result<Self, Self::Error> {
+ let commerce_indicator = get_commerce_indicator(network);
+ let cavv_algorithm = Some("2".to_string());
Ok(Self {
capture: Some(matches!(
item.router_data.request.capture_method,
@@ -301,10 +377,21 @@ impl
)),
payment_solution: solution.map(String::from),
commerce_indicator,
+ cavv_algorithm,
})
}
}
+impl From<&BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>>
+ for ClientReferenceInformation
+{
+ fn from(item: &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>) -> Self {
+ Self {
+ code: Some(item.router_data.connector_request_reference_id.clone()),
+ }
+ }
+}
+
impl From<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for ClientReferenceInformation {
fn from(item: &BarclaycardRouterData<&PaymentsAuthorizeRouterData>) -> Self {
Self {
@@ -313,6 +400,49 @@ impl From<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for ClientRefere
}
}
+impl
+ From<(
+ &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ BillTo,
+ )> for OrderInformationWithBill
+{
+ fn from(
+ (item, bill_to): (
+ &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ BillTo,
+ ),
+ ) -> Self {
+ Self {
+ amount_details: Amount {
+ total_amount: item.amount.clone(),
+ currency: item.router_data.request.currency,
+ },
+ bill_to: Some(bill_to),
+ }
+ }
+}
+
+impl From<BarclaycardAuthEnrollmentStatus> for enums::AttemptStatus {
+ fn from(item: BarclaycardAuthEnrollmentStatus) -> Self {
+ match item {
+ BarclaycardAuthEnrollmentStatus::PendingAuthentication => Self::AuthenticationPending,
+ BarclaycardAuthEnrollmentStatus::AuthenticationSuccessful => {
+ Self::AuthenticationSuccessful
+ }
+ BarclaycardAuthEnrollmentStatus::AuthenticationFailed => Self::AuthenticationFailed,
+ }
+ }
+}
+
+impl From<common_enums::DecoupledAuthenticationType> for EffectiveAuthenticationType {
+ fn from(auth_type: common_enums::DecoupledAuthenticationType) -> Self {
+ match auth_type {
+ common_enums::DecoupledAuthenticationType::Challenge => Self::CH,
+ common_enums::DecoupledAuthenticationType::Frictionless => Self::FR,
+ }
+ }
+}
+
fn convert_metadata_to_merchant_defined_info(metadata: Value) -> Vec<MerchantDefinedInformation> {
let hashmap: std::collections::BTreeMap<String, Value> =
serde_json::from_str(&metadata.to_string()).unwrap_or(std::collections::BTreeMap::new());
@@ -437,6 +567,492 @@ pub struct Avs {
code_raw: Option<String>,
}
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardConsumerAuthValidateResponse {
+ ucaf_collection_indicator: Option<String>,
+ cavv: Option<Secret<String>>,
+ ucaf_authentication_data: Option<Secret<String>>,
+ xid: Option<String>,
+ specification_version: Option<SemanticVersion>,
+ directory_server_transaction_id: Option<Secret<String>>,
+ indicator: Option<String>,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+pub struct BarclaycardThreeDSMetadata {
+ three_ds_data: BarclaycardConsumerAuthValidateResponse,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardConsumerAuthInformationEnrollmentResponse {
+ access_token: Option<Secret<String>>,
+ step_up_url: Option<String>,
+ //Added to segregate the three_ds_data in a separate struct
+ #[serde(flatten)]
+ validate_response: BarclaycardConsumerAuthValidateResponse,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum BarclaycardAuthEnrollmentStatus {
+ PendingAuthentication,
+ AuthenticationSuccessful,
+ AuthenticationFailed,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ClientAuthCheckInfoResponse {
+ id: String,
+ client_reference_information: ClientReferenceInformation,
+ consumer_authentication_information: BarclaycardConsumerAuthInformationEnrollmentResponse,
+ status: BarclaycardAuthEnrollmentStatus,
+ error_information: Option<BarclaycardErrorInformation>,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardConsumerAuthInformationValidateRequest {
+ authentication_transaction_id: String,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub enum BarclaycardPreProcessingResponse {
+ ClientAuthCheckInfo(Box<ClientAuthCheckInfoResponse>),
+ ErrorInformation(Box<BarclaycardErrorInformationResponse>),
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardAuthSetupRequest {
+ payment_information: PaymentInformation,
+ client_reference_information: ClientReferenceInformation,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardAuthValidateRequest {
+ payment_information: PaymentInformation,
+ client_reference_information: ClientReferenceInformation,
+ consumer_authentication_information: BarclaycardConsumerAuthInformationValidateRequest,
+ order_information: OrderInformation,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardAuthEnrollmentRequest {
+ payment_information: PaymentInformation,
+ client_reference_information: ClientReferenceInformation,
+ consumer_authentication_information: BarclaycardConsumerAuthInformationRequest,
+ order_information: OrderInformationWithBill,
+}
+
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "PascalCase")]
+pub struct BarclaycardRedirectionAuthResponse {
+ pub transaction_id: String,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardConsumerAuthInformationRequest {
+ return_url: String,
+ reference_id: String,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(untagged)]
+pub enum BarclaycardPreProcessingRequest {
+ AuthEnrollment(Box<BarclaycardAuthEnrollmentRequest>),
+ AuthValidate(Box<BarclaycardAuthValidateRequest>),
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BarclaycardConsumerAuthInformationResponse {
+ access_token: String,
+ device_data_collection_url: String,
+ reference_id: String,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ClientAuthSetupInfoResponse {
+ id: String,
+ client_reference_information: ClientReferenceInformation,
+ consumer_authentication_information: BarclaycardConsumerAuthInformationResponse,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub enum BarclaycardAuthSetupResponse {
+ ClientAuthSetupInfo(Box<ClientAuthSetupInfoResponse>),
+ ErrorInformation(Box<BarclaycardErrorInformationResponse>),
+}
+
+impl TryFrom<&BarclaycardRouterData<&PaymentsPreProcessingRouterData>>
+ for BarclaycardPreProcessingRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &BarclaycardRouterData<&PaymentsPreProcessingRouterData>,
+ ) -> 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(_) => {
+ 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",
+ },
+ )?,
+ };
+
+ 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<F>
+ TryFrom<
+ ResponseRouterData<
+ F,
+ BarclaycardPreProcessingResponse,
+ PaymentsPreProcessingData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<F, PaymentsPreProcessingData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ BarclaycardPreProcessingResponse,
+ PaymentsPreProcessingData,
+ PaymentsResponseData,
+ >,
+ ) -> 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,
+ 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
+ })
+ }
+ }
+ }
+}
+
+fn extract_score_id(message_extensions: &[MessageExtensionAttribute]) -> Option<u32> {
+ message_extensions.iter().find_map(|attr| {
+ attr.id
+ .ends_with("CB-SCORE")
+ .then(|| {
+ attr.id
+ .split('_')
+ .next()
+ .and_then(|p| p.strip_prefix('A'))
+ .and_then(|s| {
+ s.parse::<u32>().map(Some).unwrap_or_else(|err| {
+ router_env::logger::error!(
+ "Failed to parse score_id from '{}': {}",
+ s,
+ err
+ );
+ None
+ })
+ })
+ .or_else(|| {
+ router_env::logger::error!("Unexpected prefix format in id: {}", attr.id);
+ None
+ })
+ })
+ .flatten()
+ })
+}
+
+impl TryFrom<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for BarclaycardAuthSetupRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &BarclaycardRouterData<&PaymentsAuthorizeRouterData>,
+ ) -> 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(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("Barclaycard"),
+ )
+ .into())
+ }
+ }
+ }
+}
+
impl
TryFrom<(
&BarclaycardRouterData<&PaymentsAuthorizeRouterData>,
@@ -450,14 +1066,10 @@ impl
hyperswitch_domain_models::payment_method_data::Card,
),
) -> Result<Self, Self::Error> {
- if item.router_data.is_three_ds() {
- Err(errors::ConnectorError::NotSupported {
- message: "Card 3DS".to_string(),
- connector: "Barclaycard",
- })?
- };
-
- let email = item.router_data.request.get_email()?;
+ 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::from((item, Some(bill_to)));
let payment_information = PaymentInformation::try_from(&ccard)?;
@@ -470,13 +1082,157 @@ impl
.clone()
.map(convert_metadata_to_merchant_defined_info);
+ let pares_status = Some(BarclaycardParesStatus::AuthenticationSuccessful);
+
+ let consumer_authentication_information = item
+ .router_data
+ .request
+ .authentication_data
+ .as_ref()
+ .map(|authn_data| {
+ let (ucaf_authentication_data, cavv, ucaf_collection_indicator) =
+ if ccard.card_network == Some(common_enums::CardNetwork::Mastercard) {
+ (Some(authn_data.cavv.clone()), None, Some("2".to_string()))
+ } else {
+ (None, Some(authn_data.cavv.clone()), None)
+ };
+ let authentication_date = date_time::format_date(
+ authn_data.created_at,
+ date_time::DateFormat::YYYYMMDDHHmmss,
+ )
+ .ok();
+ let effective_authentication_type = authn_data.authentication_type.map(Into::into);
+ let network_score: Option<u32> =
+ if ccard.card_network == Some(common_enums::CardNetwork::CartesBancaires) {
+ match authn_data.message_extension.as_ref() {
+ Some(secret) => {
+ let exposed_value = secret.clone().expose();
+ match serde_json::from_value::<Vec<MessageExtensionAttribute>>(
+ exposed_value,
+ ) {
+ Ok(exts) => extract_score_id(&exts),
+ Err(err) => {
+ router_env::logger::error!(
+ "Failed to deserialize message_extension: {:?}",
+ err
+ );
+ None
+ }
+ }
+ }
+ None => None,
+ }
+ } else {
+ None
+ };
+ BarclaycardConsumerAuthInformation {
+ pares_status,
+ ucaf_collection_indicator,
+ cavv,
+ ucaf_authentication_data,
+ xid: None,
+ directory_server_transaction_id: authn_data
+ .ds_trans_id
+ .clone()
+ .map(Secret::new),
+ specification_version: authn_data.message_version.clone(),
+ pa_specification_version: authn_data.message_version.clone(),
+ veres_enrolled: Some("Y".to_string()),
+ eci_raw: authn_data.eci.clone(),
+ authentication_date,
+ effective_authentication_type,
+ challenge_code: authn_data.challenge_code.clone(),
+ pares_status_reason: authn_data.challenge_code_reason.clone(),
+ challenge_cancel_code: authn_data.challenge_cancel.clone(),
+ network_score,
+ acs_transaction_id: authn_data.acs_trans_id.clone(),
+ }
+ });
+
Ok(Self {
processing_information,
payment_information,
order_information,
client_reference_information,
merchant_defined_information,
- consumer_authentication_information: None,
+ consumer_authentication_information,
+ })
+ }
+}
+
+impl
+ TryFrom<(
+ &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ hyperswitch_domain_models::payment_method_data::Card,
+ )> for BarclaycardPaymentsRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ (item, ccard): (
+ &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ hyperswitch_domain_models::payment_method_data::Card,
+ ),
+ ) -> Result<Self, Self::Error> {
+ 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::from((item, bill_to));
+ let payment_information = PaymentInformation::try_from(&ccard)?;
+ let processing_information = ProcessingInformation::try_from((item, None, None))?;
+ let client_reference_information = ClientReferenceInformation::from(item);
+ let merchant_defined_information = item
+ .router_data
+ .request
+ .metadata
+ .clone()
+ .map(convert_metadata_to_merchant_defined_info);
+
+ let pares_status = Some(BarclaycardParesStatus::AuthenticationSuccessful);
+
+ let three_ds_info: BarclaycardThreeDSMetadata = item
+ .router_data
+ .request
+ .connector_meta
+ .clone()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "connector_meta",
+ })?
+ .parse_value("BarclaycardThreeDSMetadata")
+ .change_context(errors::ConnectorError::InvalidConnectorConfig {
+ config: "metadata",
+ })?;
+
+ let consumer_authentication_information = Some(BarclaycardConsumerAuthInformation {
+ pares_status,
+ ucaf_collection_indicator: three_ds_info.three_ds_data.ucaf_collection_indicator,
+ cavv: three_ds_info.three_ds_data.cavv,
+ ucaf_authentication_data: three_ds_info.three_ds_data.ucaf_authentication_data,
+ xid: three_ds_info.three_ds_data.xid,
+ directory_server_transaction_id: three_ds_info
+ .three_ds_data
+ .directory_server_transaction_id,
+ specification_version: three_ds_info.three_ds_data.specification_version.clone(),
+ pa_specification_version: three_ds_info.three_ds_data.specification_version.clone(),
+ veres_enrolled: None,
+ eci_raw: None,
+ authentication_date: None,
+ effective_authentication_type: None,
+ challenge_code: None,
+ pares_status_reason: None,
+ challenge_cancel_code: None,
+ network_score: None,
+ acs_transaction_id: None,
+ });
+
+ Ok(Self {
+ processing_information,
+ payment_information,
+ order_information,
+ client_reference_information,
+ merchant_defined_information,
+ consumer_authentication_information,
})
}
}
@@ -494,7 +1250,10 @@ impl
GooglePayWalletData,
),
) -> Result<Self, Self::Error> {
- let email = item.router_data.request.get_email()?;
+ 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::from((item, Some(bill_to)));
let payment_information = PaymentInformation::try_from(&google_pay_data)?;
@@ -590,6 +1349,141 @@ impl TryFrom<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for Barclayca
}
}
+impl<F>
+ TryFrom<
+ ResponseRouterData<
+ F,
+ BarclaycardAuthSetupResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<F, PaymentsAuthorizeData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ BarclaycardAuthSetupResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ ) -> 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,
+ 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<&BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>>
+ for BarclaycardPaymentsRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &BarclaycardRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ let payment_method_data = item.router_data.request.payment_method_data.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "payment_method_data",
+ },
+ )?;
+ match payment_method_data {
+ PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)),
+ 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(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("Barclaycard"),
+ )
+ .into())
+ }
+ }
+ }
+}
+
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum BarclaycardPaymentStatus {
@@ -611,6 +1505,7 @@ pub enum BarclaycardPaymentStatus {
PendingReview,
Accepted,
Cancelled,
+ StatusNotReceived,
//PartialAuthorized, not being consumed yet.
}
@@ -650,6 +1545,7 @@ fn map_barclaycard_attempt_status(
enums::AttemptStatus::AuthenticationPending
}
BarclaycardPaymentStatus::PendingReview
+ | BarclaycardPaymentStatus::StatusNotReceived
| BarclaycardPaymentStatus::Challenge
| BarclaycardPaymentStatus::Accepted => enums::AttemptStatus::Pending,
}
@@ -666,7 +1562,7 @@ pub enum BarclaycardPaymentsResponse {
#[serde(rename_all = "camelCase")]
pub struct BarclaycardClientReferenceResponse {
id: String,
- status: BarclaycardPaymentStatus,
+ status: Option<BarclaycardPaymentStatus>,
client_reference_information: ClientReferenceInformation,
processor_information: Option<ClientProcessorInformation>,
processing_information: Option<ProcessingInformationResponse>,
@@ -929,7 +1825,10 @@ impl<F>
match item.response {
BarclaycardPaymentsResponse::ClientReferenceInformation(info_response) => {
let status = map_barclaycard_attempt_status((
- info_response.status.clone(),
+ info_response
+ .status
+ .clone()
+ .unwrap_or(BarclaycardPaymentStatus::StatusNotReceived),
item.data.request.is_auto_capture()?,
));
let response = get_payment_response((&info_response, status, item.http_code))
@@ -1033,7 +1932,13 @@ impl<F>
) -> Result<Self, Self::Error> {
match item.response {
BarclaycardPaymentsResponse::ClientReferenceInformation(info_response) => {
- let status = map_barclaycard_attempt_status((info_response.status.clone(), true));
+ let status = map_barclaycard_attempt_status((
+ info_response
+ .status
+ .clone()
+ .unwrap_or(BarclaycardPaymentStatus::StatusNotReceived),
+ true,
+ ));
let response = get_payment_response((&info_response, status, item.http_code))
.map_err(|err| *err);
Ok(Self {
@@ -1070,7 +1975,13 @@ impl<F>
) -> Result<Self, Self::Error> {
match item.response {
BarclaycardPaymentsResponse::ClientReferenceInformation(info_response) => {
- let status = map_barclaycard_attempt_status((info_response.status.clone(), false));
+ let status = map_barclaycard_attempt_status((
+ info_response
+ .status
+ .clone()
+ .unwrap_or(BarclaycardPaymentStatus::StatusNotReceived),
+ false,
+ ));
let response = get_payment_response((&info_response, status, item.http_code))
.map_err(|err| *err);
Ok(Self {
@@ -1231,6 +2142,71 @@ impl<F>
}
}
+impl<F>
+ TryFrom<
+ ResponseRouterData<
+ F,
+ BarclaycardPaymentsResponse,
+ CompleteAuthorizeData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<F, CompleteAuthorizeData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ BarclaycardPaymentsResponse,
+ CompleteAuthorizeData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ match item.response {
+ BarclaycardPaymentsResponse::ClientReferenceInformation(info_response) => {
+ let status = map_barclaycard_attempt_status((
+ info_response
+ .status
+ .clone()
+ .unwrap_or(BarclaycardPaymentStatus::StatusNotReceived),
+ item.data.request.is_auto_capture()?,
+ ));
+ let response = get_payment_response((&info_response, status, item.http_code))
+ .map_err(|err| *err);
+ let connector_response = info_response
+ .processor_information
+ .as_ref()
+ .map(AdditionalPaymentMethodConnectorResponse::from)
+ .map(ConnectorResponseData::with_additional_payment_method_data);
+
+ Ok(Self {
+ status,
+ response,
+ connector_response,
+ ..item.data
+ })
+ }
+ BarclaycardPaymentsResponse::ErrorInformation(ref error_response) => {
+ Ok(map_error_response(&error_response.clone(), item, None))
+ }
+ }
+ }
+}
+
+impl From<&ClientProcessorInformation> for AdditionalPaymentMethodConnectorResponse {
+ fn from(processor_information: &ClientProcessorInformation) -> Self {
+ let payment_checks = Some(
+ serde_json::json!({"avs_response": processor_information.avs, "card_verification": processor_information.card_verification}),
+ );
+
+ Self::Card {
+ authentication_data: None,
+ payment_checks,
+ card_network: None,
+ domestic_network: None,
+ }
+ }
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OrderInformation {
@@ -1673,6 +2649,7 @@ impl TryFrom<&hyperswitch_domain_models::payment_method_data::Card> for PaymentI
expiration_year: ccard.card_exp_year.clone(),
security_code: ccard.card_cvc.clone(),
card_type,
+ type_selection_indicator: Some("1".to_owned()),
},
})))
}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index b88d7ef543..7d746072f6 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -1149,7 +1149,6 @@ default_imp_for_complete_authorize!(
connectors::Authipay,
connectors::Bamboraapac,
connectors::Bankofamerica,
- connectors::Barclaycard,
connectors::Billwerk,
connectors::Bitpay,
connectors::Blackhawknetwork,
@@ -1668,7 +1667,6 @@ default_imp_for_pre_processing_steps!(
connectors::Bambora,
connectors::Bamboraapac,
connectors::Bankofamerica,
- connectors::Barclaycard,
connectors::Billwerk,
connectors::Bitpay,
connectors::Blackhawknetwork,
diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs
index f4b40e2355..aacbfbf11f 100644
--- a/crates/hyperswitch_domain_models/src/router_response_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_response_types.rs
@@ -259,6 +259,15 @@ pub enum RedirectForm {
Html {
html_data: String,
},
+ BarclaycardAuthSetup {
+ access_token: String,
+ ddc_url: String,
+ reference_id: String,
+ },
+ BarclaycardConsumerAuth {
+ access_token: String,
+ step_up_url: String,
+ },
BlueSnap {
payment_fields_token: String, // payment-field-token
},
@@ -332,6 +341,22 @@ impl From<RedirectForm> for diesel_models::payment_attempt::RedirectForm {
form_fields,
},
RedirectForm::Html { html_data } => Self::Html { html_data },
+ RedirectForm::BarclaycardAuthSetup {
+ access_token,
+ ddc_url,
+ reference_id,
+ } => Self::BarclaycardAuthSetup {
+ access_token,
+ ddc_url,
+ reference_id,
+ },
+ RedirectForm::BarclaycardConsumerAuth {
+ access_token,
+ step_up_url,
+ } => Self::BarclaycardConsumerAuth {
+ access_token,
+ step_up_url,
+ },
RedirectForm::BlueSnap {
payment_fields_token,
} => Self::BlueSnap {
@@ -416,6 +441,22 @@ impl From<diesel_models::payment_attempt::RedirectForm> for RedirectForm {
diesel_models::payment_attempt::RedirectForm::Html { html_data } => {
Self::Html { html_data }
}
+ diesel_models::payment_attempt::RedirectForm::BarclaycardAuthSetup {
+ access_token,
+ ddc_url,
+ reference_id,
+ } => Self::BarclaycardAuthSetup {
+ access_token,
+ ddc_url,
+ reference_id,
+ },
+ diesel_models::payment_attempt::RedirectForm::BarclaycardConsumerAuth {
+ access_token,
+ step_up_url,
+ } => Self::BarclaycardConsumerAuth {
+ access_token,
+ step_up_url,
+ },
diesel_models::payment_attempt::RedirectForm::BlueSnap {
payment_fields_token,
} => Self::BlueSnap {
diff --git a/crates/payment_methods/src/configs/payment_connector_required_fields.rs b/crates/payment_methods/src/configs/payment_connector_required_fields.rs
index 15a4ef90a9..732b188900 100644
--- a/crates/payment_methods/src/configs/payment_connector_required_fields.rs
+++ b/crates/payment_methods/src/configs/payment_connector_required_fields.rs
@@ -1291,7 +1291,7 @@ fn get_cards_required_fields() -> HashMap<Connector, RequiredFieldFinal> {
fields(
vec![],
vec![],
- [card_basic(), full_name(), billing_address()].concat(),
+ [card_basic(), email(), full_name(), billing_address()].concat(),
),
),
(Connector::Billwerk, fields(vec![], vec![], card_basic())),
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index d1d7c33d8f..5008b3a68b 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -6513,7 +6513,8 @@ where
router_data = router_data.preprocessing_steps(state, connector).await?;
(router_data, false)
- } else if connector.connector_name == router_types::Connector::Cybersource
+ } else if (connector.connector_name == router_types::Connector::Cybersource
+ || connector.connector_name == router_types::Connector::Barclaycard)
&& is_operation_complete_authorize(&operation)
&& router_data.auth_type == storage_enums::AuthenticationType::ThreeDs
{
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index 6b25eb4561..6ec0ff9fe7 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -1288,6 +1288,105 @@ pub fn build_redirection_form(
RedirectForm::Html { html_data } => {
PreEscaped(format!("{html_data} <script>{logging_template}</script>"))
}
+ RedirectForm::BarclaycardAuthSetup {
+ access_token,
+ ddc_url,
+ reference_id,
+ } => {
+ maud::html! {
+ (maud::DOCTYPE)
+ html {
+ head {
+ meta name="viewport" content="width=device-width, initial-scale=1";
+ }
+ body style="background-color: #ffffff; padding: 20px; font-family: Arial, Helvetica, Sans-Serif;" {
+
+ div id="loader1" class="lottie" style="height: 150px; display: block; position: relative; margin-top: 150px; margin-left: auto; margin-right: auto;" { "" }
+
+ (PreEscaped(r#"<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.7.4/lottie.min.js"></script>"#))
+
+ (PreEscaped(r#"
+ <script>
+ var anime = bodymovin.loadAnimation({
+ container: document.getElementById('loader1'),
+ renderer: 'svg',
+ loop: true,
+ autoplay: true,
+ name: 'hyperswitch loader',
+ animationData: {"v":"4.8.0","meta":{"g":"LottieFiles AE 3.1.1","a":"","k":"","d":"","tc":""},"fr":29.9700012207031,"ip":0,"op":31.0000012626559,"w":400,"h":250,"nm":"loader_shape","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"circle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[278.25,202.671,0],"ix":2},"a":{"a":0,"k":[23.72,23.72,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[12.935,0],[0,-12.936],[-12.935,0],[0,12.935]],"o":[[-12.952,0],[0,12.935],[12.935,0],[0,-12.936]],"v":[[0,-23.471],[-23.47,0.001],[0,23.471],[23.47,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":19.99,"s":[100]},{"t":29.9800012211104,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[23.72,23.721],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"square 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[196.25,201.271,0],"ix":2},"a":{"a":0,"k":[22.028,22.03,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[1.914,0],[0,0],[0,-1.914],[0,0],[-1.914,0],[0,0],[0,1.914],[0,0]],"o":[[0,0],[-1.914,0],[0,0],[0,1.914],[0,0],[1.914,0],[0,0],[0,-1.914]],"v":[[18.313,-21.779],[-18.312,-21.779],[-21.779,-18.313],[-21.779,18.314],[-18.312,21.779],[18.313,21.779],[21.779,18.314],[21.779,-18.313]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":14.99,"s":[100]},{"t":24.9800010174563,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[22.028,22.029],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":47.0000019143492,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Triangle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[116.25,200.703,0],"ix":2},"a":{"a":0,"k":[27.11,21.243,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0.558,-0.879],[0,0],[-1.133,0],[0,0],[0.609,0.947],[0,0]],"o":[[-0.558,-0.879],[0,0],[-0.609,0.947],[0,0],[1.133,0],[0,0],[0,0]],"v":[[1.209,-20.114],[-1.192,-20.114],[-26.251,18.795],[-25.051,20.993],[25.051,20.993],[26.251,18.795],[1.192,-20.114]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":9.99,"s":[100]},{"t":19.9800008138021,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[27.11,21.243],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0}],"markers":[]}
+ })
+ </script>
+ "#))
+
+ h3 style="text-align: center;" { "Please wait while we process your payment..." }
+ }
+
+ (PreEscaped(r#"<iframe id="cardinal_collection_iframe" name="collectionIframe" height="10" width="10" style="display: none;"></iframe>"#))
+ (PreEscaped(format!("<form id=\"cardinal_collection_form\" method=\"POST\" target=\"collectionIframe\" action=\"{ddc_url}\">
+ <input id=\"cardinal_collection_form_input\" type=\"hidden\" name=\"JWT\" value=\"{access_token}\">
+ </form>")))
+ (PreEscaped(r#"<script>
+ window.onload = function() {
+ var cardinalCollectionForm = document.querySelector('#cardinal_collection_form'); if(cardinalCollectionForm) cardinalCollectionForm.submit();
+ }
+ </script>"#))
+ (PreEscaped(format!("<script>
+ {logging_template}
+ window.addEventListener(\"message\", function(event) {{
+ if (event.origin === \"https://centinelapistag.cardinalcommerce.com\" || event.origin === \"https://centinelapi.cardinalcommerce.com\") {{
+ window.location.href = window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/cybersource?referenceId={reference_id}\");
+ }}
+ }}, false);
+ </script>
+ ")))
+ }}
+ }
+ RedirectForm::BarclaycardConsumerAuth {
+ access_token,
+ step_up_url,
+ } => {
+ maud::html! {
+ (maud::DOCTYPE)
+ html {
+ head {
+ meta name="viewport" content="width=device-width, initial-scale=1";
+ }
+ body style="background-color: #ffffff; padding: 20px; font-family: Arial, Helvetica, Sans-Serif;" {
+
+ div id="loader1" class="lottie" style="height: 150px; display: block; position: relative; margin-top: 150px; margin-left: auto; margin-right: auto;" { "" }
+
+ (PreEscaped(r#"<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.7.4/lottie.min.js"></script>"#))
+
+ (PreEscaped(r#"
+ <script>
+ var anime = bodymovin.loadAnimation({
+ container: document.getElementById('loader1'),
+ renderer: 'svg',
+ loop: true,
+ autoplay: true,
+ name: 'hyperswitch loader',
+ animationData: {"v":"4.8.0","meta":{"g":"LottieFiles AE 3.1.1","a":"","k":"","d":"","tc":""},"fr":29.9700012207031,"ip":0,"op":31.0000012626559,"w":400,"h":250,"nm":"loader_shape","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"circle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[278.25,202.671,0],"ix":2},"a":{"a":0,"k":[23.72,23.72,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[12.935,0],[0,-12.936],[-12.935,0],[0,12.935]],"o":[[-12.952,0],[0,12.935],[12.935,0],[0,-12.936]],"v":[[0,-23.471],[-23.47,0.001],[0,23.471],[23.47,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":19.99,"s":[100]},{"t":29.9800012211104,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[23.72,23.721],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"square 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[196.25,201.271,0],"ix":2},"a":{"a":0,"k":[22.028,22.03,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[1.914,0],[0,0],[0,-1.914],[0,0],[-1.914,0],[0,0],[0,1.914],[0,0]],"o":[[0,0],[-1.914,0],[0,0],[0,1.914],[0,0],[1.914,0],[0,0],[0,-1.914]],"v":[[18.313,-21.779],[-18.312,-21.779],[-21.779,-18.313],[-21.779,18.314],[-18.312,21.779],[18.313,21.779],[21.779,18.314],[21.779,-18.313]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":14.99,"s":[100]},{"t":24.9800010174563,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[22.028,22.029],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":47.0000019143492,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Triangle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[116.25,200.703,0],"ix":2},"a":{"a":0,"k":[27.11,21.243,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0.558,-0.879],[0,0],[-1.133,0],[0,0],[0.609,0.947],[0,0]],"o":[[-0.558,-0.879],[0,0],[-0.609,0.947],[0,0],[1.133,0],[0,0],[0,0]],"v":[[1.209,-20.114],[-1.192,-20.114],[-26.251,18.795],[-25.051,20.993],[25.051,20.993],[26.251,18.795],[1.192,-20.114]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":9.99,"s":[100]},{"t":19.9800008138021,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[27.11,21.243],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0}],"markers":[]}
+ })
+ </script>
+ "#))
+
+ h3 style="text-align: center;" { "Please wait while we process your payment..." }
+ }
+
+ // This is the iframe recommended by cybersource but the redirection happens inside this iframe once otp
+ // is received and we lose control of the redirection on user client browser, so to avoid that we have removed this iframe and directly consumed it.
+ // (PreEscaped(r#"<iframe id="step_up_iframe" style="border: none; margin-left: auto; margin-right: auto; display: block" height="800px" width="400px" name="stepUpIframe"></iframe>"#))
+ (PreEscaped(format!("<form id=\"step-up-form\" method=\"POST\" action=\"{step_up_url}\">
+ <input type=\"hidden\" name=\"JWT\" value=\"{access_token}\">
+ </form>")))
+ (PreEscaped(format!("<script>
+ {logging_template}
+ window.onload = function() {{
+ var stepUpForm = document.querySelector('#step-up-form'); if(stepUpForm) stepUpForm.submit();
+ }}
+ </script>")))
+ }}
+ }
RedirectForm::BlueSnap {
payment_fields_token,
} => {
diff --git a/crates/router/src/types/api/connector_mapping.rs b/crates/router/src/types/api/connector_mapping.rs
index 384a430d6a..c184c9db8d 100644
--- a/crates/router/src/types/api/connector_mapping.rs
+++ b/crates/router/src/types/api/connector_mapping.rs
@@ -136,7 +136,7 @@ impl ConnectorData {
Ok(ConnectorEnum::Old(Box::new(&connector::Bankofamerica)))
}
enums::Connector::Barclaycard => {
- Ok(ConnectorEnum::Old(Box::new(&connector::Barclaycard)))
+ Ok(ConnectorEnum::Old(Box::new(connector::Barclaycard::new())))
}
enums::Connector::Billwerk => {
Ok(ConnectorEnum::Old(Box::new(connector::Billwerk::new())))
diff --git a/crates/router/tests/connectors/barclaycard.rs b/crates/router/tests/connectors/barclaycard.rs
index c2c21bbcc0..2087131c4e 100644
--- a/crates/router/tests/connectors/barclaycard.rs
+++ b/crates/router/tests/connectors/barclaycard.rs
@@ -11,7 +11,7 @@ impl utils::Connector for BarclaycardTest {
fn get_data(&self) -> api::ConnectorData {
use router::connector::Barclaycard;
utils::construct_connector_data_old(
- Box::new(&Barclaycard),
+ Box::new(Barclaycard::new()),
types::Connector::DummyConnector1,
api::GetToken::Connector,
None,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Barclaycard.js b/cypress-tests/cypress/e2e/configs/Payment/Barclaycard.js
new file mode 100644
index 0000000000..594d56e2b5
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/Payment/Barclaycard.js
@@ -0,0 +1,709 @@
+import { customerAcceptance } from "./Commons";
+
+const successfulNo3DSCardDetails = {
+ card_number: "4000000000001091",
+ card_exp_month: "01",
+ card_exp_year: "27",
+ card_holder_name: "joseph Doe",
+ card_cvc: "100",
+};
+
+const successfulThreeDSTestCardDetails = {
+ card_number: "4000000000002701",
+ card_exp_month: "01",
+ card_exp_year: "50",
+ card_holder_name: "joseph Doe",
+ card_cvc: "123",
+};
+
+// Mandate data for test cases (skipped for Barclaycard)
+const singleUseMandateData = {
+ customer_acceptance: customerAcceptance,
+ mandate_type: {
+ single_use: {
+ amount: 6544,
+ currency: "USD",
+ },
+ },
+};
+
+const multiUseMandateData = {
+ customer_acceptance: customerAcceptance,
+ mandate_type: {
+ multi_use: {
+ amount: 6544,
+ currency: "USD",
+ },
+ },
+};
+
+const payment_method_data_3ds = {
+ card: {
+ last4: "2701",
+ card_type: "CREDIT",
+ card_network: "Visa",
+ card_issuer: "INTL HDQTRS-CENTER OWNED",
+ card_issuing_country: "UNITEDSTATES",
+ card_isin: "400000",
+ card_extended_bin: null,
+ card_exp_month: "01",
+ card_exp_year: "50",
+ card_holder_name: "joseph Doe",
+ payment_checks: null,
+ authentication_data: null,
+ },
+ billing: null,
+};
+
+const billing_with_newline = {
+ address: {
+ line1: "1467",
+ line2: "Harrison Street\nApt 101",
+ line3: "Harrison Street\nApt 101",
+ city: "San Fransico\n city",
+ state: "California",
+ zip: "94122",
+ country: "NL",
+ first_name: "joseph",
+ last_name: "Doe",
+ },
+ phone: {
+ number: "9123456789",
+ country_code: "+91",
+ },
+};
+
+export const connectorDetails = {
+ card_pm: {
+ PaymentIntent: {
+ Request: {
+ currency: "USD",
+ amount: 6544,
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ setup_future_usage: "on_session",
+ },
+ },
+ },
+ PaymentIntentOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ currency: "USD",
+ customer_acceptance: null,
+ amount: 6544,
+ authentication_type: "no_three_ds",
+ setup_future_usage: "off_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ setup_future_usage: "off_session",
+ },
+ },
+ },
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ shipping_cost: 50,
+ amount: 6544,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ shipping_cost: 50,
+ amount_received: 6594,
+ amount: 6544,
+ net_amount: 6594,
+ },
+ },
+ },
+ "3DSManualCapture": {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ currency: "USD",
+ amount: 6544,
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ setup_future_usage: "on_session",
+ payment_method_data: payment_method_data_3ds,
+ },
+ },
+ },
+ "3DSAutoCapture": {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ currency: "USD",
+ amount: 6544,
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ setup_future_usage: "on_session",
+ payment_method_data: payment_method_data_3ds,
+ },
+ },
+ },
+ No3DSManualCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ amount: 6544,
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ payment_method: "card",
+ attempt_count: 1,
+ },
+ },
+ },
+ Capture: {
+ Request: {
+ amount_to_capture: 6544,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ amount: 6544,
+ amount_capturable: 0,
+ amount_received: 6544,
+ },
+ },
+ },
+ PartialCapture: {
+ Configs: {
+ CONNECTOR_CREDENTIAL: {
+ value: "connector_1",
+ },
+ },
+ Request: {
+ amount_to_capture: 1000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "partially_captured",
+ amount: 6544,
+ amount_capturable: 0,
+ amount_received: 1000,
+ },
+ },
+ },
+ Refund: {
+ Request: {
+ amount: 6544,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ },
+ },
+ },
+ SyncRefund: {
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ },
+ },
+ },
+ PartialRefund: {
+ Request: {
+ amount: 1000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ amount: 1000,
+ },
+ },
+ },
+ manualPaymentRefund: {
+ Request: {
+ amount: 6544,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ amount: 6544,
+ },
+ },
+ },
+ manualPaymentPartialRefund: {
+ Request: {
+ amount: 1000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ },
+ },
+ },
+ MandateSingleUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ amount: 6544,
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ MandateMultiUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ amount: 6544,
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ No3DSAutoCapture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ amount: 6544,
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ billing: billing_with_newline,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ payment_method: "card",
+ attempt_count: 1,
+ },
+ },
+ },
+ Void: {
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "cancelled",
+ },
+ },
+ },
+ MandateSingleUseNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ MandateMultiUseNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ amount: 6544,
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ MandateMultiUse3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ currency: "USD",
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ MandateMultiUse3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ currency: "USD",
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ PaymentMethodIdMandateNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ SaveCardUseNo3DSAutoCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_type: "debit",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ amount: 6544,
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ SaveCardUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ amount: 6544,
+ currency: "USD",
+ setup_future_usage: "on_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ SaveCardUse3DSAutoCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_type: "debit",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ },
+ SaveCardUseNo3DSManualCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ SaveCardConfirmAutoCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ setup_future_usage: "off_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ connector_mandate_id: "mock_barclaycard_mandate_id",
+ },
+ },
+ },
+ SaveCardConfirmManualCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ setup_future_usage: "off_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ connector_mandate_id: "mock_barclaycard_mandate_id",
+ },
+ },
+ },
+ SaveCardConfirmAutoCaptureOffSessionWithoutBilling: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ setup_future_usage: "off_session",
+ billing: null,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ connector_mandate_id: "mock_barclaycard_mandate_id",
+ },
+ },
+ },
+ PaymentMethodIdMandateNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ PaymentMethodIdMandate3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ currency: "USD",
+ mandate_data: null,
+ authentication_type: "three_ds",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ },
+ PaymentMethodIdMandate3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ mandate_data: null,
+ authentication_type: "three_ds",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ },
+ MITAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ MITManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ ZeroAuthMandate: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "processing",
+ },
+ },
+ },
+ ZeroAuthPaymentIntent: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ amount: 0,
+ setup_future_usage: "off_session",
+ currency: "USD",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ setup_future_usage: "off_session",
+ },
+ },
+ },
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 689a6eed8a..fcd4f6e4e8 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -10,6 +10,7 @@ import { connectorDetails as authipayConnectorDetails } from "./Authipay.js";
import { connectorDetails as authorizedotnetConnectorDetails } from "./Authorizedotnet.js";
import { connectorDetails as bamboraConnectorDetails } from "./Bambora.js";
import { connectorDetails as bamboraapacConnectorDetails } from "./Bamboraapac.js";
+import { connectorDetails as barclaycardConnectorDetails } from "./Barclaycard.js";
import { connectorDetails as bankOfAmericaConnectorDetails } from "./BankOfAmerica.js";
import { connectorDetails as billwerkConnectorDetails } from "./Billwerk.js";
import { connectorDetails as bluesnapConnectorDetails } from "./Bluesnap.js";
@@ -69,6 +70,7 @@ const connectorDetails = {
authorizedotnet: authorizedotnetConnectorDetails,
bambora: bamboraConnectorDetails,
bamboraapac: bamboraapacConnectorDetails,
+ barclaycard: barclaycardConnectorDetails,
bankofamerica: bankOfAmericaConnectorDetails,
billwerk: billwerkConnectorDetails,
bluesnap: bluesnapConnectorDetails,
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 8dc043b575..9b81a63e18 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -773,6 +773,7 @@ sts_role_session_name = ""
[temp_locker_enable_config]
paybox = { payment_method = "card" }
redsys = { payment_method = "card" }
+barclaycard = { payment_method = "card" }
[billing_connectors_payment_sync]
billing_connectors_which_require_payment_sync = "stripebilling, recurly"