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,
payload,
|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),
api_locking::LockAction::NotApplicable,

View File

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

View File

@ -180,7 +180,7 @@ pub async fn update_mca(
merchant_id: merchant_id.clone(),
};
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?;
match mca_response {

View File

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

View File

@ -3045,7 +3045,7 @@ pub async fn get_payment_filters(
_profile_id_list: Option<Vec<String>>,
) -> RouterResponse<api::PaymentListFiltersV2> {
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
} else {

View File

@ -990,7 +990,8 @@ pub async fn get_filters_for_refunds(
_profile_id_list: Option<Vec<String>>,
) -> RouterResponse<api_models::refunds::RefundListFilters> {
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
} else {

View File

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

View File

@ -124,7 +124,7 @@ pub async fn retrieve_merchant_account(
state,
&req,
payload,
|state, _, req, _| get_merchant_account(state, req),
|state, _, req, _| get_merchant_account(state, req, None),
auth::auth_type(
&auth::AdminApiAuth,
&auth::JWTAuthMerchantFromRoute {
@ -189,7 +189,7 @@ pub async fn update_merchant_account(
state,
&req,
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::AdminApiAuth,
&auth::JWTAuthMerchantFromRoute {
@ -369,7 +369,7 @@ pub async fn payment_connector_retrieve(
&req,
payload,
|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::AdminApiAuth,
@ -415,7 +415,7 @@ pub async fn payment_connector_list(
state,
&req,
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::AdminApiAuth,
&auth::JWTAuthMerchantFromRoute {
@ -468,7 +468,7 @@ pub async fn payment_connector_update(
&req,
json_payload.into_inner(),
|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::AdminApiAuth,

View File

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

View File

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

View File

@ -20,7 +20,7 @@ pub async fn payment_connector_verify(
state,
&req,
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),
api_locking::LockAction::NotApplicable,
))