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(connectors): [Bambora] data masking (#3695)

AkshayaFoigere5e44857d21a
diff --git a/crates/router/src/connector/bambora.rs b/crates/router/src/connector/bambora.rs
index e2d9e18ce9..d453677deb 100644
--- a/crates/router/src/connector/bambora.rs
+++ b/crates/router/src/connector/bambora.rs
@@ -228,8 +228,10 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
.response
.parse_struct("bambora PaymentsResponse")
.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,
@@ -324,8 +326,10 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
.response
.parse_struct("bambora PaymentsResponse")
.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,
@@ -405,8 +409,10 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
.response
.parse_struct("Bambora PaymentsResponse")
.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,
@@ -597,8 +603,10 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
.response
.parse_struct("bambora RefundResponse")
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
+
types::RefundsRouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
@@ -669,8 +677,10 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
.response
.parse_struct("bambora 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(),
diff --git a/crates/router/src/connector/bambora/transformers.rs b/crates/router/src/connector/bambora/transformers.rs
index d2c99bbaca..c47b071828 100644
--- a/crates/router/src/connector/bambora/transformers.rs
+++ b/crates/router/src/connector/bambora/transformers.rs
@@ -1,7 +1,7 @@
use base64::Engine;
-use common_utils::ext_traits::ValueExt;
+use common_utils::{ext_traits::ValueExt, pii::IpAddress};
use error_stack::{IntoReport, ResultExt};
-use masking::{PeekInterface, Secret};
+use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Deserializer, Serialize};
use crate::{
@@ -51,7 +51,7 @@ pub struct BamboraPaymentsRequest {
order_number: String,
amount: i64,
payment_method: PaymentMethod,
- customer_ip: Option<std::net::IpAddr>,
+ customer_ip: Option<Secret<String, IpAddress>>,
term_url: Option<String>,
card: BamboraCard,
}
@@ -133,7 +133,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BamboraPaymentsRequest {
amount: item.request.amount,
payment_method: PaymentMethod::Card,
card: bambora_card,
- customer_ip: browser_info.ip_address,
+ customer_ip: browser_info
+ .ip_address
+ .map(|ip_address| Secret::new(format!("{ip_address}"))),
term_url: item.request.complete_authorize_url.clone(),
})
}
@@ -235,7 +237,7 @@ impl<F, T>
mandate_reference: None,
connector_metadata: Some(
serde_json::to_value(BamboraMeta {
- three_d_session_data: response.three_d_session_data,
+ three_d_session_data: response.three_d_session_data.expose(),
})
.into_report()
.change_context(errors::ConnectorError::ResponseHandlingFailed)?,
@@ -312,7 +314,7 @@ pub struct BamboraPaymentsResponse {
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Bambora3DsResponse {
#[serde(rename = "3d_session_data")]
- three_d_session_data: String,
+ three_d_session_data: Secret<String>,
contents: String,
}
@@ -334,12 +336,12 @@ pub struct CardResponse {
#[derive(Default, Debug, Clone, Deserialize, PartialEq, Serialize)]
pub struct CardData {
- name: Option<String>,
- expiry_month: Option<String>,
- expiry_year: Option<String>,
+ name: Option<Secret<String>>,
+ expiry_month: Option<Secret<String>>,
+ expiry_year: Option<Secret<String>>,
card_type: String,
- last_four: String,
- card_bin: Option<String>,
+ last_four: Secret<String>,
+ card_bin: Option<Secret<String>>,
avs_result: String,
cvd_result: String,
cavv_result: Option<String>,
@@ -357,15 +359,15 @@ pub struct AvsObject {
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct AddressData {
- name: String,
- address_line1: String,
- address_line2: String,
+ name: Secret<String>,
+ address_line1: Secret<String>,
+ address_line2: Secret<String>,
city: String,
province: String,
country: String,
- postal_code: String,
- phone_number: String,
- email_address: String,
+ postal_code: Secret<String>,
+ phone_number: Secret<String>,
+ email_address: Secret<String>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]