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(core): add profile level config to toggle extended card bin (#4445)
Amisha Prabhat0304e8e76a8c
diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rsindex b62d3afd4a..5e03033977 100644--- a/crates/router/src/core/fraud_check.rs+++ b/crates/router/src/core/fraud_check.rs@@ -243,10 +243,11 @@ where}).collect::<Vec<_>>().concat();+let additional_payment_data = match &payment_data.payment_method_data {Some(pmd) => {let additional_payment_data =- get_additional_payment_data(pmd, db).await;+ get_additional_payment_data(pmd, db, &profile_id).await;Some(additional_payment_data)}None => payment_datadiff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 702b63b5c0..d2a2896de8 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -3649,11 +3649,23 @@ mod test {pub async fn get_additional_payment_data(pm_data: &api_models::payments::PaymentMethodData,db: &dyn StorageInterface,+ profile_id: &str,) -> api_models::payments::AdditionalPaymentData {match pm_data {api_models::payments::PaymentMethodData::Card(card_data) => {let card_isin = Some(card_data.card_number.clone().get_card_isin());- let card_extended_bin = Some(card_data.card_number.clone().get_card_extended_bin());+ let enable_extended_bin =db+ .find_config_by_key_unwrap_or(+ format!("{}_enable_extended_card_bin", profile_id).as_str(),+ Some("false".to_string()))+ .await.map_err(|err| services::logger::error!(message="Failed to fetch the config", extended_card_bin_error=?err)).ok();++ let card_extended_bin = match enable_extended_bin {+ Some(config) if config.config == "true" => {+ Some(card_data.card_number.clone().get_card_extended_bin())+ }+ _ => None,+ };let last4 = Some(card_data.card_number.clone().get_last4());if card_data.card_issuer.is_some()&& card_data.card_network.is_some()diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 125f79956a..89c996236a 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -415,13 +415,23 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>.and_then(|pmd| pmd.payment_method_data.clone());let store = state.clone().store;+ let profile_id = payment_intent+ .profile_id+ .clone()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("'profile_id' not set in payment intent")?;let additional_pm_data_fut = tokio::spawn(async move {Ok(n_request_payment_method_data.async_map(|payment_method_data| async move {- helpers::get_additional_payment_data(&payment_method_data, store.as_ref())- .await+ helpers::get_additional_payment_data(+ &payment_method_data,+ store.as_ref(),+ profile_id.as_ref(),+ )+ .await}).await)}@@ -1059,12 +1069,19 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>.clone();let payment_token = payment_data.token.clone();let payment_method_type = payment_data.payment_attempt.payment_method_type;+ let profile_id = payment_data+ .payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)?;let payment_experience = payment_data.payment_attempt.payment_experience;let additional_pm_data = payment_data.payment_method_data.as_ref().async_map(|payment_method_data| async {- helpers::get_additional_payment_data(payment_method_data, &*state.store).await+ helpers::get_additional_payment_data(payment_method_data, &*state.store, profile_id)+ .await}).await.as_ref()diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex aaebccd880..e770da7074 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -258,7 +258,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>.as_ref().map(|address| address.address_id.clone()),attempt_id,- profile_id,+ profile_id.clone(),session_expiry,).await?;@@ -277,6 +277,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>.map(|address| address.address_id.clone()),&payment_method_info,merchant_key_store,+ profile_id,).await?;@@ -771,6 +772,7 @@ impl PaymentCreate {payment_method_billing_address_id: Option<String>,payment_method_info: &Option<PaymentMethod>,key_store: &domain::MerchantKeyStore,+ profile_id: String,) -> RouterResult<(storage::PaymentAttemptNew,Option<api_models::payments::AdditionalPaymentData>,@@ -794,7 +796,12 @@ impl PaymentCreate {payment_method_data_request.payment_method_data.as_ref()}).async_map(|payment_method_data| async {- helpers::get_additional_payment_data(payment_method_data, &*state.store).await+ helpers::get_additional_payment_data(+ payment_method_data,+ &*state.store,+ &profile_id,+ )+ .await}).await;diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 804d1dbc80..0aaa600605 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -593,12 +593,20 @@ impl<F: Clone, Ctx: PaymentMethodRetrieve>storage_enums::AttemptStatus::ConfirmationAwaited}};+ let profile_id = payment_data+ .payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("'profile_id' not set in payment intent")?;let additional_pm_data = payment_data.payment_method_data.as_ref().async_map(|payment_method_data| async {- helpers::get_additional_payment_data(payment_method_data, &*state.store).await+ helpers::get_additional_payment_data(payment_method_data, &*state.store, profile_id)+ .await}).await.as_ref()