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(modular): populate additional payment method data for modular flows (#13622)
Kashif199c5b7edd76
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 2dd21c8b1c..c9ae22b136 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -519,7 +519,12 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.as_ref().and_then(|pmd| pmd.payment_method_data.clone()).map(domain::PaymentMethodData::from)- .or(payment_method_recurring_details.clone());+ .or(payment_method_recurring_details.clone())+ .or_else(|| {+ payment_method_with_raw_data+ .as_ref()+ .and_then(|payment_method| payment_method.raw_payment_method_data.clone())+ });let store = state.clone().store;let superposition_service = state.superposition_service.clone();@@ -715,8 +720,16 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>} else {None};- // Only set `payment_attempt.payment_method_data` if `additional_pm_data_from_locker` is not None- if let Some(additional_pm_data) = additional_pm_data_from_locker.as_ref() {+ // Modular payment methods keep raw payment data separate from the domain payment method.+ // Persist only the derived supplementary data, falling back to the legacy locker metadata.+ let additional_pm_data_to_persist = if payment_method_with_raw_data.is_some() {+ additional_pm_data+ .as_ref()+ .or(additional_pm_data_from_locker.as_ref())+ } else {+ additional_pm_data_from_locker.as_ref()+ };+ if let Some(additional_pm_data) = additional_pm_data_to_persist {payment_attempt.payment_method_data = Some(Encode::encode_to_value(additional_pm_data).change_context(errors::ApiErrorResponse::InternalServerError)diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex b3e4360c40..6eb940baa4 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -360,6 +360,9 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>profile_id.clone(),&customer_acceptance,payment_method_recurring_details.clone(),+ payment_method_with_raw_data+ .as_ref()+ .and_then(|payment_method| payment_method.raw_payment_method_data.clone()),customer_details.customer_id.as_ref(),dimensions,)@@ -1447,6 +1450,7 @@ impl PaymentCreate {profile_id: common_utils::id_type::ProfileId,customer_acceptance: &Option<common_payments_types::CustomerAcceptance>,payment_method_recurring_details: Option<domain::PaymentMethodData>,+ modular_raw_payment_method_data: Option<domain::PaymentMethodData>,customer_id: Option<&common_utils::id_type::CustomerId>,dimensions: &dimension_state::DimensionsWithProcessorAndProviderMerchantId,) -> RouterResult<(@@ -1474,6 +1478,7 @@ impl PaymentCreate {}).map(domain::PaymentMethodData::from).or(payment_method_recurring_details)+ .or(modular_raw_payment_method_data).zip(Some(profile_id.clone())) // since data is consumed by async move, profile_id needs to be send separately.async_map(|(payment_method_data, _)| async move {helpers::get_additional_payment_data(diff --git a/crates/router/src/core/payments/operations/payment_recurrence.rs b/crates/router/src/core/payments/operations/payment_recurrence.rsindex 3e26d4e197..7d3ac0068a 100644--- a/crates/router/src/core/payments/operations/payment_recurrence.rs+++ b/crates/router/src/core/payments/operations/payment_recurrence.rs@@ -150,7 +150,12 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.payment_method_data.as_ref().and_then(|pmd| pmd.payment_method_data.clone())- .map(domain::PaymentMethodData::from);+ .map(domain::PaymentMethodData::from)+ .or_else(|| {+ payment_method_with_raw_data+ .as_ref()+ .and_then(|payment_method| payment_method.raw_payment_method_data.clone())+ });let store = state.clone().store;let superposition_service = state.clone().superposition_service;