diff --git a/crates/drainer/src/health_check.rs b/crates/drainer/src/health_check.rs index 10514108991b..946489513b4d 100644 --- a/crates/drainer/src/health_check.rs +++ b/crates/drainer/src/health_check.rs @@ -170,7 +170,7 @@ impl HealthCheckInterface for Store { logger::debug!("Redis set_key was successful"); redis_conn - .get_key("test_key") + .get_key::<()>("test_key") .await .change_context(HealthCheckRedisError::GetFailed)?; diff --git a/crates/hyperswitch_interfaces/src/errors.rs b/crates/hyperswitch_interfaces/src/errors.rs index e36707af6b05..d8605db24a20 100644 --- a/crates/hyperswitch_interfaces/src/errors.rs +++ b/crates/hyperswitch_interfaces/src/errors.rs @@ -115,6 +115,11 @@ pub enum ConnectorError { InvalidConnectorConfig { config: &'static str }, #[error("Failed to convert amount to required type")] AmountConversionFailed, + #[error("Generic Error")] + GenericError { + error_message: String, + error_object: serde_json::Value, + }, } impl ConnectorError { diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 7d5553bb25c4..2707ef4b6f2e 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -1017,11 +1017,12 @@ impl api::IncomingWebhook for Globalpay { &self, request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - let details = std::str::from_utf8(request.body) - .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - Ok(Box::new(serde_json::from_str(details).change_context( - errors::ConnectorError::WebhookResourceObjectNotFound, - )?)) + Ok(Box::new( + request + .body + .parse_struct::("GlobalpayPaymentsResponse") + .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?, + )) } } diff --git a/crates/router/src/core/errors/utils.rs b/crates/router/src/core/errors/utils.rs index d2812447ed89..63edac5eb040 100644 --- a/crates/router/src/core/errors/utils.rs +++ b/crates/router/src/core/errors/utils.rs @@ -216,7 +216,8 @@ impl ConnectorErrorExt for error_stack::Result | errors::ConnectorError::RequestTimeoutReceived | errors::ConnectorError::CurrencyNotSupported { .. } | errors::ConnectorError::InvalidConnectorConfig { .. } - | errors::ConnectorError::AmountConversionFailed { .. } => { + | errors::ConnectorError::AmountConversionFailed { .. } + | errors::ConnectorError::GenericError { .. } => { err.change_context(errors::ApiErrorResponse::RefundFailed { data: None }) } }) @@ -311,6 +312,7 @@ impl ConnectorErrorExt for error_stack::Result errors::ConnectorError::InSufficientBalanceInPaymentMethod | errors::ConnectorError::RequestTimeoutReceived | errors::ConnectorError::ProcessingStepFailed(None)| + errors::ConnectorError::GenericError {..} | errors::ConnectorError::AmountConversionFailed => errors::ApiErrorResponse::InternalServerError }; err.change_context(error) @@ -402,7 +404,8 @@ impl ConnectorErrorExt for error_stack::Result | errors::ConnectorError::RequestTimeoutReceived | errors::ConnectorError::CurrencyNotSupported { .. } | errors::ConnectorError::ProcessingStepFailed(None) - | errors::ConnectorError::AmountConversionFailed { .. } => { + | errors::ConnectorError::AmountConversionFailed { .. } + | errors::ConnectorError::GenericError { .. } => { logger::error!(%error,"Setup Mandate flow failed"); errors::ApiErrorResponse::PaymentAuthorizationFailed { data: None } } diff --git a/crates/router/src/core/health_check.rs b/crates/router/src/core/health_check.rs index 6092ac8bbb98..83faee677d43 100644 --- a/crates/router/src/core/health_check.rs +++ b/crates/router/src/core/health_check.rs @@ -52,7 +52,7 @@ impl HealthCheckInterface for app::SessionState { logger::debug!("Redis set_key was successful"); redis_conn - .get_key("test_key") + .get_key::<()>("test_key") .await .change_context(errors::HealthCheckRedisError::GetFailed)?; diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index e2593ddd2311..95606aef3172 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -141,7 +141,7 @@ where .to_validate_request()? .validate_request(&req, &merchant_account)?; - tracing::Span::current().record("payment_id", &format!("{}", validate_result.payment_id)); + tracing::Span::current().record("payment_id", format!("{}", validate_result.payment_id)); let operations::GetTrackerResponse { operation, diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index 6b22d5ebf4d9..a597ddfe1540 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -439,71 +439,6 @@ impl api::ConnectorCommon for ConnectorEnum { } } -impl api::ConnectorCommon - for ConnectorIntegrationEnum<'_, T, ResourceCommonData, Req, Resp> -{ - fn id(&self) -> &'static str { - match self { - ConnectorIntegrationEnum::Old(old_integration) => old_integration.id(), - ConnectorIntegrationEnum::New(new_integration) => new_integration.id(), - } - } - - fn get_currency_unit(&self) -> CurrencyUnit { - match self { - ConnectorIntegrationEnum::Old(old_integration) => old_integration.get_currency_unit(), - ConnectorIntegrationEnum::New(new_integration) => new_integration.get_currency_unit(), - } - } - - fn get_auth_header( - &self, - auth_type: &types::ConnectorAuthType, - ) -> CustomResult)>, errors::ConnectorError> { - match self { - ConnectorIntegrationEnum::Old(old_integration) => { - old_integration.get_auth_header(auth_type) - } - ConnectorIntegrationEnum::New(new_integration) => { - new_integration.get_auth_header(auth_type) - } - } - } - - fn common_get_content_type(&self) -> &'static str { - match self { - ConnectorIntegrationEnum::Old(old_integration) => { - old_integration.common_get_content_type() - } - ConnectorIntegrationEnum::New(new_integration) => { - new_integration.common_get_content_type() - } - } - } - - fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { - match self { - ConnectorIntegrationEnum::Old(old_integration) => old_integration.base_url(connectors), - ConnectorIntegrationEnum::New(new_integration) => new_integration.base_url(connectors), - } - } - - fn build_error_response( - &self, - res: types::Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - match self { - ConnectorIntegrationEnum::Old(old_integration) => { - old_integration.build_error_response(res, event_builder) - } - ConnectorIntegrationEnum::New(new_integration) => { - new_integration.build_error_response(res, event_builder) - } - } - } -} - pub trait ConnectorIntegrationInterface: Send + Sync { fn clone_box( &self, diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 550b1c7af140..654c0ff330db 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -90,26 +90,17 @@ pub trait Router {} pub trait Connector: Send + Refund - + RefundV2 + Payment - + PaymentV2 + ConnectorRedirectResponse + IncomingWebhook + ConnectorAccessToken - + ConnectorAccessTokenV2 + Dispute - + DisputeV2 + FileUpload - + FileUploadV2 + ConnectorTransactionId + Payouts - + PayoutsV2 + ConnectorVerifyWebhookSource - + ConnectorVerifyWebhookSourceV2 + FraudCheck - + FraudCheckV2 + ConnectorMandateRevoke - + ConnectorMandateRevokeV2 + ExternalAuthentication + ExternalAuthenticationV2 { @@ -117,27 +108,18 @@ pub trait Connector: impl< T: Refund - + RefundV2 + Payment - + PaymentV2 + ConnectorRedirectResponse + Send + IncomingWebhook + ConnectorAccessToken - + ConnectorAccessTokenV2 + Dispute - + DisputeV2 + FileUpload - + FileUploadV2 + ConnectorTransactionId + Payouts - + PayoutsV2 + ConnectorVerifyWebhookSource - + ConnectorVerifyWebhookSourceV2 + FraudCheck - + FraudCheckV2 + ConnectorMandateRevoke - + ConnectorMandateRevokeV2 + ExternalAuthentication + ExternalAuthenticationV2, > Connector for T diff --git a/crates/router_env/tests/env.rs b/crates/router_env/tests/env.rs index 5251d2ab8ef4..8188863aff56 100644 --- a/crates/router_env/tests/env.rs +++ b/crates/router_env/tests/env.rs @@ -23,7 +23,7 @@ async fn basic() -> Result<(), Box> { #[cfg(feature = "vergen")] #[tokio::test] -async fn env_macro() -> Result<(), Box> { +async fn env_macro() { println!("version : {:?}", env::version!()); println!("build : {:?}", env::build!()); println!("commit : {:?}", env::commit!()); @@ -33,6 +33,4 @@ async fn env_macro() -> Result<(), Box> { assert!(!env::build!().is_empty()); assert!(!env::commit!().is_empty()); // assert!(env::platform!().len() > 0); - - Ok(()) } diff --git a/crates/storage_impl/src/redis/pub_sub.rs b/crates/storage_impl/src/redis/pub_sub.rs index 89877f7e8dd9..b03dadb1d08c 100644 --- a/crates/storage_impl/src/redis/pub_sub.rs +++ b/crates/storage_impl/src/redis/pub_sub.rs @@ -30,7 +30,7 @@ impl PubSubInterface for std::sync::Arc { self.subscriber.manage_subscriptions(); self.subscriber - .subscribe(channel) + .subscribe::<(), &str>(channel) .await .change_context(redis_errors::RedisError::SubscribeError)?;