Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(user): add dashboard merchant details API for dashboard bootstrap (#12160)
Kanika Bansal60fa789eb82c
diff --git a/crates/api_models/src/events/user.rs b/crates/api_models/src/events/user.rsindex 0f833aadd3..381c2c6997 100644--- a/crates/api_models/src/events/user.rs+++ b/crates/api_models/src/events/user.rs@@ -25,7 +25,8 @@ use crate::user::{SwitchOrganizationRequest, SwitchProfileRequest, TokenResponse, TwoFactorAuthStatusResponse,TwoFactorStatus, UpdateUserAccountDetailsRequest, UpdateUserAuthenticationMethodRequest,UserFromEmailRequest, UserMerchantAccountResponse, UserMerchantCreate,- UserOrgMerchantCreateRequest, VerifyEmailRequest, VerifyRecoveryCodeRequest, VerifyTotpRequest,+ UserMerchantDetailsResponse, UserOrgMerchantCreateRequest, VerifyEmailRequest,+ VerifyRecoveryCodeRequest, VerifyTotpRequest,};common_utils::impl_api_event_type!(@@ -47,6 +48,7 @@ common_utils::impl_api_event_type!(PlatformAccountCreateResponse,UserOrgMerchantCreateRequest,UserMerchantAccountResponse,+ UserMerchantDetailsResponse,UserMerchantCreate,AuthorizeResponse,ConnectAccountRequest,diff --git a/crates/api_models/src/user.rs b/crates/api_models/src/user.rsindex c0354232e6..2766b03e4a 100644--- a/crates/api_models/src/user.rs+++ b/crates/api_models/src/user.rs@@ -468,6 +468,12 @@ pub struct ListOrgsForUserResponse {pub org_type: common_enums::OrganizationType,}+#[derive(Clone, Debug, serde::Serialize)]+pub struct UserMerchantDetailsResponse {+ pub product_type: Option<common_enums::MerchantProductType>,+ pub merchant_account_type: common_enums::MerchantAccountType,+}+#[derive(Debug, serde::Serialize)]pub struct UserMerchantAccountResponse {pub merchant_id: id_type::MerchantId,diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rsindex 5148cbc9d8..ef980bb66b 100644--- a/crates/router/src/core/user.rs+++ b/crates/router/src/core/user.rs@@ -5,7 +5,7 @@ use std::{use api_models::{payments::RedirectionResponse,- user::{self as user_api, InviteMultipleUserResponse, NameIdUnit},+ user::{self as user_api, InviteMultipleUserResponse, NameIdUnit, UserMerchantDetailsResponse},};use common_enums::{connector_enums, EntityType, MerchantProductType, UserAuthType};use common_utils::{@@ -427,6 +427,31 @@ pub async fn connect_account(}}+pub async fn get_user_merchant_details(+ state: SessionState,+ user_from_token: auth::UserFromToken,+) -> UserResponse<UserMerchantDetailsResponse> {+ let key_store = state+ .store+ .get_merchant_key_store_by_merchant_id(+ &user_from_token.merchant_id,+ &state.store.get_master_key().to_vec().into(),+ )+ .await+ .change_context(UserErrors::InternalServerError)?;++ let merchant_account = state+ .store+ .find_merchant_account_by_merchant_id(&user_from_token.merchant_id, &key_store)+ .await+ .change_context(UserErrors::InternalServerError)?;++ Ok(ApplicationResponse::Json(UserMerchantDetailsResponse {+ product_type: merchant_account.product_type,+ merchant_account_type: merchant_account.merchant_account_type,+ }))+}+pub async fn signout(state: SessionState,user_from_token: auth::UserIdFromAuth,diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 0e0f77b6b5..d41453b884 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -2764,6 +2764,10 @@ impl User {web::resource("/create-merchant").route(web::post().to(user::user_merchant_account_create)),);+ route = route.service(+ web::resource("/merchant-details")+ .route(web::get().to(user::get_user_merchant_details)),+ );route = route.service(web::scope("/list").service(@@ -2823,6 +2827,10 @@ impl User {web::resource("/create_merchant").route(web::post().to(user::user_merchant_account_create)),)+ .service(+ web::resource("/merchant_details")+ .route(web::get().to(user::get_user_merchant_details)),+ )// TODO: To be deprecated.service(web::resource("/permission_info")diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rsindex 679e93dbac..21094ce3a6 100644--- a/crates/router/src/routes/lock_utils.rs+++ b/crates/router/src/routes/lock_utils.rs@@ -305,6 +305,7 @@ impl From<Flow> for ApiIdentifier {| Flow::OidcToken| Flow::ListOrgForUser| Flow::ListMerchantsForUserInOrg+ | Flow::GetUserMerchantDetails| Flow::ListProfileForUserInOrgAndMerchant| Flow::ListInvitationsForUser| Flow::AuthSelectdiff --git a/crates/router/src/routes/user.rs b/crates/router/src/routes/user.rsindex 4e7791e1aa..0554d9de49 100644--- a/crates/router/src/routes/user.rs+++ b/crates/router/src/routes/user.rs@@ -1260,3 +1260,24 @@ pub async fn authorize_token()).await}++/// Retrieve merchant details for the user (product_type, merchant_account_type).+pub async fn get_user_merchant_details(+ state: web::Data<AppState>,+ req: HttpRequest,+) -> HttpResponse {+ let flow = Flow::GetUserMerchantDetails;+ Box::pin(api::server_wrap(+ flow,+ state.clone(),+ &req,+ (),+ |state, user, _, _| user_core::get_user_merchant_details(state, user),+ &auth::DashboardNoPermissionAuth {+ allow_connected: true,+ allow_platform: true,+ },+ api_locking::LockAction::NotApplicable,+ ))+ .await+}diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rsindex d08c7e4c83..3c56116f45 100644--- a/crates/router_env/src/logger/types.rs+++ b/crates/router_env/src/logger/types.rs@@ -571,6 +571,8 @@ pub enum Flow {ListOrgForUser,/// List Merchants for user in orgListMerchantsForUserInOrg,+ /// Get merchant account details for the user (product_type, merchant_account_type)+ GetUserMerchantDetails,/// List Profile for user in org and merchantListProfileForUserInOrgAndMerchant,/// List Users in Org