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

fix(router): fix Click to Pay cavv None error (#8019)

Sahkal Poddar344dcd6e4302
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index cb454b7373..ba92854fd4 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -728,4 +728,7 @@ enabled = true
billing_connectors_which_require_payment_sync = "stripebilling, recurly"
[billing_connectors_invoice_sync]
-billing_connectors_which_requires_invoice_sync_call = "recurly"
\ No newline at end of file
+billing_connectors_which_requires_invoice_sync_call = "recurly"
+
+[authentication_providers]
+click_to_pay = {connector_list = "adyen, cybersource"}
\ No newline at end of file
diff --git a/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs b/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
index 7cfee92d33..79b37b1b05 100644
--- a/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
@@ -173,7 +173,7 @@ impl From<AuthenticationData> for Archipel3DS {
three_ds_auth_status: None,
three_ds_max_supported_version: THREE_DS_MAX_SUPPORTED_VERSION.into(),
three_ds_version: three_ds_data.message_version,
- authentication_value: Secret::new(three_ds_data.cavv),
+ authentication_value: three_ds_data.cavv,
authentication_method: None,
eci: three_ds_data.eci.map(Secret::new),
}
diff --git a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
index 57e207c9c7..d3150a3b04 100644
--- a/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
@@ -271,7 +271,7 @@ pub struct CheckoutThreeDS {
enabled: bool,
force_3ds: bool,
eci: Option<String>,
- cryptogram: Option<String>,
+ cryptogram: Option<Secret<String>>,
xid: Option<String>,
version: Option<String>,
}
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
index 25eedcd5e6..7f920f0e46 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
@@ -369,7 +369,7 @@ pub struct ProcessingInformation {
#[serde(rename_all = "camelCase")]
pub struct CybersourceConsumerAuthInformation {
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>>,
@@ -1318,11 +1318,7 @@ impl
.map(|authn_data| {
let (ucaf_authentication_data, cavv, ucaf_collection_indicator) =
if ccard.card_network == Some(common_enums::CardNetwork::Mastercard) {
- (
- Some(Secret::new(authn_data.cavv.clone())),
- None,
- Some("2".to_string()),
- )
+ (Some(authn_data.cavv.clone()), None, Some("2".to_string()))
} else {
(None, Some(authn_data.cavv.clone()), None)
};
@@ -1419,11 +1415,7 @@ impl
.map(|authn_data| {
let (ucaf_authentication_data, cavv, ucaf_collection_indicator) =
if ccard.card_network == Some(common_enums::CardNetwork::Mastercard) {
- (
- Some(Secret::new(authn_data.cavv.clone())),
- None,
- Some("2".to_string()),
- )
+ (Some(authn_data.cavv.clone()), None, Some("2".to_string()))
} else {
(None, Some(authn_data.cavv.clone()), None)
};
@@ -1505,11 +1497,7 @@ impl
.map(|authn_data| {
let (ucaf_authentication_data, cavv, ucaf_collection_indicator) =
if token_data.card_network == Some(common_enums::CardNetwork::Mastercard) {
- (
- Some(Secret::new(authn_data.cavv.clone())),
- None,
- Some("2".to_string()),
- )
+ (Some(authn_data.cavv.clone()), None, Some("2".to_string()))
} else {
(None, Some(authn_data.cavv.clone()), None)
};
@@ -3193,7 +3181,7 @@ pub enum CybersourceAuthEnrollmentStatus {
#[serde(rename_all = "camelCase")]
pub struct CybersourceConsumerAuthValidateResponse {
ucaf_collection_indicator: Option<String>,
- cavv: Option<String>,
+ cavv: Option<Secret<String>>,
ucaf_authentication_data: Option<Secret<String>>,
xid: Option<String>,
specification_version: Option<String>,
diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
index 4cd5e2dd34..76e2617717 100644
--- a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
@@ -458,7 +458,7 @@ fn create_card_details(
.threeds_server_transaction_id
.clone()
.map(Secret::new),
- cavv: Secret::new(auth_data.cavv.clone()),
+ cavv: auth_data.cavv.clone(),
eci: auth_data.eci.clone(),
xid: auth_data.ds_trans_id.clone().map(Secret::new),
three_ds_version: auth_data
diff --git a/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs
index c8dbea3844..e789cb637c 100644
--- a/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs
@@ -477,7 +477,7 @@ pub struct CardThreeDsData {
ccexp: Secret<String>,
email: Option<Email>,
cardholder_auth: Option<String>,
- cavv: Option<String>,
+ cavv: Option<Secret<String>>,
eci: Option<String>,
cvv: Secret<String>,
three_ds_version: Option<String>,
diff --git a/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs b/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
index 959e99b606..c0474535f5 100644
--- a/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
@@ -284,7 +284,7 @@ pub struct ProcessingInformation {
#[serde(rename_all = "camelCase")]
pub struct WellsfargoConsumerAuthInformation {
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>>,
@@ -933,7 +933,7 @@ impl
.map(|authn_data| {
let (ucaf_authentication_data, cavv) =
if ccard.card_network == Some(common_enums::CardNetwork::Mastercard) {
- (Some(Secret::new(authn_data.cavv.clone())), None)
+ (Some(authn_data.cavv.clone()), None)
} else {
(None, Some(authn_data.cavv.clone()))
};
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index f3fb4e9f83..ec195e9189 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -623,7 +623,7 @@ impl
#[derive(Debug, Clone)]
pub struct AuthenticationData {
pub eci: Option<String>,
- pub cavv: String,
+ pub cavv: Secret<String>,
pub threeds_server_transaction_id: Option<String>,
pub message_version: Option<common_utils::types::SemanticVersion>,
pub ds_trans_id: Option<String>,
diff --git a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs
index 81fc33fbdc..31b0e1a46a 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs
@@ -164,6 +164,6 @@ pub struct ExternalThreeDSConnectorMetadata {
#[derive(Clone, Debug)]
pub struct AuthenticationStore {
- pub cavv: Option<String>,
+ pub cavv: Option<masking::Secret<String>>,
pub authentication: diesel_models::authentication::Authentication,
}
diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs
index d9af28c17e..ab31c531e2 100644
--- a/crates/router/src/core/authentication.rs
+++ b/crates/router/src/core/authentication.rs
@@ -158,7 +158,7 @@ pub async fn perform_post_authentication(
let authentication_store =
hyperswitch_domain_models::router_request_types::authentication::AuthenticationStore {
- cavv: tokenized_data.map(|data| data.value1),
+ cavv: tokenized_data.map(|data| masking::Secret::new(data.value1)),
authentication: authentication_update,
};
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 8c5f72b340..e59b961cec 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1229,12 +1229,12 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
&authentication_id,
payment_data.service_details.clone(),
authentication_status,
- network_token,
+ network_token.clone(),
payment_data.payment_attempt.organization_id.clone(),
)
.await?;
let authentication_store = hyperswitch_domain_models::router_request_types::authentication::AuthenticationStore {
- cavv: None, // since in case of CTP we will be storing all details in network token under payment_method_data
+ cavv: network_token.and_then(|token| token.token_cryptogram),
authentication
};
payment_data.authentication = Some(authentication_store);
@@ -1408,7 +1408,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
let tokenized_data = crate::core::payment_methods::vault::get_tokenized_data(state, &authentication_id, false, key_store.key.get_inner()).await?;
let authentication_store = hyperswitch_domain_models::router_request_types::authentication::AuthenticationStore {
- cavv: Some(tokenized_data.value1),
+ cavv: Some(masking::Secret::new(tokenized_data.value1)),
authentication: updated_authentication
};
diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs
index 9f028f1228..eba5764206 100644
--- a/crates/router/src/core/unified_authentication_service.rs
+++ b/crates/router/src/core/unified_authentication_service.rs
@@ -21,7 +21,6 @@ use hyperswitch_domain_models::{
UasPreAuthenticationRouterData,
},
};
-use masking::ExposeInterface;
use super::{errors::RouterResult, payments::helpers::MerchantConnectorAccountType};
use crate::{
@@ -512,9 +511,7 @@ pub async fn create_new_authentication(
connector_metadata: None,
maximum_supported_version: None,
threeds_server_transaction_id: None,
- cavv: network_token
- .clone()
- .and_then(|data| data.token_cryptogram.map(|cavv| cavv.expose())),
+ cavv: None,
authentication_flow_type: None,
message_version: None,
eci: network_token.and_then(|data| data.eci),