diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs index ac1ab08893ba..d9778353cdaa 100644 --- a/crates/hyperswitch_domain_models/src/lib.rs +++ b/crates/hyperswitch_domain_models/src/lib.rs @@ -6,6 +6,7 @@ pub mod payments; #[cfg(feature = "payouts")] pub mod payouts; pub mod router_data; +pub mod router_flow_types; pub mod router_request_types; pub mod router_response_types; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types.rs b/crates/hyperswitch_domain_models/src/router_flow_types.rs new file mode 100644 index 000000000000..065b5f0f40b4 --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types.rs @@ -0,0 +1,17 @@ +pub mod access_token_auth; +pub mod dispute; +pub mod files; +pub mod fraud_check; +pub mod payments; +pub mod payouts; +pub mod refunds; +pub mod webhooks; + +pub use access_token_auth::*; +pub use dispute::*; +pub use files::*; +pub use fraud_check::*; +pub use payments::*; +pub use payouts::*; +pub use refunds::*; +pub use webhooks::*; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs b/crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs new file mode 100644 index 000000000000..dd45ca9ca372 --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs @@ -0,0 +1,2 @@ +#[derive(Clone, Debug)] +pub struct AccessTokenAuth; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/dispute.rs b/crates/hyperswitch_domain_models/src/router_flow_types/dispute.rs new file mode 100644 index 000000000000..ec13cae516f3 --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/dispute.rs @@ -0,0 +1,7 @@ +#[derive(Debug, Clone)] +pub struct Accept; +#[derive(Debug, Clone)] +pub struct Evidence; + +#[derive(Debug, Clone)] +pub struct Defend; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/files.rs b/crates/hyperswitch_domain_models/src/router_flow_types/files.rs new file mode 100644 index 000000000000..210b6ef54380 --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/files.rs @@ -0,0 +1,5 @@ +#[derive(Debug, Clone)] +pub struct Retrieve; + +#[derive(Debug, Clone)] +pub struct Upload; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/fraud_check.rs b/crates/hyperswitch_domain_models/src/router_flow_types/fraud_check.rs new file mode 100644 index 000000000000..a7642ea7e48a --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/fraud_check.rs @@ -0,0 +1,14 @@ +#[derive(Debug, Clone)] +pub struct Sale; + +#[derive(Debug, Clone)] +pub struct Checkout; + +#[derive(Debug, Clone)] +pub struct Transaction; + +#[derive(Debug, Clone)] +pub struct Fulfillment; + +#[derive(Debug, Clone)] +pub struct RecordReturn; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs new file mode 100644 index 000000000000..046866beea55 --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs @@ -0,0 +1,48 @@ +// Core related api layer. +#[derive(Debug, Clone)] +pub struct Authorize; + +#[derive(Debug, Clone)] +pub struct AuthorizeSessionToken; + +#[derive(Debug, Clone)] +pub struct CompleteAuthorize; + +#[derive(Debug, Clone)] +pub struct Approve; + +// Used in gift cards balance check +#[derive(Debug, Clone)] +pub struct Balance; + +#[derive(Debug, Clone)] +pub struct InitPayment; + +#[derive(Debug, Clone)] +pub struct Capture; + +#[derive(Debug, Clone)] +pub struct PSync; +#[derive(Debug, Clone)] +pub struct Void; + +#[derive(Debug, Clone)] +pub struct Reject; + +#[derive(Debug, Clone)] +pub struct Session; + +#[derive(Debug, Clone)] +pub struct PaymentMethodToken; + +#[derive(Debug, Clone)] +pub struct CreateConnectorCustomer; + +#[derive(Debug, Clone)] +pub struct SetupMandate; + +#[derive(Debug, Clone)] +pub struct PreProcessing; + +#[derive(Debug, Clone)] +pub struct IncrementalAuthorization; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/payouts.rs b/crates/hyperswitch_domain_models/src/router_flow_types/payouts.rs new file mode 100644 index 000000000000..e0f9c18cef99 --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/payouts.rs @@ -0,0 +1,20 @@ +#[derive(Debug, Clone)] +pub struct PoCancel; + +#[derive(Debug, Clone)] +pub struct PoCreate; + +#[derive(Debug, Clone)] +pub struct PoEligibility; + +#[derive(Debug, Clone)] +pub struct PoFulfill; + +#[derive(Debug, Clone)] +pub struct PoQuote; + +#[derive(Debug, Clone)] +pub struct PoRecipient; + +#[derive(Debug, Clone)] +pub struct PoRecipientAccount; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/refunds.rs b/crates/hyperswitch_domain_models/src/router_flow_types/refunds.rs new file mode 100644 index 000000000000..eea6c7d0bb06 --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/refunds.rs @@ -0,0 +1,4 @@ +#[derive(Debug, Clone)] +pub struct Execute; +#[derive(Debug, Clone)] +pub struct RSync; diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/webhooks.rs b/crates/hyperswitch_domain_models/src/router_flow_types/webhooks.rs new file mode 100644 index 000000000000..6f28a7f7b35c --- /dev/null +++ b/crates/hyperswitch_domain_models/src/router_flow_types/webhooks.rs @@ -0,0 +1,2 @@ +#[derive(Clone, Debug)] +pub struct VerifyWebhookSource; diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs index 30827e61c703..f06f336b8441 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types.rs @@ -15,7 +15,7 @@ use crate::{ errors::api_error_response::ApiErrorResponse, mandates, payments, router_data::{self, RouterData}, - router_response_types as response_types, + router_flow_types as flows, router_response_types as response_types, }; #[derive(Debug, Clone)] pub struct PaymentsAuthorizeData { @@ -134,13 +134,19 @@ impl TryFrom for ConnectorCustomerData { }) } } -impl TryFrom<&RouterData> - for ConnectorCustomerData +impl + TryFrom< + &RouterData, + > for ConnectorCustomerData { type Error = error_stack::Report; fn try_from( - data: &RouterData, + data: &RouterData< + flows::Authorize, + PaymentsAuthorizeData, + response_types::PaymentsResponseData, + >, ) -> Result { Ok(Self { email: data.request.email.clone(), diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 7aa6aad93cf7..c427f60cd1f9 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -29,6 +29,9 @@ pub mod webhooks; use std::{fmt::Debug, str::FromStr}; use error_stack::{report, ResultExt}; +pub use hyperswitch_domain_models::router_flow_types::{ + access_token_auth::AccessTokenAuth, webhooks::VerifyWebhookSource, +}; #[cfg(feature = "frm")] pub use self::fraud_check::*; @@ -50,10 +53,6 @@ use crate::{ services::{request, ConnectorIntegration, ConnectorRedirectResponse, ConnectorValidation}, types::{self, api::enums as api_enums}, }; - -#[derive(Clone, Debug)] -pub struct AccessTokenAuth; - pub trait ConnectorAccessToken: ConnectorIntegration { @@ -66,9 +65,6 @@ pub enum ConnectorCallType { SessionMultiple(Vec), } -#[derive(Clone, Debug)] -pub struct VerifyWebhookSource; - pub trait ConnectorVerifyWebhookSource: ConnectorIntegration< VerifyWebhookSource, diff --git a/crates/router/src/types/api/disputes.rs b/crates/router/src/types/api/disputes.rs index 85fdb307ed68..a8107fe4c9d8 100644 --- a/crates/router/src/types/api/disputes.rs +++ b/crates/router/src/types/api/disputes.rs @@ -8,6 +8,8 @@ pub struct DisputeId { pub dispute_id: String, } +pub use hyperswitch_domain_models::router_flow_types::dispute::{Accept, Defend, Evidence}; + #[derive(Default, Debug)] pub struct DisputePayload { pub amount: String, @@ -58,9 +60,6 @@ pub enum EvidenceType { UncategorizedFile, } -#[derive(Debug, Clone)] -pub struct Accept; - pub trait AcceptDispute: services::ConnectorIntegration< Accept, @@ -70,9 +69,6 @@ pub trait AcceptDispute: { } -#[derive(Debug, Clone)] -pub struct Evidence; - pub trait SubmitEvidence: services::ConnectorIntegration< Evidence, @@ -82,9 +78,6 @@ pub trait SubmitEvidence: { } -#[derive(Debug, Clone)] -pub struct Defend; - pub trait DefendDispute: services::ConnectorIntegration< Defend, diff --git a/crates/router/src/types/api/files.rs b/crates/router/src/types/api/files.rs index 688962bd8367..bef393bf946c 100644 --- a/crates/router/src/types/api/files.rs +++ b/crates/router/src/types/api/files.rs @@ -1,4 +1,5 @@ use api_models::enums::FileUploadProvider; +pub use hyperswitch_domain_models::router_flow_types::files::{Retrieve, Upload}; use masking::{Deserialize, Serialize}; use serde_with::serde_as; @@ -67,17 +68,11 @@ pub enum FilePurpose { DisputeEvidence, } -#[derive(Debug, Clone)] -pub struct Upload; - pub trait UploadFile: services::ConnectorIntegration { } -#[derive(Debug, Clone)] -pub struct Retrieve; - pub trait RetrieveFile: services::ConnectorIntegration< Retrieve, diff --git a/crates/router/src/types/api/fraud_check.rs b/crates/router/src/types/api/fraud_check.rs index c413126ee049..6c50ed9db90b 100644 --- a/crates/router/src/types/api/fraud_check.rs +++ b/crates/router/src/types/api/fraud_check.rs @@ -3,6 +3,9 @@ use std::str::FromStr; use api_models::enums; use common_utils::errors::CustomResult; use error_stack::ResultExt; +pub use hyperswitch_domain_models::router_flow_types::fraud_check::{ + Checkout, Fulfillment, RecordReturn, Sale, Transaction, +}; use super::{BoxedConnector, ConnectorData, SessionConnectorData}; use crate::{ @@ -15,41 +18,26 @@ use crate::{ }, }; -#[derive(Debug, Clone)] -pub struct Sale; - pub trait FraudCheckSale: api::ConnectorIntegration { } -#[derive(Debug, Clone)] -pub struct Checkout; - pub trait FraudCheckCheckout: api::ConnectorIntegration { } -#[derive(Debug, Clone)] -pub struct Transaction; - pub trait FraudCheckTransaction: api::ConnectorIntegration { } -#[derive(Debug, Clone)] -pub struct Fulfillment; - pub trait FraudCheckFulfillment: api::ConnectorIntegration { } -#[derive(Debug, Clone)] -pub struct RecordReturn; - pub trait FraudCheckRecordReturn: api::ConnectorIntegration { diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index 923f4a552685..c1f045c74a7d 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -15,6 +15,11 @@ pub use api_models::payments::{ WalletData, }; use error_stack::ResultExt; +pub use hyperswitch_domain_models::router_flow_types::payments::{ + Approve, Authorize, AuthorizeSessionToken, Balance, Capture, CompleteAuthorize, + CreateConnectorCustomer, IncrementalAuthorization, InitPayment, PSync, PaymentMethodToken, + PreProcessing, Reject, Session, SetupMandate, Void, +}; use crate::{ core::errors, @@ -24,55 +29,6 @@ use crate::{ impl super::Router for PaymentsRequest {} -// Core related api layer. -#[derive(Debug, Clone)] -pub struct Authorize; - -#[derive(Debug, Clone)] -pub struct AuthorizeSessionToken; - -#[derive(Debug, Clone)] -pub struct CompleteAuthorize; - -#[derive(Debug, Clone)] -pub struct Approve; - -// Used in gift cards balance check -#[derive(Debug, Clone)] -pub struct Balance; - -#[derive(Debug, Clone)] -pub struct InitPayment; - -#[derive(Debug, Clone)] -pub struct Capture; - -#[derive(Debug, Clone)] -pub struct PSync; -#[derive(Debug, Clone)] -pub struct Void; - -#[derive(Debug, Clone)] -pub struct Reject; - -#[derive(Debug, Clone)] -pub struct Session; - -#[derive(Debug, Clone)] -pub struct PaymentMethodToken; - -#[derive(Debug, Clone)] -pub struct CreateConnectorCustomer; - -#[derive(Debug, Clone)] -pub struct SetupMandate; - -#[derive(Debug, Clone)] -pub struct PreProcessing; - -#[derive(Debug, Clone)] -pub struct IncrementalAuthorization; - pub trait PaymentIdTypeExt { fn get_payment_intent_id(&self) -> errors::CustomResult; } diff --git a/crates/router/src/types/api/payouts.rs b/crates/router/src/types/api/payouts.rs index 53f015290df1..d4417c5f1ccd 100644 --- a/crates/router/src/types/api/payouts.rs +++ b/crates/router/src/types/api/payouts.rs @@ -4,30 +4,12 @@ pub use api_models::payouts::{ PayoutListFilters, PayoutListResponse, PayoutMethodData, PayoutRequest, PayoutRetrieveBody, PayoutRetrieveRequest, PixBankTransfer, SepaBankTransfer, Wallet as WalletPayout, }; +pub use hyperswitch_domain_models::router_flow_types::payouts::{ + PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, +}; use crate::{services::api, types}; -#[derive(Debug, Clone)] -pub struct PoCancel; - -#[derive(Debug, Clone)] -pub struct PoCreate; - -#[derive(Debug, Clone)] -pub struct PoEligibility; - -#[derive(Debug, Clone)] -pub struct PoFulfill; - -#[derive(Debug, Clone)] -pub struct PoQuote; - -#[derive(Debug, Clone)] -pub struct PoRecipient; - -#[derive(Debug, Clone)] -pub struct PoRecipientAccount; - pub trait PayoutCancel: api::ConnectorIntegration { diff --git a/crates/router/src/types/api/refunds.rs b/crates/router/src/types/api/refunds.rs index cb3306c6ffd0..ac0433080cc6 100644 --- a/crates/router/src/types/api/refunds.rs +++ b/crates/router/src/types/api/refunds.rs @@ -2,6 +2,7 @@ pub use api_models::refunds::{ RefundRequest, RefundResponse, RefundStatus, RefundType, RefundUpdateRequest, RefundsRetrieveRequest, }; +pub use hyperswitch_domain_models::router_flow_types::refunds::{Execute, RSync}; use super::ConnectorCommon; use crate::{ @@ -21,11 +22,6 @@ impl ForeignFrom for RefundStatus { } } -#[derive(Debug, Clone)] -pub struct Execute; -#[derive(Debug, Clone)] -pub struct RSync; - pub trait RefundExecute: api::ConnectorIntegration {