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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(connector): [Payu][Placetopay][PowerTranz] Mask PII data (#3928)
AkshayaFoiger4cbd00ba410c
diff --git a/crates/router/src/connector/payu/transformers.rs b/crates/router/src/connector/payu/transformers.rsindex e3ad6f8b42..e8699a1a0e 100644--- a/crates/router/src/connector/payu/transformers.rs+++ b/crates/router/src/connector/payu/transformers.rs@@ -1,4 +1,5 @@use base64::Engine;+use common_utils::pii::{Email, IpAddress};use error_stack::{IntoReport, ResultExt};use serde::{Deserialize, Serialize};@@ -15,7 +16,7 @@ const WALLET_IDENTIFIER: &str = "PBL";#[derive(Debug, Serialize, Eq, PartialEq)]#[serde(rename_all = "camelCase")]pub struct PayuPaymentsRequest {- customer_ip: std::net::IpAddr,+ customer_ip: Secret<String, IpAddress>,merchant_pos_id: Secret<String>,total_amount: i64,currency_code: enums::Currency,@@ -55,7 +56,7 @@ pub struct PayuWallet {pub value: PayuWalletCode,#[serde(rename = "type")]pub wallet_type: String,- pub authorization_code: String,+ pub authorization_code: Secret<String>,}#[derive(Debug, Eq, PartialEq, Serialize)]#[serde(rename_all = "lowercase")]@@ -83,8 +84,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {PayuWallet {value: PayuWalletCode::Ap,wallet_type: WALLET_IDENTIFIER.to_string(),- authorization_code: consts::BASE64_ENGINE- .encode(data.tokenization_data.token),+ authorization_code: Secret::new(+ consts::BASE64_ENGINE.encode(data.tokenization_data.token),+ ),}}),}),@@ -93,7 +95,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {PayuWallet {value: PayuWalletCode::Jp,wallet_type: WALLET_IDENTIFIER.to_string(),- authorization_code: data.payment_data,+ authorization_code: Secret::new(data.payment_data),}}),}),@@ -111,11 +113,14 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {},)?;Ok(Self {- customer_ip: browser_info.ip_address.ok_or(- errors::ConnectorError::MissingRequiredField {- field_name: "browser_info.ip_address",- },- )?,+ customer_ip: Secret::new(+ browser_info+ .ip_address+ .ok_or(errors::ConnectorError::MissingRequiredField {+ field_name: "browser_info.ip_address",+ })?+ .to_string(),+ ),merchant_pos_id: auth_type.merchant_pos_id,total_amount: item.request.amount,currency_code: item.request.currency,@@ -401,8 +406,8 @@ pub struct PayuOrderResponseData {ext_order_id: Option<String>,order_create_date: String,notify_url: Option<String>,- customer_ip: std::net::IpAddr,- merchant_pos_id: String,+ customer_ip: Secret<String, IpAddress>,+ merchant_pos_id: Secret<String>,description: String,validity_time: Option<String>,currency_code: enums::Currency,@@ -417,12 +422,12 @@ pub struct PayuOrderResponseData {#[serde(rename_all = "camelCase")]pub struct PayuOrderResponseBuyerData {ext_customer_id: Option<String>,- email: Option<String>,- phone: Option<String>,- first_name: Option<String>,- last_name: Option<String>,+ email: Option<Email>,+ phone: Option<Secret<String>>,+ first_name: Option<Secret<String>>,+ last_name: Option<Secret<String>>,#[serde(rename = "nin")]- national_identification_number: Option<String>,+ national_identification_number: Option<Secret<String>>,language: Option<String>,delivery: Option<String>,customer_id: Option<String>,diff --git a/crates/router/src/connector/placetopay/transformers.rs b/crates/router/src/connector/placetopay/transformers.rsindex e5dedf6ded..1c3b46fdb6 100644--- a/crates/router/src/connector/placetopay/transformers.rs+++ b/crates/router/src/connector/placetopay/transformers.rs@@ -73,7 +73,7 @@ pub struct PlacetopayAuthType {pub struct PlacetopayAuth {login: Secret<String>,tran_key: Secret<String>,- nonce: String,+ nonce: Secret<String>,seed: String,}@@ -179,7 +179,7 @@ impl TryFrom<&types::ConnectorAuthType> for PlacetopayAuth {context.update(seed.as_bytes());context.update(placetopay_auth.tran_key.peek().as_bytes());let encoded_digest = base64::Engine::encode(&consts::BASE64_ENGINE, context.finish());- let nonce = base64::Engine::encode(&consts::BASE64_ENGINE, &nonce_bytes);+ let nonce = Secret::new(base64::Engine::encode(&consts::BASE64_ENGINE, &nonce_bytes));Ok(Self {login: placetopay_auth.login,tran_key: encoded_digest.into(),diff --git a/crates/router/src/connector/powertranz.rs b/crates/router/src/connector/powertranz.rsindex 53f6a02d5b..a26886384c 100644--- a/crates/router/src/connector/powertranz.rs+++ b/crates/router/src/connector/powertranz.rs@@ -309,7 +309,7 @@ impl.get_redirect_response_payload()?.parse_value("PowerTranz RedirectResponsePayload").change_context(errors::ConnectorError::ResponseDeserializationFailed)?;- let spi_token = format!(r#""{}""#, redirect_payload.spi_token);+ let spi_token = format!(r#""{}""#, redirect_payload.spi_token.expose());Ok(RequestContent::Json(Box::new(spi_token)))}diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rsindex 54849f8bf1..0af5dde6d0 100644--- a/crates/router/src/connector/powertranz/transformers.rs+++ b/crates/router/src/connector/powertranz/transformers.rs@@ -1,8 +1,8 @@use api_models::payments::Card;-use common_utils::pii::Email;+use common_utils::pii::{Email, IpAddress};use diesel_models::enums::RefundStatus;use error_stack::IntoReport;-use masking::Secret;+use masking::{ExposeInterface, Secret};use serde::{Deserialize, Serialize};use uuid::Uuid;@@ -51,7 +51,7 @@ pub struct BrowserInfo {screen_width: Option<String>,time_zone: Option<String>,user_agent: Option<String>,- i_p: Option<std::net::IpAddr>,+ i_p: Option<Secret<String, IpAddress>>,color_depth: Option<String>,}@@ -94,7 +94,7 @@ pub struct PowertranzAddressDetails {#[derive(Debug, Deserialize)]#[serde(rename_all = "PascalCase")]pub struct RedirectResponsePayload {- pub spi_token: String,+ pub spi_token: Secret<String>,}impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest {@@ -173,7 +173,9 @@ impl TryFrom<&types::BrowserInformation> for BrowserInfo {screen_width: item.screen_width.map(|width| width.to_string()),time_zone: item.time_zone.map(|zone| zone.to_string()),user_agent: item.user_agent.clone(),- i_p: item.ip_address,+ i_p: item+ .ip_address+ .map(|ip_address| Secret::new(ip_address.to_string())),color_depth: item.color_depth.map(|depth| depth.to_string()),})}@@ -256,7 +258,7 @@ pub struct PowertranzBaseResponse {original_trxn_identifier: Option<String>,errors: Option<Vec<Error>>,iso_response_code: String,- redirect_data: Option<String>,+ redirect_data: Option<Secret<String>>,response_message: String,order_identifier: String,}@@ -322,7 +324,7 @@ impl<F, T>item.response.redirect_data.map(|redirect_data| services::RedirectForm::Html {- html_data: redirect_data,+ html_data: redirect_data.expose(),});let response = error_response.map_or(Ok(types::PaymentsResponseData::TransactionResponse {