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(connectors): [Template] add Worldpayvantiv (#8226)

AkshayaFoigerfd844c3dd506
diff --git a/config/config.example.toml b/config/config.example.toml
index 9943aa27e3..c46f23dab4 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -291,6 +291,7 @@ wellsfargopayout.base_url = "https://api-sandbox.wellsfargo.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
+worldpayvantiv.base_url = "https://www.testvantivcnp.com/sandbox/communicator/online"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
zsl.base_url = "https://api.sitoffalb.net/"
@@ -359,6 +360,7 @@ cards = [
"thunes",
"tokenio",
"worldpay",
+ "worldpayvantiv",
"worldpayxml",
"xendit",
"zen",
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index accbcfff05..593415b3c4 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -132,6 +132,7 @@ wellsfargopayout.base_url = "https://api-sandbox.wellsfargo.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
+worldpayvantiv.base_url = "https://www.testvantivcnp.com/sandbox/communicator/online"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
zen.base_url = "https://api.zen-test.com/"
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 16b0a3ad1d..c64ec0034a 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -136,6 +136,7 @@ wellsfargopayout.base_url = "https://api.wellsfargo.com/"
wise.base_url = "https://api.wise.com/"
worldline.base_url = "https://eu.api-ingenico.com/"
worldpay.base_url = "https://access.worldpay.com/"
+worldpayvantiv.base_url = "https://payments.vantivcnp.com/vap/communicator/online"
worldpayxml.base_url = "https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
zen.base_url = "https://api.zen.com/"
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 0c32b15a3b..7de9575d56 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -136,6 +136,7 @@ wellsfargopayout.base_url = "https://api-sandbox.wellsfargo.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
+worldpayvantiv.base_url = "https://www.testvantivcnp.com/sandbox/communicator/online"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
zen.base_url = "https://api.zen-test.com/"
diff --git a/config/development.toml b/config/development.toml
index 83b575d774..910426e964 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -183,6 +183,7 @@ cards = [
"wise",
"worldline",
"worldpay",
+ "worldpayvantiv",
"xendit",
"zen",
"zsl",
@@ -315,6 +316,7 @@ stripe.base_url_file_upload = "https://files.stripe.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
+worldpayvantiv.base_url = "https://www.testvantivcnp.com/sandbox/communicator/online"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index a0f2515a52..f2ac842c08 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -222,6 +222,7 @@ wellsfargopayout.base_url = "https://api-sandbox.wellsfargo.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
+worldpayvantiv.base_url = "https://www.testvantivcnp.com/sandbox/communicator/online"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
zen.base_url = "https://api.zen-test.com/"
@@ -326,6 +327,7 @@ cards = [
"wise",
"worldline",
"worldpay",
+ "worldpayvantiv",
"worldpayxml",
"xendit",
"zen",
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs
index d86192cf0f..6e2a9904ed 100644
--- a/crates/common_enums/src/connector_enums.rs
+++ b/crates/common_enums/src/connector_enums.rs
@@ -151,6 +151,7 @@ pub enum RoutableConnectors {
Wise,
Worldline,
Worldpay,
+ // Worldpayvantiv,
Worldpayxml,
Xendit,
Zen,
@@ -307,6 +308,7 @@ pub enum Connector {
Wise,
Worldline,
Worldpay,
+ // Worldpayvantiv,
Worldpayxml,
Signifyd,
Plaid,
@@ -469,6 +471,7 @@ impl Connector {
| Self::Wise
| Self::Worldline
| Self::Worldpay
+ // | Self::Worldpayvantiv
| Self::Worldpayxml
| Self::Xendit
| Self::Zen
@@ -624,6 +627,7 @@ impl From<RoutableConnectors> for Connector {
RoutableConnectors::Wise => Self::Wise,
RoutableConnectors::Worldline => Self::Worldline,
RoutableConnectors::Worldpay => Self::Worldpay,
+ // RoutableConnectors::Worldpayvantiv => Self::Worldpayvantiv,
RoutableConnectors::Worldpayxml => Self::Worldpayxml,
RoutableConnectors::Zen => Self::Zen,
RoutableConnectors::Plaid => Self::Plaid,
@@ -737,6 +741,7 @@ impl TryFrom<Connector> for RoutableConnectors {
Connector::Wise => Ok(Self::Wise),
Connector::Worldline => Ok(Self::Worldline),
Connector::Worldpay => Ok(Self::Worldpay),
+ // Connector::Worldpayvantiv => Ok(Self::Worldpayvantiv),
Connector::Worldpayxml => Ok(Self::Worldpayxml),
Connector::Xendit => Ok(Self::Xendit),
Connector::Zen => Ok(Self::Zen),
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index 5c04e30d93..731cd24517 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -263,6 +263,7 @@ pub struct ConnectorConfig {
pub wise_payout: Option<ConnectorTomlConfig>,
pub worldline: Option<ConnectorTomlConfig>,
pub worldpay: Option<ConnectorTomlConfig>,
+ pub worldpayvantiv: Option<ConnectorTomlConfig>,
pub worldpayxml: Option<ConnectorTomlConfig>,
pub xendit: Option<ConnectorTomlConfig>,
pub square: Option<ConnectorTomlConfig>,
@@ -443,6 +444,7 @@ impl ConnectorConfig {
Connector::Wise => Err("Use get_payout_connector_config".to_string()),
Connector::Worldline => Ok(connector_data.worldline),
Connector::Worldpay => Ok(connector_data.worldpay),
+ // Connector::Worldpayvantiv => Ok(connector_data.worldpayvantiv),
Connector::Worldpayxml => Ok(connector_data.worldpayxml),
Connector::Zen => Ok(connector_data.zen),
Connector::Zsl => Ok(connector_data.zsl),
diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs
index c70b03c32c..ab586e0090 100644
--- a/crates/hyperswitch_connectors/src/connectors.rs
+++ b/crates/hyperswitch_connectors/src/connectors.rs
@@ -97,6 +97,7 @@ pub mod wellsfargopayout;
pub mod wise;
pub mod worldline;
pub mod worldpay;
+pub mod worldpayvantiv;
pub mod worldpayxml;
pub mod xendit;
pub mod zen;
@@ -125,5 +126,6 @@ pub use self::{
threedsecureio::Threedsecureio, thunes::Thunes, tokenio::Tokenio, trustpay::Trustpay,
tsys::Tsys, unified_authentication_service::UnifiedAuthenticationService, vgs::Vgs, volt::Volt,
wellsfargo::Wellsfargo, wellsfargopayout::Wellsfargopayout, wise::Wise, worldline::Worldline,
- worldpay::Worldpay, worldpayxml::Worldpayxml, xendit::Xendit, zen::Zen, zsl::Zsl,
+ worldpay::Worldpay, worldpayvantiv::Worldpayvantiv, worldpayxml::Worldpayxml, xendit::Xendit,
+ zen::Zen, zsl::Zsl,
};
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs
new file mode 100644
index 0000000000..24dd76b730
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs
@@ -0,0 +1,576 @@
+pub mod transformers;
+
+use common_utils::{
+ errors::CustomResult,
+ ext_traits::BytesExt,
+ request::{Method, Request, RequestBuilder, RequestContent},
+ types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
+};
+use error_stack::{report, ResultExt};
+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::{
+ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
+ RefundSyncRouterData, RefundsRouterData,
+ },
+};
+use hyperswitch_interfaces::{
+ api::{
+ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,
+ ConnectorValidation,
+ },
+ configs::Connectors,
+ errors,
+ events::connector_api_logs::ConnectorEvent,
+ types::{self, Response},
+ webhooks,
+};
+use masking::{ExposeInterface, Mask};
+use transformers as worldpayvantiv;
+
+use crate::{constants::headers, types::ResponseRouterData, utils};
+
+#[derive(Clone)]
+pub struct Worldpayvantiv {
+ amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
+}
+
+impl Worldpayvantiv {
+ pub fn new() -> &'static Self {
+ &Self {
+ amount_converter: &StringMinorUnitForConnector,
+ }
+ }
+}
+
+impl api::Payment for Worldpayvantiv {}
+impl api::PaymentSession for Worldpayvantiv {}
+impl api::ConnectorAccessToken for Worldpayvantiv {}
+impl api::MandateSetup for Worldpayvantiv {}
+impl api::PaymentAuthorize for Worldpayvantiv {}
+impl api::PaymentSync for Worldpayvantiv {}
+impl api::PaymentCapture for Worldpayvantiv {}
+impl api::PaymentVoid for Worldpayvantiv {}
+impl api::Refund for Worldpayvantiv {}
+impl api::RefundExecute for Worldpayvantiv {}
+impl api::RefundSync for Worldpayvantiv {}
+impl api::PaymentToken for Worldpayvantiv {}
+
+impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
+ for Worldpayvantiv
+{
+ // Not Implemented (R)
+}
+
+impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Worldpayvantiv
+where
+ Self: ConnectorIntegration<Flow, Request, Response>,
+{
+ fn build_headers(
+ &self,
+ req: &RouterData<Flow, Request, Response>,
+ _connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ let mut header = vec![(
+ headers::CONTENT_TYPE.to_string(),
+ self.get_content_type().to_string().into(),
+ )];
+ let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
+ header.append(&mut api_key);
+ Ok(header)
+ }
+}
+
+impl ConnectorCommon for Worldpayvantiv {
+ fn id(&self) -> &'static str {
+ "worldpayvantiv"
+ }
+
+ fn get_currency_unit(&self) -> api::CurrencyUnit {
+ api::CurrencyUnit::Minor
+ }
+
+ fn common_get_content_type(&self) -> &'static str {
+ "application/json"
+ }
+
+ fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
+ connectors.worldpayvantiv.base_url.as_ref()
+ }
+
+ fn get_auth_header(
+ &self,
+ auth_type: &ConnectorAuthType,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ let auth = worldpayvantiv::WorldpayvantivAuthType::try_from(auth_type)
+ .change_context(errors::ConnectorError::FailedToObtainAuthType)?;
+ Ok(vec![(
+ headers::AUTHORIZATION.to_string(),
+ auth.api_key.expose().into_masked(),
+ )])
+ }
+
+ fn build_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ let response: worldpayvantiv::WorldpayvantivErrorResponse = res
+ .response
+ .parse_struct("WorldpayvantivErrorResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: response.code,
+ message: response.message,
+ reason: response.reason,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_decline_code: None,
+ network_advice_code: None,
+ network_error_message: None,
+ })
+ }
+}
+
+impl ConnectorValidation for Worldpayvantiv {
+ //TODO: implement functions when support enabled
+}
+
+impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Worldpayvantiv {
+ //TODO: implement sessions flow
+}
+
+impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Worldpayvantiv {}
+
+impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
+ for Worldpayvantiv
+{
+}
+
+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>
+ for Worldpayvantiv
+{
+ fn get_headers(
+ &self,
+ req: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &PaymentsAuthorizeRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsAuthorizeRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = worldpayvantiv::WorldpayvantivRouterData::from((amount, req));
+ let connector_req =
+ worldpayvantiv::WorldpayvantivPaymentsRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsAuthorizeType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(types::PaymentsAuthorizeType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::PaymentsAuthorizeType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsAuthorizeRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
+ let response: worldpayvantiv::WorldpayvantivPaymentsResponse = res
+ .response
+ .parse_struct("Worldpayvantiv PaymentsAuthorizeResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
+impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Worldpayvantiv {
+ fn get_headers(
+ &self,
+ req: &PaymentsSyncRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &PaymentsSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsSyncRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Get)
+ .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsSyncRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
+ let response: worldpayvantiv::WorldpayvantivPaymentsResponse = res
+ .response
+ .parse_struct("worldpayvantiv PaymentsSyncResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
+impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Worldpayvantiv {
+ fn get_headers(
+ &self,
+ req: &PaymentsCaptureRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &PaymentsCaptureRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn get_request_body(
+ &self,
+ _req: &PaymentsCaptureRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsCaptureRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PaymentsCaptureType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::PaymentsCaptureType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsCaptureRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
+ let response: worldpayvantiv::WorldpayvantivPaymentsResponse = res
+ .response
+ .parse_struct("Worldpayvantiv PaymentsCaptureResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Worldpayvantiv {}
+
+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Worldpayvantiv {
+ fn get_headers(
+ &self,
+ req: &RefundsRouterData<Execute>,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &RefundsRouterData<Execute>,
+ _connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn get_request_body(
+ &self,
+ req: &RefundsRouterData<Execute>,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let refund_amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_refund_amount,
+ req.request.currency,
+ )?;
+
+ let connector_router_data =
+ worldpayvantiv::WorldpayvantivRouterData::from((refund_amount, req));
+ let connector_req =
+ worldpayvantiv::WorldpayvantivRefundRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ 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(
+ self, req, connectors,
+ )?)
+ .set_body(types::RefundExecuteType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build();
+ Ok(Some(request))
+ }
+
+ fn handle_response(
+ &self,
+ data: &RefundsRouterData<Execute>,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
+ let response: worldpayvantiv::RefundResponse = res
+ .response
+ .parse_struct("worldpayvantiv RefundResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
+impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Worldpayvantiv {
+ fn get_headers(
+ &self,
+ req: &RefundSyncRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &RefundSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn build_request(
+ &self,
+ req: &RefundSyncRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Get)
+ .url(&types::RefundSyncType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::RefundSyncType::get_headers(self, req, connectors)?)
+ .set_body(types::RefundSyncType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &RefundSyncRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
+ let response: worldpayvantiv::RefundResponse = res
+ .response
+ .parse_struct("worldpayvantiv RefundSyncResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
+#[async_trait::async_trait]
+impl webhooks::IncomingWebhook for Worldpayvantiv {
+ fn get_webhook_object_reference_id(
+ &self,
+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ }
+
+ fn get_webhook_event_type(
+ &self,
+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {
+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ }
+
+ fn get_webhook_resource_object(
+ &self,
+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ }
+}
+
+impl ConnectorSpecifications for Worldpayvantiv {}
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
new file mode 100644
index 0000000000..fcff68890b
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
@@ -0,0 +1,232 @@
+use common_enums::enums;
+use common_utils::types::StringMinorUnit;
+use hyperswitch_domain_models::{
+ payment_method_data::PaymentMethodData,
+ router_data::{ConnectorAuthType, RouterData},
+ router_flow_types::refunds::{Execute, RSync},
+ router_request_types::ResponseId,
+ router_response_types::{PaymentsResponseData, RefundsResponseData},
+ types::{PaymentsAuthorizeRouterData, RefundsRouterData},
+};
+use hyperswitch_interfaces::errors;
+use masking::Secret;
+use serde::{Deserialize, Serialize};
+
+use crate::{
+ types::{RefundsResponseRouterData, ResponseRouterData},
+ utils::PaymentsAuthorizeRequestData,
+};
+
+//TODO: Fill the struct with respective fields
+pub struct WorldpayvantivRouterData<T> {
+ pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
+ pub router_data: T,
+}
+
+impl<T> From<(StringMinorUnit, T)> for WorldpayvantivRouterData<T> {
+ fn from((amount, item): (StringMinorUnit, T)) -> Self {
+ //Todo : use utils to convert the amount to the type of amount that a connector accepts
+ Self {
+ amount,
+ router_data: item,
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Serialize, PartialEq)]
+pub struct WorldpayvantivPaymentsRequest {
+ amount: StringMinorUnit,
+ card: WorldpayvantivCard,
+}
+
+#[derive(Default, Debug, Serialize, Eq, PartialEq)]
+pub struct WorldpayvantivCard {
+ number: cards::CardNumber,
+ expiry_month: Secret<String>,
+ expiry_year: Secret<String>,
+ cvc: Secret<String>,
+ complete: bool,
+}
+
+impl TryFrom<&WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>>
+ for WorldpayvantivPaymentsRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &WorldpayvantivRouterData<&PaymentsAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ match item.router_data.request.payment_method_data.clone() {
+ PaymentMethodData::Card(req_card) => {
+ let card = WorldpayvantivCard {
+ number: req_card.card_number,
+ expiry_month: req_card.card_exp_month,
+ expiry_year: req_card.card_exp_year,
+ cvc: req_card.card_cvc,
+ complete: item.router_data.request.is_auto_capture()?,
+ };
+ Ok(Self {
+ amount: item.amount.clone(),
+ card,
+ })
+ }
+ _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+// Auth Struct
+pub struct WorldpayvantivAuthType {
+ pub(super) api_key: Secret<String>,
+}
+
+impl TryFrom<&ConnectorAuthType> for WorldpayvantivAuthType {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
+ match auth_type {
+ ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
+ api_key: api_key.to_owned(),
+ }),
+ _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
+ }
+ }
+}
+// PaymentsResponse
+//TODO: Append the remaining status flags
+#[derive(Debug, Copy, Clone, Default, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "lowercase")]
+pub enum WorldpayvantivPaymentStatus {
+ Succeeded,
+ Failed,
+ #[default]
+ Processing,
+}
+
+impl From<WorldpayvantivPaymentStatus> for common_enums::AttemptStatus {
+ fn from(item: WorldpayvantivPaymentStatus) -> Self {
+ match item {
+ WorldpayvantivPaymentStatus::Succeeded => Self::Charged,
+ WorldpayvantivPaymentStatus::Failed => Self::Failure,
+ WorldpayvantivPaymentStatus::Processing => Self::Authorizing,
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct WorldpayvantivPaymentsResponse {
+ status: WorldpayvantivPaymentStatus,
+ id: String,
+}
+
+impl<F, T> TryFrom<ResponseRouterData<F, WorldpayvantivPaymentsResponse, T, PaymentsResponseData>>
+ for RouterData<F, T, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<F, WorldpayvantivPaymentsResponse, T, PaymentsResponseData>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ status: common_enums::AttemptStatus::from(item.response.status),
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(item.response.id),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+}
+
+//TODO: Fill the struct with respective fields
+// REFUND :
+// Type definition for RefundRequest
+#[derive(Default, Debug, Serialize)]
+pub struct WorldpayvantivRefundRequest {
+ pub amount: StringMinorUnit,
+}
+
+impl<F> TryFrom<&WorldpayvantivRouterData<&RefundsRouterData<F>>> for WorldpayvantivRefundRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &WorldpayvantivRouterData<&RefundsRouterData<F>>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ amount: item.amount.to_owned(),
+ })
+ }
+}
+
+// Type definition for Refund Response
+
+#[allow(dead_code)]
+#[derive(Debug, Copy, Serialize, Default, Deserialize, Clone)]
+pub enum RefundStatus {
+ Succeeded,
+ Failed,
+ #[default]
+ Processing,
+}
+
+impl From<RefundStatus> for enums::RefundStatus {
+ fn from(item: RefundStatus) -> Self {
+ match item {
+ RefundStatus::Succeeded => Self::Success,
+ RefundStatus::Failed => Self::Failure,
+ RefundStatus::Processing => Self::Pending,
+ //TODO: Review mapping
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+pub struct RefundResponse {
+ id: String,
+ status: RefundStatus,
+}
+
+impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: RefundsResponseRouterData<Execute, RefundResponse>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: item.response.id.to_string(),
+ refund_status: enums::RefundStatus::from(item.response.status),
+ }),
+ ..item.data
+ })
+ }
+}
+
+impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: RefundsResponseRouterData<RSync, RefundResponse>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: item.response.id.to_string(),
+ refund_status: enums::RefundStatus::from(item.response.status),
+ }),
+ ..item.data
+ })
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
+pub struct WorldpayvantivErrorResponse {
+ pub status_code: u16,
+ pub code: String,
+ pub message: String,
+ pub reason: Option<String>,
+}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 62b29ca3fe..a71f1cb413 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -212,6 +212,7 @@ default_imp_for_authorize_session_token!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -331,6 +332,7 @@ default_imp_for_calculate_tax!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -441,6 +443,7 @@ default_imp_for_session_update!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -559,6 +562,7 @@ default_imp_for_post_session_tokens!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -676,6 +680,7 @@ default_imp_for_update_metadata!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -790,6 +795,7 @@ default_imp_for_complete_authorize!(
connectors::Wellsfargo,
connectors::Wellsfargopayout,
connectors::Worldline,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
@@ -908,6 +914,7 @@ default_imp_for_incremental_authorization!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
@@ -1023,6 +1030,7 @@ default_imp_for_create_customer!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1128,6 +1136,7 @@ default_imp_for_connector_redirect_response!(
connectors::Wellsfargo,
connectors::Wellsfargopayout,
connectors::Worldline,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Volt,
connectors::Zsl,
@@ -1233,6 +1242,7 @@ default_imp_for_pre_processing_steps!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1352,6 +1362,7 @@ default_imp_for_post_processing_steps!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1473,6 +1484,7 @@ default_imp_for_approve!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1594,6 +1606,7 @@ default_imp_for_reject!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1714,6 +1727,7 @@ default_imp_for_webhook_source_verification!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1834,6 +1848,7 @@ default_imp_for_accept_dispute!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1952,6 +1967,7 @@ default_imp_for_submit_evidence!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2071,6 +2087,7 @@ default_imp_for_defend_dispute!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2198,6 +2215,7 @@ default_imp_for_file_upload!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2303,6 +2321,7 @@ default_imp_for_payouts!(
connectors::Volt,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2419,6 +2438,7 @@ default_imp_for_payouts_create!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2540,6 +2560,7 @@ default_imp_for_payouts_retrieve!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2659,6 +2680,7 @@ default_imp_for_payouts_eligibility!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2773,6 +2795,7 @@ default_imp_for_payouts_fulfill!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2891,6 +2914,7 @@ default_imp_for_payouts_cancel!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3011,6 +3035,7 @@ default_imp_for_payouts_quote!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3130,6 +3155,7 @@ default_imp_for_payouts_recipient!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3251,6 +3277,7 @@ default_imp_for_payouts_recipient_account!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3372,6 +3399,7 @@ default_imp_for_frm_sale!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3493,6 +3521,7 @@ default_imp_for_frm_checkout!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3614,6 +3643,7 @@ default_imp_for_frm_transaction!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3735,6 +3765,7 @@ default_imp_for_frm_fulfillment!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3856,6 +3887,7 @@ default_imp_for_frm_record_return!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -3973,6 +4005,7 @@ default_imp_for_revoking_mandates!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
@@ -4091,6 +4124,7 @@ default_imp_for_uas_pre_authentication!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -4209,6 +4243,7 @@ default_imp_for_uas_post_authentication!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -4328,6 +4363,7 @@ default_imp_for_uas_authentication_confirmation!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -4439,6 +4475,7 @@ default_imp_for_connector_request_id!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -4552,6 +4589,7 @@ default_imp_for_fraud_check!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -4694,6 +4732,7 @@ default_imp_for_connector_authentication!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -4813,6 +4852,7 @@ default_imp_for_uas_authentication!(
connectors::Wellsfargopayout,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
@@ -4924,6 +4964,7 @@ default_imp_for_revenue_recovery! {
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -5045,6 +5086,7 @@ default_imp_for_billing_connector_payment_sync!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -5165,6 +5207,7 @@ default_imp_for_revenue_recovery_record_back!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -5286,6 +5329,7 @@ default_imp_for_billing_connector_invoice_sync!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Vgs,
@@ -5400,6 +5444,7 @@ default_imp_for_external_vault!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Vgs,
@@ -5520,6 +5565,7 @@ default_imp_for_external_vault_insert!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Vgs,
@@ -5640,6 +5686,7 @@ default_imp_for_external_vault_retrieve!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Vgs,
@@ -5760,6 +5807,7 @@ default_imp_for_external_vault_delete!(
connectors::Wise,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Vgs,
diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
index 3a1300c9b5..93ce14d4e8 100644
--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
@@ -339,6 +339,7 @@ default_imp_for_new_connector_integration_payment!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -462,6 +463,7 @@ default_imp_for_new_connector_integration_refund!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
@@ -576,6 +578,7 @@ default_imp_for_new_connector_integration_connector_access_token!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -697,6 +700,7 @@ default_imp_for_new_connector_integration_accept_dispute!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -817,6 +821,7 @@ default_imp_for_new_connector_integration_submit_evidence!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -938,6 +943,7 @@ default_imp_for_new_connector_integration_defend_dispute!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1069,6 +1075,7 @@ default_imp_for_new_connector_integration_file_upload!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1192,6 +1199,7 @@ default_imp_for_new_connector_integration_payouts_create!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1315,6 +1323,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1438,6 +1447,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1561,6 +1571,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1684,6 +1695,7 @@ default_imp_for_new_connector_integration_payouts_quote!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1807,6 +1819,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -1930,6 +1943,7 @@ default_imp_for_new_connector_integration_payouts_sync!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2053,6 +2067,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2174,6 +2189,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2297,6 +2313,7 @@ default_imp_for_new_connector_integration_frm_sale!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2420,6 +2437,7 @@ default_imp_for_new_connector_integration_frm_checkout!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2543,6 +2561,7 @@ default_imp_for_new_connector_integration_frm_transaction!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2666,6 +2685,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2789,6 +2809,7 @@ default_imp_for_new_connector_integration_frm_record_return!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2908,6 +2929,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
@@ -2997,6 +3019,7 @@ default_imp_for_new_connector_integration_frm!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
@@ -3115,6 +3138,7 @@ default_imp_for_new_connector_integration_connector_authentication!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
@@ -3225,6 +3249,7 @@ default_imp_for_new_connector_integration_revenue_recovery!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
@@ -3361,9 +3386,10 @@ default_imp_for_new_connector_integration_external_vault!(
connectors::Vgs,
connectors::Volt,
connectors::Worldline,
- connectors::Worldpayxml,
connectors::Wise,
connectors::Worldpay,
+ connectors::Worldpayvantiv,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Wellsfargopayout,
connectors::Xendit,
diff --git a/crates/hyperswitch_domain_models/src/configs.rs b/crates/hyperswitch_domain_models/src/configs.rs
index eb58e3b650..46a100af45 100644
--- a/crates/hyperswitch_domain_models/src/configs.rs
+++ b/crates/hyperswitch_domain_models/src/configs.rs
@@ -114,6 +114,7 @@ pub struct Connectors {
pub wise: ConnectorParams,
pub worldline: ConnectorParams,
pub worldpay: ConnectorParams,
+ pub worldpayvantiv: ConnectorParams,
pub worldpayxml: ConnectorParams,
pub xendit: ConnectorParams,
pub zen: ConnectorParams,
diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs
index f405753ed7..748a2bcf83 100644
--- a/crates/router/src/connector.rs
+++ b/crates/router/src/connector.rs
@@ -37,8 +37,8 @@ pub use hyperswitch_connectors::connectors::{
unified_authentication_service, unified_authentication_service::UnifiedAuthenticationService,
vgs, vgs::Vgs, volt, volt::Volt, wellsfargo, wellsfargo::Wellsfargo, wellsfargopayout,
wellsfargopayout::Wellsfargopayout, wise, wise::Wise, worldline, worldline::Worldline,
- worldpay, worldpay::Worldpay, worldpayxml, worldpayxml::Worldpayxml, xendit, xendit::Xendit,
- zen, zen::Zen, zsl, zsl::Zsl,
+ worldpay, worldpay::Worldpay, worldpayvantiv, worldpayvantiv::Worldpayvantiv, worldpayxml,
+ worldpayxml::Worldpayxml, xendit, xendit::Xendit, zen, zen::Zen, zsl, zsl::Zsl,
};
#[cfg(feature = "dummy_connector")]
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 13c219e7eb..70c5f77754 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1730,6 +1730,10 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {
worldpay::transformers::WorldpayAuthType::try_from(self.auth_type)?;
Ok(())
}
+ // api_enums::Connector::Worldpayvantiv => {
+ // worldpayvantiv::transformers::WorldpayvantivAuthType::try_from(self.auth_type)?;
+ // Ok(())
+ // },
api_enums::Connector::Worldpayxml => {
worldpayxml::transformers::WorldpayxmlAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index e2a66e4f37..bb6f871290 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -569,6 +569,9 @@ impl ConnectorData {
enums::Connector::Worldpay => {
Ok(ConnectorEnum::Old(Box::new(connector::Worldpay::new())))
}
+ // enums::Connector::Worldpayvantiv => {
+ // Ok(ConnectorEnum::Old(Box::new(connector::Worldpayvantiv::new())))
+ // }
enums::Connector::Worldpayxml => {
Ok(ConnectorEnum::Old(Box::new(connector::Worldpayxml::new())))
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index ce991c560f..162eb0b1dc 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -340,6 +340,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
api_enums::Connector::Wise => Self::Wise,
api_enums::Connector::Worldline => Self::Worldline,
api_enums::Connector::Worldpay => Self::Worldpay,
+ // api_enums::Connector::Worldpayvantiv => Self::Worldpayvantiv,
api_enums::Connector::Worldpayxml => Self::Worldpayxml,
api_enums::Connector::Xendit => Self::Xendit,
api_enums::Connector::Zen => Self::Zen,
diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs
index d5aebe7ea4..3b855b82a4 100644
--- a/crates/router/tests/connectors/main.rs
+++ b/crates/router/tests/connectors/main.rs
@@ -98,6 +98,7 @@ mod utils;
mod vgs;
mod volt;
mod wellsfargo;
+mod worldpayvantiv;
// mod wellsfargopayout;
#[cfg(feature = "payouts")]
mod wise;
diff --git a/crates/router/tests/connectors/worldpayvantiv.rs b/crates/router/tests/connectors/worldpayvantiv.rs
new file mode 100644
index 0000000000..d4c21d04cb
--- /dev/null
+++ b/crates/router/tests/connectors/worldpayvantiv.rs
@@ -0,0 +1,421 @@
+use hyperswitch_domain_models::payment_method_data::{Card, PaymentMethodData};
+use masking::Secret;
+use router::types::{self, api, storage::enums};
+use test_utils::connector_auth;
+
+use crate::utils::{self, ConnectorActions};
+
+#[derive(Clone, Copy)]
+struct WorldpayvantivTest;
+impl ConnectorActions for WorldpayvantivTest {}
+impl utils::Connector for WorldpayvantivTest {
+ fn get_data(&self) -> api::ConnectorData {
+ use router::connector::Worldpayxml;
+ utils::construct_connector_data_old(
+ Box::new(Worldpayxml::new()),
+ types::Connector::Plaid,
+ api::GetToken::Connector,
+ None,
+ )
+ }
+
+ fn get_auth_token(&self) -> types::ConnectorAuthType {
+ utils::to_connector_auth_type(
+ connector_auth::ConnectorAuthentication::new()
+ .worldpayxml
+ .expect("Missing connector authentication configuration")
+ .into(),
+ )
+ }
+
+ fn get_name(&self) -> String {
+ "Worldpayxml".to_string()
+ }
+}
+
+static CONNECTOR: WorldpayvantivTest = WorldpayvantivTest {};
+
+fn get_default_payment_info() -> Option<utils::PaymentInfo> {
+ None
+}
+
+fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
+ None
+}
+
+// Cards Positive Tests
+// Creates a payment using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_only_authorize_payment() {
+ let response = CONNECTOR
+ .authorize_payment(payment_method_details(), get_default_payment_info())
+ .await
+ .expect("Authorize payment response");
+ assert_eq!(response.status, enums::AttemptStatus::Authorized);
+}
+
+// Captures a payment using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_capture_authorized_payment() {
+ let response = CONNECTOR
+ .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info())
+ .await
+ .expect("Capture payment response");
+ assert_eq!(response.status, enums::AttemptStatus::Charged);
+}
+
+// Partially captures a payment using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_partially_capture_authorized_payment() {
+ let response = CONNECTOR
+ .authorize_and_capture_payment(
+ payment_method_details(),
+ Some(types::PaymentsCaptureData {
+ amount_to_capture: 50,
+ ..utils::PaymentCaptureType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .expect("Capture payment response");
+ assert_eq!(response.status, enums::AttemptStatus::Charged);
+}
+
+// Synchronizes a payment using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_sync_authorized_payment() {
+ let authorize_response = CONNECTOR
+ .authorize_payment(payment_method_details(), get_default_payment_info())
+ .await
+ .expect("Authorize payment response");
+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);
+ let response = CONNECTOR
+ .psync_retry_till_status_matches(
+ enums::AttemptStatus::Authorized,
+ Some(types::PaymentsSyncData {
+ connector_transaction_id: types::ResponseId::ConnectorTransactionId(
+ txn_id.unwrap(),
+ ),
+ ..Default::default()
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .expect("PSync response");
+ assert_eq!(response.status, enums::AttemptStatus::Authorized,);
+}
+
+// Voids a payment using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_void_authorized_payment() {
+ let response = CONNECTOR
+ .authorize_and_void_payment(
+ payment_method_details(),
+ Some(types::PaymentsCancelData {
+ connector_transaction_id: String::from(""),
+ cancellation_reason: Some("requested_by_customer".to_string()),
+ ..Default::default()
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .expect("Void payment response");
+ assert_eq!(response.status, enums::AttemptStatus::Voided);
+}
+
+// Refunds a payment using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_refund_manually_captured_payment() {
+ let response = CONNECTOR
+ .capture_payment_and_refund(
+ payment_method_details(),
+ None,
+ None,
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap().refund_status,
+ enums::RefundStatus::Success,
+ );
+}
+
+// Partially refunds a payment using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_partially_refund_manually_captured_payment() {
+ let response = CONNECTOR
+ .capture_payment_and_refund(
+ payment_method_details(),
+ None,
+ Some(types::RefundsData {
+ refund_amount: 50,
+ ..utils::PaymentRefundType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap().refund_status,
+ enums::RefundStatus::Success,
+ );
+}
+
+// Synchronizes a refund using the manual capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_sync_manually_captured_refund() {
+ let refund_response = CONNECTOR
+ .capture_payment_and_refund(
+ payment_method_details(),
+ None,
+ None,
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ let response = CONNECTOR
+ .rsync_retry_till_status_matches(
+ enums::RefundStatus::Success,
+ refund_response.response.unwrap().connector_refund_id,
+ None,
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap().refund_status,
+ enums::RefundStatus::Success,
+ );
+}
+
+// Creates a payment using the automatic capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_make_payment() {
+ let authorize_response = CONNECTOR
+ .make_payment(payment_method_details(), get_default_payment_info())
+ .await
+ .unwrap();
+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
+}
+
+// Synchronizes a payment using the automatic capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_sync_auto_captured_payment() {
+ let authorize_response = CONNECTOR
+ .make_payment(payment_method_details(), get_default_payment_info())
+ .await
+ .unwrap();
+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);
+ assert_ne!(txn_id, None, "Empty connector transaction id");
+ let response = CONNECTOR
+ .psync_retry_till_status_matches(
+ enums::AttemptStatus::Charged,
+ Some(types::PaymentsSyncData {
+ connector_transaction_id: types::ResponseId::ConnectorTransactionId(
+ txn_id.unwrap(),
+ ),
+ capture_method: Some(enums::CaptureMethod::Automatic),
+ ..Default::default()
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(response.status, enums::AttemptStatus::Charged,);
+}
+
+// Refunds a payment using the automatic capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_refund_auto_captured_payment() {
+ let response = CONNECTOR
+ .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap().refund_status,
+ enums::RefundStatus::Success,
+ );
+}
+
+// Partially refunds a payment using the automatic capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_partially_refund_succeeded_payment() {
+ let refund_response = CONNECTOR
+ .make_payment_and_refund(
+ payment_method_details(),
+ Some(types::RefundsData {
+ refund_amount: 50,
+ ..utils::PaymentRefundType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ refund_response.response.unwrap().refund_status,
+ enums::RefundStatus::Success,
+ );
+}
+
+// Creates multiple refunds against a payment using the automatic capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_refund_succeeded_payment_multiple_times() {
+ CONNECTOR
+ .make_payment_and_multiple_refund(
+ payment_method_details(),
+ Some(types::RefundsData {
+ refund_amount: 50,
+ ..utils::PaymentRefundType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await;
+}
+
+// Synchronizes a refund using the automatic capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_sync_refund() {
+ let refund_response = CONNECTOR
+ .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())
+ .await
+ .unwrap();
+ let response = CONNECTOR
+ .rsync_retry_till_status_matches(
+ enums::RefundStatus::Success,
+ refund_response.response.unwrap().connector_refund_id,
+ None,
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap().refund_status,
+ enums::RefundStatus::Success,
+ );
+}
+
+// Cards Negative scenarios
+// Creates a payment with incorrect CVC.
+#[actix_web::test]
+async fn should_fail_payment_for_incorrect_cvc() {
+ let response = CONNECTOR
+ .make_payment(
+ Some(types::PaymentsAuthorizeData {
+ payment_method_data: PaymentMethodData::Card(Card {
+ card_cvc: Secret::new("12345".to_string()),
+ ..utils::CCardType::default().0
+ }),
+ ..utils::PaymentAuthorizeType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap_err().message,
+ "Your card's security code is invalid.".to_string(),
+ );
+}
+
+// Creates a payment with incorrect expiry month.
+#[actix_web::test]
+async fn should_fail_payment_for_invalid_exp_month() {
+ let response = CONNECTOR
+ .make_payment(
+ Some(types::PaymentsAuthorizeData {
+ payment_method_data: PaymentMethodData::Card(Card {
+ card_exp_month: Secret::new("20".to_string()),
+ ..utils::CCardType::default().0
+ }),
+ ..utils::PaymentAuthorizeType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap_err().message,
+ "Your card's expiration month is invalid.".to_string(),
+ );
+}
+
+// Creates a payment with incorrect expiry year.
+#[actix_web::test]
+async fn should_fail_payment_for_incorrect_expiry_year() {
+ let response = CONNECTOR
+ .make_payment(
+ Some(types::PaymentsAuthorizeData {
+ payment_method_data: PaymentMethodData::Card(Card {
+ card_exp_year: Secret::new("2000".to_string()),
+ ..utils::CCardType::default().0
+ }),
+ ..utils::PaymentAuthorizeType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap_err().message,
+ "Your card's expiration year is invalid.".to_string(),
+ );
+}
+
+// Voids a payment using automatic capture flow (Non 3DS).
+#[actix_web::test]
+async fn should_fail_void_payment_for_auto_capture() {
+ let authorize_response = CONNECTOR
+ .make_payment(payment_method_details(), get_default_payment_info())
+ .await
+ .unwrap();
+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);
+ assert_ne!(txn_id, None, "Empty connector transaction id");
+ let void_response = CONNECTOR
+ .void_payment(txn_id.unwrap(), None, get_default_payment_info())
+ .await
+ .unwrap();
+ assert_eq!(
+ void_response.response.unwrap_err().message,
+ "You cannot cancel this PaymentIntent because it has a status of succeeded."
+ );
+}
+
+// Captures a payment using invalid connector payment id.
+#[actix_web::test]
+async fn should_fail_capture_for_invalid_payment() {
+ let capture_response = CONNECTOR
+ .capture_payment("123456789".to_string(), None, get_default_payment_info())
+ .await
+ .unwrap();
+ assert_eq!(
+ capture_response.response.unwrap_err().message,
+ String::from("No such payment_intent: '123456789'")
+ );
+}
+
+// Refunds a payment with refund amount higher than payment amount.
+#[actix_web::test]
+async fn should_fail_for_refund_amount_higher_than_payment_amount() {
+ let response = CONNECTOR
+ .make_payment_and_refund(
+ payment_method_details(),
+ Some(types::RefundsData {
+ refund_amount: 150,
+ ..utils::PaymentRefundType::default().0
+ }),
+ get_default_payment_info(),
+ )
+ .await
+ .unwrap();
+ assert_eq!(
+ response.response.unwrap_err().message,
+ "Refund amount (₹1.50) is greater than charge amount (₹1.00)",
+ );
+}
+
+// Connector dependent test cases goes here
+
+// [#478]: add unit tests for non 3DS, wallets & webhooks in connector tests
diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs
index 19900c752a..ff454ddd55 100644
--- a/crates/test_utils/src/connector_auth.rs
+++ b/crates/test_utils/src/connector_auth.rs
@@ -110,6 +110,7 @@ pub struct ConnectorAuthentication {
// pub wellsfargopayout: Option<HeaderKey>,
pub wise: Option<BodyKey>,
pub worldpay: Option<BodyKey>,
+ pub worldpayvantiv: Option<HeaderKey>,
pub worldpayxml: Option<HeaderKey>,
pub xendit: Option<HeaderKey>,
pub worldline: Option<SignatureKey>,
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index e491b839ff..90a946e3bc 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -188,6 +188,7 @@ wellsfargo.base_url = "https://apitest.cybersource.com/"
wellsfargopayout.base_url = "https://api-sandbox.wellsfargo.com/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
+worldpayvantiv.base_url = "https://www.testvantivcnp.com/sandbox/communicator/online"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
wise.base_url = "https://api.sandbox.transferwise.tech/"
@@ -292,6 +293,7 @@ cards = [
"wise",
"worldline",
"worldpay",
+ "worldpayvantiv",
"worldpayxml",
"xendit",
"zen",
diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh
index f947c51418..e0bfbdffc4 100755
--- a/scripts/add_connector.sh
+++ b/scripts/add_connector.sh
@@ -6,7 +6,7 @@ function find_prev_connector() {
git checkout $self
cp $self $self.tmp
# Add new connector to existing list and sort it
- connectors=(aci adyen adyenplatform airwallex amazonpay applepay archipel authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay ctp_visa cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon facilitapay fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim hipay iatapay inespay itaubank jpmorgan juspaythreedsserver klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys shift4 square stax stripe stripebilling taxjar threedsecureio thunes tokenio trustpay tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayxml xendit zsl "$1")
+ connectors=(aci adyen adyenplatform airwallex amazonpay applepay archipel authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay ctp_visa cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon facilitapay fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim hipay iatapay inespay itaubank jpmorgan juspaythreedsserver klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys shift4 square stax stripe stripebilling taxjar threedsecureio thunes tokenio trustpay tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayvantiv worldpayxml xendit zsl "$1")
IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS
res="$(echo ${sorted[@]})"
sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp