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
feat(connector): [BOA/CYB] Make state,zip optional for Non US CA Txns (#4915)
DEEPANSHU BANSAL2f12cca7ae5a
diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rsindex dacacb5d27..671cc40e05 100644--- a/crates/router/src/connector/bankofamerica/transformers.rs+++ b/crates/router/src/connector/bankofamerica/transformers.rs@@ -264,8 +264,10 @@ pub struct BillTo {last_name: Secret<String>,address1: Secret<String>,locality: Secret<String>,- administrative_area: Secret<String>,- postal_code: Secret<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ administrative_area: Option<Secret<String>>,+ #[serde(skip_serializing_if = "Option::is_none")]+ postal_code: Option<Secret<String>>,country: api_enums::CountryAlpha2,email: pii::Email,}@@ -448,17 +450,37 @@ 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);++ let country = address.get_country()?.to_owned();let first_name = address.get_first_name()?;++ let (administrative_area, postal_code) =+ if country == api_enums::CountryAlpha2::US || country == api_enums::CountryAlpha2::CA {+ let mut state = address.to_state_code()?.peek().clone();+ state.truncate(20);+ (+ Some(Secret::from(state)),+ Some(address.get_zip()?.to_owned()),+ )+ } else {+ let zip = address.zip.clone();+ let mut_state = address.state.clone().map(|state| state.expose());+ match mut_state {+ Some(mut state) => {+ state.truncate(20);+ (Some(Secret::from(state)), zip)+ }+ None => (None, zip),+ }+ };Ok(BillTo {first_name: first_name.clone(),last_name: address.get_last_name().unwrap_or(first_name).clone(),address1: address.get_line1()?.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(),+ administrative_area,+ postal_code,+ country,email,})}diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rsindex 0fb1784301..edc5c0cac1 100644--- a/crates/router/src/connector/cybersource/transformers.rs+++ b/crates/router/src/connector/cybersource/transformers.rs@@ -482,8 +482,10 @@ pub struct BillTo {last_name: Secret<String>,address1: Secret<String>,locality: String,- administrative_area: Secret<String>,- postal_code: Secret<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ administrative_area: Option<Secret<String>>,+ #[serde(skip_serializing_if = "Option::is_none")]+ postal_code: Option<Secret<String>>,country: api_enums::CountryAlpha2,email: pii::Email,}@@ -868,17 +870,37 @@ 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);++ let country = address.get_country()?.to_owned();let first_name = address.get_first_name()?;++ let (administrative_area, postal_code) =+ if country == api_enums::CountryAlpha2::US || country == api_enums::CountryAlpha2::CA {+ let mut state = address.to_state_code()?.peek().clone();+ state.truncate(20);+ (+ Some(Secret::from(state)),+ Some(address.get_zip()?.to_owned()),+ )+ } else {+ let zip = address.zip.clone();+ let mut_state = address.state.clone().map(|state| state.expose());+ match mut_state {+ Some(mut state) => {+ state.truncate(20);+ (Some(Secret::from(state)), zip)+ }+ None => (None, zip),+ }+ };Ok(BillTo {first_name: first_name.clone(),last_name: address.get_last_name().unwrap_or(first_name).clone(),address1: address.get_line1()?.to_owned(),locality: address.get_city()?.to_owned(),- administrative_area: Secret::from(state),- postal_code: address.get_zip()?.to_owned(),- country: address.get_country()?.to_owned(),+ administrative_area,+ postal_code,+ country,email,})}