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(payment_methods): filter the apple pay retryable connectors for a specific business profile with default fallback configuration (#4794)
Shankar Singh Cd784fcb5e650
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 09787bc273..e1290637db 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -3210,11 +3210,11 @@ whererouting_data.business_sub_label = choice.sub_label.clone();}- #[cfg(feature = "retry")]+ #[cfg(all(feature = "retry", feature = "connector_choice_mca_id"))]let should_do_retry =retry::config_should_call_gsm(&*state.store, &merchant_account.merchant_id).await;- #[cfg(feature = "retry")]+ #[cfg(all(feature = "retry", feature = "connector_choice_mca_id"))]if payment_data.payment_attempt.payment_method_type== Some(storage_enums::PaymentMethodType::ApplePay)&& should_do_retry@@ -3225,15 +3225,15 @@ wherepayment_data,key_store,connector_data.clone(),- #[cfg(feature = "connector_choice_mca_id")]choice.merchant_connector_id.clone().as_ref(),- #[cfg(not(feature = "connector_choice_mca_id"))]- None,).await?;if let Some(connector_data_list) = retryable_connector_data {- return Ok(ConnectorCallType::Retryable(connector_data_list));+ if connector_data_list.len() > 1 {+ logger::info!("Constructed apple pay retryable connector list");+ return Ok(ConnectorCallType::Retryable(connector_data_list));+ }}}diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 7b39a5d950..f9f63c6cce 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -4015,6 +4015,7 @@ pub fn get_applepay_metadata(})}+#[cfg(all(feature = "retry", feature = "connector_choice_mca_id"))]pub async fn get_apple_pay_retryable_connectors<F>(state: SessionState,merchant_account: &domain::MerchantAccount,@@ -4040,7 +4041,7 @@ wheremerchant_account.merchant_id.as_str(),payment_data.creds_identifier.to_owned(),key_store,- profile_id, // need to fix this+ profile_id,&decided_connector_data.connector_name.to_string(),merchant_connector_id,)@@ -4063,9 +4064,14 @@ where.await.to_not_found_response(errors::ApiErrorResponse::InternalServerError)?;+ let profile_specific_merchant_connector_account_list = filter_mca_based_on_business_profile(+ merchant_connector_account_list,+ Some(profile_id.to_string()),+ );+let mut connector_data_list = vec![decided_connector_data.clone()];- for merchant_connector_account in merchant_connector_account_list {+ for merchant_connector_account in profile_specific_merchant_connector_account_list {if is_apple_pay_simplified_flow(merchant_connector_account.metadata,merchant_connector_account@@ -4090,7 +4096,33 @@ where}}}- Some(connector_data_list)++ let fallback_connetors_list = crate::core::routing::helpers::get_merchant_default_config(+ &*state.clone().store,+ profile_id,+ &api_enums::TransactionType::Payment,+ )+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Failed to get merchant default fallback connectors config")?;++ // connector_data_list is the list of connectors for which Apple Pay simplified flow is configured.+ // This list is arranged in the same order as the merchant's default fallback connectors configuration.+ let mut ordered_connector_data_list = vec![decided_connector_data.clone()];+ fallback_connetors_list+ .iter()+ .for_each(|fallback_connector| {+ let connector_data = connector_data_list.iter().find(|connector_data| {+ fallback_connector.merchant_connector_id == connector_data.merchant_connector_id+ && fallback_connector.merchant_connector_id+ != decided_connector_data.merchant_connector_id+ });+ if let Some(connector_data_details) = connector_data {+ ordered_connector_data_list.push(connector_data_details.clone());+ }+ });++ Some(ordered_connector_data_list)} else {None};