Skip to content

Commit

Permalink
refactor(connectors): [BOA] PII data masking (#3702)
Browse files Browse the repository at this point in the history
Co-authored-by: Arjun Karthik <[email protected]>
Co-authored-by: likhinbopanna <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent e5e4485 commit 49c71d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions crates/router/src/connector/bankofamerica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,10 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
.response
.parse_struct("bankofamerica RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);

types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
Expand Down
33 changes: 18 additions & 15 deletions crates/router/src/connector/bankofamerica/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -113,9 +113,9 @@ pub struct MerchantDefinedInformation {
pub struct BankOfAmericaConsumerAuthInformation {
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>,
}

Expand Down Expand Up @@ -213,7 +213,7 @@ pub struct BillTo {
first_name: Secret<String>,
last_name: Secret<String>,
address1: Secret<String>,
locality: String,
locality: Secret<String>,
administrative_area: Secret<String>,
postal_code: Secret<String>,
country: api_enums::CountryAlpha2,
Expand All @@ -235,7 +235,7 @@ fn build_bill_to(
first_name: address.get_first_name()?.to_owned(),
last_name: address.get_last_name()?.to_owned(),
address1: address.get_line1()?.to_owned(),
locality: address.get_city()?.to_owned(),
locality: Secret::new(address.get_city()?.to_owned()),
administrative_area: Secret::from(state),
postal_code: address.get_zip()?.to_owned(),
country: address.get_country()?.to_owned(),
Expand Down Expand Up @@ -435,7 +435,7 @@ pub struct ClientRiskInformation {

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ClientRiskInformationRules {
name: String,
name: Secret<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -889,8 +889,8 @@ impl ForeignFrom<(BankofamericaPaymentStatus, bool)> for enums::AttemptStatus {
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BankOfAmericaConsumerAuthInformationResponse {
access_token: String,
device_data_collection_url: String,
access_token: Secret<String>,
device_data_collection_url: Secret<String>,
reference_id: String,
}

Expand Down Expand Up @@ -1066,10 +1066,12 @@ impl<F>
redirection_data: Some(services::RedirectForm::CybersourceAuthSetup {
access_token: info_response
.consumer_authentication_information
.access_token,
.access_token
.expose(),
ddc_url: info_response
.consumer_authentication_information
.device_data_collection_url,
.device_data_collection_url
.expose(),
reference_id: info_response
.consumer_authentication_information
.reference_id,
Expand Down Expand Up @@ -1322,10 +1324,10 @@ pub enum BankOfAmericaAuthEnrollmentStatus {
pub struct BankOfAmericaConsumerAuthValidateResponse {
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>,
}

Expand All @@ -1337,7 +1339,7 @@ pub struct BankOfAmericaThreeDSMetadata {
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BankOfAmericaConsumerAuthInformationEnrollmentResponse {
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)]
Expand Down Expand Up @@ -1420,7 +1422,8 @@ impl<F>
let redirection_data = match (
info_response
.consumer_authentication_information
.access_token,
.access_token
.map(|access_token| access_token.expose()),
info_response
.consumer_authentication_information
.step_up_url,
Expand Down Expand Up @@ -2023,7 +2026,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("")
})
Expand Down

0 comments on commit 49c71d0

Please sign in to comment.