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

refactor(connector): [Cybersource] Mask PII data (#3786)

AkshayaFoigera5cb6bb5a456
diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs
index 4bb28439b7..14f8b2a7f9 100644
--- a/crates/router/src/connector/cybersource/transformers.rs
+++ b/crates/router/src/connector/cybersource/transformers.rs
@@ -2,7 +2,7 @@ use api_models::payments;
use base64::Engine;
use common_utils::{ext_traits::ValueExt, pii};
use error_stack::{IntoReport, ResultExt};
-use masking::{PeekInterface, Secret};
+use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use serde_json::Value;
@@ -259,9 +259,9 @@ pub struct ProcessingInformation {
pub struct CybersourceConsumerAuthInformation {
ucaf_collection_indicator: Option<String>,
cavv: Option<String>,
- ucaf_authentication_data: Option<String>,
+ ucaf_authentication_data: Option<Secret<String>>,
xid: Option<String>,
- directory_server_transaction_id: Option<String>,
+ directory_server_transaction_id: Option<Secret<String>>,
specification_version: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -385,7 +385,7 @@ pub enum PaymentInformation {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CybersoucrePaymentInstrument {
- id: String,
+ id: Secret<String>,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
@@ -1071,7 +1071,7 @@ impl
) -> Result<Self, Self::Error> {
let processing_information = ProcessingInformation::try_from((item, None, None))?;
let payment_instrument = CybersoucrePaymentInstrument {
- id: connector_mandate_id,
+ id: connector_mandate_id.into(),
};
let email = item.router_data.request.get_email()?;
let bill_to = build_bill_to(item.router_data.get_billing()?, email)?;
@@ -1491,7 +1491,7 @@ pub struct ClientRiskInformation {
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ClientRiskInformationRules {
- name: String,
+ name: Secret<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
@@ -1592,7 +1592,7 @@ fn get_payment_response(
.token_information
.clone()
.map(|token_info| types::MandateReference {
- connector_mandate_id: Some(token_info.payment_instrument.id),
+ connector_mandate_id: Some(token_info.payment_instrument.id.expose()),
payment_method_id: None,
});
Ok(types::PaymentsResponseData::TransactionResponse {
@@ -1941,10 +1941,10 @@ pub enum CybersourceAuthEnrollmentStatus {
pub struct CybersourceConsumerAuthValidateResponse {
ucaf_collection_indicator: Option<String>,
cavv: Option<String>,
- ucaf_authentication_data: Option<String>,
+ ucaf_authentication_data: Option<Secret<String>>,
xid: Option<String>,
specification_version: Option<String>,
- directory_server_transaction_id: Option<String>,
+ directory_server_transaction_id: Option<Secret<String>>,
indicator: Option<String>,
}
@@ -1956,7 +1956,7 @@ pub struct CybersourceThreeDSMetadata {
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CybersourceConsumerAuthInformationEnrollmentResponse {
- access_token: Option<String>,
+ access_token: Option<Secret<String>>,
step_up_url: Option<String>,
//Added to segregate the three_ds_data in a separate struct
#[serde(flatten)]
@@ -2044,9 +2044,9 @@ impl<F>
.consumer_authentication_information
.step_up_url,
) {
- (Some(access_token), Some(step_up_url)) => {
+ (Some(token), Some(step_up_url)) => {
Some(services::RedirectForm::CybersourceConsumerAuth {
- access_token,
+ access_token: token.expose(),
step_up_url,
})
}
@@ -2241,7 +2241,7 @@ impl<F, T>
CybersourceSetupMandatesResponse::ClientReferenceInformation(info_response) => {
let mandate_reference = info_response.token_information.clone().map(|token_info| {
types::MandateReference {
- connector_mandate_id: Some(token_info.payment_instrument.id),
+ connector_mandate_id: Some(token_info.payment_instrument.id.expose()),
payment_method_id: None,
}
});
@@ -2655,7 +2655,7 @@ impl
client_risk_information.rules.map(|rules| {
rules
.iter()
- .map(|risk_info| format!(" , {}", risk_info.name))
+ .map(|risk_info| format!(" , {}", risk_info.name.clone().expose()))
.collect::<Vec<String>>()
.join("")
})