mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
refactor(core): Add additional parameters in AppState and refactor AppState references (#2123)
Co-authored-by: Kritik Modi <kritik.modi@juspay.in> Co-authored-by: Kritik Modi <61862301+kritikmodi@users.noreply.github.com> Co-authored-by: Nitesh Balla <nitesh.balla@juspay.in>
This commit is contained in:
committed by
GitHub
parent
b39369ced9
commit
a0a8ef27b3
@ -41,9 +41,10 @@ pub fn create_merchant_publishable_key() -> String {
|
||||
}
|
||||
|
||||
pub async fn create_merchant_account(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
req: api::MerchantAccountCreate,
|
||||
) -> RouterResponse<api::MerchantAccountResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let master_key = db.get_master_key();
|
||||
|
||||
let key = services::generate_aes256_key()
|
||||
@ -227,9 +228,10 @@ pub async fn create_merchant_account(
|
||||
}
|
||||
|
||||
pub async fn get_merchant_account(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
req: api::MerchantId,
|
||||
) -> RouterResponse<api::MerchantAccountResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
.get_merchant_key_store_by_merchant_id(
|
||||
&req.merchant_id,
|
||||
@ -312,10 +314,11 @@ pub async fn create_business_profile_from_business_labels(
|
||||
Ok(())
|
||||
}
|
||||
pub async fn merchant_account_update(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: &String,
|
||||
req: api::MerchantAccountUpdate,
|
||||
) -> RouterResponse<api::MerchantAccountResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
.get_merchant_key_store_by_merchant_id(
|
||||
&req.merchant_id,
|
||||
@ -459,9 +462,10 @@ pub async fn merchant_account_update(
|
||||
}
|
||||
|
||||
pub async fn merchant_account_delete(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: String,
|
||||
) -> RouterResponse<api::MerchantAccountDeleteResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let is_deleted = db
|
||||
.delete_merchant_account_by_merchant_id(&merchant_id)
|
||||
.await
|
||||
@ -547,14 +551,14 @@ fn validate_certificate_in_mca_metadata(
|
||||
}
|
||||
|
||||
pub async fn create_payment_connector(
|
||||
state: &AppState,
|
||||
state: AppState,
|
||||
req: api::MerchantConnectorCreate,
|
||||
merchant_id: &String,
|
||||
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {
|
||||
let store = state.store.as_ref();
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
validate_dummy_connector_enabled(state, &req.connector_name).await?;
|
||||
let key_store = state
|
||||
.store
|
||||
validate_dummy_connector_enabled(&state, &req.connector_name).await?;
|
||||
let key_store = store
|
||||
.get_merchant_key_store_by_merchant_id(
|
||||
merchant_id,
|
||||
&state.store.get_master_key().to_vec().into(),
|
||||
@ -704,10 +708,11 @@ pub async fn create_payment_connector(
|
||||
}
|
||||
|
||||
pub async fn retrieve_payment_connector(
|
||||
store: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: String,
|
||||
merchant_connector_id: String,
|
||||
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {
|
||||
let store = state.store.as_ref();
|
||||
let key_store = store
|
||||
.get_merchant_key_store_by_merchant_id(
|
||||
&merchant_id,
|
||||
@ -736,9 +741,10 @@ pub async fn retrieve_payment_connector(
|
||||
}
|
||||
|
||||
pub async fn list_payment_connectors(
|
||||
store: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: String,
|
||||
) -> RouterResponse<Vec<api_models::admin::MerchantConnectorResponse>> {
|
||||
let store = state.store.as_ref();
|
||||
let key_store = store
|
||||
.get_merchant_key_store_by_merchant_id(
|
||||
&merchant_id,
|
||||
@ -772,11 +778,12 @@ pub async fn list_payment_connectors(
|
||||
}
|
||||
|
||||
pub async fn update_payment_connector(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: &str,
|
||||
merchant_connector_id: &str,
|
||||
req: api_models::admin::MerchantConnectorUpdate,
|
||||
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
.get_merchant_key_store_by_merchant_id(merchant_id, &db.get_master_key().to_vec().into())
|
||||
.await
|
||||
@ -855,10 +862,11 @@ pub async fn update_payment_connector(
|
||||
}
|
||||
|
||||
pub async fn delete_payment_connector(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: String,
|
||||
merchant_connector_id: String,
|
||||
) -> RouterResponse<api::MerchantConnectorDeleteResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
.get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
|
||||
.await
|
||||
@ -899,10 +907,11 @@ pub async fn delete_payment_connector(
|
||||
}
|
||||
|
||||
pub async fn kv_for_merchant(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: String,
|
||||
enable: bool,
|
||||
) -> RouterResponse<api_models::admin::ToggleKVResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
.get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
|
||||
.await
|
||||
@ -958,9 +967,10 @@ pub async fn kv_for_merchant(
|
||||
}
|
||||
|
||||
pub async fn check_merchant_account_kv_status(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: String,
|
||||
) -> RouterResponse<api_models::admin::ToggleKVResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
.get_merchant_key_store_by_merchant_id(&merchant_id, &db.get_master_key().to_vec().into())
|
||||
.await
|
||||
@ -1028,10 +1038,11 @@ pub async fn create_and_insert_business_profile(
|
||||
}
|
||||
|
||||
pub async fn create_business_profile(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
request: api::BusinessProfileCreate,
|
||||
merchant_id: &str,
|
||||
) -> RouterResponse<api_models::admin::BusinessProfileResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let key_store = db
|
||||
.get_merchant_key_store_by_merchant_id(merchant_id, &db.get_master_key().to_vec().into())
|
||||
.await
|
||||
@ -1071,9 +1082,10 @@ pub async fn create_business_profile(
|
||||
}
|
||||
|
||||
pub async fn list_business_profile(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
merchant_id: String,
|
||||
) -> RouterResponse<Vec<api_models::admin::BusinessProfileResponse>> {
|
||||
let db = state.store.as_ref();
|
||||
let business_profiles = db
|
||||
.list_business_profile_by_merchant_id(&merchant_id)
|
||||
.await
|
||||
@ -1090,9 +1102,10 @@ pub async fn list_business_profile(
|
||||
}
|
||||
|
||||
pub async fn retrieve_business_profile(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
profile_id: String,
|
||||
) -> RouterResponse<api_models::admin::BusinessProfileResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let business_profile = db
|
||||
.find_business_profile_by_profile_id(&profile_id)
|
||||
.await
|
||||
@ -1107,10 +1120,11 @@ pub async fn retrieve_business_profile(
|
||||
}
|
||||
|
||||
pub async fn delete_business_profile(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
profile_id: String,
|
||||
merchant_id: &str,
|
||||
) -> RouterResponse<bool> {
|
||||
let db = state.store.as_ref();
|
||||
let delete_result = db
|
||||
.delete_business_profile_by_profile_id_merchant_id(&profile_id, merchant_id)
|
||||
.await
|
||||
@ -1122,11 +1136,12 @@ pub async fn delete_business_profile(
|
||||
}
|
||||
|
||||
pub async fn update_business_profile(
|
||||
db: &dyn StorageInterface,
|
||||
state: AppState,
|
||||
profile_id: &str,
|
||||
merchant_id: &str,
|
||||
request: api::BusinessProfileUpdate,
|
||||
) -> RouterResponse<api::BusinessProfileResponse> {
|
||||
let db = state.store.as_ref();
|
||||
let business_profile = db
|
||||
.find_business_profile_by_profile_id(profile_id)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user