diff --git a/crates/payment_methods/src/controller.rs b/crates/payment_methods/src/controller.rs index bd5a9f316e..095788fa36 100644 --- a/crates/payment_methods/src/controller.rs +++ b/crates/payment_methods/src/controller.rs @@ -229,6 +229,12 @@ pub trait PaymentMethodsController { merchant_id: &id_type::MerchantId, card_network: Option, ) -> errors::PmResult<()>; + + #[cfg(feature = "v1")] + async fn get_card_details_from_locker( + &self, + pm: &payment_methods::PaymentMethod, + ) -> errors::PmResult; } pub async fn create_encrypted_data( diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 8f29e05e15..7ba707316c 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -890,6 +890,14 @@ impl PaymentMethodsController for PmCards<'_> { .await } + #[cfg(feature = "v1")] + async fn get_card_details_from_locker( + &self, + pm: &domain::PaymentMethod, + ) -> errors::RouterResult { + get_card_details_from_locker(self.state, pm).await + } + #[cfg(feature = "v1")] #[instrument(skip_all)] async fn retrieve_payment_method( @@ -4205,6 +4213,7 @@ pub async fn list_customer_payment_method( &pm, Some(parent_payment_method_token.clone()), true, + false, &merchant_context, ) .await?; @@ -4349,6 +4358,7 @@ pub async fn list_customer_payment_method( } #[cfg(feature = "v1")] +#[allow(clippy::too_many_arguments)] pub async fn get_pm_list_context( state: &routes::SessionState, payment_method: &enums::PaymentMethod, @@ -4358,6 +4368,7 @@ pub async fn get_pm_list_context( #[cfg(feature = "payouts")] parent_payment_method_token: Option, #[cfg(not(feature = "payouts"))] _parent_payment_method_token: Option, is_payment_associated: bool, + force_fetch_card_from_vault: bool, merchant_context: &domain::MerchantContext, ) -> Result, error_stack::Report> { let cards = PmCards { @@ -4366,7 +4377,11 @@ pub async fn get_pm_list_context( }; let payment_method_retrieval_context = match payment_method { enums::PaymentMethod::Card => { - let card_details = cards.get_card_details_with_locker_fallback(pm).await?; + let card_details = if force_fetch_card_from_vault { + Some(cards.get_card_details_from_locker(pm).await?) + } else { + cards.get_card_details_with_locker_fallback(pm).await? + }; card_details.as_ref().map(|card| PaymentMethodListContext { card_details: Some(card.clone()), diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rs index 3d58d1f367..198caa4b89 100644 --- a/crates/router/src/core/payouts/validator.rs +++ b/crates/router/src/core/payouts/validator.rs @@ -233,6 +233,7 @@ pub async fn validate_create_request( payment_method, None, false, + true, merchant_context, ) .await? @@ -243,7 +244,7 @@ pub async fn validate_create_request( card_number: card.card_number.get_required_value("card_number")?, card_holder_name: card.card_holder_name, expiry_month: card.expiry_month.get_required_value("expiry_month")?, - expiry_year: card.expiry_year.get_required_value("expiry_month")?, + expiry_year: card.expiry_year.get_required_value("expiry_year")?, }, ))), (_, Some(bank)) => Ok(Some(payouts::PayoutMethodData::Bank(bank))),