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

fix(connector): [Cybersource] remove newline in billing address with space (#6478)

Sakil Mostak7f1d34571f72
diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs
index c187dcb6df..b99d0cb328 100644
--- a/crates/router/src/connector/cybersource/transformers.rs
+++ b/crates/router/src/connector/cybersource/transformers.rs
@@ -1117,12 +1117,16 @@ fn build_bill_to(
Ok(address_details
.and_then(|addr| {
addr.address.as_ref().map(|addr| BillTo {
- first_name: addr.first_name.clone(),
- last_name: addr.last_name.clone(),
- address1: addr.line1.clone(),
- locality: addr.city.clone(),
- administrative_area: addr.to_state_code_as_optional().ok().flatten(),
- postal_code: addr.zip.clone(),
+ first_name: addr.first_name.remove_new_line(),
+ last_name: addr.last_name.remove_new_line(),
+ address1: addr.line1.remove_new_line(),
+ locality: addr.city.remove_new_line(),
+ administrative_area: addr
+ .to_state_code_as_optional()
+ .ok()
+ .flatten()
+ .remove_new_line(),
+ postal_code: addr.zip.remove_new_line(),
country: addr.country,
email,
})
@@ -4054,3 +4058,22 @@ fn get_cybersource_card_type(card_network: common_enums::CardNetwork) -> Option<
common_enums::CardNetwork::Interac | common_enums::CardNetwork::RuPay => None,
}
}
+
+pub trait RemoveNewLine {
+ fn remove_new_line(&self) -> Self;
+}
+
+impl RemoveNewLine for Option<Secret<String>> {
+ fn remove_new_line(&self) -> Self {
+ self.clone().map(|masked_value| {
+ let new_string = masked_value.expose().replace("\n", " ");
+ Secret::new(new_string)
+ })
+ }
+}
+
+impl RemoveNewLine for Option<String> {
+ fn remove_new_line(&self) -> Self {
+ self.clone().map(|value| value.replace("\n", " "))
+ }
+}