mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(analytics): refactor and introduce analytics APIs to accommodate OrgLevel, MerchantLevel and ProfileLevel authentication (#5729)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sampras Lopes <sampras.lopes@juspay.in>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
use common_utils::errors::CustomResult;
|
||||
use api_models::payments::PaymentIdType;
|
||||
use common_utils::{errors::CustomResult, id_type::PaymentId};
|
||||
use error_stack::{Report, ResultExt};
|
||||
|
||||
use crate::{
|
||||
@ -8,8 +9,9 @@ use crate::{
|
||||
},
|
||||
logger,
|
||||
routes::SessionState,
|
||||
types,
|
||||
types::storage,
|
||||
services::authentication::AuthenticationData,
|
||||
types::{self, storage},
|
||||
utils::find_payment_intent_from_payment_id_type,
|
||||
};
|
||||
|
||||
pub async fn check_existence_and_add_domain_to_db(
|
||||
@ -136,3 +138,19 @@ pub fn log_applepay_verification_response_if_error(
|
||||
.map_err(|error| logger::error!(applepay_domain_verification_error= ?error))
|
||||
});
|
||||
}
|
||||
pub async fn check_if_profile_id_is_present_in_payment_intent(
|
||||
payment_id: PaymentId,
|
||||
state: &SessionState,
|
||||
auth_data: &AuthenticationData,
|
||||
) -> CustomResult<(), errors::ApiErrorResponse> {
|
||||
let payment_id_type = PaymentIdType::PaymentIntentId(payment_id);
|
||||
let payment_intent = find_payment_intent_from_payment_id_type(
|
||||
state,
|
||||
payment_id_type,
|
||||
&auth_data.merchant_account,
|
||||
&auth_data.key_store,
|
||||
)
|
||||
.await
|
||||
.change_context(errors::ApiErrorResponse::Unauthorized)?;
|
||||
utils::validate_profile_id_from_auth_layer(auth_data.profile_id.clone(), &payment_intent)
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ impl TryFrom<UserCompanyName> for MerchantName {
|
||||
type Error = error_stack::Report<UserErrors>;
|
||||
|
||||
fn try_from(company_name: UserCompanyName) -> Result<Self, Self::Error> {
|
||||
Self::new(company_name.get_secret()).change_context(UserErrors::CompanyNameParsingError)
|
||||
Self::try_new(company_name.get_secret()).change_context(UserErrors::CompanyNameParsingError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user