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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): [Tesouro] Add template code (#9555)
Vani Gupta239b6d37c6ba
diff --git a/config/config.example.toml b/config/config.example.tomlindex 91966eaab1..a8f9ea22c4 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -304,6 +304,7 @@ stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"+tesouro.base_url = "https://api.sandbox.tesouro.com"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"tokenex.base_url = "https://test-api.tokenex.com"diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 33ba829cf0..fcdf05c9e4 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -142,6 +142,7 @@ stripe.base_url = "https://api.stripe.com/"stripe.base_url_file_upload = "https://files.stripe.com/"stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"+tesouro.base_url = "https://api.sandbox.tesouro.com"thunes.base_url = "https://api.limonetikqualif.com/"tokenex.base_url = "https://test-api.tokenex.com"tokenio.base_url = "https://api.sandbox.token.io"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 394067bd85..8f414935fe 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -146,6 +146,7 @@ stripe.base_url = "https://api.stripe.com/"stripe.base_url_file_upload = "https://files.stripe.com/"stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.taxjar.com/v2/"+tesouro.base_url = "https://api.tesouro.com"thunes.base_url = "https://api.limonetik.com/"tokenex.base_url = "https://api.tokenex.com"tokenio.base_url = "https://api.token.io"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex 07333518f6..2589bde4a2 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -146,6 +146,7 @@ stripe.base_url = "https://api.stripe.com/"stripe.base_url_file_upload = "https://files.stripe.com/"stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"+tesouro.base_url = "https://api.sandbox.tesouro.com"thunes.base_url = "https://api.limonetikqualif.com/"tokenex.base_url = "https://test-api.tokenex.com"tokenio.base_url = "https://api.sandbox.token.io"diff --git a/config/development.toml b/config/development.tomlindex 0628393330..8027c8763a 100644--- a/config/development.toml+++ b/config/development.toml@@ -342,6 +342,7 @@ stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"+tesouro.base_url = "https://api.sandbox.tesouro.com"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"tokenex.base_url = "https://test-api.tokenex.com"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 881de3aa4d..5cc80eeb06 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -230,6 +230,7 @@ stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"+tesouro.base_url = "https://api.sandbox.tesouro.com"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"tokenex.base_url = "https://test-api.tokenex.com"diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex fec33f7a09..1421acc337 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -365,6 +365,7 @@ pub struct ConnectorConfig {pub zen: Option<ConnectorTomlConfig>,pub zsl: Option<ConnectorTomlConfig>,pub taxjar: Option<ConnectorTomlConfig>,+ pub tesouro: Option<ConnectorTomlConfig>,pub ctp_mastercard: Option<ConnectorTomlConfig>,pub unified_authentication_service: Option<ConnectorTomlConfig>,}diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex 12aaaef440..9b7da0605e 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -7178,3 +7178,8 @@ label = "Site where transaction is initiated"placeholder = "Enter site where transaction is initiated"required = truetype = "Text"++[tesouro]+[tesouro.connector_auth.BodyKey]+api_key="Client ID"+key1="Client Secret"\ No newline at end of filediff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex 3a9513e155..660adf43a6 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -5915,3 +5915,8 @@ label = "Site where transaction is initiated"placeholder = "Enter site where transaction is initiated"required = truetype = "Text"++[tesouro]+[tesouro.connector_auth.BodyKey]+api_key="Client ID"+key1="Client Secret"\ No newline at end of filediff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex e04b4fe716..b9e9abb819 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -7156,3 +7156,8 @@ label = "Site where transaction is initiated"placeholder = "Enter site where transaction is initiated"required = truetype = "Text"++[tesouro]+[tesouro.connector_auth.BodyKey]+api_key="Client ID"+key1="Client Secret"\ No newline at end of filediff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rsindex d0b8ed74eb..60becb9804 100644--- a/crates/hyperswitch_connectors/src/connectors.rs+++ b/crates/hyperswitch_connectors/src/connectors.rs@@ -109,6 +109,7 @@ pub mod stax;pub mod stripe;pub mod stripebilling;pub mod taxjar;+pub mod tesouro;pub mod threedsecureio;pub mod thunes;pub mod tokenex;@@ -157,9 +158,9 @@ pub use self::{powertranz::Powertranz, prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay,recurly::Recurly, redsys::Redsys, riskified::Riskified, santander::Santander, shift4::Shift4,sift::Sift, signifyd::Signifyd, silverflow::Silverflow, square::Square, stax::Stax,- stripe::Stripe, stripebilling::Stripebilling, taxjar::Taxjar, threedsecureio::Threedsecureio,- thunes::Thunes, tokenex::Tokenex, tokenio::Tokenio, trustpay::Trustpay,- trustpayments::Trustpayments, tsys::Tsys,+ stripe::Stripe, stripebilling::Stripebilling, taxjar::Taxjar, tesouro::Tesouro,+ threedsecureio::Threedsecureio, thunes::Thunes, tokenex::Tokenex, tokenio::Tokenio,+ trustpay::Trustpay, trustpayments::Trustpayments, tsys::Tsys,unified_authentication_service::UnifiedAuthenticationService, vgs::Vgs, volt::Volt,wellsfargo::Wellsfargo, wellsfargopayout::Wellsfargopayout, wise::Wise, worldline::Worldline,worldpay::Worldpay, worldpayvantiv::Worldpayvantiv, worldpayxml::Worldpayxml, xendit::Xendit,diff --git a/crates/hyperswitch_connectors/src/connectors/tesouro.rs b/crates/hyperswitch_connectors/src/connectors/tesouro.rsnew file mode 100644index 0000000000..cdd0d81c6d--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/tesouro.rs@@ -0,0 +1,624 @@+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, FloatMajorUnit, FloatMajorUnitForConnector},+};+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 tesouro;++use crate::{constants::headers, types::ResponseRouterData, utils};++#[derive(Clone)]+pub struct Tesouro {+ amount_converter: &'static (dyn AmountConvertor<Output = FloatMajorUnit> + Sync),+}++impl Tesouro {+ pub fn new() -> &'static Self {+ &Self {+ amount_converter: &FloatMajorUnitForConnector,+ }+ }+}++impl api::Payment for Tesouro {}+impl api::PaymentSession for Tesouro {}+impl api::ConnectorAccessToken for Tesouro {}+impl api::MandateSetup for Tesouro {}+impl api::PaymentAuthorize for Tesouro {}+impl api::PaymentSync for Tesouro {}+impl api::PaymentCapture for Tesouro {}+impl api::PaymentVoid for Tesouro {}+impl api::Refund for Tesouro {}+impl api::RefundExecute for Tesouro {}+impl api::RefundSync for Tesouro {}+impl api::PaymentToken for Tesouro {}++impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>+ for Tesouro+{+ // Not Implemented (R)+}++impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Tesouro+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 Tesouro {+ fn id(&self) -> &'static str {+ "tesouro"+ }++ 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.tesouro.base_url.as_ref()+ }++ fn get_auth_header(+ &self,+ auth_type: &ConnectorAuthType,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ let auth = tesouro::TesouroAuthType::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: tesouro::TesouroErrorResponse = res+ .response+ .parse_struct("TesouroErrorResponse")+ .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,+ connector_metadata: None,+ })+ }+}++impl ConnectorValidation for Tesouro {+ 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 Tesouro {+ //TODO: implement sessions flow+}++impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Tesouro {}++impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Tesouro {}++impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Tesouro {+ 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 = tesouro::TesouroRouterData::from((amount, req));+ let connector_req = tesouro::TesouroPaymentsRequest::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: tesouro::TesouroPaymentsResponse = res+ .response+ .parse_struct("Tesouro 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 Tesouro {+ 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: tesouro::TesouroPaymentsResponse = res+ .response+ .parse_struct("tesouro 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 Tesouro {+ 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: tesouro::TesouroPaymentsResponse = res+ .response+ .parse_struct("Tesouro 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 Tesouro {}++impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Tesouro {+ 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 = tesouro::TesouroRouterData::from((refund_amount, req));+ let connector_req = tesouro::TesouroRefundRequest::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: tesouro::RefundResponse = res+ .response+ .parse_struct("tesouro 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 Tesouro {+ 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: tesouro::RefundResponse = res+ .response+ .parse_struct("tesouro 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 Tesouro {+ 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))+ }+}++static TESOURO_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =+ LazyLock::new(SupportedPaymentMethods::new);++static TESOURO_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {+ display_name: "Tesouro",+ description: "Tesouro connects software companies and banks in one unified ecosystem, simplifying payments",+ connector_type: enums::HyperswitchConnectorCategory::PaymentGateway,+ integration_status: enums::ConnectorIntegrationStatus::Sandbox,+};++static TESOURO_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];++impl ConnectorSpecifications for Tesouro {+ fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {+ Some(&TESOURO_CONNECTOR_INFO)+ }++ fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {+ Some(&*TESOURO_SUPPORTED_PAYMENT_METHODS)+ }++ fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {+ Some(&TESOURO_SUPPORTED_WEBHOOK_FLOWS)+ }+}diff --git a/crates/hyperswitch_connectors/src/connectors/tesouro/transformers.rs b/crates/hyperswitch_connectors/src/connectors/tesouro/transformers.rsnew file mode 100644index 0000000000..89ca59873e--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/tesouro/transformers.rs@@ -0,0 +1,219 @@+use common_enums::enums;+use common_utils::types::FloatMajorUnit;+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 TesouroRouterData<T> {+ pub amount: FloatMajorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.+ pub router_data: T,+}++impl<T> From<(FloatMajorUnit, T)> for TesouroRouterData<T> {+ fn from((amount, item): (FloatMajorUnit, 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 TesouroPaymentsRequest {+ amount: FloatMajorUnit,+ card: TesouroCard,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+pub struct TesouroCard {+ number: cards::CardNumber,+ expiry_month: Secret<String>,+ expiry_year: Secret<String>,+ cvc: Secret<String>,+ complete: bool,+}++impl TryFrom<&TesouroRouterData<&PaymentsAuthorizeRouterData>> for TesouroPaymentsRequest {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: &TesouroRouterData<&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 TesouroAuthType {+ pub(super) api_key: Secret<String>,+}++impl TryFrom<&ConnectorAuthType> for TesouroAuthType {+ 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 TesouroPaymentStatus {+ Succeeded,+ Failed,+ #[default]+ Processing,+}++impl From<TesouroPaymentStatus> for common_enums::AttemptStatus {+ fn from(item: TesouroPaymentStatus) -> Self {+ match item {+ TesouroPaymentStatus::Succeeded => Self::Charged,+ TesouroPaymentStatus::Failed => Self::Failure,+ TesouroPaymentStatus::Processing => Self::Authorizing,+ }+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]+pub struct TesouroPaymentsResponse {+ status: TesouroPaymentStatus,+ id: String,+}++impl<F, T> TryFrom<ResponseRouterData<F, TesouroPaymentsResponse, T, PaymentsResponseData>>+ for RouterData<F, T, PaymentsResponseData>+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: ResponseRouterData<F, TesouroPaymentsResponse, 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 TesouroRefundRequest {+ pub amount: FloatMajorUnit,+}++impl<F> TryFrom<&TesouroRouterData<&RefundsRouterData<F>>> for TesouroRefundRequest {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(item: &TesouroRouterData<&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 TesouroErrorResponse {+ 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.rsindex 2d7e5e3474..f035b90a82 100644--- a/crates/hyperswitch_connectors/src/default_implementations.rs+++ b/crates/hyperswitch_connectors/src/default_implementations.rs@@ -275,6 +275,7 @@ default_imp_for_authorize_session_token!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::UnifiedAuthenticationService,connectors::Volt,connectors::Threedsecureio,@@ -420,6 +421,7 @@ default_imp_for_calculate_tax!(connectors::Square,connectors::Stripe,connectors::Stripebilling,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -527,6 +529,7 @@ default_imp_for_session_update!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Mifinity,connectors::Mollie,connectors::Moneris,@@ -672,6 +675,7 @@ default_imp_for_post_session_tokens!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Mifinity,connectors::Mollie,connectors::Moneris,@@ -814,6 +818,7 @@ default_imp_for_create_order!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Mifinity,connectors::Mollie,connectors::Moneris,@@ -960,6 +965,7 @@ default_imp_for_update_metadata!(connectors::Stax,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Mifinity,connectors::Mollie,connectors::Moneris,@@ -1106,6 +1112,7 @@ default_imp_for_cancel_post_capture!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Mifinity,connectors::Mollie,connectors::Moneris,@@ -1268,6 +1275,7 @@ default_imp_for_complete_authorize!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1410,6 +1418,7 @@ default_imp_for_incremental_authorization!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1548,6 +1557,7 @@ default_imp_for_create_customer!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1679,6 +1689,7 @@ default_imp_for_connector_redirect_response!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1818,6 +1829,7 @@ default_imp_for_pre_authenticate_steps!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1962,6 +1974,7 @@ default_imp_for_authenticate_steps!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2106,6 +2119,7 @@ default_imp_for_post_authenticate_steps!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2239,6 +2253,7 @@ default_imp_for_pre_processing_steps!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2382,6 +2397,7 @@ default_imp_for_post_processing_steps!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2529,6 +2545,7 @@ default_imp_for_approve!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2676,6 +2693,7 @@ default_imp_for_reject!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2822,6 +2840,7 @@ default_imp_for_webhook_source_verification!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2968,6 +2987,7 @@ default_imp_for_accept_dispute!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3111,6 +3131,7 @@ default_imp_for_submit_evidence!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3255,6 +3276,7 @@ default_imp_for_defend_dispute!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3402,6 +3424,7 @@ default_imp_for_fetch_disputes!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3548,6 +3571,7 @@ default_imp_for_dispute_sync!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3700,6 +3724,7 @@ default_imp_for_file_upload!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3831,6 +3856,7 @@ default_imp_for_payouts!(connectors::Stax,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Tokenex,connectors::Tokenio,@@ -3973,6 +3999,7 @@ default_imp_for_payouts_create!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4119,6 +4146,7 @@ default_imp_for_payouts_retrieve!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4264,6 +4292,7 @@ default_imp_for_payouts_eligibility!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4404,6 +4433,7 @@ default_imp_for_payouts_fulfill!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4548,6 +4578,7 @@ default_imp_for_payouts_cancel!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4694,6 +4725,7 @@ default_imp_for_payouts_quote!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4839,6 +4871,7 @@ default_imp_for_payouts_recipient!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4985,6 +5018,7 @@ default_imp_for_payouts_recipient_account!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -5132,6 +5166,7 @@ default_imp_for_frm_sale!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -5279,6 +5314,7 @@ default_imp_for_frm_checkout!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -5426,6 +5462,7 @@ default_imp_for_frm_transaction!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -5573,6 +5610,7 @@ default_imp_for_frm_fulfillment!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -5720,6 +5758,7 @@ default_imp_for_frm_record_return!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -5863,6 +5902,7 @@ default_imp_for_revoking_mandates!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -6008,6 +6048,7 @@ default_imp_for_uas_pre_authentication!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -6152,6 +6193,7 @@ default_imp_for_uas_post_authentication!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -6297,6 +6339,7 @@ default_imp_for_uas_authentication_confirmation!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -6433,6 +6476,7 @@ default_imp_for_connector_request_id!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -6572,6 +6616,7 @@ default_imp_for_fraud_check!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -6741,6 +6786,7 @@ default_imp_for_connector_authentication!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Thunes,connectors::Tokenex,connectors::Tokenio,@@ -6884,6 +6930,7 @@ default_imp_for_uas_authentication!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -7022,6 +7069,7 @@ default_imp_for_revenue_recovery!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -7191,6 +7239,7 @@ default_imp_for_subscriptions!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -7338,6 +7387,7 @@ default_imp_for_billing_connector_payment_sync!(connectors::Stax,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -7484,6 +7534,7 @@ default_imp_for_revenue_recovery_record_back!(connectors::Stax,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -7632,6 +7683,7 @@ default_imp_for_billing_connector_invoice_sync!(connectors::Stripebilling,connectors::Threedsecureio,connectors::Taxjar,+ connectors::Tesouro,connectors::Thunes,connectors::Tokenex,connectors::Tokenio,@@ -7771,6 +7823,7 @@ default_imp_for_external_vault!(connectors::Stripebilling,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenio,@@ -7916,6 +7969,7 @@ default_imp_for_external_vault_insert!(connectors::Stripebilling,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenio,@@ -8059,6 +8113,7 @@ default_imp_for_gift_card_balance_check!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -8206,6 +8261,7 @@ default_imp_for_external_vault_retrieve!(connectors::Stripebilling,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenio,@@ -8351,6 +8407,7 @@ default_imp_for_external_vault_delete!(connectors::Stripebilling,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -8497,6 +8554,7 @@ default_imp_for_external_vault_create!(connectors::Stripebilling,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -8643,6 +8701,7 @@ default_imp_for_connector_authentication_token!(connectors::Stripebilling,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -8788,6 +8847,7 @@ default_imp_for_external_vault_proxy_payments_create!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rsindex 621e41dcb9..570977048f 100644--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs@@ -377,6 +377,7 @@ default_imp_for_new_connector_integration_payment!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -524,6 +525,7 @@ default_imp_for_new_connector_integration_refund!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -660,6 +662,7 @@ default_imp_for_new_connector_integration_connector_authentication_token!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -801,6 +804,7 @@ default_imp_for_new_connector_integration_connector_access_token!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -948,6 +952,7 @@ default_imp_for_new_connector_integration_accept_dispute!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1095,6 +1100,7 @@ default_imp_for_new_connector_integration_fetch_disputes!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1243,6 +1249,7 @@ default_imp_for_new_connector_integration_dispute_sync!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1391,6 +1398,7 @@ default_imp_for_new_connector_integration_defend_dispute!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1537,6 +1545,7 @@ default_imp_for_new_connector_integration_submit_evidence!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1694,6 +1703,7 @@ default_imp_for_new_connector_integration_file_upload!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1843,6 +1853,7 @@ default_imp_for_new_connector_integration_payouts_create!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1992,6 +2003,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2141,6 +2153,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2290,6 +2303,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2439,6 +2453,7 @@ default_imp_for_new_connector_integration_payouts_quote!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2588,6 +2603,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2737,6 +2753,7 @@ default_imp_for_new_connector_integration_payouts_sync!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2886,6 +2903,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3033,6 +3051,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3182,6 +3201,7 @@ default_imp_for_new_connector_integration_frm_sale!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3331,6 +3351,7 @@ default_imp_for_new_connector_integration_frm_checkout!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3480,6 +3501,7 @@ default_imp_for_new_connector_integration_frm_transaction!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3629,6 +3651,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3778,6 +3801,7 @@ default_imp_for_new_connector_integration_frm_record_return!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -3923,6 +3947,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(connectors::Square,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4038,6 +4063,7 @@ default_imp_for_new_connector_integration_frm!(connectors::Stripe,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4182,6 +4208,7 @@ default_imp_for_new_connector_integration_connector_authentication!(connectors::Stripe,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4318,6 +4345,7 @@ default_imp_for_new_connector_integration_revenue_recovery!(connectors::Stripe,connectors::Square,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4490,6 +4518,7 @@ default_imp_for_new_connector_integration_external_vault!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -4636,6 +4665,7 @@ default_imp_for_new_connector_integration_external_vault_proxy!(connectors::Stripe,connectors::Stripebilling,connectors::Taxjar,+ connectors::Tesouro,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,diff --git a/crates/hyperswitch_domain_models/src/connector_endpoints.rs b/crates/hyperswitch_domain_models/src/connector_endpoints.rsindex cca0310190..7f1657c0a3 100644--- a/crates/hyperswitch_domain_models/src/connector_endpoints.rs+++ b/crates/hyperswitch_domain_models/src/connector_endpoints.rs@@ -125,6 +125,7 @@ pub struct Connectors {pub stripe: ConnectorParamsWithFileUploadUrl,pub stripebilling: ConnectorParams,pub taxjar: ConnectorParams,+ pub tesouro: ConnectorParams,pub threedsecureio: ConnectorParams,pub thunes: ConnectorParams,pub tokenex: ConnectorParams,diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rsindex 895d9ae1a2..3bed6948c3 100644--- a/crates/router/src/connector.rs+++ b/crates/router/src/connector.rs@@ -40,10 +40,10 @@ pub use hyperswitch_connectors::connectors::{redsys::Redsys, riskified, riskified::Riskified, santander, santander::Santander, shift4,shift4::Shift4, sift, sift::Sift, signifyd, signifyd::Signifyd, silverflow,silverflow::Silverflow, square, square::Square, stax, stax::Stax, stripe, stripe::Stripe,- stripebilling, stripebilling::Stripebilling, taxjar, taxjar::Taxjar, threedsecureio,- threedsecureio::Threedsecureio, thunes, thunes::Thunes, tokenex, tokenex::Tokenex, tokenio,- tokenio::Tokenio, trustpay, trustpay::Trustpay, trustpayments, trustpayments::Trustpayments,- tsys, tsys::Tsys, unified_authentication_service,+ stripebilling, stripebilling::Stripebilling, taxjar, taxjar::Taxjar, tesouro, tesouro::Tesouro,+ threedsecureio, threedsecureio::Threedsecureio, thunes, thunes::Thunes, tokenex,+ tokenex::Tokenex, tokenio, tokenio::Tokenio, 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, worldpayvantiv,diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rsindex fbabe1155f..6f671a243e 100644--- a/crates/router/tests/connectors/main.rs+++ b/crates/router/tests/connectors/main.rs@@ -111,6 +111,7 @@ mod stax;mod stripe;mod stripebilling;mod taxjar;+mod tesouro;mod tokenex;mod tokenio;mod trustpay;diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.tomlindex 5b79c5ef2e..f48e67aff8 100644--- a/crates/router/tests/connectors/sample_auth.toml+++ b/crates/router/tests/connectors/sample_auth.toml@@ -369,4 +369,8 @@ api_key="EOrder Token"[peachpayments]api_key="API Key"-key1="Tenant ID"\ No newline at end of file+key1="Tenant ID"++[tesouro]+api_key="Client ID"+key1="Client Secret"\ No newline at end of filediff --git a/crates/router/tests/connectors/tesouro.rs b/crates/router/tests/connectors/tesouro.rsnew file mode 100644index 0000000000..44e74552fa--- /dev/null+++ b/crates/router/tests/connectors/tesouro.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 TesouroTest;+impl ConnectorActions for TesouroTest {}+impl utils::Connector for TesouroTest {+ fn get_data(&self) -> api::ConnectorData {+ use router::connector::Tesouro;+ utils::construct_connector_data_old(+ Box::new(Tesouro::new()),+ types::Connector::Plaid,+ api::GetToken::Connector,+ None,+ )+ }++ fn get_auth_token(&self) -> types::ConnectorAuthType {+ utils::to_connector_auth_type(+ connector_auth::ConnectorAuthentication::new()+ .tesouro+ .expect("Missing connector authentication configuration")+ .into(),+ )+ }++ fn get_name(&self) -> String {+ "tesouro".to_string()+ }+}++static CONNECTOR: TesouroTest = TesouroTest {};++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 testsdiff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rsindex 1208173abd..c51c415321 100644--- a/crates/test_utils/src/connector_auth.rs+++ b/crates/test_utils/src/connector_auth.rs@@ -119,6 +119,7 @@ pub struct ConnectorAuthentication {pub stripe: Option<HeaderKey>,pub stripebilling: Option<HeaderKey>,pub taxjar: Option<HeaderKey>,+ pub tesouro: Option<HeaderKey>,pub threedsecureio: Option<HeaderKey>,pub thunes: Option<HeaderKey>,pub tokenex: Option<BodyKey>,diff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex 320488eddd..62debb9969 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -197,6 +197,7 @@ stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"+tesouro.base_url = "https://api.sandbox.tesouro.com"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"tokenex.base_url = "https://test-api.tokenex.com"diff --git a/scripts/add_connector.sh b/scripts/add_connector.shindex 22573052f1..25dce6cd58 100755--- a/scripts/add_connector.sh+++ b/scripts/add_connector.sh@@ -6,7 +6,7 @@ function find_prev_connector() {git checkout $selfcp $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 bluecode bluesnap boku braintree breadpay cashtocode celero chargebee checkbook checkout coinbase cryptopay ctp_visa custombilling cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector dwolla ebanx elavon facilitapay fiserv fiservemea fiuu flexiti forte getnet gigadat globalpay globepay gocardless gpayments helcim hipay hyperswitch_vault hyperwallet hyperwallet iatapay inespay itaubank jpmorgan juspaythreedsserver katapult klarna mifinity mollie moneris mpgs multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payload payme payone paypal paysafe paystack paytm payu peachpayments phonepe placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys santander shift4 sift silverflow square stax stripe stripebilling taxjar threedsecureio thunes tokenex tokenio trustpay trustpayments tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayvantiv worldpayxml xendit zsl "$1")+ connectors=(aci adyen adyenplatform affirm airwallex amazonpay applepay archipel authipay authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay blackhawknetwork bluecode bluesnap boku braintree breadpay cashtocode celero chargebee checkbook checkout coinbase cryptopay ctp_visa custombilling cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector dwolla ebanx elavon facilitapay fiserv fiservemea fiuu flexiti forte getnet gigadat globalpay globepay gocardless gpayments helcim hipay hyperswitch_vault hyperwallet hyperwallet iatapay inespay itaubank jpmorgan juspaythreedsserver katapult klarna mifinity mollie moneris mpgs multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payload payme payone paypal paysafe paystack paytm payu peachpayments phonepe placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys santander shift4 sift silverflow square stax stripe stripebilling taxjar tesouro threedsecureio thunes tokenex tokenio trustpay trustpayments tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayvantiv worldpayxml xendit zsl "$1")IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS