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): [BOA/Cyb] Truncate state length to <20 (#3198)

DEEPANSHU BANSAL79a18e2bf7bb
diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs
index 2c91166fd5..ab9e067a93 100644
--- a/crates/router/src/connector/bankofamerica/transformers.rs
+++ b/crates/router/src/connector/bankofamerica/transformers.rs
@@ -1,7 +1,7 @@
use api_models::payments;
use base64::Engine;
use common_utils::pii;
-use masking::Secret;
+use masking::{PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use crate::{
@@ -202,12 +202,14 @@ fn build_bill_to(
.address
.as_ref()
.ok_or_else(utils::missing_field_err("billing.address"))?;
+ let mut state = address.to_state_code()?.peek().clone();
+ state.truncate(20);
Ok(BillTo {
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(),
- administrative_area: address.to_state_code()?,
+ administrative_area: Secret::from(state),
postal_code: address.get_zip()?.to_owned(),
country: address.get_country()?.to_owned(),
email,
diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs
index f99c90989d..bc4e750951 100644
--- a/crates/router/src/connector/cybersource/transformers.rs
+++ b/crates/router/src/connector/cybersource/transformers.rs
@@ -1,7 +1,7 @@
use api_models::payments;
use base64::Engine;
use common_utils::pii;
-use masking::Secret;
+use masking::{PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use crate::{
@@ -427,12 +427,14 @@ fn build_bill_to(
.address
.as_ref()
.ok_or_else(utils::missing_field_err("billing.address"))?;
+ let mut state = address.to_state_code()?.peek().clone();
+ state.truncate(20);
Ok(BillTo {
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(),
- administrative_area: address.to_state_code()?,
+ administrative_area: Secret::from(state),
postal_code: address.get_zip()?.to_owned(),
country: address.get_country()?.to_owned(),
email,