fix(router): merchant account delete does not delete the merchant_key_store (#2367)

This commit is contained in:
Hudson C. Dalprá
2023-10-04 07:05:30 +13:00
committed by GitHub
parent 9a0e637b0f
commit 35f7ce0f4d
3 changed files with 76 additions and 2 deletions

View File

@ -465,11 +465,19 @@ pub async fn merchant_account_delete(
state: AppState,
merchant_id: String,
) -> RouterResponse<api::MerchantAccountDeleteResponse> {
let mut is_deleted = false;
let db = state.store.as_ref();
let is_deleted = db
let is_merchant_account_deleted = db
.delete_merchant_account_by_merchant_id(&merchant_id)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
if is_merchant_account_deleted {
let is_merchant_key_store_deleted = db
.delete_merchant_key_store_by_merchant_id(&merchant_id)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
is_deleted = is_merchant_account_deleted && is_merchant_key_store_deleted;
}
let response = api::MerchantAccountDeleteResponse {
merchant_id,
deleted: is_deleted,