refactor(core): eliminate business profile database queries in payments confirm flow (#2190)

This commit is contained in:
BallaNitesh
2023-09-22 14:45:33 +05:30
committed by GitHub
parent 8b89969476
commit 90e43929a0
8 changed files with 28 additions and 16 deletions

View File

@ -211,6 +211,7 @@ pub async fn construct_refund_router_data<'a, F>(
merchant_account,
payment_intent.profile_id.as_ref(),
&*state.store,
false,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
@ -484,6 +485,7 @@ pub async fn construct_accept_dispute_router_data<'a>(
merchant_account,
payment_intent.profile_id.as_ref(),
&*state.store,
false,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
@ -570,6 +572,7 @@ pub async fn construct_submit_evidence_router_data<'a>(
merchant_account,
payment_intent.profile_id.as_ref(),
&*state.store,
false,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
@ -654,6 +657,7 @@ pub async fn construct_upload_file_router_data<'a>(
merchant_account,
payment_intent.profile_id.as_ref(),
&*state.store,
false,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
@ -741,6 +745,7 @@ pub async fn construct_defend_dispute_router_data<'a>(
merchant_account,
payment_intent.profile_id.as_ref(),
&*state.store,
false,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
@ -992,16 +997,19 @@ pub async fn get_profile_id_from_business_details(
merchant_account: &domain::MerchantAccount,
request_profile_id: Option<&String>,
db: &dyn StorageInterface,
should_validate: bool,
) -> RouterResult<String> {
match request_profile_id.or(merchant_account.default_profile.as_ref()) {
Some(profile_id) => {
// Check whether this business profile belongs to the merchant
let _ = validate_and_get_business_profile(
db,
Some(profile_id),
&merchant_account.merchant_id,
)
.await?;
if should_validate {
let _ = validate_and_get_business_profile(
db,
Some(profile_id),
&merchant_account.merchant_id,
)
.await?;
}
Ok(profile_id.clone())
}
None => match business_country.zip(business_label) {