Skip to content

Commit

Permalink
fix(payout): use mca_connector_id from ConnectorData to fetch mca_acc…
Browse files Browse the repository at this point in the history
…ount (#5620)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
kashif-m and hyperswitch-bot[bot] authored Aug 14, 2024
1 parent e4f4fba commit 92a07cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
14 changes: 7 additions & 7 deletions crates/router/src/core/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ pub async fn create_recipient(
// 1. Form router data
let router_data = core_utils::construct_payout_router_data(
state,
&connector_data.connector_name,
connector_data,
merchant_account,
key_store,
payout_data,
Expand Down Expand Up @@ -1313,7 +1313,7 @@ pub async fn check_payout_eligibility(
// 1. Form Router data
let router_data = core_utils::construct_payout_router_data(
state,
&connector_data.connector_name,
connector_data,
merchant_account,
key_store,
payout_data,
Expand Down Expand Up @@ -1493,7 +1493,7 @@ pub async fn create_payout(
// 1. Form Router data
let mut router_data = core_utils::construct_payout_router_data(
state,
&connector_data.connector_name,
connector_data,
merchant_account,
key_store,
payout_data,
Expand Down Expand Up @@ -1685,7 +1685,7 @@ pub async fn create_payout_retrieve(
// 1. Form Router data
let mut router_data = core_utils::construct_payout_router_data(
state,
&connector_data.connector_name,
connector_data,
merchant_account,
key_store,
payout_data,
Expand Down Expand Up @@ -1827,7 +1827,7 @@ pub async fn create_recipient_disburse_account(
// 1. Form Router data
let router_data = core_utils::construct_payout_router_data(
state,
&connector_data.connector_name,
connector_data,
merchant_account,
key_store,
payout_data,
Expand Down Expand Up @@ -1912,7 +1912,7 @@ pub async fn cancel_payout(
// 1. Form Router data
let router_data = core_utils::construct_payout_router_data(
state,
&connector_data.connector_name,
connector_data,
merchant_account,
key_store,
payout_data,
Expand Down Expand Up @@ -2017,7 +2017,7 @@ pub async fn fulfill_payout(
// 1. Form Router data
let mut router_data = core_utils::construct_payout_router_data(
state,
&connector_data.connector_name,
connector_data,
merchant_account,
key_store,
payout_data,
Expand Down
15 changes: 8 additions & 7 deletions crates/router/src/core/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
db::StorageInterface,
routes::SessionState,
types::{
self, domain,
self, api, domain,
storage::{self, enums},
PollConfig,
},
Expand All @@ -49,7 +49,7 @@ const IRRELEVANT_ATTEMPT_ID_IN_DISPUTE_FLOW: &str = "irrelevant_attempt_id_in_di
#[instrument(skip_all)]
pub async fn get_mca_for_payout<'a>(
state: &'a SessionState,
connector_id: &str,
connector_data: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
payout_data: &PayoutData,
Expand All @@ -63,8 +63,8 @@ pub async fn get_mca_for_payout<'a>(
None,
key_store,
&payout_data.profile_id,
connector_id,
payout_data.payout_attempt.merchant_connector_id.as_ref(),
&connector_data.connector_name.to_string(),
connector_data.merchant_connector_id.as_ref(),
)
.await?;
Ok(merchant_connector_account)
Expand All @@ -76,19 +76,20 @@ pub async fn get_mca_for_payout<'a>(
#[instrument(skip_all)]
pub async fn construct_payout_router_data<'a, F>(
state: &'a SessionState,
connector_name: &api_models::enums::Connector,
connector_data: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
payout_data: &mut PayoutData,
) -> RouterResult<types::PayoutsRouterData<F>> {
let merchant_connector_account = get_mca_for_payout(
state,
&connector_name.to_string(),
connector_data,
merchant_account,
key_store,
payout_data,
)
.await?;
let connector_name = connector_data.connector_name;
payout_data.merchant_connector_account = Some(merchant_connector_account.clone());
let connector_auth_type: types::ConnectorAuthType = merchant_connector_account
.get_connector_account_details()
Expand Down Expand Up @@ -770,7 +771,7 @@ pub async fn construct_upload_file_router_data<'a>(
payment_attempt: &storage::PaymentAttempt,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
create_file_request: &types::api::CreateFileRequest,
create_file_request: &api::CreateFileRequest,
connector_id: &str,
file_key: String,
) -> RouterResult<types::UploadFileRouterData> {
Expand Down

0 comments on commit 92a07cf

Please sign in to comment.