mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
deps(api_models): put the errors module behind a feature flag (#815)
This commit is contained in:
@ -4,14 +4,19 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
[features]
|
||||||
|
errors = [
|
||||||
|
"dep:actix-web",
|
||||||
|
"dep:reqwest",
|
||||||
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.3.1"
|
actix-web = { version = "4.3.1", optional = true }
|
||||||
error-stack = "0.3.1"
|
error-stack = "0.3.1"
|
||||||
frunk = "0.4.1"
|
frunk = "0.4.1"
|
||||||
frunk_core = "0.4.1"
|
frunk_core = "0.4.1"
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
reqwest = "0.11.14"
|
reqwest = { version = "0.11.14", optional = true }
|
||||||
serde = { version = "1.0.155", features = ["derive"] }
|
serde = { version = "1.0.155", features = ["derive"] }
|
||||||
serde_json = "1.0.94"
|
serde_json = "1.0.94"
|
||||||
strum = { version = "0.24.1", features = ["derive"] }
|
strum = { version = "0.24.1", features = ["derive"] }
|
||||||
|
|||||||
@ -6,6 +6,7 @@ pub mod cards_info;
|
|||||||
pub mod customers;
|
pub mod customers;
|
||||||
pub mod disputes;
|
pub mod disputes;
|
||||||
pub mod enums;
|
pub mod enums;
|
||||||
|
#[cfg(feature = "errors")]
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod files;
|
pub mod files;
|
||||||
pub mod mandates;
|
pub mod mandates;
|
||||||
|
|||||||
@ -50,14 +50,6 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct IncomingWebhookRequestDetails<'a> {
|
|
||||||
pub method: actix_web::http::Method,
|
|
||||||
pub headers: &'a actix_web::http::header::HeaderMap,
|
|
||||||
pub body: &'a [u8],
|
|
||||||
pub query_params: String,
|
|
||||||
pub query_params_json: &'a [u8],
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type MerchantWebhookConfig = std::collections::HashSet<IncomingWebhookEvent>;
|
pub type MerchantWebhookConfig = std::collections::HashSet<IncomingWebhookEvent>;
|
||||||
|
|
||||||
pub enum RefundIdType {
|
pub enum RefundIdType {
|
||||||
|
|||||||
@ -79,7 +79,7 @@ utoipa-swagger-ui = { version = "3.1.0", features = ["actix-web"] }
|
|||||||
uuid = { version = "1.3.0", features = ["serde", "v4"] }
|
uuid = { version = "1.3.0", features = ["serde", "v4"] }
|
||||||
|
|
||||||
# First party crates
|
# First party crates
|
||||||
api_models = { version = "0.1.0", path = "../api_models" }
|
api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] }
|
||||||
common_utils = { version = "0.1.0", path = "../common_utils" }
|
common_utils = { version = "0.1.0", path = "../common_utils" }
|
||||||
external_services = { version = "0.1.0", path = "../external_services" }
|
external_services = { version = "0.1.0", path = "../external_services" }
|
||||||
masking = { version = "0.1.0", path = "../masking" }
|
masking = { version = "0.1.0", path = "../masking" }
|
||||||
|
|||||||
@ -783,7 +783,7 @@ impl api::IncomingWebhook for Adyen {
|
|||||||
|
|
||||||
fn get_dispute_details(
|
fn get_dispute_details(
|
||||||
&self,
|
&self,
|
||||||
request: &api_models::webhooks::IncomingWebhookRequestDetails<'_>,
|
request: &api::IncomingWebhookRequestDetails<'_>,
|
||||||
) -> CustomResult<api::disputes::DisputePayload, errors::ConnectorError> {
|
) -> CustomResult<api::disputes::DisputePayload, errors::ConnectorError> {
|
||||||
let notif = get_webhook_object_from_body(request.body)
|
let notif = get_webhook_object_from_body(request.body)
|
||||||
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
|
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
|
||||||
|
|||||||
@ -722,7 +722,7 @@ impl api::IncomingWebhook for Trustpay {
|
|||||||
|
|
||||||
fn get_dispute_details(
|
fn get_dispute_details(
|
||||||
&self,
|
&self,
|
||||||
request: &api_models::webhooks::IncomingWebhookRequestDetails<'_>,
|
request: &api::IncomingWebhookRequestDetails<'_>,
|
||||||
) -> CustomResult<api::disputes::DisputePayload, errors::ConnectorError> {
|
) -> CustomResult<api::disputes::DisputePayload, errors::ConnectorError> {
|
||||||
let trustpay_response: trustpay::TrustpayWebhookResponse = request
|
let trustpay_response: trustpay::TrustpayWebhookResponse = request
|
||||||
.body
|
.body
|
||||||
|
|||||||
@ -301,7 +301,7 @@ async fn disputes_incoming_webhook_flow<W: api::OutgoingWebhookType>(
|
|||||||
webhook_details: api::IncomingWebhookDetails,
|
webhook_details: api::IncomingWebhookDetails,
|
||||||
source_verified: bool,
|
source_verified: bool,
|
||||||
connector: &(dyn api::Connector + Sync),
|
connector: &(dyn api::Connector + Sync),
|
||||||
request_details: &api_models::webhooks::IncomingWebhookRequestDetails<'_>,
|
request_details: &api::IncomingWebhookRequestDetails<'_>,
|
||||||
event_type: api_models::webhooks::IncomingWebhookEvent,
|
event_type: api_models::webhooks::IncomingWebhookEvent,
|
||||||
) -> CustomResult<(), errors::WebhooksFlowError> {
|
) -> CustomResult<(), errors::WebhooksFlowError> {
|
||||||
metrics::INCOMING_DISPUTE_WEBHOOK_METRIC.add(&metrics::CONTEXT, 1, &[]);
|
metrics::INCOMING_DISPUTE_WEBHOOK_METRIC.add(&metrics::CONTEXT, 1, &[]);
|
||||||
@ -497,7 +497,7 @@ pub async fn webhooks_core<W: api::OutgoingWebhookType>(
|
|||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
.attach_printable("There was an error in parsing the query params")?;
|
.attach_printable("There was an error in parsing the query params")?;
|
||||||
|
|
||||||
let mut request_details = api_models::webhooks::IncomingWebhookRequestDetails {
|
let mut request_details = api::IncomingWebhookRequestDetails {
|
||||||
method: req.method().clone(),
|
method: req.method().clone(),
|
||||||
headers: req.headers(),
|
headers: req.headers(),
|
||||||
query_params: req.query_string().to_string(),
|
query_params: req.query_string().to_string(),
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
pub use api_models::webhooks::{
|
pub use api_models::webhooks::{
|
||||||
IncomingWebhookDetails, IncomingWebhookEvent, IncomingWebhookRequestDetails,
|
IncomingWebhookDetails, IncomingWebhookEvent, MerchantWebhookConfig, ObjectReferenceId,
|
||||||
MerchantWebhookConfig, ObjectReferenceId, OutgoingWebhook, OutgoingWebhookContent,
|
OutgoingWebhook, OutgoingWebhookContent, OutgoingWebhookType, WebhookFlow,
|
||||||
OutgoingWebhookType, WebhookFlow,
|
|
||||||
};
|
};
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
|
|
||||||
@ -13,6 +12,14 @@ use crate::{
|
|||||||
utils::crypto,
|
utils::crypto,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub struct IncomingWebhookRequestDetails<'a> {
|
||||||
|
pub method: actix_web::http::Method,
|
||||||
|
pub headers: &'a actix_web::http::header::HeaderMap,
|
||||||
|
pub body: &'a [u8],
|
||||||
|
pub query_params: String,
|
||||||
|
pub query_params_json: &'a [u8],
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait IncomingWebhook: ConnectorCommon + Sync {
|
pub trait IncomingWebhook: ConnectorCommon + Sync {
|
||||||
fn get_webhook_body_decoding_algorithm(
|
fn get_webhook_body_decoding_algorithm(
|
||||||
|
|||||||
Reference in New Issue
Block a user