feat(router): dynamically toggle KV for merchant and refactoring around it (#79)

This commit is contained in:
ItsMeShashank
2022-12-09 13:10:44 +05:30
committed by GitHub
parent 5b470bf8f5
commit f76f3e2f54
38 changed files with 980 additions and 482 deletions

View File

@ -274,7 +274,7 @@ pub async fn create_payment_connector(
req: api::PaymentConnectorCreate,
merchant_id: &String,
) -> RouterResponse<api::PaymentConnectorCreate> {
store
let _merchant_account = store
.find_merchant_account_by_merchant_id(merchant_id)
.await
.map_err(|error| {
@ -332,6 +332,13 @@ pub async fn retrieve_payment_connector(
merchant_id: String,
merchant_connector_id: i32,
) -> RouterResponse<api::PaymentConnectorCreate> {
let _merchant_account = store
.find_merchant_account_by_merchant_id(&merchant_id)
.await
.map_err(|error| {
error.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
})?;
let mca = store
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&merchant_id,
@ -366,11 +373,13 @@ pub async fn update_payment_connector(
merchant_connector_id: i32,
req: api::PaymentConnectorCreate,
) -> RouterResponse<api::PaymentConnectorCreate> {
db.find_merchant_account_by_merchant_id(merchant_id)
let _merchant_account = db
.find_merchant_account_by_merchant_id(merchant_id)
.await
.map_err(|error| {
error.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
})?;
let mca = db
.find_by_merchant_connector_account_merchant_id_merchant_connector_id(
merchant_id,
@ -430,6 +439,13 @@ pub async fn delete_payment_connector(
merchant_id: String,
merchant_connector_id: i32,
) -> RouterResponse<api::DeleteMcaResponse> {
let _merchant_account = db
.find_merchant_account_by_merchant_id(&merchant_id)
.await
.map_err(|error| {
error.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
})?;
let is_deleted = db
.delete_merchant_connector_account_by_merchant_id_merchant_connector_id(
&merchant_id,