From 3ee735e7c2aca9495a95eb8a212716d6158777e6 Mon Sep 17 00:00:00 2001 From: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:06:20 +0530 Subject: [PATCH] fix(core): fix setup mandate payments to store connector mandate details (#6446) --- .../payments/operations/payment_response.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index 274b4f43c5d4..0694256fae38 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -1101,6 +1101,34 @@ impl PostUpdateTracker, types::SetupMandateRequestDa )) .await?; + payment_data.payment_method_info = if let Some(payment_method_id) = &payment_method_id { + match state + .store + .find_payment_method( + &(state.into()), + key_store, + payment_method_id, + merchant_account.storage_scheme, + ) + .await + { + Ok(payment_method) => Some(payment_method), + Err(error) => { + if error.current_context().is_db_not_found() { + logger::info!("Payment Method not found in db {:?}", error); + None + } else { + Err(error) + .change_context(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Error retrieving payment method from db") + .map_err(|err| logger::error!(payment_method_retrieve=?err)) + .ok() + } + } + } + } else { + None + }; let mandate_id = mandate::mandate_procedure( state, resp,