diff --git a/config/config.example.toml b/config/config.example.toml index f243e99bcb..b6037d4e19 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -214,6 +214,7 @@ deutschebank.base_url = "https://testmerch.directpos.de/rest-api" digitalvirgo.base_url = "https://dcb-integration-service-sandbox-external.staging.digitalvirgo.pl" dlocal.base_url = "https://sandbox.dlocal.com/" dummyconnector.base_url = "http://localhost:8080/dummy-connector" +dwolla.base_url = "https://api-sandbox.dwolla.com" ebanx.base_url = "https://sandbox.ebanxpay.com/" elavon.base_url = "https://api.demo.convergepay.com/VirtualMerchantDemo/" facilitapay.base_url = "https://sandbox-api.facilitapay.com/api/v1" diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 382e0117f9..7a164d5713 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -53,6 +53,7 @@ deutschebank.base_url = "https://testmerch.directpos.de/rest-api" digitalvirgo.base_url = "https://dcb-integration-service-sandbox-external.staging.digitalvirgo.pl" dlocal.base_url = "https://sandbox.dlocal.com/" dummyconnector.base_url = "http://localhost:8080/dummy-connector" +dwolla.base_url = "https://api-sandbox.dwolla.com" ebanx.base_url = "https://sandbox.ebanxpay.com/" elavon.base_url = "https://api.demo.convergepay.com/VirtualMerchantDemo/" facilitapay.base_url = "https://sandbox-api.facilitapay.com/api/v1" diff --git a/config/deployments/production.toml b/config/deployments/production.toml index e740b6aa76..7c1c9960ad 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -57,6 +57,7 @@ deutschebank.base_url = "https://merch.directpos.de/rest-api" digitalvirgo.base_url = "https://dcb-integration-service-sandbox-external.staging.digitalvirgo.pl" dlocal.base_url = "https://api.dlocal.com/" dummyconnector.base_url = "http://localhost:8080/dummy-connector" +dwolla.base_url = "https://api.dwolla.com" ebanx.base_url = "https://api.ebanxpay.com/" elavon.base_url = "https://api.convergepay.com/VirtualMerchant/" facilitapay.base_url = "https://api.facilitapay.com/api/v1" diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 10a2fccb1f..ea6a37308a 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -57,6 +57,7 @@ deutschebank.base_url = "https://testmerch.directpos.de/rest-api" digitalvirgo.base_url = "https://dcb-integration-service-sandbox-external.staging.digitalvirgo.pl" dlocal.base_url = "https://sandbox.dlocal.com/" dummyconnector.base_url = "http://localhost:8080/dummy-connector" +dwolla.base_url = "https://api-sandbox.dwolla.com" ebanx.base_url = "https://sandbox.ebanxpay.com/" elavon.base_url = "https://api.demo.convergepay.com/VirtualMerchantDemo/" facilitapay.base_url = "https://sandbox-api.facilitapay.com/api/v1" diff --git a/config/development.toml b/config/development.toml index dfe5f1fcc8..f9ba0a5164 100644 --- a/config/development.toml +++ b/config/development.toml @@ -119,6 +119,7 @@ cards = [ "digitalvirgo", "dlocal", "dummyconnector", + "dwolla", "ebanx", "elavon", "facilitapay", @@ -247,6 +248,7 @@ deutschebank.base_url = "https://testmerch.directpos.de/rest-api" digitalvirgo.base_url = "https://dcb-integration-service-sandbox-external.staging.digitalvirgo.pl" dlocal.base_url = "https://sandbox.dlocal.com/" dummyconnector.base_url = "http://localhost:8080/dummy-connector" +dwolla.base_url = "https://api-sandbox.dwolla.com" ebanx.base_url = "https://sandbox.ebanxpay.com/" elavon.base_url = "https://api.demo.convergepay.com/VirtualMerchantDemo/" facilitapay.base_url = "https://sandbox-api.facilitapay.com/api/v1" diff --git a/config/docker_compose.toml b/config/docker_compose.toml index e9b011b039..817d19f2ab 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -140,6 +140,7 @@ deutschebank.base_url = "https://testmerch.directpos.de/rest-api" digitalvirgo.base_url = "https://dcb-integration-service-sandbox-external.staging.digitalvirgo.pl" dlocal.base_url = "https://sandbox.dlocal.com/" dummyconnector.base_url = "http://localhost:8080/dummy-connector" +dwolla.base_url = "https://api-sandbox.dwolla.com" ebanx.base_url = "https://sandbox.ebanxpay.com/" elavon.base_url = "https://api.demo.convergepay.com/VirtualMerchantDemo/" facilitapay.base_url = "https://sandbox-api.facilitapay.com/api/v1" @@ -267,6 +268,7 @@ cards = [ "digitalvirgo", "dlocal", "dummyconnector", + "dwolla", "ebanx", "elavon", "facilitapay", diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs index 0e358e030c..51c7e82b65 100644 --- a/crates/common_enums/src/connector_enums.rs +++ b/crates/common_enums/src/connector_enums.rs @@ -84,6 +84,7 @@ pub enum RoutableConnectors { Deutschebank, Digitalvirgo, Dlocal, + // Dwolla, Ebanx, Elavon, Facilitapay, @@ -241,6 +242,7 @@ pub enum Connector { Deutschebank, Digitalvirgo, Dlocal, + // Dwolla, Ebanx, Elavon, Facilitapay, @@ -418,6 +420,7 @@ impl Connector { | Self::Deutschebank | Self::Digitalvirgo | Self::Dlocal + // | Self::Dwolla | Self::Ebanx | Self::Elavon | Self::Facilitapay @@ -580,6 +583,7 @@ impl From for Connector { RoutableConnectors::Deutschebank => Self::Deutschebank, RoutableConnectors::Digitalvirgo => Self::Digitalvirgo, RoutableConnectors::Dlocal => Self::Dlocal, + // RoutableConnectors::Dwolla => Self::Dwolla, RoutableConnectors::Ebanx => Self::Ebanx, RoutableConnectors::Elavon => Self::Elavon, RoutableConnectors::Facilitapay => Self::Facilitapay, @@ -699,6 +703,7 @@ impl TryFrom for RoutableConnectors { Connector::Deutschebank => Ok(Self::Deutschebank), Connector::Digitalvirgo => Ok(Self::Digitalvirgo), Connector::Dlocal => Ok(Self::Dlocal), + // Connector::Dwolla => Ok(Self::Dwolla), Connector::Ebanx => Ok(Self::Ebanx), Connector::Elavon => Ok(Self::Elavon), Connector::Facilitapay => Ok(Self::Facilitapay), diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs index 2c0bd6fd8f..8784f27e66 100644 --- a/crates/connector_configs/src/connector.rs +++ b/crates/connector_configs/src/connector.rs @@ -207,6 +207,7 @@ pub struct ConnectorConfig { pub deutschebank: Option, pub digitalvirgo: Option, pub dlocal: Option, + pub dwolla: Option, pub ebanx_payout: Option, pub elavon: Option, pub facilitapay: Option, diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index 7395ab45d3..9f1355a137 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -28,6 +28,7 @@ pub mod digitalvirgo; pub mod dlocal; #[cfg(feature = "dummy_connector")] pub mod dummyconnector; +pub mod dwolla; pub mod ebanx; pub mod elavon; pub mod facilitapay; @@ -116,7 +117,7 @@ pub use self::{ cashtocode::Cashtocode, chargebee::Chargebee, checkout::Checkout, coinbase::Coinbase, coingate::Coingate, cryptopay::Cryptopay, ctp_mastercard::CtpMastercard, cybersource::Cybersource, datatrans::Datatrans, deutschebank::Deutschebank, - digitalvirgo::Digitalvirgo, dlocal::Dlocal, ebanx::Ebanx, elavon::Elavon, + digitalvirgo::Digitalvirgo, dlocal::Dlocal, dwolla::Dwolla, ebanx::Ebanx, elavon::Elavon, facilitapay::Facilitapay, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, getnet::Getnet, globalpay::Globalpay, globepay::Globepay, gocardless::Gocardless, gpayments::Gpayments, helcim::Helcim, hipay::Hipay, hyperswitch_vault::HyperswitchVault, diff --git a/crates/hyperswitch_connectors/src/connectors/dwolla.rs b/crates/hyperswitch_connectors/src/connectors/dwolla.rs new file mode 100644 index 0000000000..a228366b28 --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/dwolla.rs @@ -0,0 +1,568 @@ +pub mod transformers; + +use common_utils::{ + errors::CustomResult, + ext_traits::BytesExt, + request::{Method, Request, RequestBuilder, RequestContent}, + types::{AmountConvertor, StringMajorUnit, StringMajorUnitForConnector}, +}; +use error_stack::{report, ResultExt}; +use hyperswitch_domain_models::{ + router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, + router_flow_types::{ + access_token_auth::AccessTokenAuth, + payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void}, + refunds::{Execute, RSync}, + }, + router_request_types::{ + AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData, + PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, + RefundsData, SetupMandateRequestData, + }, + router_response_types::{PaymentsResponseData, RefundsResponseData}, + types::{ + PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, + RefundSyncRouterData, RefundsRouterData, + }, +}; +use hyperswitch_interfaces::{ + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, + configs::Connectors, + errors, + events::connector_api_logs::ConnectorEvent, + types::{self, Response}, + webhooks, +}; +use masking::{ExposeInterface, Mask}; +use transformers as dwolla; + +use crate::{constants::headers, types::ResponseRouterData, utils}; + +#[derive(Clone)] +pub struct Dwolla { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Dwolla { + pub fn new() -> &'static Self { + &Self { + amount_converter: &StringMajorUnitForConnector, + } + } +} + +impl api::Payment for Dwolla {} +impl api::PaymentSession for Dwolla {} +impl api::ConnectorAccessToken for Dwolla {} +impl api::MandateSetup for Dwolla {} +impl api::PaymentAuthorize for Dwolla {} +impl api::PaymentSync for Dwolla {} +impl api::PaymentCapture for Dwolla {} +impl api::PaymentVoid for Dwolla {} +impl api::Refund for Dwolla {} +impl api::RefundExecute for Dwolla {} +impl api::RefundSync for Dwolla {} +impl api::PaymentToken for Dwolla {} + +impl ConnectorIntegration + for Dwolla +{ + // Not Implemented (R) +} + +impl ConnectorCommonExt for Dwolla +where + Self: ConnectorIntegration, +{ + fn build_headers( + &self, + req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult)>, 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 Dwolla { + fn id(&self) -> &'static str { + "dwolla" + } + + fn get_currency_unit(&self) -> api::CurrencyUnit { + api::CurrencyUnit::Base + } + + fn common_get_content_type(&self) -> &'static str { + "application/json" + } + + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { + connectors.dwolla.base_url.as_ref() + } + + fn get_auth_header( + &self, + auth_type: &ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { + let auth = dwolla::DwollaAuthType::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 { + let response: dwolla::DwollaErrorResponse = res + .response + .parse_struct("DwollaErrorResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + + Ok(ErrorResponse { + status_code: res.status_code, + code: response.code, + message: response.message, + reason: response.reason, + attempt_status: None, + connector_transaction_id: None, + network_advice_code: None, + network_decline_code: None, + network_error_message: None, + }) + } +} + +impl ConnectorValidation for Dwolla { + //TODO: implement functions when support enabled +} + +impl ConnectorIntegration for Dwolla { + //TODO: implement sessions flow +} + +impl ConnectorIntegration for Dwolla {} + +impl ConnectorIntegration for Dwolla {} + +impl ConnectorIntegration for Dwolla { + fn get_headers( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + + let connector_router_data = dwolla::DwollaRouterData::from((amount, req)); + let connector_req = dwolla::DwollaPaymentsRequest::try_from(&connector_router_data)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + + fn build_request( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: dwolla::DwollaPaymentsResponse = res + .response + .parse_struct("Dwolla 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Dwolla { + fn get_headers( + &self, + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: dwolla::DwollaPaymentsResponse = res + .response + .parse_struct("dwolla 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Dwolla { + fn get_headers( + &self, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + _req: &PaymentsCaptureRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into()) + } + + fn build_request( + &self, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: dwolla::DwollaPaymentsResponse = res + .response + .parse_struct("Dwolla 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Dwolla {} + +impl ConnectorIntegration for Dwolla { + fn get_headers( + &self, + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &RefundsRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let refund_amount = utils::convert_amount( + self.amount_converter, + req.request.minor_refund_amount, + req.request.currency, + )?; + + let connector_router_data = dwolla::DwollaRouterData::from((refund_amount, req)); + let connector_req = dwolla::DwollaRefundRequest::try_from(&connector_router_data)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + + fn build_request( + &self, + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult, 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, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult, errors::ConnectorError> { + let response: dwolla::RefundResponse = + res.response + .parse_struct("dwolla 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Dwolla { + fn get_headers( + &self, + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: dwolla::RefundResponse = res + .response + .parse_struct("dwolla 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 { + self.build_error_response(res, event_builder) + } +} + +#[async_trait::async_trait] +impl webhooks::IncomingWebhook for Dwolla { + fn get_webhook_object_reference_id( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_event_type( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_resource_object( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult, errors::ConnectorError> { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } +} + +impl ConnectorSpecifications for Dwolla {} diff --git a/crates/hyperswitch_connectors/src/connectors/dwolla/transformers.rs b/crates/hyperswitch_connectors/src/connectors/dwolla/transformers.rs new file mode 100644 index 0000000000..da79358d07 --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/dwolla/transformers.rs @@ -0,0 +1,228 @@ +use common_enums::enums; +use common_utils::types::StringMajorUnit; +use hyperswitch_domain_models::{ + payment_method_data::PaymentMethodData, + router_data::{ConnectorAuthType, RouterData}, + router_flow_types::refunds::{Execute, RSync}, + router_request_types::ResponseId, + router_response_types::{PaymentsResponseData, RefundsResponseData}, + types::{PaymentsAuthorizeRouterData, RefundsRouterData}, +}; +use hyperswitch_interfaces::errors; +use masking::Secret; +use serde::{Deserialize, Serialize}; + +use crate::{ + types::{RefundsResponseRouterData, ResponseRouterData}, + utils::PaymentsAuthorizeRequestData, +}; + +//TODO: Fill the struct with respective fields +pub struct DwollaRouterData { + pub amount: StringMajorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc. + pub router_data: T, +} + +impl From<(StringMajorUnit, T)> for DwollaRouterData { + fn from((amount, item): (StringMajorUnit, 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 DwollaPaymentsRequest { + amount: StringMajorUnit, + card: DwollaCard, +} + +#[derive(Default, Debug, Serialize, Eq, PartialEq)] +pub struct DwollaCard { + number: cards::CardNumber, + expiry_month: Secret, + expiry_year: Secret, + cvc: Secret, + complete: bool, +} + +impl TryFrom<&DwollaRouterData<&PaymentsAuthorizeRouterData>> for DwollaPaymentsRequest { + type Error = error_stack::Report; + fn try_from( + item: &DwollaRouterData<&PaymentsAuthorizeRouterData>, + ) -> Result { + match item.router_data.request.payment_method_data.clone() { + PaymentMethodData::Card(req_card) => { + let card = DwollaCard { + number: req_card.card_number, + expiry_month: req_card.card_exp_month, + expiry_year: req_card.card_exp_year, + cvc: req_card.card_cvc, + complete: item.router_data.request.is_auto_capture()?, + }; + Ok(Self { + amount: item.amount.clone(), + card, + }) + } + _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()), + } + } +} + +//TODO: Fill the struct with respective fields +// Auth Struct +pub struct DwollaAuthType { + pub(super) api_key: Secret, +} + +impl TryFrom<&ConnectorAuthType> for DwollaAuthType { + type Error = error_stack::Report; + fn try_from(auth_type: &ConnectorAuthType) -> Result { + match auth_type { + ConnectorAuthType::HeaderKey { api_key } => Ok(Self { + api_key: api_key.to_owned(), + }), + _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), + } + } +} +// PaymentsResponse +//TODO: Append the remaining status flags +#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "lowercase")] +pub enum DwollaPaymentStatus { + Succeeded, + Failed, + #[default] + Processing, +} + +impl From for common_enums::AttemptStatus { + fn from(item: DwollaPaymentStatus) -> Self { + match item { + DwollaPaymentStatus::Succeeded => Self::Charged, + DwollaPaymentStatus::Failed => Self::Failure, + DwollaPaymentStatus::Processing => Self::Authorizing, + } + } +} + +//TODO: Fill the struct with respective fields +#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct DwollaPaymentsResponse { + status: DwollaPaymentStatus, + id: String, +} + +impl TryFrom> + for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData, + ) -> Result { + 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 DwollaRefundRequest { + pub amount: StringMajorUnit, +} + +impl TryFrom<&DwollaRouterData<&RefundsRouterData>> for DwollaRefundRequest { + type Error = error_stack::Report; + fn try_from(item: &DwollaRouterData<&RefundsRouterData>) -> Result { + Ok(Self { + amount: item.amount.to_owned(), + }) + } +} + +// Type definition for Refund Response + +#[allow(dead_code)] +#[derive(Debug, Serialize, Default, Deserialize, Clone)] +pub enum RefundStatus { + Succeeded, + Failed, + #[default] + Processing, +} + +impl From 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> for RefundsRouterData { + type Error = error_stack::Report; + fn try_from( + item: RefundsResponseRouterData, + ) -> Result { + 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> for RefundsRouterData { + type Error = error_stack::Report; + fn try_from( + item: RefundsResponseRouterData, + ) -> Result { + 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 DwollaErrorResponse { + pub status_code: u16, + pub code: String, + pub message: String, + pub reason: Option, +} diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index b1c6007022..04871a1751 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -169,6 +169,7 @@ default_imp_for_authorize_session_token!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -290,6 +291,7 @@ default_imp_for_calculate_tax!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -411,6 +413,7 @@ default_imp_for_session_update!( connectors::Datatrans, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -533,6 +536,7 @@ default_imp_for_post_session_tokens!( connectors::Datatrans, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -654,6 +658,7 @@ default_imp_for_create_order!( connectors::Datatrans, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -776,6 +781,7 @@ default_imp_for_update_metadata!( connectors::Datatrans, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -894,6 +900,7 @@ default_imp_for_complete_authorize!( connectors::Cryptopay, connectors::Datatrans, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1003,6 +1010,7 @@ default_imp_for_incremental_authorization!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1126,6 +1134,7 @@ default_imp_for_create_customer!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Fiserv, @@ -1240,6 +1249,7 @@ default_imp_for_connector_redirect_response!( connectors::Datatrans, connectors::Deutschebank, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1346,6 +1356,7 @@ default_imp_for_pre_processing_steps!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1460,6 +1471,7 @@ default_imp_for_post_processing_steps!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1583,6 +1595,7 @@ default_imp_for_approve!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1707,6 +1720,7 @@ default_imp_for_reject!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1831,6 +1845,7 @@ default_imp_for_webhook_source_verification!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Ebanx, connectors::Facilitapay, @@ -1953,6 +1968,7 @@ default_imp_for_accept_dispute!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2075,6 +2091,7 @@ default_imp_for_submit_evidence!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2196,6 +2213,7 @@ default_imp_for_defend_dispute!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2327,6 +2345,7 @@ default_imp_for_file_upload!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2440,6 +2459,7 @@ default_imp_for_payouts!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Facilitapay, connectors::Fiserv, @@ -2558,6 +2578,7 @@ default_imp_for_payouts_create!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Facilitapay, connectors::Fiserv, @@ -2679,6 +2700,7 @@ default_imp_for_payouts_retrieve!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2802,6 +2824,7 @@ default_imp_for_payouts_eligibility!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Facilitapay, connectors::Fiserv, @@ -2922,6 +2945,7 @@ default_imp_for_payouts_fulfill!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Facilitapay, connectors::Fiserv, @@ -3041,6 +3065,7 @@ default_imp_for_payouts_cancel!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Facilitapay, connectors::Fiserv, @@ -3163,6 +3188,7 @@ default_imp_for_payouts_quote!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Facilitapay, connectors::Fiserv, @@ -3286,6 +3312,7 @@ default_imp_for_payouts_recipient!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Facilitapay, connectors::Fiserv, @@ -3408,6 +3435,7 @@ default_imp_for_payouts_recipient_account!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -3532,6 +3560,7 @@ default_imp_for_frm_sale!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -3656,6 +3685,7 @@ default_imp_for_frm_checkout!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -3780,6 +3810,7 @@ default_imp_for_frm_transaction!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -3904,6 +3935,7 @@ default_imp_for_frm_fulfillment!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4028,6 +4060,7 @@ default_imp_for_frm_record_return!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4147,6 +4180,7 @@ default_imp_for_revoking_mandates!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4269,6 +4303,7 @@ default_imp_for_uas_pre_authentication!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4390,6 +4425,7 @@ default_imp_for_uas_post_authentication!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4512,6 +4548,7 @@ default_imp_for_uas_authentication_confirmation!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4626,6 +4663,7 @@ default_imp_for_connector_request_id!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4742,6 +4780,7 @@ default_imp_for_fraud_check!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -4888,6 +4927,7 @@ default_imp_for_connector_authentication!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5007,6 +5047,7 @@ default_imp_for_uas_authentication!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5121,6 +5162,7 @@ default_imp_for_revenue_recovery! { connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5246,6 +5288,7 @@ default_imp_for_billing_connector_payment_sync!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5369,6 +5412,7 @@ default_imp_for_revenue_recovery_record_back!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5492,6 +5536,7 @@ default_imp_for_billing_connector_invoice_sync!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Ebanx, connectors::Facilitapay, @@ -5609,6 +5654,7 @@ default_imp_for_external_vault!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5732,6 +5778,7 @@ default_imp_for_external_vault_insert!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5855,6 +5902,7 @@ default_imp_for_external_vault_retrieve!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -5978,6 +6026,7 @@ default_imp_for_external_vault_delete!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -6101,6 +6150,7 @@ default_imp_for_external_vault_create!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index 329e2fbbb9..0121aa1d95 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -275,6 +275,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -399,6 +400,7 @@ default_imp_for_new_connector_integration_refund!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -518,6 +520,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -642,6 +645,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -765,6 +769,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -889,6 +894,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1023,6 +1029,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1149,6 +1156,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1275,6 +1283,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1401,6 +1410,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1527,6 +1537,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1653,6 +1664,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1779,6 +1791,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -1905,6 +1918,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2031,6 +2045,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2155,6 +2170,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2281,6 +2297,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2407,6 +2424,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2533,6 +2551,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2659,6 +2678,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2785,6 +2805,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -2908,6 +2929,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -3015,6 +3037,7 @@ default_imp_for_new_connector_integration_frm!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -3138,6 +3161,7 @@ default_imp_for_new_connector_integration_connector_authentication!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, @@ -3250,6 +3274,7 @@ default_imp_for_new_connector_integration_revenue_recovery!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Elavon, connectors::Ebanx, connectors::Facilitapay, @@ -3382,6 +3407,7 @@ default_imp_for_new_connector_integration_external_vault!( connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, + connectors::Dwolla, connectors::Ebanx, connectors::Elavon, connectors::Facilitapay, diff --git a/crates/hyperswitch_domain_models/src/configs.rs b/crates/hyperswitch_domain_models/src/configs.rs index 6644693836..ab84cf26aa 100644 --- a/crates/hyperswitch_domain_models/src/configs.rs +++ b/crates/hyperswitch_domain_models/src/configs.rs @@ -43,6 +43,7 @@ pub struct Connectors { pub dlocal: ConnectorParams, #[cfg(feature = "dummy_connector")] pub dummyconnector: ConnectorParams, + pub dwolla: ConnectorParams, pub ebanx: ConnectorParams, pub elavon: ConnectorParams, pub facilitapay: ConnectorParams, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index ccf2e35fde..de9eb4f392 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -13,12 +13,12 @@ pub use hyperswitch_connectors::connectors::{ coinbase, coinbase::Coinbase, coingate, coingate::Coingate, cryptopay, cryptopay::Cryptopay, ctp_mastercard, ctp_mastercard::CtpMastercard, cybersource, cybersource::Cybersource, datatrans, datatrans::Datatrans, deutschebank, deutschebank::Deutschebank, digitalvirgo, - digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal, ebanx, ebanx::Ebanx, elavon, - elavon::Elavon, facilitapay, facilitapay::Facilitapay, fiserv, fiserv::Fiserv, fiservemea, - fiservemea::Fiservemea, fiuu, fiuu::Fiuu, forte, forte::Forte, getnet, getnet::Getnet, - globalpay, globalpay::Globalpay, globepay, globepay::Globepay, gocardless, - gocardless::Gocardless, gpayments, gpayments::Gpayments, helcim, helcim::Helcim, hipay, - hipay::Hipay, hyperswitch_vault, hyperswitch_vault::HyperswitchVault, iatapay, + digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal, dwolla, dwolla::Dwolla, ebanx, + ebanx::Ebanx, elavon, elavon::Elavon, facilitapay, facilitapay::Facilitapay, fiserv, + fiserv::Fiserv, fiservemea, fiservemea::Fiservemea, fiuu, fiuu::Fiuu, forte, forte::Forte, + getnet, getnet::Getnet, globalpay, globalpay::Globalpay, globepay, globepay::Globepay, + gocardless, gocardless::Gocardless, gpayments, gpayments::Gpayments, helcim, helcim::Helcim, + hipay, hipay::Hipay, hyperswitch_vault, hyperswitch_vault::HyperswitchVault, iatapay, iatapay::Iatapay, inespay, inespay::Inespay, itaubank, itaubank::Itaubank, jpmorgan, jpmorgan::Jpmorgan, juspaythreedsserver, juspaythreedsserver::Juspaythreedsserver, klarna, klarna::Klarna, mifinity, mifinity::Mifinity, mollie, mollie::Mollie, moneris, diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index 07bae476d2..4a9cc008b6 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -1501,6 +1501,10 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> { dlocal::transformers::DlocalAuthType::try_from(self.auth_type)?; Ok(()) } + // api_enums::Connector::Dwolla => { + // dwolla::transformers::DwollaAuthType::try_from(self.auth_type)?; + // Ok(()) + // } api_enums::Connector::Ebanx => { ebanx::transformers::EbanxAuthType::try_from(self.auth_type)?; Ok(()) diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 186d9235c4..d2d18716ee 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -441,6 +441,9 @@ impl ConnectorData { enums::Connector::DummyBillingConnector => Ok(ConnectorEnum::Old(Box::new( &connector::DummyConnector::<8>, ))), + // enums::Connector::Dwolla => { + // Ok(ConnectorEnum::Old(Box::new(connector::Dwolla::new()))) + // } enums::Connector::Ebanx => { Ok(ConnectorEnum::Old(Box::new(connector::Ebanx::new()))) } diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index c66c12b154..d5c17794b3 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -243,6 +243,7 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Deutschebank => Self::Deutschebank, api_enums::Connector::Digitalvirgo => Self::Digitalvirgo, api_enums::Connector::Dlocal => Self::Dlocal, + // api_enums::Connector::Dwolla => Self::Dwolla, api_enums::Connector::Ebanx => Self::Ebanx, api_enums::Connector::Elavon => Self::Elavon, api_enums::Connector::Facilitapay => Self::Facilitapay, diff --git a/crates/router/tests/connectors/dwolla.rs b/crates/router/tests/connectors/dwolla.rs new file mode 100644 index 0000000000..4500b7ee0f --- /dev/null +++ b/crates/router/tests/connectors/dwolla.rs @@ -0,0 +1,420 @@ +use masking::Secret; +use router::types::{self, api, domain, storage::enums}; +use test_utils::connector_auth; + +use crate::utils::{self, ConnectorActions}; + +#[derive(Clone, Copy)] +struct DwollaTest; +impl ConnectorActions for DwollaTest {} +impl utils::Connector for DwollaTest { + fn get_data(&self) -> api::ConnectorData { + use router::connector::Dwolla; + utils::construct_connector_data_old( + Box::new(Dwolla::new()), + types::Connector::DummyConnector1, + api::GetToken::Connector, + None, + ) + } + + fn get_auth_token(&self) -> types::ConnectorAuthType { + utils::to_connector_auth_type( + connector_auth::ConnectorAuthentication::new() + .dwolla + .expect("Missing connector authentication configuration") + .into(), + ) + } + + fn get_name(&self) -> String { + "dwolla".to_string() + } +} + +static CONNECTOR: DwollaTest = DwollaTest {}; + +fn get_default_payment_info() -> Option { + None +} + +fn payment_method_details() -> Option { + 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: domain::PaymentMethodData::Card(domain::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: domain::PaymentMethodData::Card(domain::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: domain::PaymentMethodData::Card(domain::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/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs index fbceba0864..fced1b6bff 100644 --- a/crates/router/tests/connectors/main.rs +++ b/crates/router/tests/connectors/main.rs @@ -33,6 +33,7 @@ mod deutschebank; mod dlocal; #[cfg(feature = "dummy_connector")] mod dummyconnector; +mod dwolla; mod ebanx; mod elavon; mod facilitapay; diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.toml index 00e0820288..354959856b 100644 --- a/crates/router/tests/connectors/sample_auth.toml +++ b/crates/router/tests/connectors/sample_auth.toml @@ -343,4 +343,8 @@ api_secret = "Secret key" [santander] api_key="Client ID" -key1 ="Client Secret" \ No newline at end of file +key1 ="Client Secret" + +[dwolla] +api_key="Client ID" +key1="Client Secret" \ No newline at end of file diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs index 751065bafc..17d442315c 100644 --- a/crates/test_utils/src/connector_auth.rs +++ b/crates/test_utils/src/connector_auth.rs @@ -41,6 +41,7 @@ pub struct ConnectorAuthentication { pub dlocal: Option, #[cfg(feature = "dummy_connector")] pub dummyconnector: Option, + pub dwolla: Option, pub ebanx: Option, pub elavon: Option, pub facilitapay: Option, diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index ac1b275f7e..3c37f31556 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -107,6 +107,7 @@ deutschebank.base_url = "https://testmerch.directpos.de/rest-api" digitalvirgo.base_url = "https://dcb-integration-service-sandbox-external.staging.digitalvirgo.pl" dlocal.base_url = "https://sandbox.dlocal.com/" dummyconnector.base_url = "http://localhost:8080/dummy-connector" +dwolla.base_url = "https://api-sandbox.dwolla.com" ebanx.base_url = "https://sandbox.ebanxpay.com/" elavon.base_url = "https://api.demo.convergepay.com/VirtualMerchantDemo/" facilitapay.base_url = "https://sandbox-api.facilitapay.com/api/v1" @@ -233,6 +234,7 @@ cards = [ "digitalvirgo", "dlocal", "dummyconnector", + "dwolla", "ebanx", "elavon", "facilitapay", diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh index 52227c6274..e0a2391051 100755 --- a/scripts/add_connector.sh +++ b/scripts/add_connector.sh @@ -6,7 +6,7 @@ function find_prev_connector() { git checkout $self cp $self $self.tmp # Add new connector to existing list and sort it - connectors=(aci adyen adyenplatform airwallex amazonpay applepay archipel authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay ctp_visa cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon facilitapay fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim hipay hyperswitch_vault iatapay inespay itaubank jpmorgan juspaythreedsserver klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys santander shift4 square stax stripe stripebilling taxjar threedsecureio thunes tokenio trustpay tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayvantiv worldpayxml xendit zsl "$1") + connectors=(aci adyen adyenplatform airwallex amazonpay applepay archipel authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay ctp_visa cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector dwolla ebanx elavon facilitapay fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim hipay hyperswitch_vault iatapay inespay itaubank jpmorgan juspaythreedsserver klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys santander shift4 square stax stripe stripebilling taxjar threedsecureio thunes tokenio trustpay tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayvantiv worldpayxml xendit zsl "$1") IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS res="$(echo ${sorted[@]})" sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp