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,
|
merchant_id: &id_type::MerchantId,
|
||||||
card_network: Option<common_enums::CardNetwork>,
|
card_network: Option<common_enums::CardNetwork>,
|
||||||
) -> errors::PmResult<()>;
|
) -> 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>(
|
pub async fn create_encrypted_data<T>(
|
||||||
|
|||||||
@ -890,6 +890,14 @@ impl PaymentMethodsController for PmCards<'_> {
|
|||||||
.await
|
.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")]
|
#[cfg(feature = "v1")]
|
||||||
#[instrument(skip_all)]
|
#[instrument(skip_all)]
|
||||||
async fn retrieve_payment_method(
|
async fn retrieve_payment_method(
|
||||||
@ -4205,6 +4213,7 @@ pub async fn list_customer_payment_method(
|
|||||||
&pm,
|
&pm,
|
||||||
Some(parent_payment_method_token.clone()),
|
Some(parent_payment_method_token.clone()),
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
&merchant_context,
|
&merchant_context,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@ -4349,6 +4358,7 @@ pub async fn list_customer_payment_method(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v1")]
|
#[cfg(feature = "v1")]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub async fn get_pm_list_context(
|
pub async fn get_pm_list_context(
|
||||||
state: &routes::SessionState,
|
state: &routes::SessionState,
|
||||||
payment_method: &enums::PaymentMethod,
|
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(feature = "payouts")] parent_payment_method_token: Option<String>,
|
||||||
#[cfg(not(feature = "payouts"))] _parent_payment_method_token: Option<String>,
|
#[cfg(not(feature = "payouts"))] _parent_payment_method_token: Option<String>,
|
||||||
is_payment_associated: bool,
|
is_payment_associated: bool,
|
||||||
|
force_fetch_card_from_vault: bool,
|
||||||
merchant_context: &domain::MerchantContext,
|
merchant_context: &domain::MerchantContext,
|
||||||
) -> Result<Option<PaymentMethodListContext>, error_stack::Report<errors::ApiErrorResponse>> {
|
) -> Result<Option<PaymentMethodListContext>, error_stack::Report<errors::ApiErrorResponse>> {
|
||||||
let cards = PmCards {
|
let cards = PmCards {
|
||||||
@ -4366,7 +4377,11 @@ pub async fn get_pm_list_context(
|
|||||||
};
|
};
|
||||||
let payment_method_retrieval_context = match payment_method {
|
let payment_method_retrieval_context = match payment_method {
|
||||||
enums::PaymentMethod::Card => {
|
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.as_ref().map(|card| PaymentMethodListContext {
|
||||||
card_details: Some(card.clone()),
|
card_details: Some(card.clone()),
|
||||||
|
|||||||
@ -233,6 +233,7 @@ pub async fn validate_create_request(
|
|||||||
payment_method,
|
payment_method,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
true,
|
||||||
merchant_context,
|
merchant_context,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
@ -243,7 +244,7 @@ pub async fn validate_create_request(
|
|||||||
card_number: card.card_number.get_required_value("card_number")?,
|
card_number: card.card_number.get_required_value("card_number")?,
|
||||||
card_holder_name: card.card_holder_name,
|
card_holder_name: card.card_holder_name,
|
||||||
expiry_month: card.expiry_month.get_required_value("expiry_month")?,
|
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))),
|
(_, Some(bank)) => Ok(Some(payouts::PayoutMethodData::Bank(bank))),
|
||||||
|
|||||||
Reference in New Issue
Block a user