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

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
AkshayaFoiger
2024-02-26 17:25:42 +05:30
committed by GitHub
parent 75c633fc7c
commit a5cb6bb5a4

View File

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