Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connector): [HELCIM] Move connector to hyperswitch_connectors (#5287)

DEEPANSHU BANSAL0f89a0acbfc2
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 736d3eaa36..5da3a2f14b 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -41,6 +41,7 @@ crates/router/tests/connectors/ @juspay/hyperswitch-connector
crates/test_utils/tests/connectors/ @juspay/hyperswitch-connector
crates/test_utils/tests/sample_auth.toml @juspay/hyperswitch-connector
crates/connector_configs/ @juspay/hyperswitch-connector
+crates/hyperswitch_connectors/ @juspay/hyperswitch-connector
crates/router/src/compatibility/ @juspay/hyperswitch-compatibility
diff --git a/Cargo.lock b/Cargo.lock
index 66b38d09c1..c5eac1ef86 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3830,6 +3830,25 @@ dependencies = [
"tokio 1.37.0",
]
+[[package]]
+name = "hyperswitch_connectors"
+version = "0.1.0"
+dependencies = [
+ "api_models",
+ "async-trait",
+ "cards",
+ "common_enums",
+ "common_utils",
+ "error-stack",
+ "hyperswitch_domain_models",
+ "hyperswitch_interfaces",
+ "masking",
+ "router_env",
+ "serde",
+ "serde_json",
+ "strum 0.26.2",
+]
+
[[package]]
name = "hyperswitch_constraint_graph"
version = "0.1.0"
@@ -3892,6 +3911,7 @@ dependencies = [
"router_env",
"serde",
"serde_json",
+ "strum 0.26.2",
"thiserror",
"time",
]
@@ -6067,6 +6087,7 @@ dependencies = [
"hex",
"http 0.2.12",
"hyper 0.14.28",
+ "hyperswitch_connectors",
"hyperswitch_constraint_graph",
"hyperswitch_domain_models",
"hyperswitch_interfaces",
@@ -8371,9 +8392,9 @@ checksum = "110352d4e9076c67839003c7788d8604e24dcded13e0b375af3efaa8cf468517"
[[package]]
name = "utf8parse"
-version = "0.2.2"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "utoipa"
diff --git a/crates/analytics/Cargo.toml b/crates/analytics/Cargo.toml
index a43071b5a1..91bc16f277 100644
--- a/crates/analytics/Cargo.toml
+++ b/crates/analytics/Cargo.toml
@@ -18,7 +18,7 @@ common_enums = { version = "0.1.0", path = "../common_enums" }
common_utils = { version = "0.1.0", path = "../common_utils" }
diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_store"] }
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
-hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces" }
+hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
masking = { version = "0.1.0", path = "../masking" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false }
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 85df79701a..5d91a477cd 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -35,6 +35,6 @@ vaultrs = { version = "0.7.2", optional = true }
# First party crates
common_utils = { version = "0.1.0", path = "../common_utils" }
-hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces" }
+hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
masking = { version = "0.1.0", path = "../masking" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml
new file mode 100644
index 0000000000..0e620c6b9f
--- /dev/null
+++ b/crates/hyperswitch_connectors/Cargo.toml
@@ -0,0 +1,27 @@
+[package]
+name = "hyperswitch_connectors"
+version = "0.1.0"
+edition.workspace = true
+rust-version.workspace = true
+license.workspace = true
+
+[features]
+frm = ["hyperswitch_domain_models/frm", "hyperswitch_interfaces/frm"]
+payouts = ["hyperswitch_domain_models/payouts", "api_models/payouts", "hyperswitch_interfaces/payouts"]
+
+[dependencies]
+async-trait = "0.1.79"
+error-stack = "0.4.1"
+serde = { version = "1.0.197", features = ["derive"] }
+serde_json = "1.0.115"
+strum = { version = "0.26", features = ["derive"] }
+
+# First party crates
+api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] , default-features = false}
+cards = { version = "0.1.0", path = "../cards" }
+common_enums = { version = "0.1.0", path = "../common_enums" }
+common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext", "logs", "metrics"] }
+hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
+hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces" , default-features = false }
+masking = { version = "0.1.0", path = "../masking" }
+router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs
new file mode 100644
index 0000000000..a2d78ede2b
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors.rs
@@ -0,0 +1,2 @@
+pub mod helcim;
+pub use self::helcim::Helcim;
diff --git a/crates/router/src/connector/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs
similarity index 70%
rename from crates/router/src/connector/helcim.rs
rename to crates/hyperswitch_connectors/src/connectors/helcim.rs
index a6305ef636..8d632d8b7e 100644
--- a/crates/router/src/connector/helcim.rs
+++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs
@@ -2,30 +2,48 @@ pub mod transformers;
use std::fmt::Debug;
-use common_utils::request::RequestContent;
-use diesel_models::enums;
+use api_models::webhooks::IncomingWebhookEvent;
+use common_enums::enums;
+use common_utils::{
+ errors::CustomResult,
+ ext_traits::BytesExt,
+ request::{Method, Request, RequestBuilder, RequestContent},
+};
use error_stack::{report, ResultExt};
-use masking::ExposeInterface;
-use transformers as helcim;
-
-use super::utils::{to_connector_meta, PaymentsAuthorizeRequestData};
-use crate::{
- configs::settings,
- consts::NO_ERROR_CODE,
- core::errors::{self, CustomResult},
- events::connector_api_logs::ConnectorEvent,
- headers,
- services::{
- self,
- request::{self, Mask},
- ConnectorIntegration, ConnectorValidation,
+use hyperswitch_domain_models::{
+ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
+ router_flow_types::{
+ access_token_auth::AccessTokenAuth,
+ payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
+ refunds::{Execute, RSync},
},
+ router_request_types::{
+ AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
+ PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
+ RefundsData, SetupMandateRequestData,
+ },
+ router_response_types::{PaymentsResponseData, RefundsResponseData},
types::{
- self,
- api::{self, ConnectorCommon, ConnectorCommonExt},
- ErrorResponse, Response,
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, SetupMandateRouterData,
},
- utils::{self, BytesExt},
+};
+use hyperswitch_interfaces::{
+ api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation},
+ configs::Connectors,
+ consts::NO_ERROR_CODE,
+ errors,
+ events::connector_api_logs::ConnectorEvent,
+ types::{self, Response},
+ webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
+};
+use masking::{ExposeInterface, Mask};
+use transformers as helcim;
+
+use crate::{
+ constants::headers,
+ types::ResponseRouterData,
+ utils::{to_connector_meta, PaymentsAuthorizeRequestData},
};
#[derive(Debug, Clone)]
@@ -54,12 +72,8 @@ impl Helcim {
}
}
-impl
- ConnectorIntegration<
- api::PaymentMethodToken,
- types::PaymentMethodTokenizationData,
- types::PaymentsResponseData,
- > for Helcim
+impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
+ for Helcim
{
// Not Implemented (R)
}
@@ -70,9 +84,10 @@ where
{
fn build_headers(
&self,
- req: &types::RouterData<Flow, Request, Response>,
- _connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &RouterData<Flow, Request, Response>,
+ _connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
self.get_content_type().to_string().into(),
@@ -83,7 +98,7 @@ where
const ID_LENGTH: usize = 22;
let mut idempotency_key = vec![(
headers::IDEMPOTENCY_KEY.to_string(),
- utils::generate_id(ID_LENGTH, "HS").into_masked(),
+ common_utils::generate_id(ID_LENGTH, "HS").into_masked(),
)];
header.append(&mut api_key);
@@ -105,14 +120,15 @@ impl ConnectorCommon for Helcim {
"application/json"
}
- fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
+ fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
connectors.helcim.base_url.as_ref()
}
fn get_auth_header(
&self,
- auth_type: &types::ConnectorAuthType,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ auth_type: &ConnectorAuthType,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
let auth = helcim::HelcimAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
@@ -163,49 +179,39 @@ impl ConnectorValidation for Helcim {
match capture_method {
enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()),
enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err(
- super::utils::construct_not_supported_error_report(capture_method, self.id()),
+ crate::utils::construct_not_supported_error_report(capture_method, self.id()),
),
}
}
}
-impl ConnectorIntegration<api::Session, types::PaymentsSessionData, types::PaymentsResponseData>
- for Helcim
-{
+impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Helcim {
//TODO: implement sessions flow
}
-impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, types::AccessToken>
- for Helcim
-{
-}
+impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Helcim {}
-impl
- ConnectorIntegration<
- api::SetupMandate,
- types::SetupMandateRequestData,
- types::PaymentsResponseData,
- > for Helcim
-{
+impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Helcim {
fn get_headers(
&self,
- req: &types::SetupMandateRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &SetupMandateRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
self.build_headers(req, connectors)
}
fn get_url(
&self,
- _req: &types::SetupMandateRouterData,
- connectors: &settings::Connectors,
+ _req: &SetupMandateRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}v2/payment/verify", self.base_url(connectors)))
}
fn get_request_body(
&self,
- req: &types::SetupMandateRouterData,
- _connectors: &settings::Connectors,
+ req: &SetupMandateRouterData,
+ _connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = helcim::HelcimVerifyRequest::try_from(req)?;
@@ -213,17 +219,17 @@ impl
}
fn build_request(
&self,
- _req: &types::SetupMandateRouterData,
- _connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ _req: &SetupMandateRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
Err(
errors::ConnectorError::NotImplemented("Setup Mandate flow for Helcim".to_string())
.into(),
)
// Ok(Some(
- // services::RequestBuilder::new()
- // .method(services::Method::Post)
+ // RequestBuilder::new()
+ // .method(Method::Post)
// .url(&types::SetupMandateType::get_url(self, req, connectors)?)
// .attach_default_headers()
// .headers(types::SetupMandateType::get_headers(self, req, connectors)?)
@@ -235,17 +241,17 @@ impl
}
fn handle_response(
&self,
- data: &types::SetupMandateRouterData,
+ data: &SetupMandateRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<types::SetupMandateRouterData, errors::ConnectorError> {
+ ) -> CustomResult<SetupMandateRouterData, errors::ConnectorError> {
let response: helcim::HelcimPaymentsResponse = res
.response
.parse_struct("Helcim PaymentsAuthorizeResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- types::RouterData::try_from(types::ResponseRouterData {
+ RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
@@ -260,14 +266,13 @@ impl
}
}
-impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::PaymentsResponseData>
- for Helcim
-{
+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Helcim {
fn get_headers(
&self,
- req: &types::PaymentsAuthorizeRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
self.build_headers(req, connectors)
}
@@ -277,8 +282,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
fn get_url(
&self,
- req: &types::PaymentsAuthorizeRouterData,
- connectors: &settings::Connectors,
+ req: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
if req.request.is_auto_capture()? {
return Ok(format!("{}v2/payment/purchase", self.base_url(connectors)));
@@ -288,8 +293,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
fn get_request_body(
&self,
- req: &types::PaymentsAuthorizeRouterData,
- _connectors: &settings::Connectors,
+ req: &PaymentsAuthorizeRouterData,
+ _connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_router_data = helcim::HelcimRouterData::try_from((
&self.get_currency_unit(),
@@ -303,12 +308,12 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
fn build_request(
&self,
- req: &types::PaymentsAuthorizeRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ req: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
- services::RequestBuilder::new()
- .method(services::Method::Post)
+ RequestBuilder::new()
+ .method(Method::Post)
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
@@ -325,10 +330,10 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
fn handle_response(
&self,
- data: &types::PaymentsAuthorizeRouterData,
+ data: &PaymentsAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
+ ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
let response: helcim::HelcimPaymentsResponse = res
.response
.parse_struct("Helcim PaymentsAuthorizeResponse")
@@ -337,7 +342,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- types::RouterData::try_from(types::ResponseRouterData {
+ RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
@@ -353,14 +358,13 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
}
}
-impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>
- for Helcim
-{
+impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Helcim {
fn get_headers(
&self,
- req: &types::PaymentsSyncRouterData,
- _connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &PaymentsSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
types::PaymentsSyncType::get_content_type(self)
@@ -378,8 +382,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
fn get_url(
&self,
- req: &types::PaymentsSyncRouterData,
- connectors: &settings::Connectors,
+ req: &PaymentsSyncRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let connector_payment_id = req
.request
@@ -395,12 +399,12 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
fn build_request(
&self,
- req: &types::PaymentsSyncRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ req: &PaymentsSyncRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
- services::RequestBuilder::new()
- .method(services::Method::Get)
+ RequestBuilder::new()
+ .method(Method::Get)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
@@ -410,10 +414,10 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
fn handle_response(
&self,
- data: &types::PaymentsSyncRouterData,
+ data: &PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {
+ ) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
let response: helcim::HelcimPaymentsResponse = res
.response
.parse_struct("helcim PaymentsSyncResponse")
@@ -422,7 +426,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- types::RouterData::try_from(types::ResponseRouterData {
+ RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
@@ -444,14 +448,13 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
// }
}
-impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::PaymentsResponseData>
- for Helcim
-{
+impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Helcim {
fn get_headers(
&self,
- req: &types::PaymentsCaptureRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &PaymentsCaptureRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
self.build_headers(req, connectors)
}
@@ -461,16 +464,16 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
fn get_url(
&self,
- _req: &types::PaymentsCaptureRouterData,
- connectors: &settings::Connectors,
+ _req: &PaymentsCaptureRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}v2/payment/capture", self.base_url(connectors)))
}
fn get_request_body(
&self,
- req: &types::PaymentsCaptureRouterData,
- _connectors: &settings::Connectors,
+ req: &PaymentsCaptureRouterData,
+ _connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_router_data = helcim::HelcimRouterData::try_from((
&self.get_currency_unit(),
@@ -484,12 +487,12 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
fn build_request(
&self,
- req: &types::PaymentsCaptureRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ req: &PaymentsCaptureRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
- services::RequestBuilder::new()
- .method(services::Method::Post)
+ RequestBuilder::new()
+ .method(Method::Post)
.url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsCaptureType::get_headers(
@@ -504,10 +507,10 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
fn handle_response(
&self,
- data: &types::PaymentsCaptureRouterData,
+ data: &PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<types::PaymentsCaptureRouterData, errors::ConnectorError> {
+ ) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
let response: helcim::HelcimPaymentsResponse = res
.response
.parse_struct("Helcim PaymentsCaptureResponse")
@@ -516,7 +519,7 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- types::RouterData::try_from(types::ResponseRouterData {
+ RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
@@ -532,14 +535,13 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
}
}
-impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsResponseData>
- for Helcim
-{
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Helcim {
fn get_headers(
&self,
- req: &types::PaymentsCancelRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
self.build_headers(req, connectors)
}
@@ -549,16 +551,16 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
fn get_url(
&self,
- _req: &types::PaymentsCancelRouterData,
- connectors: &settings::Connectors,
+ _req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}v2/payment/reverse", self.base_url(connectors)))
}
fn get_request_body(
&self,
- req: &types::PaymentsCancelRouterData,
- _connectors: &settings::Connectors,
+ req: &PaymentsCancelRouterData,
+ _connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = helcim::HelcimVoidRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
@@ -566,12 +568,12 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
fn build_request(
&self,
- req: &types::PaymentsCancelRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
- services::RequestBuilder::new()
- .method(services::Method::Post)
+ RequestBuilder::new()
+ .method(Method::Post)
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
@@ -584,10 +586,10 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
fn handle_response(
&self,
- data: &types::PaymentsCancelRouterData,
+ data: &PaymentsCancelRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<types::PaymentsCancelRouterData, errors::ConnectorError> {
+ ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
let response: helcim::HelcimPaymentsResponse = res
.response
.parse_struct("HelcimPaymentsResponse")
@@ -596,7 +598,7 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- types::RouterData::try_from(types::ResponseRouterData {
+ RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
@@ -613,12 +615,13 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
}
}
-impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponseData> for Helcim {
+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Helcim {
fn get_headers(
&self,
- req: &types::RefundsRouterData<api::Execute>,
- connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &RefundsRouterData<Execute>,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
self.build_headers(req, connectors)
}
@@ -628,16 +631,16 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
fn get_url(
&self,
- _req: &types::RefundsRouterData<api::Execute>,
- connectors: &settings::Connectors,
+ _req: &RefundsRouterData<Execute>,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}v2/payment/refund", self.base_url(connectors)))
}
fn get_request_body(
&self,
- req: &types::RefundsRouterData<api::Execute>,
- _connectors: &settings::Connectors,
+ req: &RefundsRouterData<Execute>,
+ _connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_router_data = helcim::HelcimRouterData::try_from((
&self.get_currency_unit(),
@@ -651,11 +654,11 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
fn build_request(
&self,
- req: &types::RefundsRouterData<api::Execute>,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
- let request = services::RequestBuilder::new()
- .method(services::Method::Post)
+ req: &RefundsRouterData<Execute>,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ let request = RequestBuilder::new()
+ .method(Method::Post)
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundExecuteType::get_headers(
@@ -670,10 +673,10 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
fn handle_response(
&self,
- data: &types::RefundsRouterData<api::Execute>,
+ data: &RefundsRouterData<Execute>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<types::RefundsRouterData<api::Execute>, errors::ConnectorError> {
+ ) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
let response: helcim::RefundResponse =
res.response
.parse_struct("helcim RefundResponse")
@@ -682,7 +685,7 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- types::RouterData::try_from(types::ResponseRouterData {
+ RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
@@ -698,12 +701,13 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
}
}
-impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponseData> for Helcim {
+impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Helcim {
fn get_headers(
&self,
- req: &types::RefundSyncRouterData,
- _connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ req: &RefundSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::maskable::Maskable<String>)>, errors::ConnectorError>
+ {
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
types::RefundSyncType::get_content_type(self)
@@ -721,8 +725,8 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
fn get_url(
&self,
- req: &types::RefundSyncRouterData,
- connectors: &settings::Connectors,
+ req: &RefundSyncRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let connector_refund_id = req
.request
@@ -738,12 +742,12 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
fn build_request(
&self,
- req: &types::RefundSyncRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ req: &RefundSyncRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
- services::RequestBuilder::new()
- .method(services::Method::Get)
+ RequestBuilder::new()
+ .method(Method::Get)
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
@@ -753,10 +757,10 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
fn handle_response(
&self,
- data: &types::RefundSyncRouterData,
+ data: &RefundSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<types::RefundSyncRouterData, errors::ConnectorError> {
+ ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
let response: helcim::RefundResponse = res
.response
.parse_struct("helcim RefundSyncResponse")
@@ -765,7 +769,7 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- types::RouterData::try_from(types::ResponseRouterData {
+ RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
@@ -782,24 +786,24 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
}
#[async_trait::async_trait]
-impl api::IncomingWebhook for Helcim {
+impl IncomingWebhook for Helcim {
fn get_webhook_object_reference_id(
&self,
- _request: &api::IncomingWebhookRequestDetails<'_>,
- ) -> CustomResult<api::webhooks::ObjectReferenceId, errors::ConnectorError> {
+ _request: &IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
fn get_webhook_event_type(
&self,
- _request: &api::IncomingWebhookRequestDetails<'_>,
- ) -> CustomResult<api::IncomingWebhookEvent, errors::ConnectorError> {
+ _request: &IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<IncomingWebhookEvent, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
fn get_webhook_resource_object(
&self,
- _request: &api::IncomingWebhookRequestDetails<'_>,
+ _request: &IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
diff --git a/crates/router/src/connector/helcim/transformers.rs b/crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs
similarity index 70%
rename from crates/router/src/connector/helcim/transformers.rs
rename to crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs
index 2f6cf61e75..3aed97a2cb 100644
--- a/crates/router/src/connector/helcim/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs
@@ -1,16 +1,34 @@
+use common_enums::enums;
use common_utils::pii::{Email, IpAddress};
use error_stack::ResultExt;
+use hyperswitch_domain_models::{
+ payment_method_data::{Card, PaymentMethodData},
+ router_data::{ConnectorAuthType, RouterData},
+ router_flow_types::refunds::{Execute, RSync},
+ router_request_types::{
+ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData,
+ ResponseId, SetupMandateRequestData,
+ },
+ router_response_types::{PaymentsResponseData, RefundsResponseData},
+ types::{
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ RefundsRouterData, SetupMandateRouterData,
+ },
+};
+use hyperswitch_interfaces::{
+ api::{self},
+ errors,
+};
use masking::Secret;
use serde::{Deserialize, Serialize};
use crate::{
- connector::utils::{
- self, AddressDetailsData, BrowserInformationData, CardData, PaymentsAuthorizeRequestData,
+ types::{RefundsResponseRouterData, ResponseRouterData},
+ utils::{
+ AddressDetailsData, BrowserInformationData, CardData, PaymentsAuthorizeRequestData,
PaymentsCancelRequestData, PaymentsCaptureRequestData, PaymentsSetupMandateRequestData,
- RefundsRequestData, RouterData,
+ RefundsRequestData, RouterData as RouterDataUtils,
},
- core::errors,
- types::{self, api, domain, storage::enums},
};
#[derive(Debug, Serialize)]
@@ -24,7 +42,7 @@ impl<T> TryFrom<(&api::CurrencyUnit, enums::Currency, i64, T)> for HelcimRouterD
fn try_from(
(currency_unit, currency, amount, item): (&api::CurrencyUnit, enums::Currency, i64, T),
) -> Result<Self, Self::Error> {
- let amount = utils::get_amount_as_f64(currency_unit, amount, currency)?;
+ let amount = crate::utils::get_amount_as_f64(currency_unit, amount, currency)?;
Ok(Self {
amount,
router_data: item,
@@ -109,11 +127,9 @@ pub struct HelcimCard {
card_c_v_v: Secret<String>,
}
-impl TryFrom<(&types::SetupMandateRouterData, &domain::Card)> for HelcimVerifyRequest {
+impl TryFrom<(&SetupMandateRouterData, &Card)> for HelcimVerifyRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(
- value: (&types::SetupMandateRouterData, &domain::Card),
- ) -> Result<Self, Self::Error> {
+ fn try_from(value: (&SetupMandateRouterData, &Card)) -> Result<Self, Self::Error> {
let (item, req_card) = value;
let card_data = HelcimCard {
card_expiry: req_card
@@ -143,48 +159,38 @@ impl TryFrom<(&types::SetupMandateRouterData, &domain::Card)> for HelcimVerifyRe
}
}
-impl TryFrom<&types::SetupMandateRouterData> for HelcimVerifyRequest {
+impl TryFrom<&SetupMandateRouterData> for HelcimVerifyRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &types::SetupMandateRouterData) -> Result<Self, Self::Error> {
+ fn try_from(item: &SetupMandateRouterData) -> Result<Self, Self::Error> {
match item.request.payment_method_data.clone() {
- domain::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)),
- domain::PaymentMethodData::BankTransfer(_) => {
+ PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)),
+ PaymentMethodData::BankTransfer(_) => {
Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into())
}
- domain::PaymentMethodData::CardRedirect(_)
- | domain::PaymentMethodData::Wallet(_)
- | domain::PaymentMethodData::PayLater(_)
- | domain::PaymentMethodData::BankRedirect(_)
- | domain::PaymentMethodData::BankDebit(_)
- | domain::PaymentMethodData::Crypto(_)
- | domain::PaymentMethodData::MandatePayment
- | domain::PaymentMethodData::Reward
- | domain::PaymentMethodData::RealTimePayment(_)
- | domain::PaymentMethodData::Upi(_)
- | domain::PaymentMethodData::Voucher(_)
- | domain::PaymentMethodData::GiftCard(_)
- | domain::PaymentMethodData::OpenBanking(_)
- | domain::PaymentMethodData::CardToken(_) => {
- Err(errors::ConnectorError::NotImplemented(
- utils::get_unimplemented_payment_method_error_message("Helcim"),
- ))?
- }
+ PaymentMethodData::CardRedirect(_)
+ | PaymentMethodData::Wallet(_)
+ | PaymentMethodData::PayLater(_)
+ | PaymentMethodData::BankRedirect(_)
+ | PaymentMethodData::BankDebit(_)
+ | PaymentMethodData::Crypto(_)
+ | PaymentMethodData::MandatePayment
+ | PaymentMethodData::Reward
+ | PaymentMethodData::RealTimePayment(_)
+ | PaymentMethodData::Upi(_)
+ | PaymentMethodData::Voucher(_)
+ | PaymentMethodData::GiftCard(_)
+ | PaymentMethodData::OpenBanking(_)
+ | PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
+ crate::utils::get_unimplemented_payment_method_error_message("Helcim"),
+ ))?,
}
}
}
-impl
- TryFrom<(
- &HelcimRouterData<&types::PaymentsAuthorizeRouterData>,
- &domain::Card,
- )> for HelcimPaymentsRequest
-{
+impl TryFrom<(&HelcimRouterData<&PaymentsAuthorizeRouterData>, &Card)> for HelcimPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- value: (
- &HelcimRouterData<&types::PaymentsAuthorizeRouterData>,
- &domain::Card,
- ),
+ value: (&HelcimRouterData<&PaymentsAuthorizeRouterData>, &Card),
) -> Result<Self, Self::Error> {
let (item, req_card) = value;
let card_data = HelcimCard {
@@ -198,7 +204,7 @@ impl
.get_billing()?
.to_owned()
.address
- .ok_or_else(utils::missing_field_err("billing.address"))?;
+ .ok_or_else(crate::utils::missing_field_err("billing.address"))?;
let billing_address = HelcimBillingAddress {
name: req_address.get_full_name()?,
@@ -244,34 +250,32 @@ impl
}
}
-impl TryFrom<&HelcimRouterData<&types::PaymentsAuthorizeRouterData>> for HelcimPaymentsRequest {
+impl TryFrom<&HelcimRouterData<&PaymentsAuthorizeRouterData>> for HelcimPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: &HelcimRouterData<&types::PaymentsAuthorizeRouterData>,
+ item: &HelcimRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
match item.router_data.request.payment_method_data.clone() {
- domain::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)),
- domain::PaymentMethodData::BankTransfer(_) => {
+ PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)),
+ PaymentMethodData::BankTransfer(_) => {
Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into())
}
- domain::PaymentMethodData::CardRedirect(_)
- | domain::PaymentMethodData::Wallet(_)
- | domain::PaymentMethodData::PayLater(_)
- | domain::PaymentMethodData::BankRedirect(_)
- | domain::PaymentMethodData::BankDebit(_)
- | domain::PaymentMethodData::Crypto(_)
- | domain::PaymentMethodData::MandatePayment
- | domain::PaymentMethodData::Reward
- | domain::PaymentMethodData::RealTimePayment(_)
- | domain::PaymentMethodData::Upi(_)
- | domain::PaymentMethodData::Voucher(_)
- | domain::PaymentMethodData::GiftCard(_)
- | domain::PaymentMethodData::OpenBanking(_)
- | domain::PaymentMethodData::CardToken(_) => {
- Err(errors::ConnectorError::NotImplemented(
- utils::get_unimplemented_payment_method_error_message("Helcim"),
- ))?
- }
+ PaymentMethodData::CardRedirect(_)
+ | PaymentMethodData::Wallet(_)
+ | PaymentMethodData::PayLater(_)
+ | PaymentMethodData::BankRedirect(_)
+ | PaymentMethodData::BankDebit(_)
+ | PaymentMethodData::Crypto(_)
+ | PaymentMethodData::MandatePayment
+ | PaymentMethodData::Reward
+ | PaymentMethodData::RealTimePayment(_)
+ | PaymentMethodData::Upi(_)
+ | PaymentMethodData::Voucher(_)
+ | PaymentMethodData::GiftCard(_)
+ | PaymentMethodData::OpenBanking(_)
+ | PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
+ crate::utils::get_unimplemented_payment_method_error_message("Helcim"),
+ ))?,
}
}
}
@@ -281,11 +285,11 @@ pub struct HelcimAuthType {
pub(super) api_key: Secret<String>,
}
-impl TryFrom<&types::ConnectorAuthType> for HelcimAuthType {
+impl TryFrom<&ConnectorAuthType> for HelcimAuthType {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
+ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
- types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
+ ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
api_key: api_key.to_owned(),
}),
_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
@@ -345,26 +349,26 @@ pub struct HelcimPaymentsResponse {
impl<F>
TryFrom<
- types::ResponseRouterData<
+ ResponseRouterData<
F,
HelcimPaymentsResponse,
- types::SetupMandateRequestData,
- types::PaymentsResponseData,
+ SetupMandateRequestData,
+ PaymentsResponseData,
>,
- > for types::RouterData<F, types::SetupMandateRequestData, types::PaymentsResponseData>
+ > for RouterData<F, SetupMandateRequestData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::ResponseRouterData<
+ item: ResponseRouterData<
F,
HelcimPaymentsResponse,
- types::SetupMandateRequestData,
- types::PaymentsResponseData,
+ SetupMandateRequestData,
+ PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(types::PaymentsResponseData::TransactionResponse {
- resource_id: types::ResponseId::ConnectorTransactionId(
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(
item.response.transaction_id.to_string(),
),
redirection_data: None,
@@ -388,30 +392,25 @@ pub struct HelcimMetaData {
impl<F>
TryFrom<
- types::ResponseRouterData<
- F,
- HelcimPaymentsResponse,
- types::PaymentsAuthorizeData,
- types::PaymentsResponseData,
- >,
- > for types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>
+ ResponseRouterData<F, HelcimPaymentsResponse, PaymentsAuthorizeData, PaymentsResponseData>,
+ > for RouterData<F, PaymentsAuthorizeData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::ResponseRouterData<
+ item: ResponseRouterData<
F,
HelcimPaymentsResponse,
- types::PaymentsAuthorizeData,
- types::PaymentsResponseData,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
//PreAuth Transaction ID is stored in connector metadata
//Initially resource_id is stored as NoResponseID for manual capture
//After Capture Transaction is completed it is updated to store the Capture ID
let resource_id = if item.data.request.is_auto_capture()? {
- types::ResponseId::ConnectorTransactionId(item.response.transaction_id.to_string())
+ ResponseId::ConnectorTransactionId(item.response.transaction_id.to_string())
} else {
- types::ResponseId::NoResponseId
+ ResponseId::NoResponseId
};
let connector_metadata = if !item.data.request.is_auto_capture()? {
Some(serde_json::json!(HelcimMetaData {
@@ -421,7 +420,7 @@ impl<F>
None
};
Ok(Self {
- response: Ok(types::PaymentsResponseData::TransactionResponse {
+ response: Ok(PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: None,
mandate_reference: None,
@@ -459,28 +458,17 @@ impl<F>
// }
impl<F>
- TryFrom<
- types::ResponseRouterData<
- F,
- HelcimPaymentsResponse,
- types::PaymentsSyncData,
- types::PaymentsResponseData,
- >,
- > for types::RouterData<F, types::PaymentsSyncData, types::PaymentsResponseData>
+ TryFrom<ResponseRouterData<F, HelcimPaymentsResponse, PaymentsSyncData, PaymentsResponseData>>
+ for RouterData<F, PaymentsSyncData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::ResponseRouterData<
- F,
- HelcimPaymentsResponse,
- types::PaymentsSyncData,
- types::PaymentsResponseData,
- >,
+ item: ResponseRouterData<F, HelcimPaymentsResponse, PaymentsSyncData, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
match item.data.request.sync_type {
- types::SyncRequestType::SinglePaymentSync => Ok(Self {
- response: Ok(types::PaymentsResponseData::TransactionResponse {
- resource_id: types::ResponseId::ConnectorTransactionId(
+ hyperswitch_domain_models::router_request_types::SyncRequestType::SinglePaymentSync => Ok(Self {
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(
item.response.transaction_id.to_string(),
),
redirection_data: None,
@@ -494,7 +482,7 @@ impl<F>
status: enums::AttemptStatus::from(item.response),
..item.data
}),
- types::SyncRequestType::MultipleCaptureSync(_) => {
+ hyperswitch_domain_models::router_request_types::SyncRequestType::MultipleCaptureSync(_) => {
Err(errors::ConnectorError::NotImplemented(
"manual multiple capture sync".to_string(),
)
@@ -502,7 +490,7 @@ impl<F>
// let capture_sync_response_list =
// utils::construct_captures_response_hashmap(vec![item.response]);
// Ok(Self {
- // response: Ok(types::PaymentsResponseData::MultipleCaptureResponse {
+ // response: Ok(PaymentsResponseData::MultipleCaptureResponse {
// capture_sync_response_list,
// }),
// ..item.data
@@ -522,11 +510,9 @@ pub struct HelcimCaptureRequest {
ecommerce: Option<bool>,
}
-impl TryFrom<&HelcimRouterData<&types::PaymentsCaptureRouterData>> for HelcimCaptureRequest {
+impl TryFrom<&HelcimRouterData<&PaymentsCaptureRouterData>> for HelcimCaptureRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(
- item: &HelcimRouterData<&types::PaymentsCaptureRouterData>,
- ) -> Result<Self, Self::Error> {
+ fn try_from(item: &HelcimRouterData<&PaymentsCaptureRouterData>) -> Result<Self, Self::Error> {
let ip_address = item
.router_data
.request
@@ -548,26 +534,21 @@ impl TryFrom<&HelcimRouterData<&types::PaymentsCaptureRouterData>> for HelcimCap
impl<F>
TryFrom<
- types::ResponseRouterData<
- F,
- HelcimPaymentsResponse,
- types::PaymentsCaptureData,
- types::PaymentsResponseData,
- >,
- > for types::RouterData<F, types::PaymentsCaptureData, types::PaymentsResponseData>
+ ResponseRouterData<F, HelcimPaymentsResponse, PaymentsCaptureData, PaymentsResponseData>,
+ > for RouterData<F, PaymentsCaptureData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::ResponseRouterData<
+ item: ResponseRouterData<
F,
HelcimPaymentsResponse,
- types::PaymentsCaptureData,
- types::PaymentsResponseData,
+ PaymentsCaptureData,
+ PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(types::PaymentsResponseData::TransactionResponse {
- resource_id: types::ResponseId::ConnectorTransactionId(
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(
item.response.transaction_id.to_string(),
),
redirection_data: None,
@@ -593,9 +574,9 @@ pub struct HelcimVoidRequest {
ecommerce: Option<bool>,
}
-impl TryFrom<&types::PaymentsCancelRouterData> for HelcimVoidRequest {
+impl TryFrom<&PaymentsCancelRouterData> for HelcimVoidRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &types::PaymentsCancelRouterData) -> Result<Self, Self::Error> {
+ fn try_from(item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {
let ip_address = item.request.get_browser_info()?.get_ip_address()?;
Ok(Self {
card_transaction_id: item
@@ -610,27 +591,21 @@ impl TryFrom<&types::PaymentsCancelRouterData> for HelcimVoidRequest {
}
impl<F>
- TryFrom<
- types::ResponseRouterData<
- F,
- HelcimPaymentsResponse,
- types::PaymentsCancelData,
- types::PaymentsResponseData,
- >,
- > for types::RouterData<F, types::PaymentsCancelData, types::PaymentsResponseData>
+ TryFrom<ResponseRouterData<F, HelcimPaymentsResponse, PaymentsCancelData, PaymentsResponseData>>
+ for RouterData<F, PaymentsCancelData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::ResponseRouterData<
+ item: ResponseRouterData<
F,
HelcimPaymentsResponse,
- types::PaymentsCancelData,
- types::PaymentsResponseData,
+ PaymentsCancelData,
+ PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(types::PaymentsResponseData::TransactionResponse {
- resource_id: types::ResponseId::ConnectorTransactionId(
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(
item.response.transaction_id.to_string(),
),
redirection_data: None,
@@ -659,11 +634,9 @@ pub struct HelcimRefundRequest {
ecommerce: Option<bool>,
}
-impl<F> TryFrom<&HelcimRouterData<&types::RefundsRouterData<F>>> for HelcimRefundRequest {
+impl<F> TryFrom<&HelcimRouterData<&RefundsRouterData<F>>> for HelcimRefundRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(
- item: &HelcimRouterData<&types::RefundsRouterData<F>>,
- ) -> Result<Self, Self::Error> {
+ fn try_from(item: &HelcimRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
let original_transaction_id = item
.router_data
.request
@@ -710,15 +683,13 @@ impl From<RefundResponse> for enums::RefundStatus {
}
}
-impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
- for types::RefundsRouterData<api::Execute>
-{
+impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::RefundsResponseRouterData<api::Execute, RefundResponse>,
+ item: RefundsResponseRouterData<Execute, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(types::RefundsResponseData {
+ response: Ok(RefundsResponseData {
connector_refund_id: item.response.transaction_id.to_string(),
refund_status: enums::RefundStatus::from(item.response),
}),
@@ -727,15 +698,13 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
}
}
-impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>
- for types::RefundsRouterData<api::RSync>
-{
+impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::RefundsResponseRouterData<api::RSync, RefundResponse>,
+ item: RefundsResponseRouterData<RSync, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(types::RefundsResponseData {
+ response: Ok(RefundsResponseData {
connector_refund_id: item.response.transaction_id.to_string(),
refund_status: enums::RefundStatus::from(item.response),
}),
diff --git a/crates/hyperswitch_connectors/src/constants.rs b/crates/hyperswitch_connectors/src/constants.rs
new file mode 100644
index 0000000000..9f5285bd2e
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/constants.rs
@@ -0,0 +1,6 @@
+/// Header Constants
+pub(crate) mod headers {
+ pub(crate) const API_TOKEN: &str = "Api-Token";
+ pub(crate) const CONTENT_TYPE: &str = "Content-Type";
+ pub(crate) const IDEMPOTENCY_KEY: &str = "Idempotency-Key";
+}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
new file mode 100644
index 0000000000..2273b8c31d
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -0,0 +1,562 @@
+// impl api::PaymentIncrementalAuthorization for Helcim {}
+// impl api::ConnectorCustomer for Helcim {}
+// impl api::PaymentsPreProcessing for Helcim {}
+// impl api::PaymentReject for Helcim {}
+// impl api::PaymentApprove for Helcim {}
+#[cfg(feature = "frm")]
+use hyperswitch_domain_models::{
+ router_flow_types::fraud_check::{Checkout, Fulfillment, RecordReturn, Sale, Transaction},
+ router_request_types::fraud_check::{
+ FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckRecordReturnData,
+ FraudCheckSaleData, FraudCheckTransactionData,
+ },
+ router_response_types::fraud_check::FraudCheckResponseData,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::{
+ router_flow_types::payouts::{
+ PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount,
+ PoSync,
+ },
+ router_request_types::PayoutsData,
+ router_response_types::PayoutsResponseData,
+};
+use hyperswitch_domain_models::{
+ router_flow_types::{
+ dispute::{Accept, Defend, Evidence},
+ files::{Retrieve, Upload},
+ mandate_revoke::MandateRevoke,
+ payments::{
+ Approve, AuthorizeSessionToken, CompleteAuthorize, CreateConnectorCustomer,
+ IncrementalAuthorization, PostProcessing, PreProcessing, Reject,
+ },
+ webhooks::VerifyWebhookSource,
+ },
+ router_request_types::{
+ AcceptDisputeRequestData, AuthorizeSessionTokenData, CompleteAuthorizeData,
+ ConnectorCustomerData, DefendDisputeRequestData, MandateRevokeRequestData,
+ PaymentsApproveData, PaymentsIncrementalAuthorizationData, PaymentsPostProcessingData,
+ PaymentsPreProcessingData, PaymentsRejectData, RetrieveFileRequestData,
+ SubmitEvidenceRequestData, UploadFileRequestData, VerifyWebhookSourceRequestData,
+ },
+ router_response_types::{
+ AcceptDisputeResponse, DefendDisputeResponse, MandateRevokeResponseData,
+ PaymentsResponseData, RetrieveFileResponse, SubmitEvidenceResponse, UploadFileResponse,
+ VerifyWebhookSourceResponseData,
+ },
+};
+#[cfg(feature = "frm")]
+use hyperswitch_interfaces::api::fraud_check::{
+ FraudCheckCheckout, FraudCheckFulfillment, FraudCheckRecordReturn, FraudCheckSale,
+ FraudCheckTransaction,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_interfaces::api::payouts::{
+ PayoutCancel, PayoutCreate, PayoutEligibility, PayoutFulfill, PayoutQuote, PayoutRecipient,
+ PayoutRecipientAccount, PayoutSync,
+};
+use hyperswitch_interfaces::api::{
+ self,
+ disputes::{AcceptDispute, DefendDispute, Dispute, SubmitEvidence},
+ files::{FileUpload, RetrieveFile, UploadFile},
+ payments::{
+ ConnectorCustomer, PaymentApprove, PaymentAuthorizeSessionToken,
+ PaymentIncrementalAuthorization, PaymentReject, PaymentsCompleteAuthorize,
+ PaymentsPostProcessing, PaymentsPreProcessing,
+ },
+ ConnectorIntegration, ConnectorMandateRevoke,
+};
+
+macro_rules! default_imp_for_authorize_session_token {
+ ($($path:ident::$connector:ident),*) => {
+ $( impl PaymentAuthorizeSessionToken for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ AuthorizeSessionToken,
+ AuthorizeSessionTokenData,
+ PaymentsResponseData
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_authorize_session_token!(connectors::Helcim);
+
+use crate::connectors;
+macro_rules! default_imp_for_complete_authorize {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PaymentsCompleteAuthorize for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ CompleteAuthorize,
+ CompleteAuthorizeData,
+ PaymentsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_complete_authorize!(connectors::Helcim);
+
+macro_rules! default_imp_for_incremental_authorization {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PaymentIncrementalAuthorization for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ IncrementalAuthorization,
+ PaymentsIncrementalAuthorizationData,
+ PaymentsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_incremental_authorization!(connectors::Helcim);
+
+macro_rules! default_imp_for_create_customer {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl ConnectorCustomer for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ CreateConnectorCustomer,
+ ConnectorCustomerData,
+ PaymentsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_create_customer!(connectors::Helcim);
+
+macro_rules! default_imp_for_pre_processing_steps{
+ ($($path:ident::$connector:ident),*)=> {
+ $(
+ impl PaymentsPreProcessing for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PreProcessing,
+ PaymentsPreProcessingData,
+ PaymentsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_pre_processing_steps!(connectors::Helcim);
+
+macro_rules! default_imp_for_post_processing_steps{
+ ($($path:ident::$connector:ident),*)=> {
+ $(
+ impl PaymentsPostProcessing for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PostProcessing,
+ PaymentsPostProcessingData,
+ PaymentsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_post_processing_steps!(connectors::Helcim);
+
+macro_rules! default_imp_for_approve {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PaymentApprove for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Approve,
+ PaymentsApproveData,
+ PaymentsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_approve!(connectors::Helcim);
+
+macro_rules! default_imp_for_reject {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PaymentReject for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Reject,
+ PaymentsRejectData,
+ PaymentsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_reject!(connectors::Helcim);
+
+macro_rules! default_imp_for_webhook_source_verification {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl api::ConnectorVerifyWebhookSource for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ VerifyWebhookSource,
+ VerifyWebhookSourceRequestData,
+ VerifyWebhookSourceResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_webhook_source_verification!(connectors::Helcim);
+
+macro_rules! default_imp_for_accept_dispute {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl Dispute for $path::$connector {}
+ impl AcceptDispute for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Accept,
+ AcceptDisputeRequestData,
+ AcceptDisputeResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_accept_dispute!(connectors::Helcim);
+
+macro_rules! default_imp_for_submit_evidence {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl SubmitEvidence for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Evidence,
+ SubmitEvidenceRequestData,
+ SubmitEvidenceResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_submit_evidence!(connectors::Helcim);
+
+macro_rules! default_imp_for_defend_dispute {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl DefendDispute for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Defend,
+ DefendDisputeRequestData,
+ DefendDisputeResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_defend_dispute!(connectors::Helcim);
+
+macro_rules! default_imp_for_file_upload {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FileUpload for $path::$connector {}
+ impl UploadFile for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Upload,
+ UploadFileRequestData,
+ UploadFileResponse,
+ > for $path::$connector
+ {}
+ impl RetrieveFile for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Retrieve,
+ RetrieveFileRequestData,
+ RetrieveFileResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_file_upload!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_create {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutCreate for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoCreate,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_create!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_retrieve {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutSync for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoSync,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_retrieve!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_eligibility {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutEligibility for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoEligibility,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_eligibility!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_fulfill {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutFulfill for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoFulfill,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_fulfill!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_cancel {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutCancel for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoCancel,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_cancel!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_quote {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutQuote for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoQuote,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_quote!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_recipient {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutRecipient for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoRecipient,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_recipient!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_payouts_recipient_account {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutRecipientAccount for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ PoRecipientAccount,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_payouts_recipient_account!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_frm_sale {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckSale for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Sale,
+ FraudCheckSaleData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_frm_sale!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_frm_checkout {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckCheckout for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Checkout,
+ FraudCheckCheckoutData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_frm_checkout!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_frm_transaction {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckTransaction for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Transaction,
+ FraudCheckTransactionData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_frm_transaction!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_frm_fulfillment {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckFulfillment for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ Fulfillment,
+ FraudCheckFulfillmentData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_frm_fulfillment!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_frm_record_return {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckRecordReturn for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ RecordReturn,
+ FraudCheckRecordReturnData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_frm_record_return!(connectors::Helcim);
+
+macro_rules! default_imp_for_revoking_mandates {
+ ($($path:ident::$connector:ident),*) => {
+ $( impl ConnectorMandateRevoke for $path::$connector {}
+ impl
+ ConnectorIntegration<
+ MandateRevoke,
+ MandateRevokeRequestData,
+ MandateRevokeResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_revoking_mandates!(connectors::Helcim);
diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
new file mode 100644
index 0000000000..df72d3d9c4
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
@@ -0,0 +1,592 @@
+use hyperswitch_domain_models::{
+ router_data::AccessToken,
+ router_data_v2::{
+ flow_common_types::{
+ DisputesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData,
+ WebhookSourceVerifyData,
+ },
+ AccessTokenFlowData, FilesFlowData,
+ },
+ router_flow_types::{
+ dispute::{Accept, Defend, Evidence},
+ files::{Retrieve, Upload},
+ mandate_revoke::MandateRevoke,
+ payments::{
+ Approve, Authorize, AuthorizeSessionToken, Capture, CompleteAuthorize,
+ CreateConnectorCustomer, IncrementalAuthorization, PSync, PaymentMethodToken,
+ PostProcessing, PreProcessing, Reject, Session, SetupMandate, Void,
+ },
+ refunds::{Execute, RSync},
+ webhooks::VerifyWebhookSource,
+ AccessTokenAuth,
+ },
+ router_request_types::{
+ AcceptDisputeRequestData, AccessTokenRequestData, AuthorizeSessionTokenData,
+ CompleteAuthorizeData, ConnectorCustomerData, DefendDisputeRequestData,
+ MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsApproveData,
+ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData,
+ PaymentsIncrementalAuthorizationData, PaymentsPostProcessingData,
+ PaymentsPreProcessingData, PaymentsRejectData, PaymentsSessionData, PaymentsSyncData,
+ RefundsData, RetrieveFileRequestData, SetupMandateRequestData, SubmitEvidenceRequestData,
+ UploadFileRequestData, VerifyWebhookSourceRequestData,
+ },
+ router_response_types::{
+ AcceptDisputeResponse, DefendDisputeResponse, MandateRevokeResponseData,
+ PaymentsResponseData, RefundsResponseData, RetrieveFileResponse, SubmitEvidenceResponse,
+ UploadFileResponse, VerifyWebhookSourceResponseData,
+ },
+};
+#[cfg(feature = "frm")]
+use hyperswitch_domain_models::{
+ router_data_v2::FrmFlowData,
+ router_flow_types::fraud_check::{Checkout, Fulfillment, RecordReturn, Sale, Transaction},
+ router_request_types::fraud_check::{
+ FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckRecordReturnData,
+ FraudCheckSaleData, FraudCheckTransactionData,
+ },
+ router_response_types::fraud_check::FraudCheckResponseData,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::{
+ router_data_v2::PayoutFlowData,
+ router_flow_types::payouts::{
+ PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount,
+ PoSync,
+ },
+ router_request_types::PayoutsData,
+ router_response_types::PayoutsResponseData,
+};
+#[cfg(feature = "frm")]
+use hyperswitch_interfaces::api::fraud_check_v2::{
+ FraudCheckCheckoutV2, FraudCheckFulfillmentV2, FraudCheckRecordReturnV2, FraudCheckSaleV2,
+ FraudCheckTransactionV2,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_interfaces::api::payouts_v2::{
+ PayoutCancelV2, PayoutCreateV2, PayoutEligibilityV2, PayoutFulfillV2, PayoutQuoteV2,
+ PayoutRecipientAccountV2, PayoutRecipientV2, PayoutSyncV2,
+};
+use hyperswitch_interfaces::{
+ api::{
+ disputes_v2::{AcceptDisputeV2, DefendDisputeV2, DisputeV2, SubmitEvidenceV2},
+ files_v2::{FileUploadV2, RetrieveFileV2, UploadFileV2},
+ payments_v2::{
+ ConnectorCustomerV2, MandateSetupV2, PaymentApproveV2, PaymentAuthorizeSessionTokenV2,
+ PaymentAuthorizeV2, PaymentCaptureV2, PaymentIncrementalAuthorizationV2,
+ PaymentRejectV2, PaymentSessionV2, PaymentSyncV2, PaymentTokenV2, PaymentV2,
+ PaymentVoidV2, PaymentsCompleteAuthorizeV2, PaymentsPostProcessingV2,
+ PaymentsPreProcessingV2,
+ },
+ refunds_v2::{RefundExecuteV2, RefundSyncV2, RefundV2},
+ ConnectorAccessTokenV2, ConnectorMandateRevokeV2, ConnectorVerifyWebhookSourceV2,
+ },
+ connector_integration_v2::ConnectorIntegrationV2,
+};
+
+use crate::connectors;
+
+macro_rules! default_imp_for_new_connector_integration_payment {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PaymentV2 for $path::$connector{}
+ impl PaymentAuthorizeV2 for $path::$connector{}
+ impl PaymentAuthorizeSessionTokenV2 for $path::$connector{}
+ impl PaymentSyncV2 for $path::$connector{}
+ impl PaymentVoidV2 for $path::$connector{}
+ impl PaymentApproveV2 for $path::$connector{}
+ impl PaymentRejectV2 for $path::$connector{}
+ impl PaymentCaptureV2 for $path::$connector{}
+ impl PaymentSessionV2 for $path::$connector{}
+ impl MandateSetupV2 for $path::$connector{}
+ impl PaymentIncrementalAuthorizationV2 for $path::$connector{}
+ impl PaymentsCompleteAuthorizeV2 for $path::$connector{}
+ impl PaymentTokenV2 for $path::$connector{}
+ impl ConnectorCustomerV2 for $path::$connector{}
+ impl PaymentsPreProcessingV2 for $path::$connector{}
+ impl PaymentsPostProcessingV2 for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<Authorize,PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<PSync,PaymentFlowData, PaymentsSyncData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<Void, PaymentFlowData, PaymentsCancelData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<Approve,PaymentFlowData, PaymentsApproveData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<Reject,PaymentFlowData, PaymentsRejectData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<Capture,PaymentFlowData, PaymentsCaptureData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<Session,PaymentFlowData, PaymentsSessionData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<SetupMandate,PaymentFlowData, SetupMandateRequestData, PaymentsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<
+ IncrementalAuthorization,
+ PaymentFlowData,
+ PaymentsIncrementalAuthorizationData,
+ PaymentsResponseData,
+ >
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<
+ CompleteAuthorize,
+ PaymentFlowData,
+ CompleteAuthorizeData,
+ PaymentsResponseData,
+ > for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<
+ PaymentMethodToken,
+ PaymentFlowData,
+ PaymentMethodTokenizationData,
+ PaymentsResponseData,
+ > for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<
+ CreateConnectorCustomer,
+ PaymentFlowData,
+ ConnectorCustomerData,
+ PaymentsResponseData,
+ > for $path::$connector{}
+ impl ConnectorIntegrationV2<
+ PreProcessing,
+ PaymentFlowData,
+ PaymentsPreProcessingData,
+ PaymentsResponseData,
+ > for $path::$connector{}
+ impl ConnectorIntegrationV2<
+ PostProcessing,
+ PaymentFlowData,
+ PaymentsPostProcessingData,
+ PaymentsResponseData,
+ > for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<
+ AuthorizeSessionToken,
+ PaymentFlowData,
+ AuthorizeSessionTokenData,
+ PaymentsResponseData
+ > for $path::$connector{}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_payment!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_refund {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl RefundV2 for $path::$connector{}
+ impl RefundExecuteV2 for $path::$connector{}
+ impl RefundSyncV2 for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<Execute, RefundFlowData, RefundsData, RefundsResponseData>
+ for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<RSync, RefundFlowData, RefundsData, RefundsResponseData>
+ for $path::$connector{}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_refund!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_connector_access_token {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl ConnectorAccessTokenV2 for $path::$connector{}
+ impl
+ ConnectorIntegrationV2<AccessTokenAuth, AccessTokenFlowData, AccessTokenRequestData, AccessToken>
+ for $path::$connector{}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_connector_access_token!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_accept_dispute {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl DisputeV2 for $path::$connector {}
+ impl AcceptDisputeV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Accept,
+ DisputesFlowData,
+ AcceptDisputeRequestData,
+ AcceptDisputeResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_accept_dispute!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_submit_evidence {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl SubmitEvidenceV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Evidence,
+ DisputesFlowData,
+ SubmitEvidenceRequestData,
+ SubmitEvidenceResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_submit_evidence!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_defend_dispute {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl DefendDisputeV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Defend,
+ DisputesFlowData,
+ DefendDisputeRequestData,
+ DefendDisputeResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_defend_dispute!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_file_upload {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FileUploadV2 for $path::$connector {}
+ impl UploadFileV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Upload,
+ FilesFlowData,
+ UploadFileRequestData,
+ UploadFileResponse,
+ > for $path::$connector
+ {}
+ impl RetrieveFileV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Retrieve,
+ FilesFlowData,
+ RetrieveFileRequestData,
+ RetrieveFileResponse,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_file_upload!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_create {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutCreateV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoCreate,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_create!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_eligibility {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutEligibilityV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoEligibility,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_eligibility!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_fulfill {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutFulfillV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoFulfill,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_fulfill!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_cancel {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutCancelV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoCancel,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_cancel!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_quote {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutQuoteV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoQuote,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_quote!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_recipient {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutRecipientV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoRecipient,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_recipient!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_sync {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutSyncV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoSync,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_sync!(connectors::Helcim);
+
+#[cfg(feature = "payouts")]
+macro_rules! default_imp_for_new_connector_integration_payouts_recipient_account {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl PayoutRecipientAccountV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ PoRecipientAccount,
+ PayoutFlowData,
+ PayoutsData,
+ PayoutsResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "payouts")]
+default_imp_for_new_connector_integration_payouts_recipient_account!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_webhook_source_verification {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl ConnectorVerifyWebhookSourceV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ VerifyWebhookSource,
+ WebhookSourceVerifyData,
+ VerifyWebhookSourceRequestData,
+ VerifyWebhookSourceResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_webhook_source_verification!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_new_connector_integration_frm_sale {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckSaleV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Sale,
+ FrmFlowData,
+ FraudCheckSaleData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_new_connector_integration_frm_sale!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_new_connector_integration_frm_checkout {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckCheckoutV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Checkout,
+ FrmFlowData,
+ FraudCheckCheckoutData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_new_connector_integration_frm_checkout!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_new_connector_integration_frm_transaction {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckTransactionV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Transaction,
+ FrmFlowData,
+ FraudCheckTransactionData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_new_connector_integration_frm_transaction!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_new_connector_integration_frm_fulfillment {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckFulfillmentV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ Fulfillment,
+ FrmFlowData,
+ FraudCheckFulfillmentData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_new_connector_integration_frm_fulfillment!(connectors::Helcim);
+
+#[cfg(feature = "frm")]
+macro_rules! default_imp_for_new_connector_integration_frm_record_return {
+ ($($path:ident::$connector:ident),*) => {
+ $(
+ impl FraudCheckRecordReturnV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ RecordReturn,
+ FrmFlowData,
+ FraudCheckRecordReturnData,
+ FraudCheckResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+#[cfg(feature = "frm")]
+default_imp_for_new_connector_integration_frm_record_return!(connectors::Helcim);
+
+macro_rules! default_imp_for_new_connector_integration_revoking_mandates {
+ ($($path:ident::$connector:ident),*) => {
+ $( impl ConnectorMandateRevokeV2 for $path::$connector {}
+ impl
+ ConnectorIntegrationV2<
+ MandateRevoke,
+ MandateRevokeFlowData,
+ MandateRevokeRequestData,
+ MandateRevokeResponseData,
+ > for $path::$connector
+ {}
+ )*
+ };
+}
+
+default_imp_for_new_connector_integration_revoking_mandates!(connectors::Helcim);
diff --git a/crates/hyperswitch_connectors/src/lib.rs b/crates/hyperswitch_connectors/src/lib.rs
new file mode 100644
index 0000000000..aa0ff7e975
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/lib.rs
@@ -0,0 +1,8 @@
+//! Hyperswitch connectors
+
+pub mod connectors;
+pub mod constants;
+pub mod default_implementations;
+pub mod default_implementations_v2;
+pub mod types;
+pub mod utils;
diff --git a/crates/hyperswitch_connectors/src/types.rs b/crates/hyperswitch_connectors/src/types.rs
new file mode 100644
index 0000000000..3238bd5e82
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/types.rs
@@ -0,0 +1,14 @@
+use hyperswitch_domain_models::{
+ router_data::RouterData, router_request_types::RefundsData,
+ router_response_types::RefundsResponseData,
+};
+
+pub(crate) type RefundsResponseRouterData<F, R> =
+ ResponseRouterData<F, R, RefundsData, RefundsResponseData>;
+
+// TODO: Remove `ResponseRouterData` from router crate after all the related type aliases are moved to this crate.
+pub struct ResponseRouterData<Flow, R, Request, Response> {
+ pub response: R,
+ pub data: RouterData<Flow, Request, Response>,
+ pub http_code: u16,
+}
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
new file mode 100644
index 0000000000..0b8ecac9b0
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -0,0 +1,1077 @@
+use api_models::payments::{self, Address, AddressDetails, OrderDetailsWithAmount, PhoneDetails};
+use common_enums::{enums, enums::FutureUsage};
+use common_utils::{
+ errors::ReportSwitchExt,
+ ext_traits::{OptionExt, ValueExt},
+ id_type,
+ pii::{self, Email, IpAddress},
+};
+use error_stack::ResultExt;
+use hyperswitch_domain_models::{
+ payment_method_data::{Card, PaymentMethodData},
+ router_data::{PaymentMethodToken, RecurringMandatePaymentData},
+ router_request_types::{
+ AuthenticationData, BrowserInformation, PaymentsAuthorizeData, PaymentsCancelData,
+ PaymentsCaptureData, RefundsData, SetupMandateRequestData,
+ },
+};
+use hyperswitch_interfaces::{api, errors};
+use masking::{ExposeInterface, PeekInterface, Secret};
+
+type Error = error_stack::Report<errors::ConnectorError>;
+
+pub(crate) fn construct_not_supported_error_report(
+ capture_method: enums::CaptureMethod,
+ connector_name: &'static str,
+) -> error_stack::Report<errors::ConnectorError> {
+ errors::ConnectorError::NotSupported {
+ message: capture_method.to_string(),
+ connector: connector_name,
+ }
+ .into()
+}
+
+pub(crate) fn get_amount_as_f64(
+ currency_unit: &api::CurrencyUnit,
+ amount: i64,
+ currency: enums::Currency,
+) -> Result<f64, error_stack::Report<errors::ConnectorError>> {
+ let amount = match currency_unit {
+ api::CurrencyUnit::Base => to_currency_base_unit_asf64(amount, currency)?,
+ api::CurrencyUnit::Minor => u32::try_from(amount)
+ .change_context(errors::ConnectorError::ParsingFailed)?
+ .into(),
+ };
+ Ok(amount)
+}
+
+pub(crate) fn to_currency_base_unit_asf64(
+ amount: i64,
+ currency: enums::Currency,
+) -> Result<f64, error_stack::Report<errors::ConnectorError>> {
+ currency
+ .to_currency_base_unit_asf64(amount)
+ .change_context(errors::ConnectorError::ParsingFailed)
+}
+
+pub(crate) fn missing_field_err(
+ message: &'static str,
+) -> Box<dyn Fn() -> error_stack::Report<errors::ConnectorError> + '_> {
+ Box::new(move || {
+ errors::ConnectorError::MissingRequiredField {
+ field_name: message,
+ }
+ .into()
+ })
+}
+
+pub(crate) const SELECTED_PAYMENT_METHOD: &str = "Selected payment method";
+
+pub(crate) fn get_unimplemented_payment_method_error_message(connector: &str) -> String {
+ format!("{} through {}", SELECTED_PAYMENT_METHOD, connector)
+}
+
+pub(crate) fn to_connector_meta<T>(connector_meta: Option<serde_json::Value>) -> Result<T, Error>
+where
+ T: serde::de::DeserializeOwned,
+{
+ let json = connector_meta.ok_or_else(missing_field_err("connector_meta_data"))?;
+ json.parse_value(std::any::type_name::<T>()).switch()
+}
+
+// TODO: Make all traits as `pub(crate) trait` once all connectors are moved.
+pub trait RouterData {
+ fn get_billing(&self) -> Result<&Address, Error>;
+ fn get_billing_country(&self) -> Result<api_models::enums::CountryAlpha2, Error>;
+ fn get_billing_phone(&self) -> Result<&PhoneDetails, Error>;
+ fn get_description(&self) -> Result<String, Error>;
+ fn get_return_url(&self) -> Result<String, Error>;
+ fn get_billing_address(&self) -> Result<&AddressDetails, Error>;
+ fn get_shipping_address(&self) -> Result<&AddressDetails, Error>;
+ fn get_shipping_address_with_phone_number(&self) -> Result<&Address, Error>;
+ fn get_connector_meta(&self) -> Result<pii::SecretSerdeValue, Error>;
+ fn get_session_token(&self) -> Result<String, Error>;
+ fn get_billing_first_name(&self) -> Result<Secret<String>, Error>;
+ fn get_billing_full_name(&self) -> Result<Secret<String>, Error>;
+ fn get_billing_last_name(&self) -> Result<Secret<String>, Error>;
+ fn get_billing_line1(&self) -> Result<Secret<String>, Error>;
+ fn get_billing_city(&self) -> Result<String, Error>;
+ fn get_billing_email(&self) -> Result<Email, Error>;
+ fn get_billing_phone_number(&self) -> Result<Secret<String>, Error>;
+ fn to_connector_meta<T>(&self) -> Result<T, Error>
+ where
+ T: serde::de::DeserializeOwned;
+ fn is_three_ds(&self) -> bool;
+ fn get_payment_method_token(&self) -> Result<PaymentMethodToken, Error>;
+ fn get_customer_id(&self) -> Result<id_type::CustomerId, Error>;
+ fn get_connector_customer_id(&self) -> Result<String, Error>;
+ fn get_preprocessing_id(&self) -> Result<String, Error>;
+ fn get_recurring_mandate_payment_data(&self) -> Result<RecurringMandatePaymentData, Error>;
+ #[cfg(feature = "payouts")]
+ fn get_payout_method_data(&self) -> Result<api_models::payouts::PayoutMethodData, Error>;
+ #[cfg(feature = "payouts")]
+ fn get_quote_id(&self) -> Result<String, Error>;
+
+ fn get_optional_billing(&self) -> Option<&Address>;
+ fn get_optional_shipping(&self) -> Option<&Address>;
+ fn get_optional_shipping_line1(&self) -> Option<Secret<String>>;
+ fn get_optional_shipping_line2(&self) -> Option<Secret<String>>;
+ fn get_optional_shipping_city(&self) -> Option<String>;
+ fn get_optional_shipping_country(&self) -> Option<enums::CountryAlpha2>;
+ fn get_optional_shipping_zip(&self) -> Option<Secret<String>>;
+ fn get_optional_shipping_state(&self) -> Option<Secret<String>>;
+ fn get_optional_shipping_first_name(&self) -> Option<Secret<String>>;
+ fn get_optional_shipping_last_name(&self) -> Option<Secret<String>>;
+ fn get_optional_shipping_phone_number(&self) -> Option<Secret<String>>;
+ fn get_optional_shipping_email(&self) -> Option<Email>;
+
+ fn get_optional_billing_full_name(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_line1(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_line2(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_city(&self) -> Option<String>;
+ fn get_optional_billing_country(&self) -> Option<enums::CountryAlpha2>;
+ fn get_optional_billing_zip(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_state(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_first_name(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_last_name(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_phone_number(&self) -> Option<Secret<String>>;
+ fn get_optional_billing_email(&self) -> Option<Email>;
+}
+
+impl<Flow, Request, Response> RouterData
+ for hyperswitch_domain_models::router_data::RouterData<Flow, Request, Response>
+{
+ fn get_billing(&self) -> Result<&Address, Error> {
+ self.address
+ .get_payment_method_billing()
+ .ok_or_else(missing_field_err("billing"))
+ }
+
+ fn get_billing_country(&self) -> Result<api_models::enums::CountryAlpha2, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|a| a.address.as_ref())
+ .and_then(|ad| ad.country)
+ .ok_or_else(missing_field_err(
+ "payment_method_data.billing.address.country",
+ ))
+ }
+
+ fn get_billing_phone(&self) -> Result<&PhoneDetails, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|a| a.phone.as_ref())
+ .ok_or_else(missing_field_err("billing.phone"))
+ }
+
+ fn get_optional_billing(&self) -> Option<&Address> {
+ self.address.get_payment_method_billing()
+ }
+
+ fn get_optional_shipping(&self) -> Option<&Address> {
+ self.address.get_shipping()
+ }
+
+ fn get_optional_shipping_first_name(&self) -> Option<Secret<String>> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.first_name)
+ })
+ }
+
+ fn get_optional_shipping_last_name(&self) -> Option<Secret<String>> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.last_name)
+ })
+ }
+
+ fn get_optional_shipping_line1(&self) -> Option<Secret<String>> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.line1)
+ })
+ }
+
+ fn get_optional_shipping_line2(&self) -> Option<Secret<String>> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.line2)
+ })
+ }
+
+ fn get_optional_shipping_city(&self) -> Option<String> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.city)
+ })
+ }
+
+ fn get_optional_shipping_state(&self) -> Option<Secret<String>> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.state)
+ })
+ }
+
+ fn get_optional_shipping_country(&self) -> Option<enums::CountryAlpha2> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.country)
+ })
+ }
+
+ fn get_optional_shipping_zip(&self) -> Option<Secret<String>> {
+ self.address.get_shipping().and_then(|shipping_address| {
+ shipping_address
+ .clone()
+ .address
+ .and_then(|shipping_details| shipping_details.zip)
+ })
+ }
+
+ fn get_optional_shipping_email(&self) -> Option<Email> {
+ self.address
+ .get_shipping()
+ .and_then(|shipping_address| shipping_address.clone().email)
+ }
+
+ fn get_optional_shipping_phone_number(&self) -> Option<Secret<String>> {
+ self.address
+ .get_shipping()
+ .and_then(|shipping_address| shipping_address.clone().phone)
+ .and_then(|phone_details| phone_details.get_number_with_country_code().ok())
+ }
+
+ fn get_description(&self) -> Result<String, Error> {
+ self.description
+ .clone()
+ .ok_or_else(missing_field_err("description"))
+ }
+ fn get_return_url(&self) -> Result<String, Error> {
+ self.return_url
+ .clone()
+ .ok_or_else(missing_field_err("return_url"))
+ }
+ fn get_billing_address(&self) -> Result<&AddressDetails, Error> {
+ self.address
+ .get_payment_method_billing()
+ .as_ref()
+ .and_then(|a| a.address.as_ref())
+ .ok_or_else(missing_field_err("billing.address"))
+ }
+
+ fn get_connector_meta(&self) -> Result<pii::SecretSerdeValue, Error> {
+ self.connector_meta_data
+ .clone()
+ .ok_or_else(missing_field_err("connector_meta_data"))
+ }
+
+ fn get_session_token(&self) -> Result<String, Error> {
+ self.session_token
+ .clone()
+ .ok_or_else(missing_field_err("session_token"))
+ }
+
+ fn get_billing_first_name(&self) -> Result<Secret<String>, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.first_name.clone())
+ })
+ .ok_or_else(missing_field_err(
+ "payment_method_data.billing.address.first_name",
+ ))
+ }
+
+ fn get_billing_full_name(&self) -> Result<Secret<String>, Error> {
+ self.get_optional_billing()
+ .and_then(|billing_details| billing_details.address.as_ref())
+ .and_then(|billing_address| billing_address.get_optional_full_name())
+ .ok_or_else(missing_field_err(
+ "payment_method_data.billing.address.first_name",
+ ))
+ }
+
+ fn get_billing_last_name(&self) -> Result<Secret<String>, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.last_name.clone())
+ })
+ .ok_or_else(missing_field_err(
+ "payment_method_data.billing.address.last_name",
+ ))
+ }
+
+ fn get_billing_line1(&self) -> Result<Secret<String>, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.line1.clone())
+ })
+ .ok_or_else(missing_field_err(
+ "payment_method_data.billing.address.line1",
+ ))
+ }
+ fn get_billing_city(&self) -> Result<String, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.city)
+ })
+ .ok_or_else(missing_field_err(
+ "payment_method_data.billing.address.city",
+ ))
+ }
+
+ fn get_billing_email(&self) -> Result<Email, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| billing_address.email.clone())
+ .ok_or_else(missing_field_err("payment_method_data.billing.email"))
+ }
+
+ fn get_billing_phone_number(&self) -> Result<Secret<String>, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| billing_address.clone().phone)
+ .map(|phone_details| phone_details.get_number_with_country_code())
+ .transpose()?
+ .ok_or_else(missing_field_err("payment_method_data.billing.phone"))
+ }
+
+ fn get_optional_billing_line1(&self) -> Option<Secret<String>> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.line1)
+ })
+ }
+
+ fn get_optional_billing_line2(&self) -> Option<Secret<String>> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.line2)
+ })
+ }
+
+ fn get_optional_billing_city(&self) -> Option<String> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.city)
+ })
+ }
+
+ fn get_optional_billing_country(&self) -> Option<enums::CountryAlpha2> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.country)
+ })
+ }
+
+ fn get_optional_billing_zip(&self) -> Option<Secret<String>> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.zip)
+ })
+ }
+
+ fn get_optional_billing_state(&self) -> Option<Secret<String>> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.state)
+ })
+ }
+
+ fn get_optional_billing_first_name(&self) -> Option<Secret<String>> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.first_name)
+ })
+ }
+
+ fn get_optional_billing_last_name(&self) -> Option<Secret<String>> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.last_name)
+ })
+ }
+
+ fn get_optional_billing_phone_number(&self) -> Option<Secret<String>> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .phone
+ .and_then(|phone_data| phone_data.number)
+ })
+ }
+
+ fn get_optional_billing_email(&self) -> Option<Email> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| billing_address.clone().email)
+ }
+ fn to_connector_meta<T>(&self) -> Result<T, Error>
+ where
+ T: serde::de::DeserializeOwned,
+ {
+ self.get_connector_meta()?
+ .parse_value(std::any::type_name::<T>())
+ .change_context(errors::ConnectorError::NoConnectorMetaData)
+ }
+
+ fn is_three_ds(&self) -> bool {
+ matches!(self.auth_type, enums::AuthenticationType::ThreeDs)
+ }
+
+ fn get_shipping_address(&self) -> Result<&AddressDetails, Error> {
+ self.address
+ .get_shipping()
+ .and_then(|a| a.address.as_ref())
+ .ok_or_else(missing_field_err("shipping.address"))
+ }
+
+ fn get_shipping_address_with_phone_number(&self) -> Result<&Address, Error> {
+ self.address
+ .get_shipping()
+ .ok_or_else(missing_field_err("shipping"))
+ }
+
+ fn get_payment_method_token(&self) -> Result<PaymentMethodToken, Error> {
+ self.payment_method_token
+ .clone()
+ .ok_or_else(missing_field_err("payment_method_token"))
+ }
+ fn get_customer_id(&self) -> Result<id_type::CustomerId, Error> {
+ self.customer_id
+ .to_owned()
+ .ok_or_else(missing_field_err("customer_id"))
+ }
+ fn get_connector_customer_id(&self) -> Result<String, Error> {
+ self.connector_customer
+ .to_owned()
+ .ok_or_else(missing_field_err("connector_customer_id"))
+ }
+ fn get_preprocessing_id(&self) -> Result<String, Error> {
+ self.preprocessing_id
+ .to_owned()
+ .ok_or_else(missing_field_err("preprocessing_id"))
+ }
+ fn get_recurring_mandate_payment_data(&self) -> Result<RecurringMandatePaymentData, Error> {
+ self.recurring_mandate_payment_data
+ .to_owned()
+ .ok_or_else(missing_field_err("recurring_mandate_payment_data"))
+ }
+
+ fn get_optional_billing_full_name(&self) -> Option<Secret<String>> {
+ self.get_optional_billing()
+ .and_then(|billing_details| billing_details.address.as_ref())
+ .and_then(|billing_address| billing_address.get_optional_full_name())
+ }
+
+ #[cfg(feature = "payouts")]
+ fn get_payout_method_data(&self) -> Result<api_models::payouts::PayoutMethodData, Error> {
+ self.payout_method_data
+ .to_owned()
+ .ok_or_else(missing_field_err("payout_method_data"))
+ }
+ #[cfg(feature = "payouts")]
+ fn get_quote_id(&self) -> Result<String, Error> {
+ self.quote_id
+ .to_owned()
+ .ok_or_else(missing_field_err("quote_id"))
+ }
+}
+
+pub trait CardData {
+ fn get_card_expiry_year_2_digit(&self) -> Result<Secret<String>, errors::ConnectorError>;
+ fn get_card_expiry_month_year_2_digit_with_delimiter(
+ &self,
+ delimiter: String,
+ ) -> Result<Secret<String>, errors::ConnectorError>;
+ fn get_expiry_date_as_yyyymm(&self, delimiter: &str) -> Secret<String>;
+ fn get_expiry_date_as_mmyyyy(&self, delimiter: &str) -> Secret<String>;
+ fn get_expiry_year_4_digit(&self) -> Secret<String>;
+ fn get_expiry_date_as_yymm(&self) -> Result<Secret<String>, errors::ConnectorError>;
+ fn get_expiry_month_as_i8(&self) -> Result<Secret<i8>, Error>;
+ fn get_expiry_year_as_i32(&self) -> Result<Secret<i32>, Error>;
+}
+
+impl CardData for Card {
+ fn get_card_expiry_year_2_digit(&self) -> Result<Secret<String>, errors::ConnectorError> {
+ let binding = self.card_exp_year.clone();
+ let year = binding.peek();
+ Ok(Secret::new(
+ year.get(year.len() - 2..)
+ .ok_or(errors::ConnectorError::RequestEncodingFailed)?
+ .to_string(),
+ ))
+ }
+ fn get_card_expiry_month_year_2_digit_with_delimiter(
+ &self,
+ delimiter: String,
+ ) -> Result<Secret<String>, errors::ConnectorError> {
+ let year = self.get_card_expiry_year_2_digit()?;
+ Ok(Secret::new(format!(
+ "{}{}{}",
+ self.card_exp_month.peek(),
+ delimiter,
+ year.peek()
+ )))
+ }
+ fn get_expiry_date_as_yyyymm(&self, delimiter: &str) -> Secret<String> {
+ let year = self.get_expiry_year_4_digit();
+ Secret::new(format!(
+ "{}{}{}",
+ year.peek(),
+ delimiter,
+ self.card_exp_month.peek()
+ ))
+ }
+ fn get_expiry_date_as_mmyyyy(&self, delimiter: &str) -> Secret<String> {
+ let year = self.get_expiry_year_4_digit();
+ Secret::new(format!(
+ "{}{}{}",
+ self.card_exp_month.peek(),
+ delimiter,
+ year.peek()
+ ))
+ }
+ fn get_expiry_year_4_digit(&self) -> Secret<String> {
+ let mut year = self.card_exp_year.peek().clone();
+ if year.len() == 2 {
+ year = format!("20{}", year);
+ }
+ Secret::new(year)
+ }
+ fn get_expiry_date_as_yymm(&self) -> Result<Secret<String>, errors::ConnectorError> {
+ let year = self.get_card_expiry_year_2_digit()?.expose();
+ let month = self.card_exp_month.clone().expose();
+ Ok(Secret::new(format!("{year}{month}")))
+ }
+ fn get_expiry_month_as_i8(&self) -> Result<Secret<i8>, Error> {
+ self.card_exp_month
+ .peek()
+ .clone()
+ .parse::<i8>()
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)
+ .map(Secret::new)
+ }
+ fn get_expiry_year_as_i32(&self) -> Result<Secret<i32>, Error> {
+ self.card_exp_year
+ .peek()
+ .clone()
+ .parse::<i32>()
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)
+ .map(Secret::new)
+ }
+}
+
+pub trait AddressDetailsData {
+ fn get_first_name(&self) -> Result<&Secret<String>, Error>;
+ fn get_last_name(&self) -> Result<&Secret<String>, Error>;
+ fn get_full_name(&self) -> Result<Secret<String>, Error>;
+ fn get_line1(&self) -> Result<&Secret<String>, Error>;
+ fn get_city(&self) -> Result<&String, Error>;
+ fn get_line2(&self) -> Result<&Secret<String>, Error>;
+ fn get_state(&self) -> Result<&Secret<String>, Error>;
+ fn get_zip(&self) -> Result<&Secret<String>, Error>;
+ fn get_country(&self) -> Result<&api_models::enums::CountryAlpha2, Error>;
+ fn get_combined_address_line(&self) -> Result<Secret<String>, Error>;
+ fn get_optional_line2(&self) -> Option<Secret<String>>;
+}
+
+impl AddressDetailsData for AddressDetails {
+ fn get_first_name(&self) -> Result<&Secret<String>, Error> {
+ self.first_name
+ .as_ref()
+ .ok_or_else(missing_field_err("address.first_name"))
+ }
+
+ fn get_last_name(&self) -> Result<&Secret<String>, Error> {
+ self.last_name
+ .as_ref()
+ .ok_or_else(missing_field_err("address.last_name"))
+ }
+
+ fn get_full_name(&self) -> Result<Secret<String>, Error> {
+ let first_name = self.get_first_name()?.peek().to_owned();
+ let last_name = self
+ .get_last_name()
+ .ok()
+ .cloned()
+ .unwrap_or(Secret::new("".to_string()));
+ let last_name = last_name.peek();
+ let full_name = format!("{} {}", first_name, last_name).trim().to_string();
+ Ok(Secret::new(full_name))
+ }
+
+ fn get_line1(&self) -> Result<&Secret<String>, Error> {
+ self.line1
+ .as_ref()
+ .ok_or_else(missing_field_err("address.line1"))
+ }
+
+ fn get_city(&self) -> Result<&String, Error> {
+ self.city
+ .as_ref()
+ .ok_or_else(missing_field_err("address.city"))
+ }
+
+ fn get_state(&self) -> Result<&Secret<String>, Error> {
+ self.state
+ .as_ref()
+ .ok_or_else(missing_field_err("address.state"))
+ }
+
+ fn get_line2(&self) -> Result<&Secret<String>, Error> {
+ self.line2
+ .as_ref()
+ .ok_or_else(missing_field_err("address.line2"))
+ }
+
+ fn get_zip(&self) -> Result<&Secret<String>, Error> {
+ self.zip
+ .as_ref()
+ .ok_or_else(missing_field_err("address.zip"))
+ }
+
+ fn get_country(&self) -> Result<&api_models::enums::CountryAlpha2, Error> {
+ self.country
+ .as_ref()
+ .ok_or_else(missing_field_err("address.country"))
+ }
+
+ fn get_combined_address_line(&self) -> Result<Secret<String>, Error> {
+ Ok(Secret::new(format!(
+ "{},{}",
+ self.get_line1()?.peek(),
+ self.get_line2()?.peek()
+ )))
+ }
+
+ fn get_optional_line2(&self) -> Option<Secret<String>> {
+ self.line2.clone()
+ }
+}
+
+pub trait PhoneDetailsData {
+ fn get_number(&self) -> Result<Secret<String>, Error>;
+ fn get_country_code(&self) -> Result<String, Error>;
+ fn get_number_with_country_code(&self) -> Result<Secret<String>, Error>;
+ fn get_number_with_hash_country_code(&self) -> Result<Secret<String>, Error>;
+ fn extract_country_code(&self) -> Result<String, Error>;
+}
+
+impl PhoneDetailsData for PhoneDetails {
+ fn get_country_code(&self) -> Result<String, Error> {
+ self.country_code
+ .clone()
+ .ok_or_else(missing_field_err("billing.phone.country_code"))
+ }
+ fn extract_country_code(&self) -> Result<String, Error> {
+ self.get_country_code()
+ .map(|cc| cc.trim_start_matches('+').to_string())
+ }
+ fn get_number(&self) -> Result<Secret<String>, Error> {
+ self.number
+ .clone()
+ .ok_or_else(missing_field_err("billing.phone.number"))
+ }
+ fn get_number_with_country_code(&self) -> Result<Secret<String>, Error> {
+ let number = self.get_number()?;
+ let country_code = self.get_country_code()?;
+ Ok(Secret::new(format!("{}{}", country_code, number.peek())))
+ }
+ fn get_number_with_hash_country_code(&self) -> Result<Secret<String>, Error> {
+ let number = self.get_number()?;
+ let country_code = self.get_country_code()?;
+ let number_without_plus = country_code.trim_start_matches('+');
+ Ok(Secret::new(format!(
+ "{}#{}",
+ number_without_plus,
+ number.peek()
+ )))
+ }
+}
+
+pub trait PaymentsAuthorizeRequestData {
+ fn is_auto_capture(&self) -> Result<bool, Error>;
+ fn get_email(&self) -> Result<Email, Error>;
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
+ fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error>;
+ fn get_card(&self) -> Result<Card, Error>;
+ fn get_return_url(&self) -> Result<String, Error>;
+ fn connector_mandate_id(&self) -> Option<String>;
+ fn is_mandate_payment(&self) -> bool;
+ fn is_customer_initiated_mandate_payment(&self) -> bool;
+ fn get_webhook_url(&self) -> Result<String, Error>;
+ fn get_router_return_url(&self) -> Result<String, Error>;
+ fn is_wallet(&self) -> bool;
+ fn is_card(&self) -> bool;
+ fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error>;
+ fn get_connector_mandate_id(&self) -> Result<String, Error>;
+ fn get_complete_authorize_url(&self) -> Result<String, Error>;
+ fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>>;
+ fn get_original_amount(&self) -> i64;
+ fn get_surcharge_amount(&self) -> Option<i64>;
+ fn get_tax_on_surcharge_amount(&self) -> Option<i64>;
+ fn get_total_surcharge_amount(&self) -> Option<i64>;
+ fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue>;
+ fn get_authentication_data(&self) -> Result<AuthenticationData, Error>;
+}
+
+impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
+ fn is_auto_capture(&self) -> Result<bool, Error> {
+ match self.capture_method {
+ Some(enums::CaptureMethod::Automatic) | None => Ok(true),
+ Some(enums::CaptureMethod::Manual) => Ok(false),
+ Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()),
+ }
+ }
+ fn get_email(&self) -> Result<Email, Error> {
+ self.email.clone().ok_or_else(missing_field_err("email"))
+ }
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
+ self.browser_info
+ .clone()
+ .ok_or_else(missing_field_err("browser_info"))
+ }
+ fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error> {
+ self.order_details
+ .clone()
+ .ok_or_else(missing_field_err("order_details"))
+ }
+
+ fn get_card(&self) -> Result<Card, Error> {
+ match self.payment_method_data.clone() {
+ PaymentMethodData::Card(card) => Ok(card),
+ _ => Err(missing_field_err("card")()),
+ }
+ }
+ fn get_return_url(&self) -> Result<String, Error> {
+ self.router_return_url
+ .clone()
+ .ok_or_else(missing_field_err("return_url"))
+ }
+
+ fn get_complete_authorize_url(&self) -> Result<String, Error> {
+ self.complete_authorize_url
+ .clone()
+ .ok_or_else(missing_field_err("complete_authorize_url"))
+ }
+
+ fn connector_mandate_id(&self) -> Option<String> {
+ self.mandate_id
+ .as_ref()
+ .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
+ Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
+ connector_mandate_ids.connector_mandate_id.clone()
+ }
+ Some(payments::MandateReferenceId::NetworkMandateId(_)) | None => None,
+ })
+ }
+ fn is_mandate_payment(&self) -> bool {
+ ((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
+ && self.setup_future_usage.map_or(false, |setup_future_usage| {
+ setup_future_usage == FutureUsage::OffSession
+ }))
+ || self
+ .mandate_id
+ .as_ref()
+ .and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref())
+ .is_some()
+ }
+ fn get_webhook_url(&self) -> Result<String, Error> {
+ self.webhook_url
+ .clone()
+ .ok_or_else(missing_field_err("webhook_url"))
+ }
+ fn get_router_return_url(&self) -> Result<String, Error> {
+ self.router_return_url
+ .clone()
+ .ok_or_else(missing_field_err("return_url"))
+ }
+ fn is_wallet(&self) -> bool {
+ matches!(self.payment_method_data, PaymentMethodData::Wallet(_))
+ }
+ fn is_card(&self) -> bool {
+ matches!(self.payment_method_data, PaymentMethodData::Card(_))
+ }
+
+ fn get_payment_method_type(&self) -> Result<enums::PaymentMethodType, Error> {
+ self.payment_method_type
+ .to_owned()
+ .ok_or_else(missing_field_err("payment_method_type"))
+ }
+
+ fn get_connector_mandate_id(&self) -> Result<String, Error> {
+ self.connector_mandate_id()
+ .ok_or_else(missing_field_err("connector_mandate_id"))
+ }
+ fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> {
+ self.browser_info.clone().and_then(|browser_info| {
+ browser_info
+ .ip_address
+ .map(|ip| Secret::new(ip.to_string()))
+ })
+ }
+ fn get_original_amount(&self) -> i64 {
+ self.surcharge_details
+ .as_ref()
+ .map(|surcharge_details| surcharge_details.original_amount.get_amount_as_i64())
+ .unwrap_or(self.amount)
+ }
+ fn get_surcharge_amount(&self) -> Option<i64> {
+ self.surcharge_details
+ .as_ref()
+ .map(|surcharge_details| surcharge_details.surcharge_amount.get_amount_as_i64())
+ }
+ fn get_tax_on_surcharge_amount(&self) -> Option<i64> {
+ self.surcharge_details.as_ref().map(|surcharge_details| {
+ surcharge_details
+ .tax_on_surcharge_amount
+ .get_amount_as_i64()
+ })
+ }
+ fn get_total_surcharge_amount(&self) -> Option<i64> {
+ self.surcharge_details.as_ref().map(|surcharge_details| {
+ surcharge_details
+ .get_total_surcharge_amount()
+ .get_amount_as_i64()
+ })
+ }
+
+ fn is_customer_initiated_mandate_payment(&self) -> bool {
+ (self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
+ && self.setup_future_usage.map_or(false, |setup_future_usage| {
+ setup_future_usage == FutureUsage::OffSession
+ })
+ }
+
+ fn get_metadata_as_object(&self) -> Option<pii::SecretSerdeValue> {
+ self.metadata.clone().and_then(|meta_data| match meta_data {
+ serde_json::Value::Null
+ | serde_json::Value::Bool(_)
+ | serde_json::Value::Number(_)
+ | serde_json::Value::String(_)
+ | serde_json::Value::Array(_) => None,
+ serde_json::Value::Object(_) => Some(meta_data.into()),
+ })
+ }
+
+ fn get_authentication_data(&self) -> Result<AuthenticationData, Error> {
+ self.authentication_data
+ .clone()
+ .ok_or_else(missing_field_err("authentication_data"))
+ }
+}
+
+pub trait PaymentsCaptureRequestData {
+ fn is_multiple_capture(&self) -> bool;
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
+}
+
+impl PaymentsCaptureRequestData for PaymentsCaptureData {
+ fn is_multiple_capture(&self) -> bool {
+ self.multiple_capture_data.is_some()
+ }
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
+ self.browser_info
+ .clone()
+ .ok_or_else(missing_field_err("browser_info"))
+ }
+}
+
+pub trait PaymentsCancelRequestData {
+ fn get_amount(&self) -> Result<i64, Error>;
+ fn get_currency(&self) -> Result<enums::Currency, Error>;
+ fn get_cancellation_reason(&self) -> Result<String, Error>;
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
+}
+
+impl PaymentsCancelRequestData for PaymentsCancelData {
+ fn get_amount(&self) -> Result<i64, Error> {
+ self.amount.ok_or_else(missing_field_err("amount"))
+ }
+ fn get_currency(&self) -> Result<enums::Currency, Error> {
+ self.currency.ok_or_else(missing_field_err("currency"))
+ }
+ fn get_cancellation_reason(&self) -> Result<String, Error> {
+ self.cancellation_reason
+ .clone()
+ .ok_or_else(missing_field_err("cancellation_reason"))
+ }
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
+ self.browser_info
+ .clone()
+ .ok_or_else(missing_field_err("browser_info"))
+ }
+}
+
+pub trait RefundsRequestData {
+ fn get_connector_refund_id(&self) -> Result<String, Error>;
+ fn get_webhook_url(&self) -> Result<String, Error>;
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
+}
+
+impl RefundsRequestData for RefundsData {
+ #[track_caller]
+ fn get_connector_refund_id(&self) -> Result<String, Error> {
+ self.connector_refund_id
+ .clone()
+ .get_required_value("connector_refund_id")
+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)
+ }
+ fn get_webhook_url(&self) -> Result<String, Error> {
+ self.webhook_url
+ .clone()
+ .ok_or_else(missing_field_err("webhook_url"))
+ }
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
+ self.browser_info
+ .clone()
+ .ok_or_else(missing_field_err("browser_info"))
+ }
+}
+
+pub trait PaymentsSetupMandateRequestData {
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
+ fn get_email(&self) -> Result<Email, Error>;
+ fn is_card(&self) -> bool;
+}
+
+impl PaymentsSetupMandateRequestData for SetupMandateRequestData {
+ fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
+ self.browser_info
+ .clone()
+ .ok_or_else(missing_field_err("browser_info"))
+ }
+ fn get_email(&self) -> Result<Email, Error> {
+ self.email.clone().ok_or_else(missing_field_err("email"))
+ }
+ fn is_card(&self) -> bool {
+ matches!(self.payment_method_data, PaymentMethodData::Card(_))
+ }
+}
+
+pub trait BrowserInformationData {
+ fn get_accept_header(&self) -> Result<String, Error>;
+ fn get_language(&self) -> Result<String, Error>;
+ fn get_screen_height(&self) -> Result<u32, Error>;
+ fn get_screen_width(&self) -> Result<u32, Error>;
+ fn get_color_depth(&self) -> Result<u8, Error>;
+ fn get_user_agent(&self) -> Result<String, Error>;
+ fn get_time_zone(&self) -> Result<i32, Error>;
+ fn get_java_enabled(&self) -> Result<bool, Error>;
+ fn get_java_script_enabled(&self) -> Result<bool, Error>;
+ fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error>;
+}
+
+impl BrowserInformationData for BrowserInformation {
+ fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> {
+ let ip_address = self
+ .ip_address
+ .ok_or_else(missing_field_err("browser_info.ip_address"))?;
+ Ok(Secret::new(ip_address.to_string()))
+ }
+ fn get_accept_header(&self) -> Result<String, Error> {
+ self.accept_header
+ .clone()
+ .ok_or_else(missing_field_err("browser_info.accept_header"))
+ }
+ fn get_language(&self) -> Result<String, Error> {
+ self.language
+ .clone()
+ .ok_or_else(missing_field_err("browser_info.language"))
+ }
+ fn get_screen_height(&self) -> Result<u32, Error> {
+ self.screen_height
+ .ok_or_else(missing_field_err("browser_info.screen_height"))
+ }
+ fn get_screen_width(&self) -> Result<u32, Error> {
+ self.screen_width
+ .ok_or_else(missing_field_err("browser_info.screen_width"))
+ }
+ fn get_color_depth(&self) -> Result<u8, Error> {
+ self.color_depth
+ .ok_or_else(missing_field_err("browser_info.color_depth"))
+ }
+ fn get_user_agent(&self) -> Result<String, Error> {
+ self.user_agent
+ .clone()
+ .ok_or_else(missing_field_err("browser_info.user_agent"))
+ }
+ fn get_time_zone(&self) -> Result<i32, Error> {
+ self.time_zone
+ .ok_or_else(missing_field_err("browser_info.time_zone"))
+ }
+ fn get_java_enabled(&self) -> Result<bool, Error> {
+ self.java_enabled
+ .ok_or_else(missing_field_err("browser_info.java_enabled"))
+ }
+ fn get_java_script_enabled(&self) -> Result<bool, Error> {
+ self.java_script_enabled
+ .ok_or_else(missing_field_err("browser_info.java_script_enabled"))
+ }
+}
diff --git a/crates/hyperswitch_domain_models/Cargo.toml b/crates/hyperswitch_domain_models/Cargo.toml
index 2ce3ecca53..d10d72ab3a 100644
--- a/crates/hyperswitch_domain_models/Cargo.toml
+++ b/crates/hyperswitch_domain_models/Cargo.toml
@@ -8,7 +8,7 @@ readme = "README.md"
license.workspace = true
[features]
-default = ["olap", "payouts", "frm", "v1"]
+default = ["olap", "frm", "v1"]
encryption_service = []
olap = []
payouts = ["api_models/payouts"]
diff --git a/crates/hyperswitch_domain_models/src/lib.rs b/crates/hyperswitch_domain_models/src/lib.rs
index 387c024df1..c48f721b21 100644
--- a/crates/hyperswitch_domain_models/src/lib.rs
+++ b/crates/hyperswitch_domain_models/src/lib.rs
@@ -17,6 +17,7 @@ pub mod router_response_types;
pub mod behaviour;
pub mod merchant_key_store;
pub mod type_encryption;
+pub mod types;
#[cfg(not(feature = "payouts"))]
pub trait PayoutAttemptInterface {}
diff --git a/crates/hyperswitch_domain_models/src/router_flow_types.rs b/crates/hyperswitch_domain_models/src/router_flow_types.rs
index 065b5f0f40..6cdde87772 100644
--- a/crates/hyperswitch_domain_models/src/router_flow_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_flow_types.rs
@@ -2,6 +2,7 @@ pub mod access_token_auth;
pub mod dispute;
pub mod files;
pub mod fraud_check;
+pub mod mandate_revoke;
pub mod payments;
pub mod payouts;
pub mod refunds;
diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/mandate_revoke.rs b/crates/hyperswitch_domain_models/src/router_flow_types/mandate_revoke.rs
new file mode 100644
index 0000000000..1c8f750cee
--- /dev/null
+++ b/crates/hyperswitch_domain_models/src/router_flow_types/mandate_revoke.rs
@@ -0,0 +1,2 @@
+#[derive(Clone, Debug)]
+pub struct MandateRevoke;
diff --git a/crates/hyperswitch_domain_models/src/types.rs b/crates/hyperswitch_domain_models/src/types.rs
new file mode 100644
index 0000000000..814d235e6f
--- /dev/null
+++ b/crates/hyperswitch_domain_models/src/types.rs
@@ -0,0 +1,19 @@
+use crate::{
+ router_data::RouterData,
+ router_flow_types::{Authorize, Capture, PSync, RSync, SetupMandate, Void},
+ router_request_types::{
+ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData,
+ RefundsData, SetupMandateRequestData,
+ },
+ router_response_types::{PaymentsResponseData, RefundsResponseData},
+};
+
+pub type PaymentsAuthorizeRouterData =
+ RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData>;
+pub type PaymentsSyncRouterData = RouterData<PSync, PaymentsSyncData, PaymentsResponseData>;
+pub type PaymentsCaptureRouterData = RouterData<Capture, PaymentsCaptureData, PaymentsResponseData>;
+pub type PaymentsCancelRouterData = RouterData<Void, PaymentsCancelData, PaymentsResponseData>;
+pub type SetupMandateRouterData =
+ RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>;
+pub type RefundsRouterData<F> = RouterData<F, RefundsData, RefundsResponseData>;
+pub type RefundSyncRouterData = RouterData<RSync, RefundsData, RefundsResponseData>;
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index 05d5987aba..7830415e5d 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -7,9 +7,10 @@ readme = "README.md"
license.workspace = true
[features]
-default = ["dummy_connector", "payouts"]
+default = ["dummy_connector", "frm", "payouts"]
dummy_connector = []
-payouts = []
+payouts = ["hyperswitch_domain_models/payouts"]
+frm = ["hyperswitch_domain_models/frm"]
[dependencies]
actix-web = "4.5.1"
@@ -23,6 +24,7 @@ once_cell = "1.19.0"
reqwest = "0.11.27"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
+strum = { version = "0.26", features = ["derive"] }
thiserror = "1.0.58"
time = "0.3.35"
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index 30dad9acb9..82ae0d141d 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -1,16 +1,48 @@
//! API interface
+pub mod disputes;
+pub mod disputes_v2;
+pub mod files;
+pub mod files_v2;
+#[cfg(feature = "frm")]
+pub mod fraud_check;
+#[cfg(feature = "frm")]
+pub mod fraud_check_v2;
+pub mod payments;
+pub mod payments_v2;
+#[cfg(feature = "payouts")]
+pub mod payouts;
+#[cfg(feature = "payouts")]
+pub mod payouts_v2;
+pub mod refunds;
+pub mod refunds_v2;
+
+use common_enums::enums::{CaptureMethod, PaymentMethodType};
use common_utils::{
errors::CustomResult,
request::{Method, Request, RequestContent},
};
-use hyperswitch_domain_models::router_data::{ConnectorAuthType, ErrorResponse, RouterData};
+use error_stack::ResultExt;
+use hyperswitch_domain_models::{
+ payment_method_data::PaymentMethodData,
+ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
+ router_data_v2::{
+ flow_common_types::WebhookSourceVerifyData, AccessTokenFlowData, MandateRevokeFlowData,
+ },
+ router_flow_types::{mandate_revoke::MandateRevoke, AccessTokenAuth, VerifyWebhookSource},
+ router_request_types::{
+ AccessTokenRequestData, MandateRevokeRequestData, VerifyWebhookSourceRequestData,
+ },
+ router_response_types::{MandateRevokeResponseData, VerifyWebhookSourceResponseData},
+};
use masking::Maskable;
use router_env::metrics::add_attributes;
use serde_json::json;
+pub use self::{payments::*, refunds::*};
use crate::{
- configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, metrics, types,
+ configs::Connectors, connector_integration_v2::ConnectorIntegrationV2, consts, errors,
+ events::connector_api_logs::ConnectorEvent, metrics, types,
};
/// type BoxedConnectorIntegration
@@ -254,3 +286,115 @@ pub trait ConnectorCommonExt<Flow, Req, Resp>:
Ok(Vec::new())
}
}
+
+/// trait ConnectorMandateRevoke
+pub trait ConnectorMandateRevoke:
+ ConnectorIntegration<MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>
+{
+}
+
+/// trait ConnectorMandateRevokeV2
+pub trait ConnectorMandateRevokeV2:
+ ConnectorIntegrationV2<
+ MandateRevoke,
+ MandateRevokeFlowData,
+ MandateRevokeRequestData,
+ MandateRevokeResponseData,
+>
+{
+}
+
+/// trait ConnectorAccessToken
+pub trait ConnectorAccessToken:
+ ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>
+{
+}
+
+/// trait ConnectorAccessTokenV2
+pub trait ConnectorAccessTokenV2:
+ ConnectorIntegrationV2<AccessTokenAuth, AccessTokenFlowData, AccessTokenRequestData, AccessToken>
+{
+}
+
+/// trait ConnectorVerifyWebhookSource
+pub trait ConnectorVerifyWebhookSource:
+ ConnectorIntegration<
+ VerifyWebhookSource,
+ VerifyWebhookSourceRequestData,
+ VerifyWebhookSourceResponseData,
+>
+{
+}
+
+/// trait ConnectorVerifyWebhookSourceV2
+pub trait ConnectorVerifyWebhookSourceV2:
+ ConnectorIntegrationV2<
+ VerifyWebhookSource,
+ WebhookSourceVerifyData,
+ VerifyWebhookSourceRequestData,
+ VerifyWebhookSourceResponseData,
+>
+{
+}
+
+/// trait ConnectorValidation
+pub trait ConnectorValidation: ConnectorCommon {
+ /// fn validate_capture_method
+ fn validate_capture_method(
+ &self,
+ capture_method: Option<CaptureMethod>,
+ _pmt: Option<PaymentMethodType>,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ let capture_method = capture_method.unwrap_or_default();
+ match capture_method {
+ CaptureMethod::Automatic => Ok(()),
+ CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => {
+ Err(errors::ConnectorError::NotSupported {
+ message: capture_method.to_string(),
+ connector: self.id(),
+ }
+ .into())
+ }
+ }
+ }
+
+ /// fn validate_mandate_payment
+ fn validate_mandate_payment(
+ &self,
+ pm_type: Option<PaymentMethodType>,
+ _pm_data: PaymentMethodData,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ let connector = self.id();
+ match pm_type {
+ Some(pm_type) => Err(errors::ConnectorError::NotSupported {
+ message: format!("{} mandate payment", pm_type),
+ connector,
+ }
+ .into()),
+ None => Err(errors::ConnectorError::NotSupported {
+ message: " mandate payment".to_string(),
+ connector,
+ }
+ .into()),
+ }
+ }
+
+ /// fn validate_psync_reference_id
+ fn validate_psync_reference_id(
+ &self,
+ data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: common_enums::enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ data.connector_transaction_id
+ .get_connector_transaction_id()
+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)
+ .map(|_| ())
+ }
+
+ /// fn is_webhook_source_verification_mandatory
+ fn is_webhook_source_verification_mandatory(&self) -> bool {
+ false
+ }
+}
diff --git a/crates/hyperswitch_interfaces/src/api/disputes.rs b/crates/hyperswitch_interfaces/src/api/disputes.rs
new file mode 100644
index 0000000000..3ff5d6fb95
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/disputes.rs
@@ -0,0 +1,32 @@
+//! Disputes interface
+
+use hyperswitch_domain_models::{
+ router_flow_types::dispute::{Accept, Defend, Evidence},
+ router_request_types::{
+ AcceptDisputeRequestData, DefendDisputeRequestData, SubmitEvidenceRequestData,
+ },
+ router_response_types::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse},
+};
+
+use crate::api::ConnectorIntegration;
+
+/// trait AcceptDispute
+pub trait AcceptDispute:
+ ConnectorIntegration<Accept, AcceptDisputeRequestData, AcceptDisputeResponse>
+{
+}
+
+/// trait SubmitEvidence
+pub trait SubmitEvidence:
+ ConnectorIntegration<Evidence, SubmitEvidenceRequestData, SubmitEvidenceResponse>
+{
+}
+
+/// trait DefendDispute
+pub trait DefendDispute:
+ ConnectorIntegration<Defend, DefendDisputeRequestData, DefendDisputeResponse>
+{
+}
+
+/// trait Dispute
+pub trait Dispute: super::ConnectorCommon + AcceptDispute + SubmitEvidence + DefendDispute {}
diff --git a/crates/hyperswitch_interfaces/src/api/disputes_v2.rs b/crates/hyperswitch_interfaces/src/api/disputes_v2.rs
new file mode 100644
index 0000000000..b038b141d9
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/disputes_v2.rs
@@ -0,0 +1,40 @@
+//! Disputes V2 interface
+use hyperswitch_domain_models::{
+ router_data_v2::DisputesFlowData,
+ router_flow_types::dispute::{Accept, Defend, Evidence},
+ router_request_types::{
+ AcceptDisputeRequestData, DefendDisputeRequestData, SubmitEvidenceRequestData,
+ },
+ router_response_types::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse},
+};
+
+use crate::api::ConnectorIntegrationV2;
+
+/// trait AcceptDisputeV2
+pub trait AcceptDisputeV2:
+ ConnectorIntegrationV2<Accept, DisputesFlowData, AcceptDisputeRequestData, AcceptDisputeResponse>
+{
+}
+
+/// trait SubmitEvidenceV2
+pub trait SubmitEvidenceV2:
+ ConnectorIntegrationV2<
+ Evidence,
+ DisputesFlowData,
+ SubmitEvidenceRequestData,
+ SubmitEvidenceResponse,
+>
+{
+}
+
+/// trait DefendDisputeV2
+pub trait DefendDisputeV2:
+ ConnectorIntegrationV2<Defend, DisputesFlowData, DefendDisputeRequestData, DefendDisputeResponse>
+{
+}
+
+/// trait DisputeV2
+pub trait DisputeV2:
+ super::ConnectorCommon + AcceptDisputeV2 + SubmitEvidenceV2 + DefendDisputeV2
+{
+}
diff --git a/crates/hyperswitch_interfaces/src/api/files.rs b/crates/hyperswitch_interfaces/src/api/files.rs
new file mode 100644
index 0000000000..7cee6b9f4c
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/files.rs
@@ -0,0 +1,49 @@
+//! Files interface
+
+use hyperswitch_domain_models::{
+ router_flow_types::files::{Retrieve, Upload},
+ router_request_types::{RetrieveFileRequestData, UploadFileRequestData},
+ router_response_types::{RetrieveFileResponse, UploadFileResponse},
+};
+
+use crate::{
+ api::{ConnectorCommon, ConnectorIntegration},
+ errors,
+};
+
+/// enum FilePurpose
+#[derive(Debug, serde::Deserialize, strum::Display, Clone, serde::Serialize)]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum FilePurpose {
+ /// DisputeEvidence
+ DisputeEvidence,
+}
+
+/// trait UploadFile
+pub trait UploadFile:
+ ConnectorIntegration<Upload, UploadFileRequestData, UploadFileResponse>
+{
+}
+
+/// trait RetrieveFile
+pub trait RetrieveFile:
+ ConnectorIntegration<Retrieve, RetrieveFileRequestData, RetrieveFileResponse>
+{
+}
+
+/// trait FileUpload
+pub trait FileUpload: ConnectorCommon + Sync + UploadFile + RetrieveFile {
+ /// fn validate_file_upload
+ fn validate_file_upload(
+ &self,
+ _purpose: FilePurpose,
+ _file_size: i32,
+ _file_type: mime::Mime,
+ ) -> common_utils::errors::CustomResult<(), errors::ConnectorError> {
+ Err(errors::ConnectorError::FileValidationFailed {
+ reason: "".to_owned(),
+ }
+ .into())
+ }
+}
diff --git a/crates/hyperswitch_interfaces/src/api/files_v2.rs b/crates/hyperswitch_interfaces/src/api/files_v2.rs
new file mode 100644
index 0000000000..ba8336b973
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/files_v2.rs
@@ -0,0 +1,38 @@
+//! Files V2 interface
+
+use hyperswitch_domain_models::{
+ router_data_v2::FilesFlowData,
+ router_flow_types::{Retrieve, Upload},
+ router_request_types::{RetrieveFileRequestData, UploadFileRequestData},
+ router_response_types::{RetrieveFileResponse, UploadFileResponse},
+};
+
+use crate::api::{errors, files::FilePurpose, ConnectorCommon, ConnectorIntegrationV2};
+
+/// trait UploadFileV2
+pub trait UploadFileV2:
+ ConnectorIntegrationV2<Upload, FilesFlowData, UploadFileRequestData, UploadFileResponse>
+{
+}
+
+/// trait RetrieveFileV2
+pub trait RetrieveFileV2:
+ ConnectorIntegrationV2<Retrieve, FilesFlowData, RetrieveFileRequestData, RetrieveFileResponse>
+{
+}
+
+/// trait FileUploadV2
+pub trait FileUploadV2: ConnectorCommon + Sync + UploadFileV2 + RetrieveFileV2 {
+ /// fn validate_file_upload_v2
+ fn validate_file_upload_v2(
+ &self,
+ _purpose: FilePurpose,
+ _file_size: i32,
+ _file_type: mime::Mime,
+ ) -> common_utils::errors::CustomResult<(), errors::ConnectorError> {
+ Err(errors::ConnectorError::FileValidationFailed {
+ reason: "".to_owned(),
+ }
+ .into())
+ }
+}
diff --git a/crates/hyperswitch_interfaces/src/api/fraud_check.rs b/crates/hyperswitch_interfaces/src/api/fraud_check.rs
new file mode 100644
index 0000000000..5bee65c8d9
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/fraud_check.rs
@@ -0,0 +1,41 @@
+//! FRM interface
+use hyperswitch_domain_models::{
+ router_flow_types::{Checkout, Fulfillment, RecordReturn, Sale, Transaction},
+ router_request_types::fraud_check::{
+ FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckRecordReturnData,
+ FraudCheckSaleData, FraudCheckTransactionData,
+ },
+ router_response_types::fraud_check::FraudCheckResponseData,
+};
+
+use crate::api::ConnectorIntegration;
+
+/// trait FraudCheckSale
+pub trait FraudCheckSale:
+ ConnectorIntegration<Sale, FraudCheckSaleData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckCheckout
+pub trait FraudCheckCheckout:
+ ConnectorIntegration<Checkout, FraudCheckCheckoutData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckTransaction
+pub trait FraudCheckTransaction:
+ ConnectorIntegration<Transaction, FraudCheckTransactionData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckFulfillment
+pub trait FraudCheckFulfillment:
+ ConnectorIntegration<Fulfillment, FraudCheckFulfillmentData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckRecordReturn
+pub trait FraudCheckRecordReturn:
+ ConnectorIntegration<RecordReturn, FraudCheckRecordReturnData, FraudCheckResponseData>
+{
+}
diff --git a/crates/hyperswitch_interfaces/src/api/fraud_check_v2.rs b/crates/hyperswitch_interfaces/src/api/fraud_check_v2.rs
new file mode 100644
index 0000000000..f549290950
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/fraud_check_v2.rs
@@ -0,0 +1,47 @@
+//! FRM V2 interface
+use hyperswitch_domain_models::{
+ router_data_v2::flow_common_types::FrmFlowData,
+ router_flow_types::{Checkout, Fulfillment, RecordReturn, Sale, Transaction},
+ router_request_types::fraud_check::{
+ FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckRecordReturnData,
+ FraudCheckSaleData, FraudCheckTransactionData,
+ },
+ router_response_types::fraud_check::FraudCheckResponseData,
+};
+
+use crate::api::ConnectorIntegrationV2;
+
+/// trait FraudCheckSaleV2
+pub trait FraudCheckSaleV2:
+ ConnectorIntegrationV2<Sale, FrmFlowData, FraudCheckSaleData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckCheckoutV2
+pub trait FraudCheckCheckoutV2:
+ ConnectorIntegrationV2<Checkout, FrmFlowData, FraudCheckCheckoutData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckTransactionV2
+pub trait FraudCheckTransactionV2:
+ ConnectorIntegrationV2<Transaction, FrmFlowData, FraudCheckTransactionData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckFulfillmentV2
+pub trait FraudCheckFulfillmentV2:
+ ConnectorIntegrationV2<Fulfillment, FrmFlowData, FraudCheckFulfillmentData, FraudCheckResponseData>
+{
+}
+
+/// trait FraudCheckRecordReturnV2
+pub trait FraudCheckRecordReturnV2:
+ ConnectorIntegrationV2<
+ RecordReturn,
+ FrmFlowData,
+ FraudCheckRecordReturnData,
+ FraudCheckResponseData,
+>
+{
+}
diff --git a/crates/hyperswitch_interfaces/src/api/payments.rs b/crates/hyperswitch_interfaces/src/api/payments.rs
new file mode 100644
index 0000000000..8a53f65805
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/payments.rs
@@ -0,0 +1,135 @@
+//! Payments interface
+
+use hyperswitch_domain_models::{
+ router_flow_types::payments::{
+ Approve, Authorize, AuthorizeSessionToken, Capture, CompleteAuthorize,
+ CreateConnectorCustomer, IncrementalAuthorization, PSync, PaymentMethodToken,
+ PostProcessing, PreProcessing, Reject, Session, SetupMandate, Void,
+ },
+ router_request_types::{
+ AuthorizeSessionTokenData, CompleteAuthorizeData, ConnectorCustomerData,
+ PaymentMethodTokenizationData, PaymentsApproveData, PaymentsAuthorizeData,
+ PaymentsCancelData, PaymentsCaptureData, PaymentsIncrementalAuthorizationData,
+ PaymentsPostProcessingData, PaymentsPreProcessingData, PaymentsRejectData,
+ PaymentsSessionData, PaymentsSyncData, SetupMandateRequestData,
+ },
+ router_response_types::PaymentsResponseData,
+};
+
+use crate::api;
+
+/// trait Payment
+pub trait Payment:
+ api::ConnectorCommon
+ + api::ConnectorValidation
+ + PaymentAuthorize
+ + PaymentAuthorizeSessionToken
+ + PaymentsCompleteAuthorize
+ + PaymentSync
+ + PaymentCapture
+ + PaymentVoid
+ + PaymentApprove
+ + PaymentReject
+ + MandateSetup
+ + PaymentSession
+ + PaymentToken
+ + PaymentsPreProcessing
+ + PaymentsPostProcessing
+ + ConnectorCustomer
+ + PaymentIncrementalAuthorization
+{
+}
+
+/// trait PaymentSession
+pub trait PaymentSession:
+ api::ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData>
+{
+}
+
+/// trait MandateSetup
+pub trait MandateSetup:
+ api::ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentAuthorize
+pub trait PaymentAuthorize:
+ api::ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentCapture
+pub trait PaymentCapture:
+ api::ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentSync
+pub trait PaymentSync:
+ api::ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentVoid
+pub trait PaymentVoid:
+ api::ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentApprove
+pub trait PaymentApprove:
+ api::ConnectorIntegration<Approve, PaymentsApproveData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentReject
+pub trait PaymentReject:
+ api::ConnectorIntegration<Reject, PaymentsRejectData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentToken
+pub trait PaymentToken:
+ api::ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentAuthorizeSessionToken
+pub trait PaymentAuthorizeSessionToken:
+ api::ConnectorIntegration<AuthorizeSessionToken, AuthorizeSessionTokenData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentIncrementalAuthorization
+pub trait PaymentIncrementalAuthorization:
+ api::ConnectorIntegration<
+ IncrementalAuthorization,
+ PaymentsIncrementalAuthorizationData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait PaymentsCompleteAuthorize
+pub trait PaymentsCompleteAuthorize:
+ api::ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>
+{
+}
+
+/// trait ConnectorCustomer
+pub trait ConnectorCustomer:
+ api::ConnectorIntegration<CreateConnectorCustomer, ConnectorCustomerData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentsPreProcessing
+pub trait PaymentsPreProcessing:
+ api::ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentsPostProcessing
+pub trait PaymentsPostProcessing:
+ api::ConnectorIntegration<PostProcessing, PaymentsPostProcessingData, PaymentsResponseData>
+{
+}
diff --git a/crates/hyperswitch_interfaces/src/api/payments_v2.rs b/crates/hyperswitch_interfaces/src/api/payments_v2.rs
new file mode 100644
index 0000000000..4ebe9e8517
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/payments_v2.rs
@@ -0,0 +1,167 @@
+//! Payments V2 interface
+
+use hyperswitch_domain_models::{
+ router_data_v2::PaymentFlowData,
+ router_flow_types::payments::{
+ Approve, Authorize, AuthorizeSessionToken, Capture, CompleteAuthorize,
+ CreateConnectorCustomer, IncrementalAuthorization, PSync, PaymentMethodToken,
+ PostProcessing, PreProcessing, Reject, Session, SetupMandate, Void,
+ },
+ router_request_types::{
+ AuthorizeSessionTokenData, CompleteAuthorizeData, ConnectorCustomerData,
+ PaymentMethodTokenizationData, PaymentsApproveData, PaymentsAuthorizeData,
+ PaymentsCancelData, PaymentsCaptureData, PaymentsIncrementalAuthorizationData,
+ PaymentsPostProcessingData, PaymentsPreProcessingData, PaymentsRejectData,
+ PaymentsSessionData, PaymentsSyncData, SetupMandateRequestData,
+ },
+ router_response_types::PaymentsResponseData,
+};
+
+use crate::api::{ConnectorCommon, ConnectorIntegrationV2, ConnectorValidation};
+
+/// trait PaymentAuthorizeV2
+pub trait PaymentAuthorizeV2:
+ ConnectorIntegrationV2<Authorize, PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentAuthorizeSessionTokenV2
+pub trait PaymentAuthorizeSessionTokenV2:
+ ConnectorIntegrationV2<
+ AuthorizeSessionToken,
+ PaymentFlowData,
+ AuthorizeSessionTokenData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait PaymentSyncV2
+pub trait PaymentSyncV2:
+ ConnectorIntegrationV2<PSync, PaymentFlowData, PaymentsSyncData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentVoidV2
+pub trait PaymentVoidV2:
+ ConnectorIntegrationV2<Void, PaymentFlowData, PaymentsCancelData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentApproveV2
+pub trait PaymentApproveV2:
+ ConnectorIntegrationV2<Approve, PaymentFlowData, PaymentsApproveData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentRejectV2
+pub trait PaymentRejectV2:
+ ConnectorIntegrationV2<Reject, PaymentFlowData, PaymentsRejectData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentCaptureV2
+pub trait PaymentCaptureV2:
+ ConnectorIntegrationV2<Capture, PaymentFlowData, PaymentsCaptureData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentSessionV2
+pub trait PaymentSessionV2:
+ ConnectorIntegrationV2<Session, PaymentFlowData, PaymentsSessionData, PaymentsResponseData>
+{
+}
+
+/// trait MandateSetupV2
+pub trait MandateSetupV2:
+ ConnectorIntegrationV2<SetupMandate, PaymentFlowData, SetupMandateRequestData, PaymentsResponseData>
+{
+}
+
+/// trait PaymentIncrementalAuthorizationV2
+pub trait PaymentIncrementalAuthorizationV2:
+ ConnectorIntegrationV2<
+ IncrementalAuthorization,
+ PaymentFlowData,
+ PaymentsIncrementalAuthorizationData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait PaymentsCompleteAuthorizeV2
+pub trait PaymentsCompleteAuthorizeV2:
+ ConnectorIntegrationV2<
+ CompleteAuthorize,
+ PaymentFlowData,
+ CompleteAuthorizeData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait PaymentTokenV2
+pub trait PaymentTokenV2:
+ ConnectorIntegrationV2<
+ PaymentMethodToken,
+ PaymentFlowData,
+ PaymentMethodTokenizationData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait ConnectorCustomerV2
+pub trait ConnectorCustomerV2:
+ ConnectorIntegrationV2<
+ CreateConnectorCustomer,
+ PaymentFlowData,
+ ConnectorCustomerData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait PaymentsPreProcessingV2
+pub trait PaymentsPreProcessingV2:
+ ConnectorIntegrationV2<
+ PreProcessing,
+ PaymentFlowData,
+ PaymentsPreProcessingData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait PaymentsPostProcessingV2
+pub trait PaymentsPostProcessingV2:
+ ConnectorIntegrationV2<
+ PostProcessing,
+ PaymentFlowData,
+ PaymentsPostProcessingData,
+ PaymentsResponseData,
+>
+{
+}
+
+/// trait PaymentV2
+pub trait PaymentV2:
+ ConnectorCommon
+ + ConnectorValidation
+ + PaymentAuthorizeV2
+ + PaymentAuthorizeSessionTokenV2
+ + PaymentsCompleteAuthorizeV2
+ + PaymentSyncV2
+ + PaymentCaptureV2
+ + PaymentVoidV2
+ + PaymentApproveV2
+ + PaymentRejectV2
+ + MandateSetupV2
+ + PaymentSessionV2
+ + PaymentTokenV2
+ + PaymentsPreProcessingV2
+ + PaymentsPostProcessingV2
+ + ConnectorCustomerV2
+ + PaymentIncrementalAuthorizationV2
+{
+}
diff --git a/crates/hyperswitch_interfaces/src/api/payouts.rs b/crates/hyperswitch_interfaces/src/api/payouts.rs
new file mode 100644
index 0000000000..894f636707
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/payouts.rs
@@ -0,0 +1,44 @@
+//! Payouts interface
+
+use hyperswitch_domain_models::router_flow_types::payouts::{
+ PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, PoSync,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::{
+ router_request_types::PayoutsData, router_response_types::PayoutsResponseData,
+};
+
+use crate::api::ConnectorIntegration;
+
+/// trait PayoutCancel
+pub trait PayoutCancel: ConnectorIntegration<PoCancel, PayoutsData, PayoutsResponseData> {}
+
+/// trait PayoutCreate
+pub trait PayoutCreate: ConnectorIntegration<PoCreate, PayoutsData, PayoutsResponseData> {}
+
+/// trait PayoutEligibility
+pub trait PayoutEligibility:
+ ConnectorIntegration<PoEligibility, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutFulfill
+pub trait PayoutFulfill: ConnectorIntegration<PoFulfill, PayoutsData, PayoutsResponseData> {}
+
+/// trait PayoutQuote
+pub trait PayoutQuote: ConnectorIntegration<PoQuote, PayoutsData, PayoutsResponseData> {}
+
+/// trait PayoutRecipient
+pub trait PayoutRecipient:
+ ConnectorIntegration<PoRecipient, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutRecipientAccount
+pub trait PayoutRecipientAccount:
+ ConnectorIntegration<PoRecipientAccount, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutSync
+pub trait PayoutSync: ConnectorIntegration<PoSync, PayoutsData, PayoutsResponseData> {}
diff --git a/crates/hyperswitch_interfaces/src/api/payouts_v2.rs b/crates/hyperswitch_interfaces/src/api/payouts_v2.rs
new file mode 100644
index 0000000000..40e0726ce8
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/payouts_v2.rs
@@ -0,0 +1,59 @@
+//! Payouts V2 interface
+use hyperswitch_domain_models::router_flow_types::payouts::{
+ PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, PoSync,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::{
+ router_data_v2::flow_common_types::PayoutFlowData, router_request_types::PayoutsData,
+ router_response_types::PayoutsResponseData,
+};
+
+use crate::api::ConnectorIntegrationV2;
+
+/// trait PayoutCancelV2
+pub trait PayoutCancelV2:
+ ConnectorIntegrationV2<PoCancel, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutCreateV2
+pub trait PayoutCreateV2:
+ ConnectorIntegrationV2<PoCreate, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutEligibilityV2
+pub trait PayoutEligibilityV2:
+ ConnectorIntegrationV2<PoEligibility, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutFulfillV2
+pub trait PayoutFulfillV2:
+ ConnectorIntegrationV2<PoFulfill, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutQuoteV2
+pub trait PayoutQuoteV2:
+ ConnectorIntegrationV2<PoQuote, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutRecipientV2
+pub trait PayoutRecipientV2:
+ ConnectorIntegrationV2<PoRecipient, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutRecipientAccountV2
+pub trait PayoutRecipientAccountV2:
+ ConnectorIntegrationV2<PoRecipientAccount, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
+
+/// trait PayoutSyncV2
+pub trait PayoutSyncV2:
+ ConnectorIntegrationV2<PoSync, PayoutFlowData, PayoutsData, PayoutsResponseData>
+{
+}
diff --git a/crates/hyperswitch_interfaces/src/api/refunds.rs b/crates/hyperswitch_interfaces/src/api/refunds.rs
new file mode 100644
index 0000000000..f09c0d1aea
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/refunds.rs
@@ -0,0 +1,21 @@
+//! Refunds interface
+
+use hyperswitch_domain_models::{
+ router_flow_types::{Execute, RSync},
+ router_request_types::RefundsData,
+ router_response_types::RefundsResponseData,
+};
+
+use crate::api::{self, ConnectorCommon};
+
+/// trait RefundExecute
+pub trait RefundExecute:
+ api::ConnectorIntegration<Execute, RefundsData, RefundsResponseData>
+{
+}
+
+/// trait RefundSync
+pub trait RefundSync: api::ConnectorIntegration<RSync, RefundsData, RefundsResponseData> {}
+
+/// trait Refund
+pub trait Refund: ConnectorCommon + RefundExecute + RefundSync {}
diff --git a/crates/hyperswitch_interfaces/src/api/refunds_v2.rs b/crates/hyperswitch_interfaces/src/api/refunds_v2.rs
new file mode 100644
index 0000000000..7812c3e283
--- /dev/null
+++ b/crates/hyperswitch_interfaces/src/api/refunds_v2.rs
@@ -0,0 +1,25 @@
+//! Refunds V2 interface
+
+use hyperswitch_domain_models::{
+ router_data_v2::flow_common_types::RefundFlowData,
+ router_flow_types::refunds::{Execute, RSync},
+ router_request_types::RefundsData,
+ router_response_types::RefundsResponseData,
+};
+
+use crate::api::{ConnectorCommon, ConnectorIntegrationV2};
+
+/// trait RefundExecuteV2
+pub trait RefundExecuteV2:
+ ConnectorIntegrationV2<Execute, RefundFlowData, RefundsData, RefundsResponseData>
+{
+}
+
+/// trait RefundSyncV2
+pub trait RefundSyncV2:
+ ConnectorIntegrationV2<RSync, RefundFlowData, RefundsData, RefundsResponseData>
+{
+}
+
+/// trait RefundV2
+pub trait RefundV2: ConnectorCommon + RefundExecuteV2 + RefundSyncV2 {}
diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs
index 2f0c5c2fbd..06a1d6028e 100644
--- a/crates/hyperswitch_interfaces/src/types.rs
+++ b/crates/hyperswitch_interfaces/src/types.rs
@@ -1,5 +1,45 @@
//! Types interface
+use hyperswitch_domain_models::{
+ router_data::AccessToken,
+ router_flow_types::{
+ access_token_auth::AccessTokenAuth,
+ dispute::{Accept, Defend, Evidence},
+ files::{Retrieve, Upload},
+ mandate_revoke::MandateRevoke,
+ payments::{
+ Authorize, AuthorizeSessionToken, Balance, Capture, CompleteAuthorize,
+ CreateConnectorCustomer, IncrementalAuthorization, InitPayment, PSync,
+ PaymentMethodToken, PostProcessing, PreProcessing, Session, SetupMandate, Void,
+ },
+ refunds::{Execute, RSync},
+ webhooks::VerifyWebhookSource,
+ },
+ router_request_types::{
+ AcceptDisputeRequestData, AccessTokenRequestData, AuthorizeSessionTokenData,
+ CompleteAuthorizeData, ConnectorCustomerData, DefendDisputeRequestData,
+ MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
+ PaymentsCancelData, PaymentsCaptureData, PaymentsIncrementalAuthorizationData,
+ PaymentsPostProcessingData, PaymentsPreProcessingData, PaymentsSessionData,
+ PaymentsSyncData, RefundsData, RetrieveFileRequestData, SetupMandateRequestData,
+ SubmitEvidenceRequestData, UploadFileRequestData, VerifyWebhookSourceRequestData,
+ },
+ router_response_types::{
+ AcceptDisputeResponse, DefendDisputeResponse, MandateRevokeResponseData,
+ PaymentsResponseData, RefundsResponseData, RetrieveFileResponse, SubmitEvidenceResponse,
+ UploadFileResponse, VerifyWebhookSourceResponseData,
+ },
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::{
+ router_flow_types::payouts::{
+ PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount,
+ PoSync,
+ },
+ router_request_types::PayoutsData,
+ router_response_types::PayoutsResponseData,
+};
+use crate::api::ConnectorIntegration;
/// struct Response
#[derive(Clone, Debug)]
pub struct Response {
@@ -10,3 +50,124 @@ pub struct Response {
/// status code
pub status_code: u16,
}
+
+/// Type alias for `ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>`
+pub type PaymentsAuthorizeType =
+ dyn ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>`
+pub type SetupMandateType =
+ dyn ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>`
+pub type MandateRevokeType =
+ dyn ConnectorIntegration<MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>;
+/// Type alias for `ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>`
+pub type PaymentsPreProcessingType =
+ dyn ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<PostProcessing, PaymentsPostProcessingData, PaymentsResponseData>`
+pub type PaymentsPostProcessingType =
+ dyn ConnectorIntegration<PostProcessing, PaymentsPostProcessingData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>`
+pub type PaymentsCompleteAuthorizeType =
+ dyn ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<AuthorizeSessionToken, AuthorizeSessionTokenData, PaymentsResponseData>`
+pub type PaymentsPreAuthorizeType = dyn ConnectorIntegration<
+ AuthorizeSessionToken,
+ AuthorizeSessionTokenData,
+ PaymentsResponseData,
+>;
+/// Type alias for `ConnectorIntegration<InitPayment, PaymentsAuthorizeData, PaymentsResponseData>`
+pub type PaymentsInitType =
+ dyn ConnectorIntegration<InitPayment, PaymentsAuthorizeData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<Balance, PaymentsAuthorizeData, PaymentsResponseData`
+pub type PaymentsBalanceType =
+ dyn ConnectorIntegration<Balance, PaymentsAuthorizeData, PaymentsResponseData>;
+/// Type alias for `PaymentsSyncType = dyn ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData>`
+pub type PaymentsSyncType = dyn ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData>`
+pub type PaymentsCaptureType =
+ dyn ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData>`
+pub type PaymentsSessionType =
+ dyn ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData>;
+/// Type alias for `ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData>`
+pub type PaymentsVoidType =
+ dyn ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData>;
+
+/// Type alias for `ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>`
+pub type TokenizationType = dyn ConnectorIntegration<
+ PaymentMethodToken,
+ PaymentMethodTokenizationData,
+ PaymentsResponseData,
+>;
+/// Type alias for `ConnectorIntegration<IncrementalAuthorization, PaymentsIncrementalAuthorizationData, PaymentsResponseData>`
+pub type IncrementalAuthorizationType = dyn ConnectorIntegration<
+ IncrementalAuthorization,
+ PaymentsIncrementalAuthorizationData,
+ PaymentsResponseData,
+>;
+
+/// Type alias for `ConnectorIntegration<CreateConnectorCustomer, ConnectorCustomerData, PaymentsResponseData>`
+pub type ConnectorCustomerType =
+ dyn ConnectorIntegration<CreateConnectorCustomer, ConnectorCustomerData, PaymentsResponseData>;
+
+/// Type alias for `ConnectorIntegration<Execute, RefundsData, RefundsResponseData>`
+pub type RefundExecuteType = dyn ConnectorIntegration<Execute, RefundsData, RefundsResponseData>;
+/// Type alias for `ConnectorIntegration<RSync, RefundsData, RefundsResponseData>`
+pub type RefundSyncType = dyn ConnectorIntegration<RSync, RefundsData, RefundsResponseData>;
+
+/// Type alias for `ConnectorIntegration<PoCancel, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutCancelType = dyn ConnectorIntegration<PoCancel, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<PoCreate, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutCreateType = dyn ConnectorIntegration<PoCreate, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<PoEligibility, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutEligibilityType =
+ dyn ConnectorIntegration<PoEligibility, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<PoFulfill, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutFulfillType = dyn ConnectorIntegration<PoFulfill, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<PoRecipient, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutRecipientType =
+ dyn ConnectorIntegration<PoRecipient, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<PoRecipientAccount, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutRecipientAccountType =
+ dyn ConnectorIntegration<PoRecipientAccount, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<PoQuote, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutQuoteType = dyn ConnectorIntegration<PoQuote, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<PoSync, PayoutsData, PayoutsResponseData>`
+#[cfg(feature = "payouts")]
+pub type PayoutSyncType = dyn ConnectorIntegration<PoSync, PayoutsData, PayoutsResponseData>;
+/// Type alias for `ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>`
+pub type RefreshTokenType =
+ dyn ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>;
+
+/// Type alias for `ConnectorIntegration<Accept, AcceptDisputeRequestData, AcceptDisputeResponse>`
+pub type AcceptDisputeType =
+ dyn ConnectorIntegration<Accept, AcceptDisputeRequestData, AcceptDisputeResponse>;
+/// Type alias for `ConnectorIntegration<VerifyWebhookSource, VerifyWebhookSourceRequestData, VerifyWebhookSourceResponseData>`
+pub type VerifyWebhookSourceType = dyn ConnectorIntegration<
+ VerifyWebhookSource,
+ VerifyWebhookSourceRequestData,
+ VerifyWebhookSourceResponseData,
+>;
+
+/// Type alias for `ConnectorIntegration<Evidence, SubmitEvidenceRequestData, SubmitEvidenceResponse>`
+pub type SubmitEvidenceType =
+ dyn ConnectorIntegration<Evidence, SubmitEvidenceRequestData, SubmitEvidenceResponse>;
+
+/// Type alias for `ConnectorIntegration<Upload, UploadFileRequestData, UploadFileResponse>`
+pub type UploadFileType =
+ dyn ConnectorIntegration<Upload, UploadFileRequestData, UploadFileResponse>;
+
+/// Type alias for `ConnectorIntegration<Retrieve, RetrieveFileRequestData, RetrieveFileResponse>`
+pub type RetrieveFileType =
+ dyn ConnectorIntegration<Retrieve, RetrieveFileRequestData, RetrieveFileResponse>;
+
+/// Type alias for `ConnectorIntegration<Defend, DefendDisputeRequestData, DefendDisputeResponse>`
+pub type DefendDisputeType =
+ dyn ConnectorIntegration<Defend, DefendDisputeRequestData, DefendDisputeResponse>;
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index e7a0db07e8..90774ed0df 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -16,17 +16,17 @@ keymanager_mtls = ["reqwest/rustls-tls", "common_utils/keymanager_mtls"]
encryption_service = ["hyperswitch_domain_models/encryption_service", "common_utils/encryption_service"]
email = ["external_services/email", "scheduler/email", "olap"]
keymanager_create = []
-frm = ["api_models/frm", "hyperswitch_domain_models/frm"]
+frm = ["api_models/frm", "hyperswitch_domain_models/frm", "hyperswitch_connectors/frm", "hyperswitch_interfaces/frm"]
stripe = ["dep:serde_qs"]
release = ["stripe", "email", "accounts_cache", "kv_store", "vergen", "recon", "external_services/aws_kms", "external_services/aws_s3", "keymanager_mtls", "keymanager_create", "encryption_service"]
oltp = ["storage_impl/oltp"]
kv_store = ["scheduler/kv_store"]
accounts_cache = []
vergen = ["router_env/vergen"]
-dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "kgraph_utils/dummy_connector"]
+dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector","hyperswitch_interfaces/dummy_connector", "kgraph_utils/dummy_connector"]
external_access_dc = ["dummy_connector"]
detailed_errors = ["api_models/detailed_errors", "error-stack/serde"]
-payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_domain_models/payouts", "storage_impl/payouts"]
+payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_connectors/payouts", "hyperswitch_domain_models/payouts", "storage_impl/payouts"]
payout_retry = ["payouts"]
recon = ["email", "api_models/recon"]
retry = []
@@ -127,9 +127,10 @@ diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_
euclid = { version = "0.1.0", path = "../euclid", features = ["valued_jit"] }
events = { version = "0.1.0", path = "../events" }
external_services = { version = "0.1.0", path = "../external_services" }
+hyperswitch_connectors = { version = "0.1.0", path = "../hyperswitch_connectors" , default-features = false }
hyperswitch_constraint_graph = { version = "0.1.0", path = "../hyperswitch_constraint_graph" }
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
-hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces" }
+hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
kgraph_utils = { version = "0.1.0", path = "../kgraph_utils" }
masking = { version = "0.1.0", path = "../masking" }
pm_auth = { version = "0.1.0", path = "../pm_auth", package = "pm_auth" }
diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs
index 3a938d0ba6..365b0ca87a 100644
--- a/crates/router/src/connector.rs
+++ b/crates/router/src/connector.rs
@@ -27,7 +27,6 @@ pub mod globalpay;
pub mod globepay;
pub mod gocardless;
pub mod gpayments;
-pub mod helcim;
pub mod iatapay;
pub mod itaubank;
pub mod klarna;
@@ -70,6 +69,8 @@ pub mod worldpay;
pub mod zen;
pub mod zsl;
+pub use hyperswitch_connectors::connectors::{helcim, helcim::Helcim};
+
#[cfg(feature = "dummy_connector")]
pub use self::dummyconnector::DummyConnector;
pub use self::{
@@ -79,8 +80,8 @@ pub use self::{
boku::Boku, braintree::Braintree, cashtocode::Cashtocode, checkout::Checkout,
coinbase::Coinbase, cryptopay::Cryptopay, cybersource::Cybersource, datatrans::Datatrans,
dlocal::Dlocal, ebanx::Ebanx, fiserv::Fiserv, forte::Forte, globalpay::Globalpay,
- globepay::Globepay, gocardless::Gocardless, gpayments::Gpayments, helcim::Helcim,
- iatapay::Iatapay, itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, mollie::Mollie,
+ globepay::Globepay, gocardless::Gocardless, gpayments::Gpayments, iatapay::Iatapay,
+ itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, mollie::Mollie,
multisafepay::Multisafepay, netcetera::Netcetera, nexinets::Nexinets, nmi::Nmi, noon::Noon,
nuvei::Nuvei, opayo::Opayo, opennode::Opennode, payeezy::Payeezy, payme::Payme, payone::Payone,
paypal::Paypal, payu::Payu, placetopay::Placetopay, plaid::Plaid, powertranz::Powertranz,
diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs
index 9d747c2b57..3e54364e59 100644
--- a/crates/router/src/connector/adyen.rs
+++ b/crates/router/src/connector/adyen.rs
@@ -282,9 +282,12 @@ impl ConnectorValidation for Adyen {
fn validate_psync_reference_id(
&self,
- data: &types::PaymentsSyncRouterData,
+ data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
- if data.request.encoded_data.is_some() {
+ if data.encoded_data.is_some() {
return Ok(());
}
Err(errors::ConnectorError::MissingRequiredField {
diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs
index ed54b1e052..e6f01700c6 100644
--- a/crates/router/src/connector/bluesnap.rs
+++ b/crates/router/src/connector/bluesnap.rs
@@ -196,10 +196,13 @@ impl ConnectorValidation for Bluesnap {
fn validate_psync_reference_id(
&self,
- data: &types::PaymentsSyncRouterData,
+ data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ is_three_ds: bool,
+ status: enums::AttemptStatus,
+ connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
// If 3DS payment was triggered, connector will have context about payment in CompleteAuthorizeFlow and thus can't make force_sync
- if data.is_three_ds() && data.status == enums::AttemptStatus::AuthenticationPending {
+ if is_three_ds && status == enums::AttemptStatus::AuthenticationPending {
return Err(
errors::ConnectorError::MissingConnectorRelatedTransactionID {
id: "connector_transaction_id".to_string(),
@@ -209,7 +212,6 @@ impl ConnectorValidation for Bluesnap {
}
// if connector_transaction_id is present, psync can be made
if data
- .request
.connector_transaction_id
.get_connector_transaction_id()
.is_ok()
@@ -218,7 +220,7 @@ impl ConnectorValidation for Bluesnap {
}
// if merchant_id is present, psync can be made along with attempt_id
let meta_data: CustomResult<bluesnap::BluesnapConnectorMetaData, errors::ConnectorError> =
- connector_utils::to_connector_meta_from_secret(data.connector_meta_data.clone());
+ connector_utils::to_connector_meta_from_secret(connector_meta_data.clone());
meta_data.map(|_| ())
}
diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs
index 2bef8d46d7..765a07646c 100644
--- a/crates/router/src/connector/cryptopay.rs
+++ b/crates/router/src/connector/cryptopay.rs
@@ -327,7 +327,10 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
impl ConnectorValidation for Cryptopay {
fn validate_psync_reference_id(
&self,
- _data: &types::PaymentsSyncRouterData,
+ _data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: common_enums::enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
// since we can make psync call with our reference_id, having connector_transaction_id is not an mandatory criteria
Ok(())
diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs
index e43bc0808e..76665c2700 100644
--- a/crates/router/src/connector/nmi.rs
+++ b/crates/router/src/connector/nmi.rs
@@ -124,7 +124,10 @@ impl ConnectorValidation for Nmi {
fn validate_psync_reference_id(
&self,
- _data: &types::PaymentsSyncRouterData,
+ _data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
// in case we dont have transaction id, we can make psync using attempt id
Ok(())
diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs
index 4cc049a558..b2b47e5fd3 100644
--- a/crates/router/src/connector/noon.rs
+++ b/crates/router/src/connector/noon.rs
@@ -205,7 +205,10 @@ impl ConnectorValidation for Noon {
fn validate_psync_reference_id(
&self,
- _data: &types::PaymentsSyncRouterData,
+ _data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
// since we can make psync call with our reference_id, having connector_transaction_id is not an mandatory criteria
Ok(())
diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rs
index 9490ff138d..2d522dbdf1 100644
--- a/crates/router/src/connector/zen.rs
+++ b/crates/router/src/connector/zen.rs
@@ -139,7 +139,10 @@ impl ConnectorCommon for Zen {
impl ConnectorValidation for Zen {
fn validate_psync_reference_id(
&self,
- _data: &types::PaymentsSyncRouterData,
+ _data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: common_enums::enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
// since we can make psync call with our reference_id, having connector_transaction_id is not an mandatory criteria
Ok(())
diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs
index e86f94dc25..dbb50b1803 100644
--- a/crates/router/src/core/payments/connector_integration_v2_impls.rs
+++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs
@@ -661,7 +661,6 @@ default_imp_for_new_connector_integration_payment!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -748,7 +747,6 @@ default_imp_for_new_connector_integration_refund!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -830,7 +828,6 @@ default_imp_for_new_connector_integration_connector_access_token!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -934,7 +931,6 @@ default_imp_for_new_connector_integration_accept_dispute!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1020,7 +1016,6 @@ default_imp_for_new_connector_integration_defend_dispute!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1090,7 +1085,6 @@ default_imp_for_new_connector_integration_submit_evidence!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1187,7 +1181,6 @@ default_imp_for_new_connector_integration_file_upload!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1355,7 +1348,6 @@ default_imp_for_new_connector_integration_payouts_create!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1444,7 +1436,6 @@ default_imp_for_new_connector_integration_payouts_eligibility!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1533,7 +1524,6 @@ default_imp_for_new_connector_integration_payouts_fulfill!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1622,7 +1612,6 @@ default_imp_for_new_connector_integration_payouts_cancel!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1711,7 +1700,6 @@ default_imp_for_new_connector_integration_payouts_quote!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1800,7 +1788,6 @@ default_imp_for_new_connector_integration_payouts_recipient!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1889,7 +1876,6 @@ default_imp_for_new_connector_integration_payouts_sync!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1978,7 +1964,6 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2065,7 +2050,6 @@ default_imp_for_new_connector_integration_webhook_source_verification!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2233,7 +2217,6 @@ default_imp_for_new_connector_integration_frm_sale!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2322,7 +2305,6 @@ default_imp_for_new_connector_integration_frm_checkout!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2411,7 +2393,6 @@ default_imp_for_new_connector_integration_frm_transaction!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2500,7 +2481,6 @@ default_imp_for_new_connector_integration_frm_fulfillment!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2589,7 +2569,6 @@ default_imp_for_new_connector_integration_frm_record_return!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2675,7 +2654,6 @@ default_imp_for_new_connector_integration_revoking_mandates!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index 3e9d18d117..32d739bcf9 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -206,7 +206,6 @@ default_imp_for_complete_authorize!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -294,7 +293,6 @@ default_imp_for_webhook_source_verification!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -390,7 +388,6 @@ default_imp_for_create_customer!(
connector::Globalpay,
connector::Globepay,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -652,7 +649,6 @@ default_imp_for_accept_dispute!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -771,7 +767,6 @@ default_imp_for_file_upload!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -867,7 +862,6 @@ default_imp_for_submit_evidence!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -963,7 +957,6 @@ default_imp_for_defend_dispute!(
connector::Globalpay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1074,7 +1067,6 @@ default_imp_for_pre_processing_steps!(
connector::Globalpay,
connector::Globepay,
connector::Gpayments,
- connector::Helcim,
connector::Klarna,
connector::Mifinity,
connector::Mollie,
@@ -1157,7 +1149,6 @@ default_imp_for_post_processing_steps!(
connector::Globalpay,
connector::Globepay,
connector::Gpayments,
- connector::Helcim,
connector::Klarna,
connector::Mifinity,
connector::Mollie,
@@ -1318,7 +1309,6 @@ default_imp_for_payouts_create!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1414,7 +1404,6 @@ default_imp_for_payouts_retrieve!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1513,7 +1502,6 @@ default_imp_for_payouts_eligibility!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1607,7 +1595,6 @@ default_imp_for_payouts_fulfill!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1700,7 +1687,6 @@ default_imp_for_payouts_cancel!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1796,7 +1782,6 @@ default_imp_for_payouts_quote!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1893,7 +1878,6 @@ default_imp_for_payouts_recipient!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -1993,7 +1977,6 @@ default_imp_for_payouts_recipient_account!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2090,7 +2073,6 @@ default_imp_for_approve!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2188,7 +2170,6 @@ default_imp_for_reject!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2368,7 +2349,6 @@ default_imp_for_frm_sale!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2466,7 +2446,6 @@ default_imp_for_frm_checkout!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2564,7 +2543,6 @@ default_imp_for_frm_transaction!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2662,7 +2640,6 @@ default_imp_for_frm_fulfillment!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2760,7 +2737,6 @@ default_imp_for_frm_record_return!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2855,7 +2831,6 @@ default_imp_for_incremental_authorization!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -2950,7 +2925,6 @@ default_imp_for_revoking_mandates!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
@@ -3198,7 +3172,6 @@ default_imp_for_authorize_session_token!(
connector::Globepay,
connector::Gocardless,
connector::Gpayments,
- connector::Helcim,
connector::Iatapay,
connector::Itaubank,
connector::Klarna,
diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs
index cb6c6f50d5..ab53aee86d 100644
--- a/crates/router/src/core/payments/flows/psync_flow.rs
+++ b/crates/router/src/core/payments/flows/psync_flow.rs
@@ -4,6 +4,7 @@ use async_trait::async_trait;
use super::{ConstructFlowSpecificData, Feature};
use crate::{
+ connector::utils::RouterData,
core::{
errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult},
payments::{self, access_token, helpers, transformers, PaymentData},
@@ -12,7 +13,6 @@ use crate::{
services::{self, api::ConnectorValidation, logger},
types::{self, api, domain, storage},
};
-
#[async_trait]
impl ConstructFlowSpecificData<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>
for PaymentData<api::PSync>
@@ -151,7 +151,12 @@ impl Feature<api::PSync, types::PaymentsSyncData>
//validate_psync_reference_id if call_connector_action is trigger
if connector
.connector
- .validate_psync_reference_id(self)
+ .validate_psync_reference_id(
+ &self.request,
+ self.is_three_ds(),
+ self.status,
+ self.connector_meta_data.clone(),
+ )
.is_err()
{
logger::warn!(
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index 129be81e41..517d8a4df7 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -17,7 +17,6 @@ use actix_web::{
http::header::{HeaderName, HeaderValue},
web, FromRequest, HttpRequest, HttpResponse, Responder, ResponseError,
};
-use api_models::enums::{CaptureMethod, PaymentMethodType};
pub use client::{proxy_bypass_urls, ApiClient, MockApiClient, ProxyClient};
pub use common_utils::request::{ContentType, Method, Request, RequestBuilder};
use common_utils::{
@@ -37,7 +36,8 @@ pub use hyperswitch_domain_models::{
};
pub use hyperswitch_interfaces::{
api::{
- BoxedConnectorIntegration, CaptureSyncMethod, ConnectorIntegration, ConnectorIntegrationAny,
+ BoxedConnectorIntegration, CaptureSyncMethod, ConnectorIntegration,
+ ConnectorIntegrationAny, ConnectorValidation,
},
connector_integration_v2::{
BoxedConnectorIntegrationV2, ConnectorIntegrationAnyV2, ConnectorIntegrationV2,
@@ -75,11 +75,7 @@ use crate::{
connector_integration_interface::RouterDataConversion,
generic_link_response::build_generic_link_html,
},
- types::{
- self,
- api::{self, ConnectorCommon},
- ErrorResponse,
- },
+ types::{self, api, ErrorResponse},
};
pub type BoxedPaymentConnectorIntegrationInterface<T, Req, Resp> =
@@ -105,61 +101,6 @@ pub type BoxedAccessTokenConnectorIntegrationInterface<T, Req, Resp> =
pub type BoxedFilesConnectorIntegrationInterface<T, Req, Resp> =
BoxedConnectorIntegrationInterface<T, common_types::FilesFlowData, Req, Resp>;
-pub trait ConnectorValidation: ConnectorCommon {
- fn validate_capture_method(
- &self,
- capture_method: Option<CaptureMethod>,
- _pmt: Option<PaymentMethodType>,
- ) -> CustomResult<(), errors::ConnectorError> {
- let capture_method = capture_method.unwrap_or_default();
- match capture_method {
- CaptureMethod::Automatic => Ok(()),
- CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => {
- Err(errors::ConnectorError::NotSupported {
- message: capture_method.to_string(),
- connector: self.id(),
- }
- .into())
- }
- }
- }
-
- fn validate_mandate_payment(
- &self,
- pm_type: Option<PaymentMethodType>,
- _pm_data: types::domain::payments::PaymentMethodData,
- ) -> CustomResult<(), errors::ConnectorError> {
- let connector = self.id();
- match pm_type {
- Some(pm_type) => Err(errors::ConnectorError::NotSupported {
- message: format!("{} mandate payment", pm_type),
- connector,
- }
- .into()),
- None => Err(errors::ConnectorError::NotSupported {
- message: " mandate payment".to_string(),
- connector,
- }
- .into()),
- }
- }
-
- fn validate_psync_reference_id(
- &self,
- data: &types::PaymentsSyncRouterData,
- ) -> CustomResult<(), errors::ConnectorError> {
- data.request
- .connector_transaction_id
- .get_connector_transaction_id()
- .change_context(errors::ConnectorError::MissingConnectorTransactionID)
- .map(|_| ())
- }
-
- fn is_webhook_source_verification_mandatory(&self) -> bool {
- false
- }
-}
-
/// Handle the flow by interacting with connector module
/// `connector_request` is applicable only in case if the `CallConnectorAction` is `Trigger`
/// In other cases, It will be created if required, even if it is not passed
diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs
index d2376feb74..8da81a52f9 100644
--- a/crates/router/src/services/connector_integration_interface.rs
+++ b/crates/router/src/services/connector_integration_interface.rs
@@ -359,11 +359,24 @@ impl ConnectorValidation for ConnectorEnum {
fn validate_psync_reference_id(
&self,
- data: &types::PaymentsSyncRouterData,
+ data: &hyperswitch_domain_models::router_request_types::PaymentsSyncData,
+ is_three_ds: bool,
+ status: common_enums::enums::AttemptStatus,
+ connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
match self {
- Self::Old(connector) => connector.validate_psync_reference_id(data),
- Self::New(connector) => connector.validate_psync_reference_id(data),
+ Self::Old(connector) => connector.validate_psync_reference_id(
+ data,
+ is_three_ds,
+ status,
+ connector_meta_data,
+ ),
+ Self::New(connector) => connector.validate_psync_reference_id(
+ data,
+ is_three_ds,
+ status,
+ connector_meta_data,
+ ),
}
}
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 641553642a..d3c5d7c256 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -23,6 +23,20 @@ pub use api_models::{enums::PayoutConnectors, payouts as payout_types};
pub use common_utils::{pii, pii::Email, request::RequestContent, types::MinorUnit};
#[cfg(feature = "frm")]
pub use hyperswitch_domain_models::router_data_v2::FrmFlowData;
+use hyperswitch_domain_models::router_flow_types::{
+ self,
+ access_token_auth::AccessTokenAuth,
+ dispute::{Accept, Defend, Evidence},
+ files::{Retrieve, Upload},
+ mandate_revoke::MandateRevoke,
+ payments::{
+ Approve, Authorize, AuthorizeSessionToken, Balance, Capture, CompleteAuthorize,
+ CreateConnectorCustomer, IncrementalAuthorization, InitPayment, PSync, PostProcessing,
+ PreProcessing, Reject, Session, SetupMandate, Void,
+ },
+ refunds::{Execute, RSync},
+ webhooks::VerifyWebhookSource,
+};
pub use hyperswitch_domain_models::{
payment_address::PaymentAddress,
router_data::{
@@ -60,7 +74,20 @@ pub use hyperswitch_domain_models::{
router_data_v2::PayoutFlowData, router_request_types::PayoutsData,
router_response_types::PayoutsResponseData,
};
-pub use hyperswitch_interfaces::types::Response;
+pub use hyperswitch_interfaces::types::{
+ AcceptDisputeType, ConnectorCustomerType, DefendDisputeType, IncrementalAuthorizationType,
+ MandateRevokeType, PaymentsAuthorizeType, PaymentsBalanceType, PaymentsCaptureType,
+ PaymentsCompleteAuthorizeType, PaymentsInitType, PaymentsPostProcessingType,
+ PaymentsPreAuthorizeType, PaymentsPreProcessingType, PaymentsSessionType, PaymentsSyncType,
+ PaymentsVoidType, RefreshTokenType, RefundExecuteType, RefundSyncType, Response,
+ RetrieveFileType, SetupMandateType, SubmitEvidenceType, TokenizationType, UploadFileType,
+ VerifyWebhookSourceType,
+};
+#[cfg(feature = "payouts")]
+pub use hyperswitch_interfaces::types::{
+ PayoutCancelType, PayoutCreateType, PayoutEligibilityType, PayoutFulfillType, PayoutQuoteType,
+ PayoutRecipientAccountType, PayoutRecipientType, PayoutSyncType,
+};
pub use crate::core::payments::CustomerDetails;
#[cfg(feature = "payouts")]
@@ -77,232 +104,94 @@ use crate::{
services,
types::transformers::{ForeignFrom, ForeignTryFrom},
};
+
pub type PaymentsAuthorizeRouterData =
- RouterData<api::Authorize, PaymentsAuthorizeData, PaymentsResponseData>;
+ RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData>;
pub type PaymentsPreProcessingRouterData =
- RouterData<api::PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>;
+ RouterData<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>;
pub type PaymentsPostProcessingRouterData =
- RouterData<api::PostProcessing, PaymentsPostProcessingData, PaymentsResponseData>;
+ RouterData<PostProcessing, PaymentsPostProcessingData, PaymentsResponseData>;
pub type PaymentsAuthorizeSessionTokenRouterData =
- RouterData<api::AuthorizeSessionToken, AuthorizeSessionTokenData, PaymentsResponseData>;
+ RouterData<AuthorizeSessionToken, AuthorizeSessionTokenData, PaymentsResponseData>;
pub type PaymentsCompleteAuthorizeRouterData =
- RouterData<api::CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>;
+ RouterData<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>;
pub type PaymentsInitRouterData =
- RouterData<api::InitPayment, PaymentsAuthorizeData, PaymentsResponseData>;
+ RouterData<InitPayment, PaymentsAuthorizeData, PaymentsResponseData>;
pub type PaymentsBalanceRouterData =
- RouterData<api::Balance, PaymentsAuthorizeData, PaymentsResponseData>;
-pub type PaymentsSyncRouterData = RouterData<api::PSync, PaymentsSyncData, PaymentsResponseData>;
-pub type PaymentsCaptureRouterData =
- RouterData<api::Capture, PaymentsCaptureData, PaymentsResponseData>;
+ RouterData<Balance, PaymentsAuthorizeData, PaymentsResponseData>;
+pub type PaymentsSyncRouterData = RouterData<PSync, PaymentsSyncData, PaymentsResponseData>;
+pub type PaymentsCaptureRouterData = RouterData<Capture, PaymentsCaptureData, PaymentsResponseData>;
pub type PaymentsIncrementalAuthorizationRouterData = RouterData<
- api::IncrementalAuthorization,
+ IncrementalAuthorization,
PaymentsIncrementalAuthorizationData,
PaymentsResponseData,
>;
-pub type PaymentsCancelRouterData = RouterData<api::Void, PaymentsCancelData, PaymentsResponseData>;
-pub type PaymentsRejectRouterData =
- RouterData<api::Reject, PaymentsRejectData, PaymentsResponseData>;
-pub type PaymentsApproveRouterData =
- RouterData<api::Approve, PaymentsApproveData, PaymentsResponseData>;
-pub type PaymentsSessionRouterData =
- RouterData<api::Session, PaymentsSessionData, PaymentsResponseData>;
+pub type PaymentsCancelRouterData = RouterData<Void, PaymentsCancelData, PaymentsResponseData>;
+pub type PaymentsRejectRouterData = RouterData<Reject, PaymentsRejectData, PaymentsResponseData>;
+pub type PaymentsApproveRouterData = RouterData<Approve, PaymentsApproveData, PaymentsResponseData>;
+pub type PaymentsSessionRouterData = RouterData<Session, PaymentsSessionData, PaymentsResponseData>;
pub type RefundsRouterData<F> = RouterData<F, RefundsData, RefundsResponseData>;
-pub type RefundExecuteRouterData = RouterData<api::Execute, RefundsData, RefundsResponseData>;
-pub type RefundSyncRouterData = RouterData<api::RSync, RefundsData, RefundsResponseData>;
-pub type TokenizationRouterData =
- RouterData<api::PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>;
+pub type RefundExecuteRouterData = RouterData<Execute, RefundsData, RefundsResponseData>;
+pub type RefundSyncRouterData = RouterData<RSync, RefundsData, RefundsResponseData>;
+pub type TokenizationRouterData = RouterData<
+ router_flow_types::PaymentMethodToken,
+ PaymentMethodTokenizationData,
+ PaymentsResponseData,
+>;
pub type ConnectorCustomerRouterData =
- RouterData<api::CreateConnectorCustomer, ConnectorCustomerData, PaymentsResponseData>;
+ RouterData<CreateConnectorCustomer, ConnectorCustomerData, PaymentsResponseData>;
-pub type RefreshTokenRouterData =
- RouterData<api::AccessTokenAuth, AccessTokenRequestData, AccessToken>;
+pub type RefreshTokenRouterData = RouterData<AccessTokenAuth, AccessTokenRequestData, AccessToken>;
pub type PaymentsResponseRouterData<R> =
- ResponseRouterData<api::Authorize, R, PaymentsAuthorizeData, PaymentsResponseData>;
+ ResponseRouterData<Authorize, R, PaymentsAuthorizeData, PaymentsResponseData>;
pub type PaymentsCancelResponseRouterData<R> =
- ResponseRouterData<api::Void, R, PaymentsCancelData, PaymentsResponseData>;
+ ResponseRouterData<Void, R, PaymentsCancelData, PaymentsResponseData>;
pub type PaymentsBalanceResponseRouterData<R> =
- ResponseRouterData<api::Balance, R, PaymentsAuthorizeData, PaymentsResponseData>;
+ ResponseRouterData<Balance, R, PaymentsAuthorizeData, PaymentsResponseData>;
pub type PaymentsSyncResponseRouterData<R> =
- ResponseRouterData<api::PSync, R, PaymentsSyncData, PaymentsResponseData>;
+ ResponseRouterData<PSync, R, PaymentsSyncData, PaymentsResponseData>;
pub type PaymentsSessionResponseRouterData<R> =
- ResponseRouterData<api::Session, R, PaymentsSessionData, PaymentsResponseData>;
+ ResponseRouterData<Session, R, PaymentsSessionData, PaymentsResponseData>;
pub type PaymentsInitResponseRouterData<R> =
- ResponseRouterData<api::InitPayment, R, PaymentsAuthorizeData, PaymentsResponseData>;
+ ResponseRouterData<InitPayment, R, PaymentsAuthorizeData, PaymentsResponseData>;
pub type PaymentsCaptureResponseRouterData<R> =
- ResponseRouterData<api::Capture, R, PaymentsCaptureData, PaymentsResponseData>;
+ ResponseRouterData<Capture, R, PaymentsCaptureData, PaymentsResponseData>;
pub type PaymentsPreprocessingResponseRouterData<R> =
- ResponseRouterData<api::PreProcessing, R, PaymentsPreProcessingData, PaymentsResponseData>;
-pub type TokenizationResponseRouterData<R> = ResponseRouterData<
- api::PaymentMethodToken,
- R,
- PaymentMethodTokenizationData,
- PaymentsResponseData,
->;
-pub type ConnectorCustomerResponseRouterData<R> = ResponseRouterData<
- api::CreateConnectorCustomer,
- R,
- ConnectorCustomerData,
- PaymentsResponseData,
->;
+ ResponseRouterData<PreProcessing, R, PaymentsPreProcessingData, PaymentsResponseData>;
+pub type TokenizationResponseRouterData<R> =
+ ResponseRouterData<PaymentMethodToken, R, PaymentMethodTokenizationData, PaymentsResponseData>;
+pub type ConnectorCustomerResponseRouterData<R> =
+ ResponseRouterData<CreateConnectorCustomer, R, ConnectorCustomerData, PaymentsResponseData>;
pub type RefundsResponseRouterData<F, R> =
ResponseRouterData<F, R, RefundsData, RefundsResponseData>;
-pub type PaymentsAuthorizeType =
- dyn services::ConnectorIntegration<api::Authorize, PaymentsAuthorizeData, PaymentsResponseData>;
-pub type SetupMandateType = dyn services::ConnectorIntegration<
- api::SetupMandate,
- SetupMandateRequestData,
- PaymentsResponseData,
->;
-pub type MandateRevokeType = dyn services::ConnectorIntegration<
- api::MandateRevoke,
- MandateRevokeRequestData,
- MandateRevokeResponseData,
->;
-pub type PaymentsPreProcessingType = dyn services::ConnectorIntegration<
- api::PreProcessing,
- PaymentsPreProcessingData,
- PaymentsResponseData,
->;
-pub type PaymentsPostProcessingType = dyn services::ConnectorIntegration<
- api::PostProcessing,
- PaymentsPostProcessingData,
- PaymentsResponseData,
->;
-pub type PaymentsCompleteAuthorizeType = dyn services::ConnectorIntegration<
- api::CompleteAuthorize,
- CompleteAuthorizeData,
- PaymentsResponseData,
->;
-pub type PaymentsPreAuthorizeType = dyn services::ConnectorIntegration<
- api::AuthorizeSessionToken,
- AuthorizeSessionTokenData,
- PaymentsResponseData,
->;
-pub type PaymentsInitType = dyn services::ConnectorIntegration<
- api::InitPayment,
- PaymentsAuthorizeData,
- PaymentsResponseData,
->;
-pub type PaymentsBalanceType =
- dyn services::ConnectorIntegration<api::Balance, PaymentsAuthorizeData, PaymentsResponseData>;
-pub type PaymentsSyncType =
- dyn services::ConnectorIntegration<api::PSync, PaymentsSyncData, PaymentsResponseData>;
-pub type PaymentsCaptureType =
- dyn services::ConnectorIntegration<api::Capture, PaymentsCaptureData, PaymentsResponseData>;
-pub type PaymentsSessionType =
- dyn services::ConnectorIntegration<api::Session, PaymentsSessionData, PaymentsResponseData>;
-pub type PaymentsVoidType =
- dyn services::ConnectorIntegration<api::Void, PaymentsCancelData, PaymentsResponseData>;
-pub type TokenizationType = dyn services::ConnectorIntegration<
- api::PaymentMethodToken,
- PaymentMethodTokenizationData,
- PaymentsResponseData,
->;
-pub type IncrementalAuthorizationType = dyn services::ConnectorIntegration<
- api::IncrementalAuthorization,
- PaymentsIncrementalAuthorizationData,
- PaymentsResponseData,
->;
-
-pub type ConnectorCustomerType = dyn services::ConnectorIntegration<
- api::CreateConnectorCustomer,
- ConnectorCustomerData,
- PaymentsResponseData,
->;
-
-pub type RefundExecuteType =
- dyn services::ConnectorIntegration<api::Execute, RefundsData, RefundsResponseData>;
-pub type RefundSyncType =
- dyn services::ConnectorIntegration<api::RSync, RefundsData, RefundsResponseData>;
-
-#[cfg(feature = "payouts")]
-pub type PayoutCancelType =
- dyn services::ConnectorIntegration<api::PoCancel, PayoutsData, PayoutsResponseData>;
-#[cfg(feature = "payouts")]
-pub type PayoutCreateType =
- dyn services::ConnectorIntegration<api::PoCreate, PayoutsData, PayoutsResponseData>;
-#[cfg(feature = "payouts")]
-pub type PayoutEligibilityType =
- dyn services::ConnectorIntegration<api::PoEligibility, PayoutsData, PayoutsResponseData>;
-#[cfg(feature = "payouts")]
-pub type PayoutFulfillType =
- dyn services::ConnectorIntegration<api::PoFulfill, PayoutsData, PayoutsResponseData>;
-#[cfg(feature = "payouts")]
-pub type PayoutRecipientType =
- dyn services::ConnectorIntegration<api::PoRecipient, PayoutsData, PayoutsResponseData>;
-#[cfg(feature = "payouts")]
-pub type PayoutRecipientAccountType =
- dyn services::ConnectorIntegration<api::PoRecipientAccount, PayoutsData, PayoutsResponseData>;
-#[cfg(feature = "payouts")]
-pub type PayoutQuoteType =
- dyn services::ConnectorIntegration<api::PoQuote, PayoutsData, PayoutsResponseData>;
-#[cfg(feature = "payouts")]
-pub type PayoutSyncType =
- dyn services::ConnectorIntegration<api::PoSync, PayoutsData, PayoutsResponseData>;
-
-pub type RefreshTokenType =
- dyn services::ConnectorIntegration<api::AccessTokenAuth, AccessTokenRequestData, AccessToken>;
-
-pub type AcceptDisputeType = dyn services::ConnectorIntegration<
- api::Accept,
- AcceptDisputeRequestData,
- AcceptDisputeResponse,
->;
-pub type VerifyWebhookSourceType = dyn services::ConnectorIntegration<
- api::VerifyWebhookSource,
- VerifyWebhookSourceRequestData,
- VerifyWebhookSourceResponseData,
->;
-
-pub type SubmitEvidenceType = dyn services::ConnectorIntegration<
- api::Evidence,
- SubmitEvidenceRequestData,
- SubmitEvidenceResponse,
->;
-
-pub type UploadFileType =
- dyn services::ConnectorIntegration<api::Upload, UploadFileRequestData, UploadFileResponse>;
-
-pub type RetrieveFileType = dyn services::ConnectorIntegration<
- api::Retrieve,
- RetrieveFileRequestData,
- RetrieveFileResponse,
->;
-
-pub type DefendDisputeType = dyn services::ConnectorIntegration<
- api::Defend,
- DefendDisputeRequestData,
- DefendDisputeResponse,
->;
-
pub type SetupMandateRouterData =
- RouterData<api::SetupMandate, SetupMandateRequestData, PaymentsResponseData>;
+ RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>;
pub type AcceptDisputeRouterData =
- RouterData<api::Accept, AcceptDisputeRequestData, AcceptDisputeResponse>;
+ RouterData<Accept, AcceptDisputeRequestData, AcceptDisputeResponse>;
pub type VerifyWebhookSourceRouterData = RouterData<
- api::VerifyWebhookSource,
+ VerifyWebhookSource,
VerifyWebhookSourceRequestData,
VerifyWebhookSourceResponseData,
>;
pub type SubmitEvidenceRouterData =
- RouterData<api::Evidence, SubmitEvidenceRequestData, SubmitEvidenceResponse>;
+ RouterData<Evidence, SubmitEvidenceRequestData, SubmitEvidenceResponse>;
-pub type UploadFileRouterData = RouterData<api::Upload, UploadFileRequestData, UploadFileResponse>;
+pub type UploadFileRouterData = RouterData<Upload, UploadFileRequestData, UploadFileResponse>;
pub type RetrieveFileRouterData =
- RouterData<api::Retrieve, RetrieveFileRequestData, RetrieveFileResponse>;
+ RouterData<Retrieve, RetrieveFileRequestData, RetrieveFileResponse>;
pub type DefendDisputeRouterData =
- RouterData<api::Defend, DefendDisputeRequestData, DefendDisputeResponse>;
+ RouterData<Defend, DefendDisputeRequestData, DefendDisputeResponse>;
pub type MandateRevokeRouterData =
- RouterData<api::MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>;
+ RouterData<MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>;
#[cfg(feature = "payouts")]
pub type PayoutsRouterData<F> = RouterData<F, PayoutsData, PayoutsResponseData>;
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index ec474242d2..ceb50a9882 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -39,11 +39,15 @@ pub mod refunds_v2;
use std::{fmt::Debug, str::FromStr};
use error_stack::{report, ResultExt};
-use hyperswitch_domain_models::router_data_v2::AccessTokenFlowData;
pub use hyperswitch_domain_models::router_flow_types::{
- access_token_auth::AccessTokenAuth, webhooks::VerifyWebhookSource,
+ access_token_auth::AccessTokenAuth, mandate_revoke::MandateRevoke,
+ webhooks::VerifyWebhookSource,
+};
+pub use hyperswitch_interfaces::api::{
+ ConnectorAccessToken, ConnectorAccessTokenV2, ConnectorCommon, ConnectorCommonExt,
+ ConnectorMandateRevoke, ConnectorMandateRevokeV2, ConnectorVerifyWebhookSource,
+ ConnectorVerifyWebhookSourceV2, CurrencyUnit,
};
-pub use hyperswitch_interfaces::api::{ConnectorCommon, ConnectorCommonExt, CurrencyUnit};
#[cfg(feature = "frm")]
pub use self::fraud_check::*;
@@ -51,7 +55,8 @@ pub use self::fraud_check::*;
pub use self::payouts::*;
pub use self::{
admin::*, api_keys::*, authentication::*, configs::*, customers::*, disputes::*, files::*,
- payment_link::*, payment_methods::*, payments::*, poll::*, refunds::*, webhooks::*,
+ payment_link::*, payment_methods::*, payments::*, poll::*, refunds::*, refunds_v2::*,
+ webhooks::*,
};
use crate::{
configs::settings::Connectors,
@@ -60,26 +65,9 @@ use crate::{
errors::{self, CustomResult},
payments::types as payments_types,
},
- services::{
- connector_integration_interface::ConnectorEnum, ConnectorIntegration,
- ConnectorIntegrationV2, ConnectorRedirectResponse, ConnectorValidation,
- },
+ services::{connector_integration_interface::ConnectorEnum, ConnectorRedirectResponse},
types::{self, api::enums as api_enums},
};
-pub trait ConnectorAccessToken:
- ConnectorIntegration<AccessTokenAuth, types::AccessTokenRequestData, types::AccessToken>
-{
-}
-
-pub trait ConnectorAccessTokenV2:
- ConnectorIntegrationV2<
- AccessTokenAuth,
- AccessTokenFlowData,
- types::AccessTokenRequestData,
- types::AccessToken,
->
-{
-}
#[derive(Clone)]
pub enum ConnectorCallType {
@@ -88,46 +76,6 @@ pub enum ConnectorCallType {
SessionMultiple(Vec<SessionConnectorData>),
}
-pub trait ConnectorVerifyWebhookSource:
- ConnectorIntegration<
- VerifyWebhookSource,
- types::VerifyWebhookSourceRequestData,
- types::VerifyWebhookSourceResponseData,
->
-{
-}
-pub trait ConnectorVerifyWebhookSourceV2:
- ConnectorIntegrationV2<
- VerifyWebhookSource,
- types::WebhookSourceVerifyData,
- types::VerifyWebhookSourceRequestData,
- types::VerifyWebhookSourceResponseData,
->
-{
-}
-
-#[derive(Clone, Debug)]
-pub struct MandateRevoke;
-
-pub trait ConnectorMandateRevoke:
- ConnectorIntegration<
- MandateRevoke,
- types::MandateRevokeRequestData,
- types::MandateRevokeResponseData,
->
-{
-}
-
-pub trait ConnectorMandateRevokeV2:
- ConnectorIntegrationV2<
- MandateRevoke,
- types::MandateRevokeFlowData,
- types::MandateRevokeRequestData,
- types::MandateRevokeResponseData,
->
-{
-}
-
pub trait ConnectorTransactionId: ConnectorCommon + Sync {
fn connector_transaction_id(
&self,
diff --git a/crates/router/src/types/api/disputes.rs b/crates/router/src/types/api/disputes.rs
index 247b8bf45e..b3bc66e010 100644
--- a/crates/router/src/types/api/disputes.rs
+++ b/crates/router/src/types/api/disputes.rs
@@ -1,7 +1,10 @@
-pub use hyperswitch_interfaces::disputes::DisputePayload;
+pub use hyperswitch_interfaces::{
+ api::disputes::{AcceptDispute, DefendDispute, Dispute, SubmitEvidence},
+ disputes::DisputePayload,
+};
use masking::{Deserialize, Serialize};
-use crate::{services, types};
+use crate::types;
#[derive(Default, Debug, Deserialize, Serialize)]
pub struct DisputeId {
@@ -47,32 +50,3 @@ pub enum EvidenceType {
RecurringTransactionAgreement,
UncategorizedFile,
}
-
-pub trait AcceptDispute:
- services::ConnectorIntegration<
- Accept,
- types::AcceptDisputeRequestData,
- types::AcceptDisputeResponse,
->
-{
-}
-
-pub trait SubmitEvidence:
- services::ConnectorIntegration<
- Evidence,
- types::SubmitEvidenceRequestData,
- types::SubmitEvidenceResponse,
->
-{
-}
-
-pub trait DefendDispute:
- services::ConnectorIntegration<
- Defend,
- types::DefendDisputeRequestData,
- types::DefendDisputeResponse,
->
-{
-}
-
-pub trait Dispute: super::ConnectorCommon + AcceptDispute + SubmitEvidence + DefendDispute {}
diff --git a/crates/router/src/types/api/disputes_v2.rs b/crates/router/src/types/api/disputes_v2.rs
index e9df4cc3cd..af9594cf60 100644
--- a/crates/router/src/types/api/disputes_v2.rs
+++ b/crates/router/src/types/api/disputes_v2.rs
@@ -1,41 +1,3 @@
-use hyperswitch_domain_models::{
- router_data_v2::DisputesFlowData,
- router_flow_types::dispute::{Accept, Defend, Evidence},
+pub use hyperswitch_interfaces::api::disputes_v2::{
+ AcceptDisputeV2, DefendDisputeV2, DisputeV2, SubmitEvidenceV2,
};
-
-use crate::{services, types};
-
-pub trait AcceptDisputeV2:
- services::ConnectorIntegrationV2<
- Accept,
- DisputesFlowData,
- types::AcceptDisputeRequestData,
- types::AcceptDisputeResponse,
->
-{
-}
-
-pub trait SubmitEvidenceV2:
- services::ConnectorIntegrationV2<
- Evidence,
- DisputesFlowData,
- types::SubmitEvidenceRequestData,
- types::SubmitEvidenceResponse,
->
-{
-}
-
-pub trait DefendDisputeV2:
- services::ConnectorIntegrationV2<
- Defend,
- DisputesFlowData,
- types::DefendDisputeRequestData,
- types::DefendDisputeResponse,
->
-{
-}
-
-pub trait DisputeV2:
- super::ConnectorCommon + AcceptDisputeV2 + SubmitEvidenceV2 + DefendDisputeV2
-{
-}
diff --git a/crates/router/src/types/api/files.rs b/crates/router/src/types/api/files.rs
index fd09401411..9a991c040f 100644
--- a/crates/router/src/types/api/files.rs
+++ b/crates/router/src/types/api/files.rs
@@ -1,13 +1,12 @@
use api_models::enums::FileUploadProvider;
pub use hyperswitch_domain_models::router_flow_types::files::{Retrieve, Upload};
+pub use hyperswitch_interfaces::api::files::{FilePurpose, FileUpload, RetrieveFile, UploadFile};
use masking::{Deserialize, Serialize};
use serde_with::serde_as;
pub use super::files_v2::{FileUploadV2, RetrieveFileV2, UploadFileV2};
-use super::ConnectorCommon;
use crate::{
core::errors,
- services,
types::{self, transformers::ForeignTryFrom},
};
@@ -61,38 +60,3 @@ pub struct CreateFileRequest {
pub purpose: FilePurpose,
pub dispute_id: Option<String>,
}
-
-#[derive(Debug, serde::Deserialize, strum::Display, Clone, serde::Serialize)]
-#[serde(rename_all = "snake_case")]
-#[strum(serialize_all = "snake_case")]
-pub enum FilePurpose {
- DisputeEvidence,
-}
-
-pub trait UploadFile:
- services::ConnectorIntegration<Upload, types::UploadFileRequestData, types::UploadFileResponse>
-{
-}
-
-pub trait RetrieveFile:
- services::ConnectorIntegration<
- Retrieve,
- types::RetrieveFileRequestData,
- types::RetrieveFileResponse,
->
-{
-}
-
-pub trait FileUpload: ConnectorCommon + Sync + UploadFile + RetrieveFile {
- fn validate_file_upload(
- &self,
- _purpose: FilePurpose,
- _file_size: i32,
- _file_type: mime::Mime,
- ) -> common_utils::errors::CustomResult<(), errors::ConnectorError> {
- Err(errors::ConnectorError::FileValidationFailed {
- reason: "".to_owned(),
- }
- .into())
- }
-}
diff --git a/crates/router/src/types/api/files_v2.rs b/crates/router/src/types/api/files_v2.rs
index 9e9ba423e6..8ea5661ae9 100644
--- a/crates/router/src/types/api/files_v2.rs
+++ b/crates/router/src/types/api/files_v2.rs
@@ -1,38 +1,2 @@
pub use hyperswitch_domain_models::router_flow_types::files::{Retrieve, Upload};
-
-use super::ConnectorCommon;
-use crate::{core::errors, services, types, types::api::FilePurpose};
-
-pub trait UploadFileV2:
- services::ConnectorIntegrationV2<
- Upload,
- types::FilesFlowData,
- types::UploadFileRequestData,
- types::UploadFileResponse,
->
-{
-}
-
-pub trait RetrieveFileV2:
- services::ConnectorIntegrationV2<
- Retrieve,
- types::FilesFlowData,
- types::RetrieveFileRequestData,
- types::RetrieveFileResponse,
->
-{
-}
-
-pub trait FileUploadV2: ConnectorCommon + Sync + UploadFileV2 + RetrieveFileV2 {
- fn validate_file_upload_v2(
- &self,
- _purpose: FilePurpose,
- _file_size: i32,
- _file_type: mime::Mime,
- ) -> common_utils::errors::CustomResult<(), errors::ConnectorError> {
- Err(errors::ConnectorError::FileValidationFailed {
- reason: "".to_owned(),
- }
- .into())
- }
-}
+pub use hyperswitch_interfaces::api::files_v2::{FileUploadV2, RetrieveFileV2, UploadFileV2};
diff --git a/crates/router/src/types/api/fraud_check.rs b/crates/router/src/types/api/fraud_check.rs
index f0d2d0c6f0..2d1a42092f 100644
--- a/crates/router/src/types/api/fraud_check.rs
+++ b/crates/router/src/types/api/fraud_check.rs
@@ -6,46 +6,17 @@ use error_stack::ResultExt;
pub use hyperswitch_domain_models::router_flow_types::fraud_check::{
Checkout, Fulfillment, RecordReturn, Sale, Transaction,
};
+pub use hyperswitch_interfaces::api::fraud_check::{
+ FraudCheckCheckout, FraudCheckFulfillment, FraudCheckRecordReturn, FraudCheckSale,
+ FraudCheckTransaction,
+};
pub use super::fraud_check_v2::{
FraudCheckCheckoutV2, FraudCheckFulfillmentV2, FraudCheckRecordReturnV2, FraudCheckSaleV2,
FraudCheckTransactionV2, FraudCheckV2,
};
use super::{ConnectorData, SessionConnectorData};
-use crate::{
- connector,
- core::errors,
- services::{api, connector_integration_interface::ConnectorEnum},
- types::fraud_check::{
- FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckRecordReturnData,
- FraudCheckResponseData, FraudCheckSaleData, FraudCheckTransactionData,
- },
-};
-
-pub trait FraudCheckSale:
- api::ConnectorIntegration<Sale, FraudCheckSaleData, FraudCheckResponseData>
-{
-}
-
-pub trait FraudCheckCheckout:
- api::ConnectorIntegration<Checkout, FraudCheckCheckoutData, FraudCheckResponseData>
-{
-}
-
-pub trait FraudCheckTransaction:
- api::ConnectorIntegration<Transaction, FraudCheckTransactionData, FraudCheckResponseData>
-{
-}
-
-pub trait FraudCheckFulfillment:
- api::ConnectorIntegration<Fulfillment, FraudCheckFulfillmentData, FraudCheckResponseData>
-{
-}
-
-pub trait FraudCheckRecordReturn:
- api::ConnectorIntegration<RecordReturn, FraudCheckRecordReturnData, FraudCheckResponseData>
-{
-}
+use crate::{connector, core::errors, services::connector_integration_interface::ConnectorEnum};
#[derive(Clone)]
pub struct FraudCheckConnectorData {
diff --git a/crates/router/src/types/api/fraud_check_v2.rs b/crates/router/src/types/api/fraud_check_v2.rs
index 53dad6d568..c6f2b4a8ff 100644
--- a/crates/router/src/types/api/fraud_check_v2.rs
+++ b/crates/router/src/types/api/fraud_check_v2.rs
@@ -1,62 +1,12 @@
pub use hyperswitch_domain_models::router_flow_types::fraud_check::{
Checkout, Fulfillment, RecordReturn, Sale, Transaction,
};
-
-use crate::{
- services::api,
- types::{
- self,
- fraud_check::{
- FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckRecordReturnData,
- FraudCheckResponseData, FraudCheckSaleData, FraudCheckTransactionData,
- },
- },
+pub use hyperswitch_interfaces::api::fraud_check_v2::{
+ FraudCheckCheckoutV2, FraudCheckFulfillmentV2, FraudCheckRecordReturnV2, FraudCheckSaleV2,
+ FraudCheckTransactionV2,
};
-pub trait FraudCheckSaleV2:
- api::ConnectorIntegrationV2<Sale, types::FrmFlowData, FraudCheckSaleData, FraudCheckResponseData>
-{
-}
-
-pub trait FraudCheckCheckoutV2:
- api::ConnectorIntegrationV2<
- Checkout,
- types::FrmFlowData,
- FraudCheckCheckoutData,
- FraudCheckResponseData,
->
-{
-}
-
-pub trait FraudCheckTransactionV2:
- api::ConnectorIntegrationV2<
- Transaction,
- types::FrmFlowData,
- FraudCheckTransactionData,
- FraudCheckResponseData,
->
-{
-}
-
-pub trait FraudCheckFulfillmentV2:
- api::ConnectorIntegrationV2<
- Fulfillment,
- types::FrmFlowData,
- FraudCheckFulfillmentData,
- FraudCheckResponseData,
->
-{
-}
-
-pub trait FraudCheckRecordReturnV2:
- api::ConnectorIntegrationV2<
- RecordReturn,
- types::FrmFlowData,
- FraudCheckRecordReturnData,
- FraudCheckResponseData,
->
-{
-}
+use crate::types;
#[cfg(feature = "frm")]
pub trait FraudCheckV2:
diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs
index 3c1d8175e8..04889e191b 100644
--- a/crates/router/src/types/api/payments.rs
+++ b/crates/router/src/types/api/payments.rs
@@ -20,6 +20,12 @@ pub use hyperswitch_domain_models::router_flow_types::payments::{
CreateConnectorCustomer, IncrementalAuthorization, InitPayment, PSync, PaymentMethodToken,
PostProcessing, PreProcessing, Reject, Session, SetupMandate, Void,
};
+pub use hyperswitch_interfaces::api::payments::{
+ ConnectorCustomer, MandateSetup, Payment, PaymentApprove, PaymentAuthorize,
+ PaymentAuthorizeSessionToken, PaymentCapture, PaymentIncrementalAuthorization, PaymentReject,
+ PaymentSession, PaymentSync, PaymentToken, PaymentVoid, PaymentsCompleteAuthorize,
+ PaymentsPostProcessing, PaymentsPreProcessing,
+};
pub use super::payments_v2::{
ConnectorCustomerV2, MandateSetupV2, PaymentApproveV2, PaymentAuthorizeSessionTokenV2,
@@ -27,11 +33,7 @@ pub use super::payments_v2::{
PaymentSessionV2, PaymentSyncV2, PaymentTokenV2, PaymentV2, PaymentVoidV2,
PaymentsCompleteAuthorizeV2, PaymentsPostProcessingV2, PaymentsPreProcessingV2,
};
-use crate::{
- core::errors,
- services::api,
- types::{self, api as api_types},
-};
+use crate::core::errors;
impl super::Router for PaymentsRequest {}
@@ -76,132 +78,6 @@ impl MandateValidationFieldsExt for MandateValidationFields {
}
}
-// Extract only the last 4 digits of card
-
-pub trait PaymentAuthorize:
- api::ConnectorIntegration<Authorize, types::PaymentsAuthorizeData, types::PaymentsResponseData>
-{
-}
-
-pub trait PaymentAuthorizeSessionToken:
- api::ConnectorIntegration<
- AuthorizeSessionToken,
- types::AuthorizeSessionTokenData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentSync:
- api::ConnectorIntegration<PSync, types::PaymentsSyncData, types::PaymentsResponseData>
-{
-}
-
-pub trait PaymentVoid:
- api::ConnectorIntegration<Void, types::PaymentsCancelData, types::PaymentsResponseData>
-{
-}
-
-pub trait PaymentApprove:
- api::ConnectorIntegration<Approve, types::PaymentsApproveData, types::PaymentsResponseData>
-{
-}
-
-pub trait PaymentReject:
- api::ConnectorIntegration<Reject, types::PaymentsRejectData, types::PaymentsResponseData>
-{
-}
-
-pub trait PaymentCapture:
- api::ConnectorIntegration<Capture, types::PaymentsCaptureData, types::PaymentsResponseData>
-{
-}
-
-pub trait PaymentSession:
- api::ConnectorIntegration<Session, types::PaymentsSessionData, types::PaymentsResponseData>
-{
-}
-
-pub trait MandateSetup:
- api::ConnectorIntegration<SetupMandate, types::SetupMandateRequestData, types::PaymentsResponseData>
-{
-}
-
-pub trait PaymentIncrementalAuthorization:
- api::ConnectorIntegration<
- IncrementalAuthorization,
- types::PaymentsIncrementalAuthorizationData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentsCompleteAuthorize:
- api::ConnectorIntegration<
- CompleteAuthorize,
- types::CompleteAuthorizeData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentToken:
- api::ConnectorIntegration<
- PaymentMethodToken,
- types::PaymentMethodTokenizationData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait ConnectorCustomer:
- api::ConnectorIntegration<
- CreateConnectorCustomer,
- types::ConnectorCustomerData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentsPreProcessing:
- api::ConnectorIntegration<
- PreProcessing,
- types::PaymentsPreProcessingData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentsPostProcessing:
- api::ConnectorIntegration<
- PostProcessing,
- types::PaymentsPostProcessingData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait Payment:
- api_types::ConnectorCommon
- + api_types::ConnectorValidation
- + PaymentAuthorize
- + PaymentAuthorizeSessionToken
- + PaymentsCompleteAuthorize
- + PaymentSync
- + PaymentCapture
- + PaymentVoid
- + PaymentApprove
- + PaymentReject
- + MandateSetup
- + PaymentSession
- + PaymentToken
- + PaymentsPreProcessing
- + PaymentsPostProcessing
- + ConnectorCustomer
- + PaymentIncrementalAuthorization
-{
-}
-
#[cfg(test)]
mod payments_test {
#![allow(clippy::expect_used, clippy::unwrap_used)]
diff --git a/crates/router/src/types/api/payments_v2.rs b/crates/router/src/types/api/payments_v2.rs
index 639dc0de5b..8d8e3498ef 100644
--- a/crates/router/src/types/api/payments_v2.rs
+++ b/crates/router/src/types/api/payments_v2.rs
@@ -1,184 +1,6 @@
-use hyperswitch_domain_models::{
- router_data_v2::PaymentFlowData,
- router_flow_types::payments::{
- Approve, Authorize, AuthorizeSessionToken, Capture, CompleteAuthorize,
- CreateConnectorCustomer, IncrementalAuthorization, PSync, PaymentMethodToken,
- PostProcessing, PreProcessing, Reject, Session, SetupMandate, Void,
- },
+pub use hyperswitch_interfaces::api::payments_v2::{
+ ConnectorCustomerV2, MandateSetupV2, PaymentApproveV2, PaymentAuthorizeSessionTokenV2,
+ PaymentAuthorizeV2, PaymentCaptureV2, PaymentIncrementalAuthorizationV2, PaymentRejectV2,
+ PaymentSessionV2, PaymentSyncV2, PaymentTokenV2, PaymentV2, PaymentVoidV2,
+ PaymentsCompleteAuthorizeV2, PaymentsPostProcessingV2, PaymentsPreProcessingV2,
};
-
-use crate::{
- services::api,
- types::{self, api as api_types},
-};
-
-pub trait PaymentAuthorizeV2:
- api::ConnectorIntegrationV2<
- Authorize,
- PaymentFlowData,
- types::PaymentsAuthorizeData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentAuthorizeSessionTokenV2:
- api::ConnectorIntegrationV2<
- AuthorizeSessionToken,
- PaymentFlowData,
- types::AuthorizeSessionTokenData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentSyncV2:
- api::ConnectorIntegrationV2<
- PSync,
- PaymentFlowData,
- types::PaymentsSyncData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentVoidV2:
- api::ConnectorIntegrationV2<
- Void,
- PaymentFlowData,
- types::PaymentsCancelData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentApproveV2:
- api::ConnectorIntegrationV2<
- Approve,
- PaymentFlowData,
- types::PaymentsApproveData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentRejectV2:
- api::ConnectorIntegrationV2<
- Reject,
- PaymentFlowData,
- types::PaymentsRejectData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentCaptureV2:
- api::ConnectorIntegrationV2<
- Capture,
- PaymentFlowData,
- types::PaymentsCaptureData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentSessionV2:
- api::ConnectorIntegrationV2<
- Session,
- PaymentFlowData,
- types::PaymentsSessionData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait MandateSetupV2:
- api::ConnectorIntegrationV2<
- SetupMandate,
- PaymentFlowData,
- types::SetupMandateRequestData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentIncrementalAuthorizationV2:
- api::ConnectorIntegrationV2<
- IncrementalAuthorization,
- PaymentFlowData,
- types::PaymentsIncrementalAuthorizationData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentsCompleteAuthorizeV2:
- api::ConnectorIntegrationV2<
- CompleteAuthorize,
- PaymentFlowData,
- types::CompleteAuthorizeData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentTokenV2:
- api::ConnectorIntegrationV2<
- PaymentMethodToken,
- PaymentFlowData,
- types::PaymentMethodTokenizationData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait ConnectorCustomerV2:
- api::ConnectorIntegrationV2<
- CreateConnectorCustomer,
- PaymentFlowData,
- types::ConnectorCustomerData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentsPreProcessingV2:
- api::ConnectorIntegrationV2<
- PreProcessing,
- PaymentFlowData,
- types::PaymentsPreProcessingData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentsPostProcessingV2:
- api::ConnectorIntegrationV2<
- PostProcessing,
- PaymentFlowData,
- types::PaymentsPostProcessingData,
- types::PaymentsResponseData,
->
-{
-}
-
-pub trait PaymentV2:
- api_types::ConnectorCommon
- + api_types::ConnectorValidation
- + PaymentAuthorizeV2
- + PaymentAuthorizeSessionTokenV2
- + PaymentsCompleteAuthorizeV2
- + PaymentSyncV2
- + PaymentCaptureV2
- + PaymentVoidV2
- + PaymentApproveV2
- + PaymentRejectV2
- + MandateSetupV2
- + PaymentSessionV2
- + PaymentTokenV2
- + PaymentsPreProcessingV2
- + PaymentsPostProcessingV2
- + ConnectorCustomerV2
- + PaymentIncrementalAuthorizationV2
-{
-}
diff --git a/crates/router/src/types/api/payouts.rs b/crates/router/src/types/api/payouts.rs
index 777b1e68b5..0e89950d69 100644
--- a/crates/router/src/types/api/payouts.rs
+++ b/crates/router/src/types/api/payouts.rs
@@ -7,49 +7,12 @@ pub use api_models::payouts::{
pub use hyperswitch_domain_models::router_flow_types::payouts::{
PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, PoSync,
};
+pub use hyperswitch_interfaces::api::payouts::{
+ PayoutCancel, PayoutCreate, PayoutEligibility, PayoutFulfill, PayoutQuote, PayoutRecipient,
+ PayoutRecipientAccount, PayoutSync,
+};
pub use super::payouts_v2::{
PayoutCancelV2, PayoutCreateV2, PayoutEligibilityV2, PayoutFulfillV2, PayoutQuoteV2,
PayoutRecipientAccountV2, PayoutRecipientV2, PayoutSyncV2, PayoutsV2,
};
-use crate::{services::api, types};
-
-pub trait PayoutCancel:
- api::ConnectorIntegration<PoCancel, types::PayoutsData, types::PayoutsResponseData>
-{
-}
-
-pub trait PayoutCreate:
- api::ConnectorIntegration<PoCreate, types::PayoutsData, types::PayoutsResponseData>
-{
-}
-
-pub trait PayoutEligibility:
- api::ConnectorIntegration<PoEligibility, types::PayoutsData, types::PayoutsResponseData>
-{
-}
-
-pub trait PayoutFulfill:
- api::ConnectorIntegration<PoFulfill, types::PayoutsData, types::PayoutsResponseData>
-{
-}
-
-pub trait PayoutQuote:
- api::ConnectorIntegration<PoQuote, types::PayoutsData, types::PayoutsResponseData>
-{
-}
-
-pub trait PayoutRecipient:
- api::ConnectorIntegration<PoRecipient, types::PayoutsData, types::PayoutsResponseData>
-{
-}
-
-pub trait PayoutRecipientAccount:
- api::ConnectorIntegration<PoRecipientAccount, types::PayoutsData, types::PayoutsResponseData>
-{
-}
-
-pub trait PayoutSync:
- api::ConnectorIntegration<PoSync, types::PayoutsData, types::PayoutsResponseData>
-{
-}
diff --git a/crates/router/src/types/api/payouts_v2.rs b/crates/router/src/types/api/payouts_v2.rs
index c204bb9798..00a451e772 100644
--- a/crates/router/src/types/api/payouts_v2.rs
+++ b/crates/router/src/types/api/payouts_v2.rs
@@ -7,91 +7,12 @@ pub use api_models::payouts::{
pub use hyperswitch_domain_models::router_flow_types::payouts::{
PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, PoSync,
};
-
-use crate::{
- services::api,
- types::{self, api as api_types},
+pub use hyperswitch_interfaces::api::payouts_v2::{
+ PayoutCancelV2, PayoutCreateV2, PayoutEligibilityV2, PayoutFulfillV2, PayoutQuoteV2,
+ PayoutRecipientAccountV2, PayoutRecipientV2, PayoutSyncV2,
};
-pub trait PayoutCancelV2:
- api::ConnectorIntegrationV2<
- PoCancel,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
-
-pub trait PayoutCreateV2:
- api::ConnectorIntegrationV2<
- PoCreate,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
-
-pub trait PayoutEligibilityV2:
- api::ConnectorIntegrationV2<
- PoEligibility,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
-
-pub trait PayoutFulfillV2:
- api::ConnectorIntegrationV2<
- PoFulfill,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
-
-pub trait PayoutQuoteV2:
- api::ConnectorIntegrationV2<
- PoQuote,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
-
-pub trait PayoutRecipientV2:
- api::ConnectorIntegrationV2<
- PoRecipient,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
-
-pub trait PayoutRecipientAccountV2:
- api::ConnectorIntegrationV2<
- PoRecipientAccount,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
-
-pub trait PayoutSyncV2:
- api::ConnectorIntegrationV2<
- PoSync,
- types::PayoutFlowData,
- types::PayoutsData,
- types::PayoutsResponseData,
->
-{
-}
+use crate::types::api as api_types;
pub trait PayoutsV2:
api_types::ConnectorCommon
diff --git a/crates/router/src/types/api/refunds.rs b/crates/router/src/types/api/refunds.rs
index 67ca7cbfc4..7aafe4de15 100644
--- a/crates/router/src/types/api/refunds.rs
+++ b/crates/router/src/types/api/refunds.rs
@@ -3,13 +3,9 @@ pub use api_models::refunds::{
RefundsRetrieveRequest,
};
pub use hyperswitch_domain_models::router_flow_types::refunds::{Execute, RSync};
+pub use hyperswitch_interfaces::api::refunds::{Refund, RefundExecute, RefundSync};
-pub use super::refunds_v2::{RefundExecuteV2, RefundSyncV2, RefundV2};
-use super::ConnectorCommon;
-use crate::{
- services::api,
- types::{self, storage::enums as storage_enums, transformers::ForeignFrom},
-};
+use crate::types::{storage::enums as storage_enums, transformers::ForeignFrom};
impl ForeignFrom<storage_enums::RefundStatus> for RefundStatus {
fn foreign_from(status: storage_enums::RefundStatus) -> Self {
@@ -22,15 +18,3 @@ impl ForeignFrom<storage_enums::RefundStatus> for RefundStatus {
}
}
}
-
-pub trait RefundExecute:
- api::ConnectorIntegration<Execute, types::RefundsData, types::RefundsResponseData>
-{
-}
-
-pub trait RefundSync:
- api::ConnectorIntegration<RSync, types::RefundsData, types::RefundsResponseData>
-{
-}
-
-pub trait Refund: ConnectorCommon + RefundExecute + RefundSync {}
diff --git a/crates/router/src/types/api/refunds_v2.rs b/crates/router/src/types/api/refunds_v2.rs
index d0e3e8db29..49db7be943 100644
--- a/crates/router/src/types/api/refunds_v2.rs
+++ b/crates/router/src/types/api/refunds_v2.rs
@@ -1,18 +1 @@
-use hyperswitch_domain_models::{
- router_data_v2::flow_common_types::RefundFlowData,
- router_flow_types::refunds::{Execute, RSync},
-};
-
-use super::ConnectorCommon;
-use crate::{services::api, types};
-pub trait RefundExecuteV2:
- api::ConnectorIntegrationV2<Execute, RefundFlowData, types::RefundsData, types::RefundsResponseData>
-{
-}
-
-pub trait RefundSyncV2:
- api::ConnectorIntegrationV2<RSync, RefundFlowData, types::RefundsData, types::RefundsResponseData>
-{
-}
-
-pub trait RefundV2: ConnectorCommon + RefundExecuteV2 + RefundSyncV2 {}
+pub use hyperswitch_interfaces::api::refunds_v2::{RefundExecuteV2, RefundSyncV2, RefundV2};