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
fix: [Gocardless] add region in customer create request based on country (#2389)
Arjun Karthikc293cb6ffafd
diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/router/src/connector/gocardless/transformers.rsindex 222855db67..e8e7b1ebc2 100644--- a/crates/router/src/connector/gocardless/transformers.rs+++ b/crates/router/src/connector/gocardless/transformers.rs@@ -1,6 +1,6 @@use api_models::{- enums::{BankType, CountryAlpha2},- payments::BankDebitData,+ enums::{BankType, CountryAlpha2, UsStatesAbbreviation},+ payments::{AddressDetails, BankDebitData},};use common_utils::pii::{self, IpAddress};use masking::{ExposeInterface, Secret};@@ -12,7 +12,7 @@ use crate::{ConnectorCustomerData, PaymentsAuthorizeRequestData, PaymentsPreProcessingData, RouterData,},core::errors,- types::{self, api, storage::enums, MandateReference},+ types::{self, api, storage::enums, transformers::ForeignTryFrom, MandateReference},};pub struct GocardlessRouterData<T> {@@ -55,6 +55,7 @@ pub struct GocardlessCustomer {address_line2: Option<Secret<String>>,address_line3: Option<Secret<String>>,city: Option<Secret<String>>,+ region: Option<Secret<String>>,country_code: Option<CountryAlpha2>,email: pii::Email,given_name: Secret<String>,@@ -80,6 +81,7 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for GocardlessCustomerRequestlet metadata = CustomerMetaData {crm_id: item.customer_id.clone().map(Secret::new),};+ let region = get_region(billing_address)?;Ok(Self {customers: GocardlessCustomer {email,@@ -90,6 +92,7 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for GocardlessCustomerRequestaddress_line2: billing_address.line2.to_owned(),address_line3: billing_address.line3.to_owned(),country_code: billing_address.country,+ region,// Should be populated based on the billing countrydanish_identity_number: None,postal_code: billing_address.zip.to_owned(),@@ -101,6 +104,20 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for GocardlessCustomerRequest}}+fn get_region(+ address_details: &AddressDetails,+) -> Result<Option<Secret<String>>, error_stack::Report<errors::ConnectorError>> {+ match address_details.country {+ Some(CountryAlpha2::US) => {+ let state = address_details.get_state()?.to_owned();+ Ok(Some(Secret::new(+ UsStatesAbbreviation::foreign_try_from(state.expose())?.to_string(),+ )))+ }+ _ => Ok(None),+ }+}+#[derive(Debug, Clone, Deserialize)]pub struct GocardlessCustomerResponse {customers: Customers,