mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
feat(core): Create Payout Webhook Flow (#4696)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -415,6 +415,60 @@ pub async fn get_mca_from_payment_intent(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "payouts")]
|
||||
pub async fn get_mca_from_payout_attempt(
|
||||
db: &dyn StorageInterface,
|
||||
merchant_account: &domain::MerchantAccount,
|
||||
payout_id_type: webhooks::PayoutIdType,
|
||||
connector_name: &str,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::MerchantConnectorAccount, errors::ApiErrorResponse> {
|
||||
let payout = match payout_id_type {
|
||||
webhooks::PayoutIdType::PayoutAttemptId(payout_attempt_id) => db
|
||||
.find_payout_attempt_by_merchant_id_payout_attempt_id(
|
||||
&merchant_account.merchant_id,
|
||||
&payout_attempt_id,
|
||||
merchant_account.storage_scheme,
|
||||
)
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::PayoutNotFound)?,
|
||||
webhooks::PayoutIdType::ConnectorPayoutId(connector_payout_id) => db
|
||||
.find_payout_attempt_by_merchant_id_connector_payout_id(
|
||||
&merchant_account.merchant_id,
|
||||
&connector_payout_id,
|
||||
merchant_account.storage_scheme,
|
||||
)
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::PayoutNotFound)?,
|
||||
};
|
||||
|
||||
match payout.merchant_connector_id {
|
||||
Some(merchant_connector_id) => db
|
||||
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
|
||||
&merchant_account.merchant_id,
|
||||
&merchant_connector_id,
|
||||
key_store,
|
||||
)
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
|
||||
id: merchant_connector_id,
|
||||
}),
|
||||
None => db
|
||||
.find_merchant_connector_account_by_profile_id_connector_name(
|
||||
&payout.profile_id,
|
||||
connector_name,
|
||||
key_store,
|
||||
)
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::MerchantConnectorAccountNotFound {
|
||||
id: format!(
|
||||
"profile_id {} and connector_name {}",
|
||||
payout.profile_id, connector_name
|
||||
),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_mca_from_object_reference_id(
|
||||
db: &dyn StorageInterface,
|
||||
object_reference_id: webhooks::ObjectReferenceId,
|
||||
@ -481,6 +535,17 @@ pub async fn get_mca_from_object_reference_id(
|
||||
)
|
||||
.await
|
||||
}
|
||||
#[cfg(feature = "payouts")]
|
||||
webhooks::ObjectReferenceId::PayoutId(payout_id_type) => {
|
||||
get_mca_from_payout_attempt(
|
||||
db,
|
||||
merchant_account,
|
||||
payout_id_type,
|
||||
connector_name,
|
||||
key_store,
|
||||
)
|
||||
.await
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user