Skip to content

Commit

Permalink
refactor: sync up with 2130 pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Chethan-rao committed Oct 14, 2023
1 parent 27f700e commit 644b0df
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,26 @@ async fn get_card_details(
pub async fn get_card_details_from_locker(
state: &routes::AppState,
pm: &storage::PaymentMethod,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card = get_card_from_locker(
state,
&pm.customer_id,
&pm.merchant_id,
&pm.payment_method_id,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error getting card from card vault")?;

payment_methods::get_card_detail(pm, card)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Get Card Details Failed")
}

pub async fn get_lookup_key_from_locker(
state: &routes::AppState,
payment_token: &str,
pm: &storage::PaymentMethod,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card_detail = get_card_details_from_locker(state, pm).await?;
let card = card_detail.clone();
Expand Down Expand Up @@ -2096,39 +2116,6 @@ async fn get_bank_account_connector_details(
}
}

pub async fn get_card_details_from_locker(
state: &routes::AppState,
payment_token: &str,
pm: &storage::PaymentMethod,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card = get_card_from_locker(
state,
&pm.customer_id,
&pm.merchant_id,
&pm.payment_method_id,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error getting card from card vault")?;

payment_methods::get_card_detail(pm, card)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Get Card Details Failed")
}

pub async fn get_lookup_key_from_locker(
state: &routes::AppState,
payment_token: &str,
pm: &storage::PaymentMethod,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card_detail = get_card_details_from_locker(state, pm).await?;
let card = card_detail.clone();
let resp =
BasiliskCardSupport::create_payment_method_data_in_locker(state, payment_token, card, pm)
.await?;
Ok(resp)
}

#[cfg(feature = "payouts")]
pub async fn get_lookup_key_for_payout_method(
state: &routes::AppState,
Expand Down

0 comments on commit 644b0df

Please sign in to comment.