feat(core): accept profile_id in merchant_account, connectors and customers core functions (#5505)

This commit is contained in:
Hrithikesh
2024-08-05 17:08:29 +05:30
committed by GitHub
parent 53b5551df7
commit a3e01bb4ae
11 changed files with 29 additions and 13 deletions

View File

@ -85,7 +85,7 @@ pub async fn customer_retrieve(
&req, &req,
payload, payload,
|state, auth, req, _| { |state, auth, req, _| {
customers::retrieve_customer(state, auth.merchant_account, auth.key_store, req) customers::retrieve_customer(state, auth.merchant_account, None, auth.key_store, req)
}, },
&auth::HeaderAuth(auth::ApiKeyAuth), &auth::HeaderAuth(auth::ApiKeyAuth),
api_locking::LockAction::NotApplicable, api_locking::LockAction::NotApplicable,

View File

@ -737,6 +737,7 @@ pub async fn list_merchant_account(
pub async fn get_merchant_account( pub async fn get_merchant_account(
state: SessionState, state: SessionState,
req: api::MerchantId, req: api::MerchantId,
_profile_id: Option<String>,
) -> RouterResponse<api::MerchantAccountResponse> { ) -> RouterResponse<api::MerchantAccountResponse> {
let db = state.store.as_ref(); let db = state.store.as_ref();
let key_manager_state = &(&state).into(); let key_manager_state = &(&state).into();
@ -904,6 +905,7 @@ pub async fn update_business_profile_cascade(
pub async fn merchant_account_update( pub async fn merchant_account_update(
state: SessionState, state: SessionState,
merchant_id: &id_type::MerchantId, merchant_id: &id_type::MerchantId,
_profile_id: Option<String>,
req: api::MerchantAccountUpdate, req: api::MerchantAccountUpdate,
) -> RouterResponse<api::MerchantAccountResponse> { ) -> RouterResponse<api::MerchantAccountResponse> {
let db = state.store.as_ref(); let db = state.store.as_ref();
@ -2759,6 +2761,7 @@ async fn validate_pm_auth(
pub async fn retrieve_payment_connector( pub async fn retrieve_payment_connector(
state: SessionState, state: SessionState,
merchant_id: id_type::MerchantId, merchant_id: id_type::MerchantId,
_profile_id: Option<String>,
merchant_connector_id: String, merchant_connector_id: String,
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> { ) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {
let store = state.store.as_ref(); let store = state.store.as_ref();
@ -2807,6 +2810,7 @@ pub async fn retrieve_payment_connector(
pub async fn list_payment_connectors( pub async fn list_payment_connectors(
state: SessionState, state: SessionState,
merchant_id: id_type::MerchantId, merchant_id: id_type::MerchantId,
_profile_id_list: Option<Vec<String>>,
) -> RouterResponse<Vec<api_models::admin::MerchantConnectorListResponse>> { ) -> RouterResponse<Vec<api_models::admin::MerchantConnectorListResponse>> {
let store = state.store.as_ref(); let store = state.store.as_ref();
let key_manager_state = &(&state).into(); let key_manager_state = &(&state).into();
@ -2847,6 +2851,7 @@ pub async fn list_payment_connectors(
pub async fn update_payment_connector( pub async fn update_payment_connector(
state: SessionState, state: SessionState,
merchant_id: &id_type::MerchantId, merchant_id: &id_type::MerchantId,
_profile_id: Option<String>,
merchant_connector_id: &str, merchant_connector_id: &str,
req: api_models::admin::MerchantConnectorUpdate, req: api_models::admin::MerchantConnectorUpdate,
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> { ) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {

View File

@ -180,7 +180,7 @@ pub async fn update_mca(
merchant_id: merchant_id.clone(), merchant_id: merchant_id.clone(),
}; };
let mca_response = let mca_response =
admin::update_payment_connector(state.clone(), &merchant_id, &connector_id, request) admin::update_payment_connector(state.clone(), &merchant_id, None, &connector_id, request)
.await?; .await?;
match mca_response { match mca_response {

View File

@ -366,6 +366,7 @@ impl<'a> MerchantReferenceIdForCustomer<'a> {
pub async fn retrieve_customer( pub async fn retrieve_customer(
state: SessionState, state: SessionState,
merchant_account: domain::MerchantAccount, merchant_account: domain::MerchantAccount,
_profile_id: Option<String>,
key_store: domain::MerchantKeyStore, key_store: domain::MerchantKeyStore,
req: customers::CustomerId, req: customers::CustomerId,
) -> errors::CustomerResponse<customers::CustomerResponse> { ) -> errors::CustomerResponse<customers::CustomerResponse> {
@ -399,6 +400,7 @@ pub async fn retrieve_customer(
pub async fn list_customers( pub async fn list_customers(
state: SessionState, state: SessionState,
merchant_id: id_type::MerchantId, merchant_id: id_type::MerchantId,
_profile_id_list: Option<Vec<String>>,
key_store: domain::MerchantKeyStore, key_store: domain::MerchantKeyStore,
) -> errors::CustomerResponse<Vec<customers::CustomerResponse>> { ) -> errors::CustomerResponse<Vec<customers::CustomerResponse>> {
let db = state.store.as_ref(); let db = state.store.as_ref();

View File

@ -3045,7 +3045,7 @@ pub async fn get_payment_filters(
_profile_id_list: Option<Vec<String>>, _profile_id_list: Option<Vec<String>>,
) -> RouterResponse<api::PaymentListFiltersV2> { ) -> RouterResponse<api::PaymentListFiltersV2> {
let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) = let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =
super::admin::list_payment_connectors(state, merchant.get_id().to_owned()).await? super::admin::list_payment_connectors(state, merchant.get_id().to_owned(), None).await?
{ {
data data
} else { } else {

View File

@ -990,7 +990,8 @@ pub async fn get_filters_for_refunds(
_profile_id_list: Option<Vec<String>>, _profile_id_list: Option<Vec<String>>,
) -> RouterResponse<api_models::refunds::RefundListFilters> { ) -> RouterResponse<api_models::refunds::RefundListFilters> {
let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) = let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =
super::admin::list_payment_connectors(state, merchant_account.get_id().to_owned()).await? super::admin::list_payment_connectors(state, merchant_account.get_id().to_owned(), None)
.await?
{ {
data data
} else { } else {

View File

@ -19,6 +19,7 @@ use crate::{
pub async fn verify_connector_credentials( pub async fn verify_connector_credentials(
state: SessionState, state: SessionState,
req: VerifyConnectorRequest, req: VerifyConnectorRequest,
_profile_id: Option<String>,
) -> errors::RouterResponse<()> { ) -> errors::RouterResponse<()> {
let boxed_connector = api::ConnectorData::get_connector_by_name( let boxed_connector = api::ConnectorData::get_connector_by_name(
&state.conf.connectors, &state.conf.connectors,

View File

@ -124,7 +124,7 @@ pub async fn retrieve_merchant_account(
state, state,
&req, &req,
payload, payload,
|state, _, req, _| get_merchant_account(state, req), |state, _, req, _| get_merchant_account(state, req, None),
auth::auth_type( auth::auth_type(
&auth::AdminApiAuth, &auth::AdminApiAuth,
&auth::JWTAuthMerchantFromRoute { &auth::JWTAuthMerchantFromRoute {
@ -189,7 +189,7 @@ pub async fn update_merchant_account(
state, state,
&req, &req,
json_payload.into_inner(), json_payload.into_inner(),
|state, _, req, _| merchant_account_update(state, &merchant_id, req), |state, _, req, _| merchant_account_update(state, &merchant_id, None, req),
auth::auth_type( auth::auth_type(
&auth::AdminApiAuth, &auth::AdminApiAuth,
&auth::JWTAuthMerchantFromRoute { &auth::JWTAuthMerchantFromRoute {
@ -369,7 +369,7 @@ pub async fn payment_connector_retrieve(
&req, &req,
payload, payload,
|state, _, req, _| { |state, _, req, _| {
retrieve_payment_connector(state, req.merchant_id, req.merchant_connector_id) retrieve_payment_connector(state, req.merchant_id, None, req.merchant_connector_id)
}, },
auth::auth_type( auth::auth_type(
&auth::AdminApiAuth, &auth::AdminApiAuth,
@ -415,7 +415,7 @@ pub async fn payment_connector_list(
state, state,
&req, &req,
merchant_id.to_owned(), merchant_id.to_owned(),
|state, _, merchant_id, _| list_payment_connectors(state, merchant_id), |state, _, merchant_id, _| list_payment_connectors(state, merchant_id, None),
auth::auth_type( auth::auth_type(
&auth::AdminApiAuth, &auth::AdminApiAuth,
&auth::JWTAuthMerchantFromRoute { &auth::JWTAuthMerchantFromRoute {
@ -468,7 +468,7 @@ pub async fn payment_connector_update(
&req, &req,
json_payload.into_inner(), json_payload.into_inner(),
|state, _, req, _| { |state, _, req, _| {
update_payment_connector(state, &merchant_id, &merchant_connector_id, req) update_payment_connector(state, &merchant_id, None, &merchant_connector_id, req)
}, },
auth::auth_type( auth::auth_type(
&auth::AdminApiAuth, &auth::AdminApiAuth,

View File

@ -63,7 +63,9 @@ pub async fn customers_retrieve(
state, state,
&req, &req,
payload, payload,
|state, auth, req, _| retrieve_customer(state, auth.merchant_account, auth.key_store, req), |state, auth, req, _| {
retrieve_customer(state, auth.merchant_account, None, auth.key_store, req)
},
&*auth, &*auth,
api_locking::LockAction::NotApplicable, api_locking::LockAction::NotApplicable,
)) ))
@ -84,6 +86,7 @@ pub async fn customers_list(state: web::Data<AppState>, req: HttpRequest) -> Htt
list_customers( list_customers(
state, state,
auth.merchant_account.get_id().to_owned(), auth.merchant_account.get_id().to_owned(),
None,
auth.key_store, auth.key_store,
) )
}, },

View File

@ -130,6 +130,7 @@ pub async fn payments_create(
state, state,
req_state, req_state,
auth.merchant_account, auth.merchant_account,
None,
auth.key_store, auth.key_store,
HeaderPayload::default(), HeaderPayload::default(),
req, req,
@ -422,6 +423,7 @@ pub async fn payments_update(
state, state,
req_state, req_state,
auth.merchant_account, auth.merchant_account,
None,
auth.key_store, auth.key_store,
HeaderPayload::default(), HeaderPayload::default(),
req, req,
@ -500,6 +502,7 @@ pub async fn payments_confirm(
state, state,
req_state, req_state,
auth.merchant_account, auth.merchant_account,
None,
auth.key_store, auth.key_store,
header_payload.clone(), header_payload.clone(),
req, req,
@ -1176,6 +1179,7 @@ async fn authorize_verify_select<Op>(
state: app::SessionState, state: app::SessionState,
req_state: ReqState, req_state: ReqState,
merchant_account: domain::MerchantAccount, merchant_account: domain::MerchantAccount,
profile_id: Option<String>,
key_store: domain::MerchantKeyStore, key_store: domain::MerchantKeyStore,
header_payload: HeaderPayload, header_payload: HeaderPayload,
req: api_models::payments::PaymentsRequest, req: api_models::payments::PaymentsRequest,
@ -1211,7 +1215,7 @@ where
state, state,
req_state, req_state,
merchant_account, merchant_account,
None, profile_id,
key_store, key_store,
operation, operation,
req, req,
@ -1232,7 +1236,7 @@ where
state, state,
req_state, req_state,
merchant_account, merchant_account,
None, profile_id,
key_store, key_store,
operation, operation,
req, req,

View File

@ -20,7 +20,7 @@ pub async fn payment_connector_verify(
state, state,
&req, &req,
json_payload.into_inner(), json_payload.into_inner(),
|state, _: (), req, _| verify_connector::verify_connector_credentials(state, req), |state, _: (), req, _| verify_connector::verify_connector_credentials(state, req, None),
&auth::JWTAuth(Permission::MerchantConnectorAccountWrite), &auth::JWTAuth(Permission::MerchantConnectorAccountWrite),
api_locking::LockAction::NotApplicable, api_locking::LockAction::NotApplicable,
)) ))