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): Introduce connector template code for WorldpayXML (#7968)

AkshayaFoiger57cb3a9ff0fc
diff --git a/config/config.example.toml b/config/config.example.toml
index 9da72f40a8..e505e9106f 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -286,6 +286,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/"
+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/"
zen.base_url = "https://api.zen-test.com/"
@@ -351,6 +352,7 @@ cards = [
"threedsecureio",
"thunes",
"worldpay",
+ "worldpayxml",
"xendit",
"zen",
"zsl",
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 85216c08be..dbf44df958 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -127,6 +127,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/"
+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/"
zen.secondary_base_url = "https://secure.zen-test.com/"
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index ec8ffb0f2b..4d4647dbaa 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -131,6 +131,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/"
+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/"
zen.secondary_base_url = "https://secure.zen.com/"
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 146d96f730..5cfc67408c 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -131,6 +131,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/"
+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/"
zen.secondary_base_url = "https://secure.zen-test.com/"
diff --git a/config/development.toml b/config/development.toml
index 1d542e17b0..05b0a38eb5 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -326,6 +326,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/"
+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/"
tsys.base_url = "https://stagegw.transnox.com/"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 49365ab76f..7ce48f40e9 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -217,6 +217,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/"
+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/"
zen.secondary_base_url = "https://secure.zen-test.com/"
@@ -315,6 +316,7 @@ cards = [
"wise",
"worldline",
"worldpay",
+ "worldpayxml",
"xendit",
"zen",
"zsl",
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs
index 87bb4f0bcb..30bcbaa528 100644
--- a/crates/common_enums/src/connector_enums.rs
+++ b/crates/common_enums/src/connector_enums.rs
@@ -146,6 +146,7 @@ pub enum RoutableConnectors {
Wise,
Worldline,
Worldpay,
+ // Worldpayxml,
Xendit,
Zen,
Plaid,
@@ -296,6 +297,7 @@ pub enum Connector {
Wise,
Worldline,
Worldpay,
+ // Worldpayxml,
Signifyd,
Plaid,
Riskified,
@@ -453,6 +455,7 @@ impl Connector {
| Self::Wise
| Self::Worldline
| Self::Worldpay
+ // | Self::Worldpayxml
| Self::Xendit
| Self::Zen
| Self::Zsl
@@ -603,6 +606,7 @@ impl From<RoutableConnectors> for Connector {
RoutableConnectors::Wise => Self::Wise,
RoutableConnectors::Worldline => Self::Worldline,
RoutableConnectors::Worldpay => Self::Worldpay,
+ // RoutableConnectors::Worldpayxml => Self::Worldpayxml,
RoutableConnectors::Zen => Self::Zen,
RoutableConnectors::Plaid => Self::Plaid,
RoutableConnectors::Zsl => Self::Zsl,
@@ -711,6 +715,7 @@ impl TryFrom<Connector> for RoutableConnectors {
Connector::Wise => Ok(Self::Wise),
Connector::Worldline => Ok(Self::Worldline),
Connector::Worldpay => Ok(Self::Worldpay),
+ // Connector::Worldpayxml => Ok(Self::Worldpayxml),
Connector::Xendit => Ok(Self::Xendit),
Connector::Zen => Ok(Self::Zen),
Connector::Plaid => Ok(Self::Plaid),
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index 5b97473ff0..b21f65a2fa 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -256,6 +256,7 @@ pub struct ConnectorConfig {
pub wise_payout: Option<ConnectorTomlConfig>,
pub worldline: Option<ConnectorTomlConfig>,
pub worldpay: Option<ConnectorTomlConfig>,
+ // pub worldpayxml: Option<ConnectorTomlConfig>,
pub xendit: Option<ConnectorTomlConfig>,
pub square: Option<ConnectorTomlConfig>,
pub stax: Option<ConnectorTomlConfig>,
@@ -432,6 +433,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::Worldpayxml => Ok(connector_data.worldpayxml),
Connector::Zen => Ok(connector_data.zen),
Connector::Zsl => Ok(connector_data.zsl),
#[cfg(feature = "dummy_connector")]
diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs
index 2e5941880e..0679e873d4 100644
--- a/crates/hyperswitch_connectors/src/connectors.rs
+++ b/crates/hyperswitch_connectors/src/connectors.rs
@@ -87,6 +87,7 @@ pub mod volt;
pub mod wellsfargo;
pub mod worldline;
pub mod worldpay;
+pub mod worldpayxml;
pub mod xendit;
pub mod zen;
pub mod zsl;
@@ -111,6 +112,6 @@ pub use self::{
recurly::Recurly, redsys::Redsys, riskified::Riskified, shift4::Shift4, square::Square,
stax::Stax, stripebilling::Stripebilling, taxjar::Taxjar, thunes::Thunes, trustpay::Trustpay,
tsys::Tsys, unified_authentication_service::UnifiedAuthenticationService, volt::Volt,
- wellsfargo::Wellsfargo, worldline::Worldline, worldpay::Worldpay, xendit::Xendit, zen::Zen,
- zsl::Zsl,
+ wellsfargo::Wellsfargo, worldline::Worldline, worldpay::Worldpay, worldpayxml::Worldpayxml,
+ xendit::Xendit, zen::Zen, zsl::Zsl,
};
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs b/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs
new file mode 100644
index 0000000000..6cb73f2735
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs
@@ -0,0 +1,573 @@
+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 worldpayxml;
+
+use crate::{constants::headers, types::ResponseRouterData, utils};
+
+#[derive(Clone)]
+pub struct Worldpayxml {
+ amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
+}
+
+impl Worldpayxml {
+ pub fn new() -> &'static Self {
+ &Self {
+ amount_converter: &StringMinorUnitForConnector,
+ }
+ }
+}
+
+impl api::Payment for Worldpayxml {}
+impl api::PaymentSession for Worldpayxml {}
+impl api::ConnectorAccessToken for Worldpayxml {}
+impl api::MandateSetup for Worldpayxml {}
+impl api::PaymentAuthorize for Worldpayxml {}
+impl api::PaymentSync for Worldpayxml {}
+impl api::PaymentCapture for Worldpayxml {}
+impl api::PaymentVoid for Worldpayxml {}
+impl api::Refund for Worldpayxml {}
+impl api::RefundExecute for Worldpayxml {}
+impl api::RefundSync for Worldpayxml {}
+impl api::PaymentToken for Worldpayxml {}
+
+impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
+ for Worldpayxml
+{
+ // Not Implemented (R)
+}
+
+impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Worldpayxml
+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 Worldpayxml {
+ fn id(&self) -> &'static str {
+ "worldpayxml"
+ }
+
+ 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.worldpayxml.base_url.as_ref()
+ }
+
+ fn get_auth_header(
+ &self,
+ auth_type: &ConnectorAuthType,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ let auth = worldpayxml::WorldpayxmlAuthType::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: worldpayxml::WorldpayxmlErrorResponse = res
+ .response
+ .parse_struct("WorldpayxmlErrorResponse")
+ .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_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ })
+ }
+}
+
+impl ConnectorValidation for Worldpayxml {
+ //TODO: implement functions when support enabled
+}
+
+impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Worldpayxml {
+ //TODO: implement sessions flow
+}
+
+impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Worldpayxml {}
+
+impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
+ for Worldpayxml
+{
+}
+
+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Worldpayxml {
+ 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 = worldpayxml::WorldpayxmlRouterData::from((amount, req));
+ let connector_req =
+ worldpayxml::WorldpayxmlPaymentsRequest::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: worldpayxml::WorldpayxmlPaymentsResponse = res
+ .response
+ .parse_struct("Worldpayxml 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 Worldpayxml {
+ 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: worldpayxml::WorldpayxmlPaymentsResponse = res
+ .response
+ .parse_struct("worldpayxml 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 Worldpayxml {
+ 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: worldpayxml::WorldpayxmlPaymentsResponse = res
+ .response
+ .parse_struct("Worldpayxml 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 Worldpayxml {}
+
+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Worldpayxml {
+ 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 = worldpayxml::WorldpayxmlRouterData::from((refund_amount, req));
+ let connector_req =
+ worldpayxml::WorldpayxmlRefundRequest::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: worldpayxml::RefundResponse = res
+ .response
+ .parse_struct("worldpayxml 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 Worldpayxml {
+ 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: worldpayxml::RefundResponse = res
+ .response
+ .parse_struct("worldpayxml 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 Worldpayxml {
+ 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 Worldpayxml {}
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs
new file mode 100644
index 0000000000..8063db0478
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs
@@ -0,0 +1,228 @@
+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 WorldpayxmlRouterData<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 WorldpayxmlRouterData<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 WorldpayxmlPaymentsRequest {
+ amount: StringMinorUnit,
+ card: WorldpayxmlCard,
+}
+
+#[derive(Default, Debug, Serialize, Eq, PartialEq)]
+pub struct WorldpayxmlCard {
+ number: cards::CardNumber,
+ expiry_month: Secret<String>,
+ expiry_year: Secret<String>,
+ cvc: Secret<String>,
+ complete: bool,
+}
+
+impl TryFrom<&WorldpayxmlRouterData<&PaymentsAuthorizeRouterData>> for WorldpayxmlPaymentsRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &WorldpayxmlRouterData<&PaymentsAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ match item.router_data.request.payment_method_data.clone() {
+ PaymentMethodData::Card(req_card) => {
+ let card = WorldpayxmlCard {
+ 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 WorldpayxmlAuthType {
+ pub(super) api_key: Secret<String>,
+}
+
+impl TryFrom<&ConnectorAuthType> for WorldpayxmlAuthType {
+ 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, Clone, Default, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "lowercase")]
+pub enum WorldpayxmlPaymentStatus {
+ Succeeded,
+ Failed,
+ #[default]
+ Processing,
+}
+
+impl From<WorldpayxmlPaymentStatus> for common_enums::AttemptStatus {
+ fn from(item: WorldpayxmlPaymentStatus) -> Self {
+ match item {
+ WorldpayxmlPaymentStatus::Succeeded => Self::Charged,
+ WorldpayxmlPaymentStatus::Failed => Self::Failure,
+ WorldpayxmlPaymentStatus::Processing => Self::Authorizing,
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct WorldpayxmlPaymentsResponse {
+ status: WorldpayxmlPaymentStatus,
+ id: String,
+}
+
+impl<F, T> TryFrom<ResponseRouterData<F, WorldpayxmlPaymentsResponse, T, PaymentsResponseData>>
+ for RouterData<F, T, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<F, WorldpayxmlPaymentsResponse, 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 WorldpayxmlRefundRequest {
+ pub amount: StringMinorUnit,
+}
+
+impl<F> TryFrom<&WorldpayxmlRouterData<&RefundsRouterData<F>>> for WorldpayxmlRefundRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &WorldpayxmlRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+ Ok(Self {
+ amount: item.amount.to_owned(),
+ })
+ }
+}
+
+// Type definition for Refund Response
+
+#[allow(dead_code)]
+#[derive(Debug, 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 WorldpayxmlErrorResponse {
+ 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 f8a274d1e1..f7b01800aa 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -201,6 +201,7 @@ default_imp_for_authorize_session_token!(
connectors::Tsys,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -309,6 +310,7 @@ default_imp_for_calculate_tax!(
connectors::Volt,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -410,6 +412,7 @@ default_imp_for_session_update!(
connectors::Hipay,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -517,6 +520,7 @@ default_imp_for_post_session_tokens!(
connectors::Hipay,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Powertranz,
@@ -625,6 +629,7 @@ default_imp_for_update_metadata!(
connectors::Hipay,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Powertranz,
@@ -724,6 +729,7 @@ default_imp_for_complete_authorize!(
connectors::UnifiedAuthenticationService,
connectors::Wellsfargo,
connectors::Worldline,
+ connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
connectors::Zen,
@@ -832,6 +838,7 @@ default_imp_for_incremental_authorization!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
connectors::Zen,
@@ -938,6 +945,7 @@ default_imp_for_create_customer!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -1032,6 +1040,7 @@ default_imp_for_connector_redirect_response!(
connectors::UnifiedAuthenticationService,
connectors::Wellsfargo,
connectors::Worldline,
+ connectors::Worldpayxml,
connectors::Volt,
connectors::Zsl,
connectors::CtpMastercard
@@ -1127,6 +1136,7 @@ default_imp_for_pre_processing_steps!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Zen,
@@ -1235,6 +1245,7 @@ default_imp_for_post_processing_steps!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -1345,6 +1356,7 @@ default_imp_for_approve!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -1455,6 +1467,7 @@ default_imp_for_reject!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -1564,6 +1577,7 @@ default_imp_for_webhook_source_verification!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -1673,6 +1687,7 @@ default_imp_for_accept_dispute!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -1781,6 +1796,7 @@ default_imp_for_submit_evidence!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -1889,6 +1905,7 @@ default_imp_for_defend_dispute!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2006,6 +2023,7 @@ default_imp_for_file_upload!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2102,6 +2120,7 @@ default_imp_for_payouts!(
connectors::Volt,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2209,6 +2228,7 @@ default_imp_for_payouts_create!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2319,6 +2339,7 @@ default_imp_for_payouts_retrieve!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2428,6 +2449,7 @@ default_imp_for_payouts_eligibility!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2533,6 +2555,7 @@ default_imp_for_payouts_fulfill!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2642,6 +2665,7 @@ default_imp_for_payouts_cancel!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2752,6 +2776,7 @@ default_imp_for_payouts_quote!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2862,6 +2887,7 @@ default_imp_for_payouts_recipient!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -2973,6 +2999,7 @@ default_imp_for_payouts_recipient_account!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3084,6 +3111,7 @@ default_imp_for_frm_sale!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3195,6 +3223,7 @@ default_imp_for_frm_checkout!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3306,6 +3335,7 @@ default_imp_for_frm_transaction!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3417,6 +3447,7 @@ default_imp_for_frm_fulfillment!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3528,6 +3559,7 @@ default_imp_for_frm_record_return!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3634,6 +3666,7 @@ default_imp_for_revoking_mandates!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
connectors::Zen,
@@ -3742,6 +3775,7 @@ default_imp_for_uas_pre_authentication!(
connectors::Tsys,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3849,6 +3883,7 @@ default_imp_for_uas_post_authentication!(
connectors::Tsys,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -3957,6 +3992,7 @@ default_imp_for_uas_authentication_confirmation!(
connectors::Tsys,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -4057,6 +4093,7 @@ default_imp_for_connector_request_id!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -4160,6 +4197,7 @@ default_imp_for_fraud_check!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -4292,6 +4330,7 @@ default_imp_for_connector_authentication!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -4399,6 +4438,7 @@ default_imp_for_uas_authentication!(
connectors::Wellsfargo,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Volt,
connectors::Xendit,
connectors::Zen,
@@ -4500,6 +4540,7 @@ default_imp_for_revenue_recovery! {
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -4610,6 +4651,7 @@ default_imp_for_billing_connector_payment_sync!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -4719,6 +4761,7 @@ default_imp_for_revenue_recovery_record_back!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
@@ -4830,6 +4873,7 @@ default_imp_for_billing_connector_invoice_sync!(
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
index c131cab0f1..897241b687 100644
--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
@@ -326,6 +326,7 @@ default_imp_for_new_connector_integration_payment!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -438,6 +439,7 @@ default_imp_for_new_connector_integration_refund!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
connectors::Zsl
@@ -543,6 +545,7 @@ default_imp_for_new_connector_integration_connector_access_token!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -654,6 +657,7 @@ default_imp_for_new_connector_integration_accept_dispute!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -764,6 +768,7 @@ default_imp_for_new_connector_integration_submit_evidence!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -875,6 +880,7 @@ default_imp_for_new_connector_integration_defend_dispute!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -996,6 +1002,7 @@ default_imp_for_new_connector_integration_file_upload!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1109,6 +1116,7 @@ default_imp_for_new_connector_integration_payouts_create!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1222,6 +1230,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1335,6 +1344,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1448,6 +1458,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1561,6 +1572,7 @@ default_imp_for_new_connector_integration_payouts_quote!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1674,6 +1686,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1787,6 +1800,7 @@ default_imp_for_new_connector_integration_payouts_sync!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -1900,6 +1914,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2011,6 +2026,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2124,6 +2140,7 @@ default_imp_for_new_connector_integration_frm_sale!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2237,6 +2254,7 @@ default_imp_for_new_connector_integration_frm_checkout!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2350,6 +2368,7 @@ default_imp_for_new_connector_integration_frm_transaction!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2463,6 +2482,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2576,6 +2596,7 @@ default_imp_for_new_connector_integration_frm_record_return!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2685,6 +2706,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Wellsfargo,
connectors::Xendit,
connectors::Zen,
@@ -2764,6 +2786,7 @@ default_imp_for_new_connector_integration_frm!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
connectors::Zsl
@@ -2873,6 +2896,7 @@ default_imp_for_new_connector_integration_connector_authentication!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
connectors::Zsl
@@ -2974,6 +2998,7 @@ default_imp_for_new_connector_integration_revenue_recovery!(
connectors::Worldline,
connectors::Volt,
connectors::Worldpay,
+ connectors::Worldpayxml,
connectors::Xendit,
connectors::Zen,
connectors::Zsl
diff --git a/crates/hyperswitch_domain_models/src/configs.rs b/crates/hyperswitch_domain_models/src/configs.rs
index a2ab95fe8c..5ebf77a542 100644
--- a/crates/hyperswitch_domain_models/src/configs.rs
+++ b/crates/hyperswitch_domain_models/src/configs.rs
@@ -109,6 +109,7 @@ pub struct Connectors {
pub wise: ConnectorParams,
pub worldline: ConnectorParams,
pub worldpay: ConnectorParams,
+ pub worldpayxml: ConnectorParams,
pub xendit: ConnectorParams,
pub zen: ConnectorParams,
pub zsl: ConnectorParams,
diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs
index e5a91afc78..e696513478 100644
--- a/crates/router/src/connector.rs
+++ b/crates/router/src/connector.rs
@@ -38,8 +38,8 @@ pub use hyperswitch_connectors::connectors::{
stax::Stax, stripebilling, stripebilling::Stripebilling, taxjar, taxjar::Taxjar, thunes,
thunes::Thunes, trustpay, trustpay::Trustpay, tsys, tsys::Tsys, unified_authentication_service,
unified_authentication_service::UnifiedAuthenticationService, volt, volt::Volt, wellsfargo,
- wellsfargo::Wellsfargo, worldline, worldline::Worldline, worldpay, worldpay::Worldpay, xendit,
- xendit::Xendit, zen, zen::Zen, zsl, zsl::Zsl,
+ wellsfargo::Wellsfargo, worldline, worldline::Worldline, worldpay, worldpay::Worldpay,
+ 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 c8738fa120..04ea9ab573 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1612,6 +1612,10 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {
worldpay::transformers::WorldpayAuthType::try_from(self.auth_type)?;
Ok(())
}
+ // api_enums::Connector::Worldpayxml => {
+ // worldpayxml::transformers::WorldpayxmlAuthType::try_from(self.auth_type)?;
+ // Ok(())
+ // },
api_enums::Connector::Xendit => {
xendit::transformers::XenditAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index de9eedb43e..caff3c707f 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -522,6 +522,8 @@ impl ConnectorData {
enums::Connector::Worldpay => {
Ok(ConnectorEnum::Old(Box::new(connector::Worldpay::new())))
}
+ // enums::Connector::Worldpayxml => { Ok(ConnectorEnum::Old(Box::new(connector::Worldpayxml)))
+ // },
enums::Connector::Xendit => {
Ok(ConnectorEnum::Old(Box::new(connector::Xendit::new())))
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 98a47b4a1d..43ac6882bc 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -331,6 +331,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::Worldpayxml => Self::Worldpayxml,
api_enums::Connector::Xendit => Self::Xendit,
api_enums::Connector::Zen => Self::Zen,
api_enums::Connector::Zsl => Self::Zsl,
diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs
index d6edc5c6b8..b2e546a157 100644
--- a/crates/router/tests/connectors/main.rs
+++ b/crates/router/tests/connectors/main.rs
@@ -99,5 +99,6 @@ mod wellsfargo;
mod wise;
mod worldline;
mod worldpay;
+mod worldpayxml;
mod zen;
mod zsl;
diff --git a/crates/router/tests/connectors/worldpayxml.rs b/crates/router/tests/connectors/worldpayxml.rs
new file mode 100644
index 0000000000..e93d5acc02
--- /dev/null
+++ b/crates/router/tests/connectors/worldpayxml.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 WorldpayxmlTest;
+impl ConnectorActions for WorldpayxmlTest {}
+impl utils::Connector for WorldpayxmlTest {
+ 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: WorldpayxmlTest = WorldpayxmlTest {};
+
+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 c12563303c..6db09af0c7 100644
--- a/crates/test_utils/src/connector_auth.rs
+++ b/crates/test_utils/src/connector_auth.rs
@@ -105,6 +105,7 @@ pub struct ConnectorAuthentication {
// pub wellsfargopayout: Option<HeaderKey>,
pub wise: Option<BodyKey>,
pub worldpay: Option<BodyKey>,
+ pub worldpayxml: Option<HeaderKey>,
pub xendit: Option<HeaderKey>,
pub worldline: Option<SignatureKey>,
pub zen: Option<HeaderKey>,
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 93337e6616..1e5b978b81 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -183,6 +183,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/"
+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/"
zen.base_url = "https://api.zen-test.com/"
@@ -281,6 +282,7 @@ cards = [
"wise",
"worldline",
"worldpay",
+ "worldpayxml",
"xendit",
"zen",
"zsl",
diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh
index 8aab99447a..9a4a7ccbfa 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 authorizedotnet bambora bamboraapac bankofamerica 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 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 trustpay tsys unified_authentication_service volt wellsfargo wellsfargopayout wise worldline worldpay xendit zsl "$1")
+ connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica 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 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 trustpay tsys unified_authentication_service volt wellsfargo wellsfargopayout wise worldline worldpay worldpayxml xendit zsl "$1")
IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS
res="$(echo ${sorted[@]})"
sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp