Skip to content

Commit

Permalink
fix(connector): skip 3DS in network_transaction_id flow for cyberso…
Browse files Browse the repository at this point in the history
…urce (#5781)
  • Loading branch information
ShankarSinghC committed Sep 3, 2024
1 parent 0fb8e85 commit 84f079c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
9 changes: 6 additions & 3 deletions crates/router/src/connector/cybersource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
) -> CustomResult<String, errors::ConnectorError> {
if req.is_three_ds()
&& req.request.is_card()
&& req.request.connector_mandate_id().is_none()
&& (req.request.connector_mandate_id().is_none()
&& req.request.get_optional_network_transaction_id().is_none())
&& req.request.authentication_data.is_none()
{
Ok(format!(
Expand Down Expand Up @@ -929,7 +930,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
))?;
if req.is_three_ds()
&& req.request.is_card()
&& req.request.connector_mandate_id().is_none()
&& (req.request.connector_mandate_id().is_none()
&& req.request.get_optional_network_transaction_id().is_none())
&& req.request.authentication_data.is_none()
{
let connector_req =
Expand Down Expand Up @@ -970,7 +972,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
if data.is_three_ds()
&& data.request.is_card()
&& data.request.connector_mandate_id().is_none()
&& (data.request.connector_mandate_id().is_none()
&& data.request.get_optional_network_transaction_id().is_none())
&& data.request.authentication_data.is_none()
{
let response: cybersource::CybersourceAuthSetupResponse = res
Expand Down
13 changes: 12 additions & 1 deletion crates/router/src/connector/cybersource/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,12 +1043,23 @@ impl
Err(_) => None,
};

let security_code = if item
.router_data
.request
.get_optional_network_transaction_id()
.is_some()
{
None
} else {
Some(ccard.card_cvc)
};

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: Some(ccard.card_cvc),
security_code,
card_type: card_type.clone(),
},
}));
Expand Down
13 changes: 13 additions & 0 deletions crates/router/src/connector/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ pub trait PaymentsAuthorizeRequestData {
fn get_card(&self) -> Result<domain::Card, Error>;
fn get_return_url(&self) -> Result<String, Error>;
fn connector_mandate_id(&self) -> Option<String>;
fn get_optional_network_transaction_id(&self) -> Option<String>;
fn is_mandate_payment(&self) -> bool;
fn is_customer_initiated_mandate_payment(&self) -> bool;
fn get_webhook_url(&self) -> Result<String, Error>;
Expand Down Expand Up @@ -843,6 +844,18 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
Some(payments::MandateReferenceId::NetworkMandateId(_)) | None => None,
})
}

fn get_optional_network_transaction_id(&self) -> Option<String> {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
Some(network_transaction_id.clone())
}
Some(payments::MandateReferenceId::ConnectorMandateId(_)) | None => None,
})
}

fn is_mandate_payment(&self) -> bool {
((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage.map_or(false, |setup_future_usage| {
Expand Down

0 comments on commit 84f079c

Please sign in to comment.