feat(multitenancy): add support for multitenancy and handle the same in router, producer, consumer, drainer and analytics (#4630)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
Jagan
2024-06-03 17:57:30 +05:30
committed by GitHub
parent a1788b8da9
commit 15d6c3e846
188 changed files with 2260 additions and 1414 deletions

View File

@ -155,7 +155,7 @@ pub async fn customer_delete(
state.into_inner(),
&req,
payload,
|state, auth, req, _| {
|state, auth: auth::AuthenticationData, req, _| {
customers::delete_customer(state, auth.merchant_account, req, auth.key_store)
},
&auth::ApiKeyAuth,

View File

@ -264,6 +264,8 @@ pub enum StripeErrorCode {
PaymentMethodDeleteFailed,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "", message = "Extended card info does not exist")]
ExtendedCardInfoNotFound,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "IR_28", message = "Invalid tenant")]
InvalidTenant,
// [#216]: https://github.com/juspay/hyperswitch/issues/216
// Implement the remaining stripe error codes
@ -646,6 +648,8 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
Self::InvalidWalletToken { wallet_name }
}
errors::ApiErrorResponse::ExtendedCardInfoNotFound => Self::ExtendedCardInfoNotFound,
errors::ApiErrorResponse::InvalidTenant { tenant_id: _ }
| errors::ApiErrorResponse::MissingTenantId => Self::InvalidTenant,
}
}
}
@ -725,7 +729,8 @@ impl actix_web::ResponseError for StripeErrorCode {
| Self::InternalServerError
| Self::MandateActive
| Self::CustomerRedacted
| Self::WebhookProcessingError => StatusCode::INTERNAL_SERVER_ERROR,
| Self::WebhookProcessingError
| Self::InvalidTenant => StatusCode::INTERNAL_SERVER_ERROR,
Self::ReturnUrlUnavailable => StatusCode::SERVICE_UNAVAILABLE,
Self::ExternalConnectorError { status_code, .. } => {
StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)

View File

@ -10,7 +10,7 @@ use crate::{
events::api_logs::ApiEventMetric,
routes::{
app::{AppStateInfo, ReqState},
metrics, AppState,
metrics, AppState, SessionState,
},
services::{self, api, authentication as auth, logger},
};
@ -22,11 +22,11 @@ pub async fn compatibility_api_wrap<'a, 'b, U, T, Q, F, Fut, S, E, E2>(
request: &'a HttpRequest,
payload: T,
func: F,
api_authentication: &dyn auth::AuthenticateAndFetch<U, AppState>,
api_authentication: &dyn auth::AuthenticateAndFetch<U, SessionState>,
lock_action: api_locking::LockAction,
) -> HttpResponse
where
F: Fn(AppState, U, T, ReqState) -> Fut,
F: Fn(SessionState, U, T, ReqState) -> Fut,
Fut: Future<Output = CustomResult<api::ApplicationResponse<Q>, E2>>,
E2: ErrorSwitch<E> + std::error::Error + Send + Sync + 'static,
Q: Serialize + std::fmt::Debug + 'a + ApiEventMetric,
@ -49,6 +49,7 @@ where
api::server_wrap_util(
&flow,
state.clone().into(),
request.headers(),
req_state,
request,
payload,