mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
fix(payment-methods): fetch payment method details in payouts flow (#8729)
This commit is contained in:
@ -229,6 +229,12 @@ pub trait PaymentMethodsController {
|
||||
merchant_id: &id_type::MerchantId,
|
||||
card_network: Option<common_enums::CardNetwork>,
|
||||
) -> errors::PmResult<()>;
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
async fn get_card_details_from_locker(
|
||||
&self,
|
||||
pm: &payment_methods::PaymentMethod,
|
||||
) -> errors::PmResult<api::CardDetailFromLocker>;
|
||||
}
|
||||
|
||||
pub async fn create_encrypted_data<T>(
|
||||
|
||||
@ -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<api::CardDetailFromLocker> {
|
||||
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<String>,
|
||||
#[cfg(not(feature = "payouts"))] _parent_payment_method_token: Option<String>,
|
||||
is_payment_associated: bool,
|
||||
force_fetch_card_from_vault: bool,
|
||||
merchant_context: &domain::MerchantContext,
|
||||
) -> Result<Option<PaymentMethodListContext>, error_stack::Report<errors::ApiErrorResponse>> {
|
||||
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()),
|
||||
|
||||
@ -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))),
|
||||
|
||||
Reference in New Issue
Block a user