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): [Trustly] Template code for connector (#11472)

Vani Gupta44704177b538
diff --git a/config/config.example.toml b/config/config.example.toml
index b34d1a29ca..04061cd6a0 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -332,6 +332,7 @@ thunes.base_url = "https://api.limonetikqualif.com/"
tokenex.base_url = "https://test-api.tokenex.com"
tokenio.base_url = "https://api.sandbox.token.io"
truelayer.base_url = "https://api.truelayer-sandbox.com"
+trustly.base_url = "https://test.trustly.com/api/1"
truelayer.secondary_base_url = "https://auth.truelayer-sandbox.com"
stripe.base_url_file_upload = "https://files.stripe.com/"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index f86e83a9b5..c2c7afe8fd 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -156,6 +156,7 @@ thunes.base_url = "https://api.limonetikqualif.com/"
tokenex.base_url = "https://test-api.tokenex.com"
tokenio.base_url = "https://api.sandbox.token.io"
truelayer.base_url = "https://api.truelayer-sandbox.com"
+trustly.base_url = "https://test.trustly.com/api/1"
truelayer.secondary_base_url = "https://auth.truelayer-sandbox.com"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpayments.base_url = "https://webservices.securetrading.net/"
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 0b0572f259..21833cdd3a 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -159,6 +159,7 @@ thunes.base_url = "https://api.limonetik.com/"
tokenex.base_url = "https://api.tokenex.com"
tokenio.base_url = "https://api.token.io"
truelayer.base_url = "https://api.truelayer.com"
+trustly.base_url = "https://api.trustly.com/1"
truelayer.secondary_base_url = "https://auth.truelayer.com"
trustpay.base_url = "https://tpgw.trustpay.eu/"
trustpayments.base_url = "https://webservices.securetrading.net/"
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 3e841ad77c..e82a4071ce 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -159,6 +159,7 @@ thunes.base_url = "https://api.limonetikqualif.com/"
tokenex.base_url = "https://test-api.tokenex.com"
tokenio.base_url = "https://api.sandbox.token.io"
truelayer.base_url = "https://api.truelayer-sandbox.com"
+trustly.base_url = "https://test.trustly.com/api/1"
truelayer.secondary_base_url = "https://auth.truelayer-sandbox.com"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpayments.base_url = "https://webservices.securetrading.net/"
diff --git a/config/development.toml b/config/development.toml
index 8ec2979472..4b6cc02e30 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -362,6 +362,7 @@ thunes.base_url = "https://api.limonetikqualif.com/"
tokenex.base_url = "https://test-api.tokenex.com"
tokenio.base_url = "https://api.sandbox.token.io"
truelayer.base_url = "https://api.truelayer-sandbox.com"
+trustly.base_url = "https://test.trustly.com/api/1"
truelayer.secondary_base_url = "https://auth.truelayer-sandbox.com"
stripe.base_url_file_upload = "https://files.stripe.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 537ab79752..0d8b275e3f 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -263,6 +263,7 @@ thunes.base_url = "https://api.limonetikqualif.com/"
tokenex.base_url = "https://test-api.tokenex.com"
tokenio.base_url = "https://api.sandbox.token.io"
truelayer.base_url = "https://api.truelayer-sandbox.com"
+trustly.base_url = "https://test.trustly.com/api/1"
truelayer.secondary_base_url = "https://auth.truelayer-sandbox.com"
stripe.base_url_file_upload = "https://files.stripe.com/"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index a4bdfd12bc..6701c836e7 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -369,6 +369,7 @@ pub struct ConnectorConfig {
pub tokenex: Option<ConnectorTomlConfig>,
pub tokenio: Option<ConnectorTomlConfig>,
pub truelayer: Option<ConnectorTomlConfig>,
+ pub trustly: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub truelayer_payout: Option<ConnectorTomlConfig>,
pub trustpay: Option<ConnectorTomlConfig>,
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index 71a821693d..6d17d7f292 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -8238,3 +8238,7 @@ payment_method_type = "CartesBancaires"
payment_method_type = "UnionPay"
[revolv3.connector_auth.HeaderKey]
api_key = "Static Tokens"
+
+[trustly]
+[trustly.connector_auth.HeaderKey]
+api_key = "API Key"
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index f0ca7688fe..df63ad453f 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -7121,3 +7121,7 @@ payment_method_type = "CartesBancaires"
payment_method_type = "UnionPay"
[revolv3.connector_auth.HeaderKey]
api_key = "Static Tokens"
+
+[trustly]
+[trustly.connector_auth.HeaderKey]
+api_key = "API Key"
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 18718b7446..7547e1ad26 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -8212,3 +8212,7 @@ payment_method_type = "CartesBancaires"
payment_method_type = "UnionPay"
[revolv3.connector_auth.HeaderKey]
api_key = "Static Tokens"
+
+[trustly]
+[trustly.connector_auth.HeaderKey]
+api_key = "API Key"
diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs
index 6c5d3274d7..806394a7c2 100644
--- a/crates/hyperswitch_connectors/src/connectors.rs
+++ b/crates/hyperswitch_connectors/src/connectors.rs
@@ -123,6 +123,7 @@ pub mod thunes;
pub mod tokenex;
pub mod tokenio;
pub mod truelayer;
+pub mod trustly;
pub mod trustpay;
pub mod trustpayments;
pub mod tsys;
@@ -173,8 +174,8 @@ pub use self::{
riskified::Riskified, santander::Santander, shift4::Shift4, sift::Sift, signifyd::Signifyd,
silverflow::Silverflow, square::Square, stax::Stax, stripe::Stripe,
stripebilling::Stripebilling, taxjar::Taxjar, tesouro::Tesouro, threedsecureio::Threedsecureio,
- thunes::Thunes, tokenex::Tokenex, tokenio::Tokenio, truelayer::Truelayer, trustpay::Trustpay,
- trustpayments::Trustpayments, tsys::Tsys,
+ thunes::Thunes, tokenex::Tokenex, tokenio::Tokenio, truelayer::Truelayer, trustly::Trustly,
+ trustpay::Trustpay, trustpayments::Trustpayments, tsys::Tsys,
unified_authentication_service::UnifiedAuthenticationService, vgs::Vgs, volt::Volt,
wellsfargo::Wellsfargo, wellsfargopayout::Wellsfargopayout, wise::Wise, worldline::Worldline,
worldpay::Worldpay, worldpaymodular::Worldpaymodular, worldpayvantiv::Worldpayvantiv,
diff --git a/crates/hyperswitch_connectors/src/connectors/trustly.rs b/crates/hyperswitch_connectors/src/connectors/trustly.rs
new file mode 100644
index 0000000000..dfbda0dd99
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors/trustly.rs
@@ -0,0 +1,626 @@
+pub mod transformers;
+
+use std::sync::LazyLock;
+
+use common_enums::enums;
+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::{
+ payment_method_data::PaymentMethodData,
+ 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::{
+ ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods,
+ },
+ 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 trustly;
+
+use crate::{constants::headers, types::ResponseRouterData, utils};
+
+#[derive(Clone)]
+pub struct Trustly {
+ amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
+}
+
+impl Trustly {
+ pub fn new() -> &'static Self {
+ &Self {
+ amount_converter: &StringMinorUnitForConnector,
+ }
+ }
+}
+
+impl api::Payment for Trustly {}
+impl api::PaymentSession for Trustly {}
+impl api::ConnectorAccessToken for Trustly {}
+impl api::MandateSetup for Trustly {}
+impl api::PaymentAuthorize for Trustly {}
+impl api::PaymentSync for Trustly {}
+impl api::PaymentCapture for Trustly {}
+impl api::PaymentVoid for Trustly {}
+impl api::Refund for Trustly {}
+impl api::RefundExecute for Trustly {}
+impl api::RefundSync for Trustly {}
+impl api::PaymentToken for Trustly {}
+
+impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
+ for Trustly
+{
+ // Not Implemented (R)
+}
+
+impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Trustly
+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 Trustly {
+ fn id(&self) -> &'static str {
+ "trustly"
+ }
+
+ fn get_currency_unit(&self) -> api::CurrencyUnit {
+ api::CurrencyUnit::Base
+ // TODO! Check connector documentation, on which unit they are processing the currency.
+ // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor,
+ // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base
+ }
+
+ fn common_get_content_type(&self) -> &'static str {
+ "application/json"
+ }
+
+ fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
+ connectors.trustly.base_url.as_ref()
+ }
+
+ fn get_auth_header(
+ &self,
+ auth_type: &ConnectorAuthType,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ let auth = trustly::TrustlyAuthType::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: trustly::TrustlyErrorResponse = res
+ .response
+ .parse_struct("TrustlyErrorResponse")
+ .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,
+ connector_response_reference_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ })
+ }
+}
+
+impl ConnectorValidation for Trustly {
+ fn validate_mandate_payment(
+ &self,
+ _pm_type: Option<enums::PaymentMethodType>,
+ pm_data: PaymentMethodData,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ match pm_data {
+ PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented(
+ "validate_mandate_payment does not support cards".to_string(),
+ )
+ .into()),
+ _ => Ok(()),
+ }
+ }
+
+ fn validate_psync_reference_id(
+ &self,
+ _data: &PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ Ok(())
+ }
+}
+
+impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Trustly {
+ //TODO: implement sessions flow
+}
+
+impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Trustly {}
+
+impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Trustly {}
+
+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Trustly {
+ 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 = trustly::TrustlyRouterData::from((amount, req));
+ let connector_req = trustly::TrustlyPaymentsRequest::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: trustly::TrustlyPaymentsResponse = res
+ .response
+ .parse_struct("Trustly 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 Trustly {
+ 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: trustly::TrustlyPaymentsResponse = res
+ .response
+ .parse_struct("trustly 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 Trustly {
+ 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: trustly::TrustlyPaymentsResponse = res
+ .response
+ .parse_struct("Trustly 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 Trustly {}
+
+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Trustly {
+ 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 = trustly::TrustlyRouterData::from((refund_amount, req));
+ let connector_req = trustly::TrustlyRefundRequest::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: trustly::RefundResponse = res
+ .response
+ .parse_struct("trustly 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 Trustly {
+ 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: trustly::RefundResponse = res
+ .response
+ .parse_struct("trustly 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 Trustly {
+ 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<'_>,
+ _context: Option<&webhooks::WebhookContext>,
+ ) -> 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))
+ }
+}
+
+static TRUSTLY_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
+ LazyLock::new(SupportedPaymentMethods::new);
+
+static TRUSTLY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
+ display_name: "Trustly",
+ description: "Trustly connector",
+ connector_type: enums::HyperswitchConnectorCategory::PaymentGateway,
+ integration_status: enums::ConnectorIntegrationStatus::Live,
+};
+
+static TRUSTLY_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
+
+impl ConnectorSpecifications for Trustly {
+ fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
+ Some(&TRUSTLY_CONNECTOR_INFO)
+ }
+
+ fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
+ Some(&*TRUSTLY_SUPPORTED_PAYMENT_METHODS)
+ }
+
+ fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
+ Some(&TRUSTLY_SUPPORTED_WEBHOOK_FLOWS)
+ }
+}
diff --git a/crates/hyperswitch_connectors/src/connectors/trustly/transformers.rs b/crates/hyperswitch_connectors/src/connectors/trustly/transformers.rs
new file mode 100644
index 0000000000..7ece67f8c9
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors/trustly/transformers.rs
@@ -0,0 +1,220 @@
+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};
+
+//TODO: Fill the struct with respective fields
+pub struct TrustlyRouterData<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 TrustlyRouterData<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 TrustlyPaymentsRequest {
+ amount: StringMinorUnit,
+ card: TrustlyCard,
+}
+
+#[derive(Default, Debug, Serialize, Eq, PartialEq)]
+pub struct TrustlyCard {
+ number: cards::CardNumber,
+ expiry_month: Secret<String>,
+ expiry_year: Secret<String>,
+ cvc: Secret<String>,
+ complete: bool,
+}
+
+impl TryFrom<&TrustlyRouterData<&PaymentsAuthorizeRouterData>> for TrustlyPaymentsRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &TrustlyRouterData<&PaymentsAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ match item.router_data.request.payment_method_data.clone() {
+ PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented(
+ "Card payment method not implemented".to_string(),
+ )
+ .into()),
+ _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+// Auth Struct
+pub struct TrustlyAuthType {
+ pub(super) api_key: Secret<String>,
+}
+
+impl TryFrom<&ConnectorAuthType> for TrustlyAuthType {
+ 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, Copy, Default, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "lowercase")]
+pub enum TrustlyPaymentStatus {
+ Succeeded,
+ Failed,
+ #[default]
+ Processing,
+}
+
+impl From<TrustlyPaymentStatus> for common_enums::AttemptStatus {
+ fn from(item: TrustlyPaymentStatus) -> Self {
+ match item {
+ TrustlyPaymentStatus::Succeeded => Self::Charged,
+ TrustlyPaymentStatus::Failed => Self::Failure,
+ TrustlyPaymentStatus::Processing => Self::Authorizing,
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct TrustlyPaymentsResponse {
+ status: TrustlyPaymentStatus,
+ id: String,
+}
+
+impl<F, T> TryFrom<ResponseRouterData<F, TrustlyPaymentsResponse, T, PaymentsResponseData>>
+ for RouterData<F, T, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<F, TrustlyPaymentsResponse, 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,
+ authentication_data: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+}
+
+//TODO: Fill the struct with respective fields
+// REFUND :
+// Type definition for RefundRequest
+#[derive(Default, Debug, Serialize)]
+pub struct TrustlyRefundRequest {
+ pub amount: StringMinorUnit,
+}
+
+impl<F> TryFrom<&TrustlyRouterData<&RefundsRouterData<F>>> for TrustlyRefundRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &TrustlyRouterData<&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 TrustlyErrorResponse {
+ pub status_code: u16,
+ pub code: String,
+ pub message: String,
+ pub reason: Option<String>,
+ pub network_advice_code: Option<String>,
+ pub network_decline_code: Option<String>,
+ pub network_error_message: Option<String>,
+}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 36909abf01..f30c43f07d 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -302,6 +302,7 @@ default_imp_for_authorize_session_token!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -458,6 +459,7 @@ default_imp_for_payment_settlement_split_create!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -614,6 +616,7 @@ default_imp_for_calculate_tax!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -783,6 +786,7 @@ default_imp_for_session_update!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -937,6 +941,7 @@ default_imp_for_post_session_tokens!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1090,6 +1095,7 @@ default_imp_for_create_order!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpayments,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
@@ -1245,6 +1251,7 @@ default_imp_for_update_metadata!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1411,6 +1418,7 @@ default_imp_for_cancel_post_capture!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1540,6 +1548,7 @@ default_imp_for_complete_authorize!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1692,6 +1701,7 @@ default_imp_for_incremental_authorization!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1855,6 +1865,7 @@ default_imp_for_extend_authorization!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1993,6 +2004,7 @@ default_imp_for_create_customer!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2138,6 +2150,7 @@ default_imp_for_connector_redirect_response!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
connectors::Wise,
@@ -2283,6 +2296,7 @@ default_imp_for_pre_authenticate_steps!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2439,6 +2453,7 @@ default_imp_for_authenticate_steps!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2594,6 +2609,7 @@ default_imp_for_post_authenticate_steps!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2741,6 +2757,7 @@ default_imp_for_pre_processing_steps!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
connectors::Wise,
@@ -2895,6 +2912,7 @@ default_imp_for_post_processing_steps!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3054,6 +3072,7 @@ default_imp_for_approve!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3213,6 +3232,7 @@ default_imp_for_reject!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3249,6 +3269,7 @@ macro_rules! default_imp_for_webhook_source_verification {
}
default_imp_for_webhook_source_verification!(
+ connectors::Trustly,
connectors::Paysafe,
connectors::Vgs,
connectors::Aci,
@@ -3528,6 +3549,7 @@ default_imp_for_accept_dispute!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3683,6 +3705,7 @@ default_imp_for_submit_evidence!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3839,6 +3862,7 @@ default_imp_for_defend_dispute!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3998,6 +4022,7 @@ default_imp_for_fetch_disputes!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4156,6 +4181,7 @@ default_imp_for_dispute_sync!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4320,6 +4346,7 @@ default_imp_for_file_upload!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4348,6 +4375,7 @@ macro_rules! default_imp_for_payouts {
}
default_imp_for_payouts!(
+ connectors::Trustly,
connectors::Worldpaymodular,
connectors::Paysafe,
connectors::Affirm,
@@ -4609,6 +4637,7 @@ default_imp_for_payouts_create!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4646,6 +4675,7 @@ macro_rules! default_imp_for_payouts_retrieve {
#[cfg(feature = "payouts")]
default_imp_for_payouts_retrieve!(
+ connectors::Trustly,
connectors::Paysafe,
connectors::Vgs,
connectors::Aci,
@@ -4921,6 +4951,7 @@ default_imp_for_payouts_eligibility!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4958,6 +4989,7 @@ macro_rules! default_imp_for_payouts_fulfill {
#[cfg(feature = "payouts")]
default_imp_for_payouts_fulfill!(
+ connectors::Trustly,
connectors::Worldpaymodular,
connectors::Paysafe,
connectors::Affirm,
@@ -5223,6 +5255,7 @@ default_imp_for_payouts_cancel!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -5379,6 +5412,7 @@ default_imp_for_payouts_quote!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -5536,6 +5570,7 @@ default_imp_for_payouts_recipient!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -5694,6 +5729,7 @@ default_imp_for_payouts_recipient_account!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -5853,6 +5889,7 @@ default_imp_for_frm_sale!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -6011,6 +6048,7 @@ default_imp_for_frm_checkout!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -6169,6 +6207,7 @@ default_imp_for_frm_transaction!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -6328,6 +6367,7 @@ default_imp_for_frm_fulfillment!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -6487,6 +6527,7 @@ default_imp_for_frm_record_return!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -6642,6 +6683,7 @@ default_imp_for_revoking_mandates!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -6799,6 +6841,7 @@ default_imp_for_uas_pre_authentication!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -6955,6 +6998,7 @@ default_imp_for_uas_webhook!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -7111,6 +7155,7 @@ default_imp_for_uas_post_authentication!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -7268,6 +7313,7 @@ default_imp_for_uas_authentication_confirmation!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -7416,6 +7462,7 @@ default_imp_for_connector_request_id!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -7566,6 +7613,7 @@ default_imp_for_fraud_check!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -7746,6 +7794,7 @@ default_imp_for_connector_authentication!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -7902,6 +7951,7 @@ default_imp_for_uas_authentication!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -8052,6 +8102,7 @@ default_imp_for_revenue_recovery!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -8260,6 +8311,7 @@ default_imp_for_subscriptions!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -8419,6 +8471,7 @@ default_imp_for_billing_connector_payment_sync!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -8570,6 +8623,7 @@ default_imp_for_revenue_recovery_record_back!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -8729,6 +8783,7 @@ default_imp_for_billing_connector_invoice_sync!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -8880,6 +8935,7 @@ default_imp_for_external_vault!(
connectors::Thunes,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -9037,6 +9093,7 @@ default_imp_for_external_vault_insert!(
connectors::Thunes,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -9192,6 +9249,7 @@ default_imp_for_gift_card_balance_check!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -9350,6 +9408,7 @@ default_imp_for_external_vault_retrieve!(
connectors::Thunes,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -9508,6 +9567,7 @@ default_imp_for_external_vault_delete!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -9666,6 +9726,7 @@ default_imp_for_external_vault_create!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -9824,6 +9885,7 @@ default_imp_for_connector_authentication_token!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -9981,6 +10043,7 @@ default_imp_for_external_vault_proxy_payments_create!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -10141,6 +10204,7 @@ default_imp_for_connector_webhook_register!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -10994,6 +11058,7 @@ default_impl_connector_access_token!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
index 3474ac893c..4f66437cc2 100644
--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs
@@ -442,6 +442,7 @@ default_imp_for_new_connector_integration_payment!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -601,6 +602,7 @@ default_imp_for_new_connector_integration_refund!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -749,6 +751,7 @@ default_imp_for_new_connector_integration_connector_authentication_token!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
@@ -902,6 +905,7 @@ default_imp_for_new_connector_integration_connector_access_token!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1061,6 +1065,7 @@ default_imp_for_new_connector_integration_accept_dispute!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1220,6 +1225,7 @@ default_imp_for_new_connector_integration_fetch_disputes!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1380,6 +1386,7 @@ default_imp_for_new_connector_integration_dispute_sync!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1540,6 +1547,7 @@ default_imp_for_new_connector_integration_defend_dispute!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1698,6 +1706,7 @@ default_imp_for_new_connector_integration_submit_evidence!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -1867,6 +1876,7 @@ default_imp_for_new_connector_integration_file_upload!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2028,6 +2038,7 @@ default_imp_for_new_connector_integration_payouts_create!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2189,6 +2200,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2350,6 +2362,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2511,6 +2524,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2672,6 +2686,7 @@ default_imp_for_new_connector_integration_payouts_quote!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2833,6 +2848,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -2994,6 +3010,7 @@ default_imp_for_new_connector_integration_payouts_sync!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3155,6 +3172,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3314,6 +3332,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3475,6 +3494,7 @@ default_imp_for_new_connector_integration_frm_sale!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3636,6 +3656,7 @@ default_imp_for_new_connector_integration_frm_checkout!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3797,6 +3818,7 @@ default_imp_for_new_connector_integration_frm_transaction!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -3958,6 +3980,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4119,6 +4142,7 @@ default_imp_for_new_connector_integration_frm_record_return!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4276,6 +4300,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -4403,6 +4428,7 @@ default_imp_for_new_connector_integration_frm!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpayments,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
@@ -4559,6 +4585,7 @@ default_imp_for_new_connector_integration_connector_authentication!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpayments,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
@@ -4707,6 +4734,7 @@ default_imp_for_new_connector_integration_revenue_recovery!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpayments,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
@@ -4891,6 +4919,7 @@ default_imp_for_new_connector_integration_external_vault!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -5049,6 +5078,7 @@ default_imp_for_new_connector_integration_external_vault_proxy!(
connectors::Tokenex,
connectors::Tokenio,
connectors::Truelayer,
+ connectors::Trustly,
connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
@@ -5088,6 +5118,7 @@ macro_rules! default_imp_for_new_connector_integration_webhook_register {
}
default_imp_for_new_connector_integration_webhook_register!(
+ connectors::Trustly,
connectors::Aci,
connectors::Adyen,
connectors::Adyenplatform,
diff --git a/crates/hyperswitch_domain_models/src/connector_endpoints.rs b/crates/hyperswitch_domain_models/src/connector_endpoints.rs
index 0cde0f2a52..1c69b85915 100644
--- a/crates/hyperswitch_domain_models/src/connector_endpoints.rs
+++ b/crates/hyperswitch_domain_models/src/connector_endpoints.rs
@@ -138,6 +138,7 @@ pub struct Connectors {
pub tokenex: ConnectorParams,
pub tokenio: ConnectorParams,
pub truelayer: ConnectorParamsWithSecondaryBaseUrl,
+ pub trustly: ConnectorParams,
pub trustpay: ConnectorParamsWithMoreUrls,
pub trustpayments: ConnectorParams,
pub tsys: ConnectorParams,
diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs
index ed851a8306..a87c49b018 100644
--- a/crates/router/src/connector.rs
+++ b/crates/router/src/connector.rs
@@ -46,12 +46,13 @@ pub use hyperswitch_connectors::connectors::{
silverflow, silverflow::Silverflow, square, square::Square, stax, stax::Stax, stripe,
stripe::Stripe, stripebilling, stripebilling::Stripebilling, taxjar, taxjar::Taxjar, tesouro,
tesouro::Tesouro, threedsecureio, threedsecureio::Threedsecureio, thunes, thunes::Thunes,
- tokenex, tokenex::Tokenex, tokenio, tokenio::Tokenio, truelayer, truelayer::Truelayer,
- trustpay, trustpay::Trustpay, trustpayments, trustpayments::Trustpayments, tsys, tsys::Tsys,
- 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, worldpaymodular, worldpaymodular::Worldpaymodular,
- worldpayvantiv, worldpayvantiv::Worldpayvantiv, worldpayxml, worldpayxml::Worldpayxml, xendit,
- xendit::Xendit, zen, zen::Zen, zift, zift::Zift, zsl, zsl::Zsl,
+ tokenex, tokenex::Tokenex, tokenio, tokenio::Tokenio, truelayer, truelayer::Truelayer, trustly,
+ trustly::Trustly, trustpay, trustpay::Trustpay, trustpayments, trustpayments::Trustpayments,
+ tsys, tsys::Tsys, 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, worldpaymodular,
+ worldpaymodular::Worldpaymodular, worldpayvantiv, worldpayvantiv::Worldpayvantiv, worldpayxml,
+ worldpayxml::Worldpayxml, xendit, xendit::Xendit, zen, zen::Zen, zift, zift::Zift, zsl,
+ zsl::Zsl,
};
diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs
index c4bfdf2656..34ea916738 100644
--- a/crates/router/tests/connectors/main.rs
+++ b/crates/router/tests/connectors/main.rs
@@ -123,6 +123,7 @@ mod tesouro;
mod tokenex;
mod tokenio;
mod truelayer;
+mod trustly;
mod trustpay;
mod trustpayments;
mod tsys;
diff --git a/crates/router/tests/connectors/trustly.rs b/crates/router/tests/connectors/trustly.rs
new file mode 100644
index 0000000000..931b496cd1
--- /dev/null
+++ b/crates/router/tests/connectors/trustly.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 TrustlyTest;
+impl ConnectorActions for TrustlyTest {}
+impl utils::Connector for TrustlyTest {
+ fn get_data(&self) -> api::ConnectorData {
+ use router::connector::Trustly;
+ utils::construct_connector_data_old(
+ Box::new(Trustly::new()),
+ types::Connector::Plaid,
+ api::GetToken::Connector,
+ None,
+ )
+ }
+
+ fn get_auth_token(&self) -> types::ConnectorAuthType {
+ utils::to_connector_auth_type(
+ connector_auth::ConnectorAuthentication::new()
+ .trustly
+ .expect("Missing connector authentication configuration")
+ .into(),
+ )
+ }
+
+ fn get_name(&self) -> String {
+ "trustly".to_string()
+ }
+}
+
+static CONNECTOR: TrustlyTest = TrustlyTest {};
+
+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 4b9c70dc74..622a5cfd4b 100644
--- a/crates/test_utils/src/connector_auth.rs
+++ b/crates/test_utils/src/connector_auth.rs
@@ -133,6 +133,7 @@ pub struct ConnectorAuthentication {
pub tokenex: Option<BodyKey>,
pub tokenio: Option<HeaderKey>,
pub truelayer: Option<BodyKey>,
+ pub trustly: Option<HeaderKey>,
pub stripe_au: Option<HeaderKey>,
pub stripe_uk: Option<HeaderKey>,
pub trustpay: Option<SignatureKey>,
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index e5442f1ba4..e130d60ae9 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -223,6 +223,7 @@ thunes.base_url = "https://api.limonetikqualif.com/"
tokenex.base_url = "https://test-api.tokenex.com"
tokenio.base_url = "https://api.sandbox.token.io"
truelayer.base_url = "https://api.truelayer-sandbox.com"
+trustly.base_url = "https://test.trustly.com/api/1"
truelayer.secondary_base_url = "https://auth.truelayer-sandbox.com"
stripe.base_url_file_upload = "https://files.stripe.com/"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh
index 4538afcae2..edd997ec35 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 affirm airwallex amazonpay applepay archipel authipay authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay blackhawknetwork bluesnap boku braintree breadpay calida cashtocode celero chargebee checkbook checkout coinbase cryptopay ctp_visa custombilling cybersource cybersourcedecisionmanager datatrans deutschebank digitalvirgo dlocal dummyconnector dwolla ebanx elavon envoy facilitapay finix fiserv fiservemea fiuu flexiti forte getnet gigadat globalpay globepay gocardless gpayments helcim hipay hyperpg hyperswitch_vault hyperwallet hyperwallet iatapay inespay itaubank jpmorgan juspaythreedsserver katapult klarna loonio mifinity mollie moneris mpgs multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payjustnow payjustnowinstore payload payme payone paypal paysafe paystack paytm payu peachpayments phonepe placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys revolv3 santander shift4 sift silverflow square stax stripe stripebilling taxjar tesouro threedsecureio thunes tokenex tokenio truelayer trustpay trustpayments tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpaymodular worldpayvantiv worldpayxml xendit zift zsl "$1")
+ connectors=(aci adyen adyenplatform affirm airwallex amazonpay applepay archipel authipay authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay blackhawknetwork bluesnap boku braintree breadpay calida cashtocode celero chargebee checkbook checkout coinbase cryptopay ctp_visa custombilling cybersource cybersourcedecisionmanager datatrans deutschebank digitalvirgo dlocal dummyconnector dwolla ebanx elavon envoy facilitapay finix fiserv fiservemea fiuu flexiti forte getnet gigadat globalpay globepay gocardless gpayments helcim hipay hyperpg hyperswitch_vault hyperwallet hyperwallet iatapay inespay itaubank jpmorgan juspaythreedsserver katapult klarna loonio mifinity mollie moneris mpgs multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payjustnow payjustnowinstore payload payme payone paypal paysafe paystack paytm payu peachpayments phonepe placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys revolv3 santander shift4 sift silverflow square stax stripe stripebilling taxjar tesouro threedsecureio thunes tokenex tokenio truelayer trustly trustpay trustpayments tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpaymodular worldpayvantiv worldpayxml xendit zift zsl "$1")
IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS