Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

Feat(connector): [WELLSFARGO] Add template code (#5333)

awasthi2194bb3e78fddf
diff --git a/config/config.example.toml b/config/config.example.toml
index aa98c0533e..941a315aae 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -251,6 +251,7 @@ trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/"
tsys.base_url = "https://stagegw.transnox.com/"
volt.base_url = "https://api.sandbox.volt.io/"
+wellsfargo.base_url = "https://apitest.cybersource.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index c11fb1b890..7c946f8209 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -89,6 +89,7 @@ trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/"
tsys.base_url = "https://stagegw.transnox.com/"
volt.base_url = "https://api.sandbox.volt.io/"
+wellsfargo.base_url = "https://apitest.cybersource.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 478c77bdd5..4630b96922 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -93,6 +93,7 @@ trustpay.base_url = "https://tpgw.trustpay.eu/"
trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/"
tsys.base_url = "https://gateway.transit-pass.com/"
volt.base_url = "https://api.volt.io/"
+wellsfargo.base_url = "https://api.cybersource.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index ad93982225..5fb7bfe0d6 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -93,6 +93,7 @@ trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/"
tsys.base_url = "https://stagegw.transnox.com/"
volt.base_url = "https://api.sandbox.volt.io/"
+wellsfargo.base_url = "https://apitest.cybersource.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
diff --git a/config/development.toml b/config/development.toml
index 49bc7756cc..48aa82b07a 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -152,6 +152,7 @@ cards = [
"trustpay",
"tsys",
"volt",
+ "wellsfargo",
"wise",
"worldline",
"worldpay",
@@ -248,6 +249,7 @@ worldpay.base_url = "https://try.access.worldpay.com/"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
tsys.base_url = "https://stagegw.transnox.com/"
volt.base_url = "https://api.sandbox.volt.io/"
+wellsfargo.base_url = "https://apitest.cybersource.com/"
trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/"
zen.base_url = "https://api.zen-test.com/"
zen.secondary_base_url = "https://secure.zen-test.com/"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 7f89acd01e..61fdf86e45 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -180,6 +180,7 @@ trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/"
tsys.base_url = "https://stagegw.transnox.com/"
volt.base_url = "https://api.sandbox.volt.io/"
+wellsfargo.base_url = "https://apitest.cybersource.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
@@ -251,6 +252,7 @@ cards = [
"trustpay",
"tsys",
"volt",
+ "wellsfargo",
"wise",
"worldline",
"worldpay",
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 28a1296468..79cb60da2d 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -132,6 +132,7 @@ pub enum Connector {
// Tsys,
Tsys,
Volt,
+ // Wellsfargo,
Wise,
Worldline,
Worldpay,
@@ -250,6 +251,7 @@ impl Connector {
| Self::Trustpay
| Self::Tsys
| Self::Volt
+ // | Self::Wellsfargo
| Self::Wise
| Self::Worldline
| Self::Worldpay
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 16f877c4c3..a9eec76cc1 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -247,6 +247,7 @@ pub enum RoutableConnectors {
// Tsys,
Tsys,
Volt,
+ // Wellsfargo,
Wise,
Worldline,
Worldpay,
diff --git a/crates/hyperswitch_interfaces/src/configs.rs b/crates/hyperswitch_interfaces/src/configs.rs
index 3072a952b1..7634c006a7 100644
--- a/crates/hyperswitch_interfaces/src/configs.rs
+++ b/crates/hyperswitch_interfaces/src/configs.rs
@@ -77,6 +77,7 @@ pub struct Connectors {
pub trustpay: ConnectorParamsWithMoreUrls,
pub tsys: ConnectorParams,
pub volt: ConnectorParams,
+ pub wellsfargo: ConnectorParams,
pub wise: ConnectorParams,
pub worldline: ConnectorParams,
pub worldpay: ConnectorParams,
diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs
index 85f51bcc11..3a938d0ba6 100644
--- a/crates/router/src/connector.rs
+++ b/crates/router/src/connector.rs
@@ -63,6 +63,7 @@ pub mod trustpay;
pub mod tsys;
pub mod utils;
pub mod volt;
+pub mod wellsfargo;
pub mod wise;
pub mod worldline;
pub mod worldpay;
@@ -85,6 +86,6 @@ pub use self::{
paypal::Paypal, payu::Payu, placetopay::Placetopay, plaid::Plaid, powertranz::Powertranz,
prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay, riskified::Riskified, shift4::Shift4,
signifyd::Signifyd, square::Square, stax::Stax, stripe::Stripe, threedsecureio::Threedsecureio,
- trustpay::Trustpay, tsys::Tsys, volt::Volt, wise::Wise, worldline::Worldline,
- worldpay::Worldpay, zen::Zen, zsl::Zsl,
+ trustpay::Trustpay, tsys::Tsys, volt::Volt, wellsfargo::Wellsfargo, wise::Wise,
+ worldline::Worldline, worldpay::Worldpay, zen::Zen, zsl::Zsl,
};
diff --git a/crates/router/src/connector/wellsfargo.rs b/crates/router/src/connector/wellsfargo.rs
new file mode 100644
index 0000000000..51ff838afd
--- /dev/null
+++ b/crates/router/src/connector/wellsfargo.rs
@@ -0,0 +1,579 @@
+pub mod transformers;
+
+use common_utils::types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector};
+use error_stack::{report, ResultExt};
+use masking::ExposeInterface;
+use transformers as wellsfargo;
+
+use super::utils::{self as connector_utils};
+use crate::{
+ configs::settings,
+ core::errors::{self, CustomResult},
+ events::connector_api_logs::ConnectorEvent,
+ headers,
+ services::{
+ self,
+ request::{self, Mask},
+ ConnectorIntegration, ConnectorValidation,
+ },
+ types::{
+ self,
+ api::{self, ConnectorCommon, ConnectorCommonExt},
+ ErrorResponse, RequestContent, Response,
+ },
+ utils::BytesExt,
+};
+
+#[derive(Clone)]
+pub struct Wellsfargo {
+ amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
+}
+
+impl Wellsfargo {
+ pub fn new() -> &'static Self {
+ &Self {
+ amount_converter: &StringMinorUnitForConnector,
+ }
+ }
+}
+
+impl api::Payment for Wellsfargo {}
+impl api::PaymentSession for Wellsfargo {}
+impl api::ConnectorAccessToken for Wellsfargo {}
+impl api::MandateSetup for Wellsfargo {}
+impl api::PaymentAuthorize for Wellsfargo {}
+impl api::PaymentSync for Wellsfargo {}
+impl api::PaymentCapture for Wellsfargo {}
+impl api::PaymentVoid for Wellsfargo {}
+impl api::Refund for Wellsfargo {}
+impl api::RefundExecute for Wellsfargo {}
+impl api::RefundSync for Wellsfargo {}
+impl api::PaymentToken for Wellsfargo {}
+
+impl
+ ConnectorIntegration<
+ api::PaymentMethodToken,
+ types::PaymentMethodTokenizationData,
+ types::PaymentsResponseData,
+ > for Wellsfargo
+{
+ // Not Implemented (R)
+}
+
+impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Wellsfargo
+where
+ Self: ConnectorIntegration<Flow, Request, Response>,
+{
+ fn build_headers(
+ &self,
+ req: &types::RouterData<Flow, Request, Response>,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::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 Wellsfargo {
+ fn id(&self) -> &'static str {
+ "wellsfargo"
+ }
+
+ fn get_currency_unit(&self) -> api::CurrencyUnit {
+ api::CurrencyUnit::Minor
+ // 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 settings::Connectors) -> &'a str {
+ connectors.wellsfargo.base_url.as_ref()
+ }
+
+ fn get_auth_header(
+ &self,
+ auth_type: &types::ConnectorAuthType,
+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ let auth = wellsfargo::WellsfargoAuthType::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: wellsfargo::WellsfargoErrorResponse = res
+ .response
+ .parse_struct("WellsfargoErrorResponse")
+ .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,
+ })
+ }
+}
+
+impl ConnectorValidation for Wellsfargo {
+ //TODO: implement functions when support enabled
+}
+
+impl ConnectorIntegration<api::Session, types::PaymentsSessionData, types::PaymentsResponseData>
+ for Wellsfargo
+{
+ //TODO: implement sessions flow
+}
+
+impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, types::AccessToken>
+ for Wellsfargo
+{
+}
+
+impl
+ ConnectorIntegration<
+ api::SetupMandate,
+ types::SetupMandateRequestData,
+ types::PaymentsResponseData,
+ > for Wellsfargo
+{
+}
+
+impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::PaymentsResponseData>
+ for Wellsfargo
+{
+ fn get_headers(
+ &self,
+ req: &types::PaymentsAuthorizeRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::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: &types::PaymentsAuthorizeRouterData,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn get_request_body(
+ &self,
+ req: &types::PaymentsAuthorizeRouterData,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount = connector_utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req));
+ let connector_req =
+ wellsfargo::WellsfargoPaymentsRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &types::PaymentsAuthorizeRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ Ok(Some(
+ services::RequestBuilder::new()
+ .method(services::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: &types::PaymentsAuthorizeRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
+ let response: wellsfargo::WellsfargoPaymentsResponse = res
+ .response
+ .parse_struct("Wellsfargo PaymentsAuthorizeResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ types::RouterData::try_from(types::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<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>
+ for Wellsfargo
+{
+ fn get_headers(
+ &self,
+ req: &types::PaymentsSyncRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::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: &types::PaymentsSyncRouterData,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn build_request(
+ &self,
+ req: &types::PaymentsSyncRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ Ok(Some(
+ services::RequestBuilder::new()
+ .method(services::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: &types::PaymentsSyncRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {
+ let response: wellsfargo::WellsfargoPaymentsResponse = res
+ .response
+ .parse_struct("wellsfargo PaymentsSyncResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ types::RouterData::try_from(types::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<api::Capture, types::PaymentsCaptureData, types::PaymentsResponseData>
+ for Wellsfargo
+{
+ fn get_headers(
+ &self,
+ req: &types::PaymentsCaptureRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::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: &types::PaymentsCaptureRouterData,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn get_request_body(
+ &self,
+ _req: &types::PaymentsCaptureRouterData,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
+ }
+
+ fn build_request(
+ &self,
+ req: &types::PaymentsCaptureRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ Ok(Some(
+ services::RequestBuilder::new()
+ .method(services::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: &types::PaymentsCaptureRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<types::PaymentsCaptureRouterData, errors::ConnectorError> {
+ let response: wellsfargo::WellsfargoPaymentsResponse = res
+ .response
+ .parse_struct("Wellsfargo PaymentsCaptureResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ types::RouterData::try_from(types::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<api::Void, types::PaymentsCancelData, types::PaymentsResponseData>
+ for Wellsfargo
+{
+}
+
+impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponseData>
+ for Wellsfargo
+{
+ fn get_headers(
+ &self,
+ req: &types::RefundsRouterData<api::Execute>,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::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: &types::RefundsRouterData<api::Execute>,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn get_request_body(
+ &self,
+ req: &types::RefundsRouterData<api::Execute>,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let refund_amount = connector_utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_refund_amount,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = wellsfargo::WellsfargoRouterData::from((refund_amount, req));
+ let connector_req = wellsfargo::WellsfargoRefundRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &types::RefundsRouterData<api::Execute>,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ let request = services::RequestBuilder::new()
+ .method(services::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: &types::RefundsRouterData<api::Execute>,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<types::RefundsRouterData<api::Execute>, errors::ConnectorError> {
+ let response: wellsfargo::RefundResponse = res
+ .response
+ .parse_struct("wellsfargo RefundResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ types::RouterData::try_from(types::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<api::RSync, types::RefundsData, types::RefundsResponseData>
+ for Wellsfargo
+{
+ fn get_headers(
+ &self,
+ req: &types::RefundSyncRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::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: &types::RefundSyncRouterData,
+ _connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ }
+
+ fn build_request(
+ &self,
+ req: &types::RefundSyncRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ Ok(Some(
+ services::RequestBuilder::new()
+ .method(services::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: &types::RefundSyncRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<types::RefundSyncRouterData, errors::ConnectorError> {
+ let response: wellsfargo::RefundResponse = res
+ .response
+ .parse_struct("wellsfargo RefundSyncResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ types::RouterData::try_from(types::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 api::IncomingWebhook for Wellsfargo {
+ fn get_webhook_object_reference_id(
+ &self,
+ _request: &api::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<api::webhooks::ObjectReferenceId, errors::ConnectorError> {
+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ }
+
+ fn get_webhook_event_type(
+ &self,
+ _request: &api::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<api::IncomingWebhookEvent, errors::ConnectorError> {
+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ }
+
+ fn get_webhook_resource_object(
+ &self,
+ _request: &api::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ }
+}
diff --git a/crates/router/src/connector/wellsfargo/transformers.rs b/crates/router/src/connector/wellsfargo/transformers.rs
new file mode 100644
index 0000000000..d0a1bb4140
--- /dev/null
+++ b/crates/router/src/connector/wellsfargo/transformers.rs
@@ -0,0 +1,234 @@
+use common_utils::types::StringMinorUnit;
+use masking::Secret;
+use serde::{Deserialize, Serialize};
+
+use crate::{
+ connector::utils::PaymentsAuthorizeRequestData,
+ core::errors,
+ types::{self, api, domain, storage::enums},
+};
+
+//TODO: Fill the struct with respective fields
+pub struct WellsfargoRouterData<T> {
+ pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
+ pub router_data: T,
+}
+
+impl<T> From<(StringMinorUnit, T)> for WellsfargoRouterData<T> {
+ fn from((amount, item): (StringMinorUnit, T)) -> Self {
+ //Todo : use utils to convert the amount to the type of amount that a connector accepts
+ Self {
+ amount,
+ router_data: item,
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Serialize, PartialEq)]
+pub struct WellsfargoPaymentsRequest {
+ amount: StringMinorUnit,
+ card: WellsfargoCard,
+}
+
+#[derive(Default, Debug, Serialize, Eq, PartialEq)]
+pub struct WellsfargoCard {
+ number: cards::CardNumber,
+ expiry_month: Secret<String>,
+ expiry_year: Secret<String>,
+ cvc: Secret<String>,
+ complete: bool,
+}
+
+impl TryFrom<&WellsfargoRouterData<&types::PaymentsAuthorizeRouterData>>
+ for WellsfargoPaymentsRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &WellsfargoRouterData<&types::PaymentsAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ match item.router_data.request.payment_method_data.clone() {
+ domain::PaymentMethodData::Card(req_card) => {
+ let card = WellsfargoCard {
+ 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 methods".to_string()).into()),
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+// Auth Struct
+pub struct WellsfargoAuthType {
+ pub(super) api_key: Secret<String>,
+}
+
+impl TryFrom<&types::ConnectorAuthType> for WellsfargoAuthType {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
+ match auth_type {
+ types::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 WellsfargoPaymentStatus {
+ Succeeded,
+ Failed,
+ #[default]
+ Processing,
+}
+
+impl From<WellsfargoPaymentStatus> for enums::AttemptStatus {
+ fn from(item: WellsfargoPaymentStatus) -> Self {
+ match item {
+ WellsfargoPaymentStatus::Succeeded => Self::Charged,
+ WellsfargoPaymentStatus::Failed => Self::Failure,
+ WellsfargoPaymentStatus::Processing => Self::Authorizing,
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct WellsfargoPaymentsResponse {
+ status: WellsfargoPaymentStatus,
+ id: String,
+}
+
+impl<F, T>
+ TryFrom<
+ types::ResponseRouterData<F, WellsfargoPaymentsResponse, T, types::PaymentsResponseData>,
+ > for types::RouterData<F, T, types::PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: types::ResponseRouterData<
+ F,
+ WellsfargoPaymentsResponse,
+ T,
+ types::PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ status: enums::AttemptStatus::from(item.response.status),
+ response: Ok(types::PaymentsResponseData::TransactionResponse {
+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
+ redirection_data: None,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ }),
+ ..item.data
+ })
+ }
+}
+
+//TODO: Fill the struct with respective fields
+// REFUND :
+// Type definition for RefundRequest
+#[derive(Default, Debug, Serialize)]
+pub struct WellsfargoRefundRequest {
+ pub amount: StringMinorUnit,
+}
+
+impl<F> TryFrom<&WellsfargoRouterData<&types::RefundsRouterData<F>>> for WellsfargoRefundRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &WellsfargoRouterData<&types::RefundsRouterData<F>>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ amount: item.amount.to_owned(),
+ })
+ }
+}
+
+// Type definition for Refund Response
+
+#[allow(dead_code)]
+#[derive(Debug, Serialize, Default, Deserialize, Clone)]
+pub enum RefundStatus {
+ Succeeded,
+ Failed,
+ #[default]
+ Processing,
+}
+
+impl From<RefundStatus> for enums::RefundStatus {
+ fn from(item: RefundStatus) -> Self {
+ match item {
+ RefundStatus::Succeeded => Self::Success,
+ RefundStatus::Failed => Self::Failure,
+ RefundStatus::Processing => Self::Pending,
+ //TODO: Review mapping
+ }
+ }
+}
+
+//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+pub struct RefundResponse {
+ id: String,
+ status: RefundStatus,
+}
+
+impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
+ for types::RefundsRouterData<api::Execute>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: types::RefundsResponseRouterData<api::Execute, RefundResponse>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(types::RefundsResponseData {
+ connector_refund_id: item.response.id.to_string(),
+ refund_status: enums::RefundStatus::from(item.response.status),
+ }),
+ ..item.data
+ })
+ }
+}
+
+impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>
+ for types::RefundsRouterData<api::RSync>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: types::RefundsResponseRouterData<api::RSync, RefundResponse>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(types::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 WellsfargoErrorResponse {
+ pub status_code: u16,
+ pub code: String,
+ pub message: String,
+ pub reason: Option<String>,
+}
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 607c478eb4..ca73a07de3 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -2639,6 +2639,10 @@ pub(crate) fn validate_auth_and_metadata_type_with_connector(
volt::transformers::VoltAuthType::try_from(val)?;
Ok(())
}
+ // api_enums::Connector::Wellsfargo => {
+ // wellsfargo::transformers::WellsfargoAuthType::try_from(val)?;
+ // Ok(())
+ // }
api_enums::Connector::Wise => {
wise::transformers::WiseAuthType::try_from(val)?;
Ok(())
diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs
index 277326889d..e86f94dc25 100644
--- a/crates/router/src/core/payments/connector_integration_v2_impls.rs
+++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs
@@ -695,6 +695,7 @@ default_imp_for_new_connector_integration_payment!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -781,6 +782,7 @@ default_imp_for_new_connector_integration_refund!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -862,6 +864,7 @@ default_imp_for_new_connector_integration_connector_access_token!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -965,6 +968,7 @@ default_imp_for_new_connector_integration_accept_dispute!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1050,6 +1054,7 @@ default_imp_for_new_connector_integration_defend_dispute!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1119,6 +1124,7 @@ default_imp_for_new_connector_integration_submit_evidence!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1215,6 +1221,7 @@ default_imp_for_new_connector_integration_file_upload!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1293,6 +1300,7 @@ default_imp_for_new_connector_integration_payouts!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1381,6 +1389,7 @@ default_imp_for_new_connector_integration_payouts_create!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1469,6 +1478,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1557,6 +1567,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1645,6 +1656,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1733,6 +1745,7 @@ default_imp_for_new_connector_integration_payouts_quote!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1821,6 +1834,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1909,6 +1923,7 @@ default_imp_for_new_connector_integration_payouts_sync!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1997,6 +2012,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2083,6 +2099,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2161,6 +2178,7 @@ default_imp_for_new_connector_integration_frm!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2249,6 +2267,7 @@ default_imp_for_new_connector_integration_frm_sale!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2337,6 +2356,7 @@ default_imp_for_new_connector_integration_frm_checkout!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2425,6 +2445,7 @@ default_imp_for_new_connector_integration_frm_transaction!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2513,6 +2534,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2601,6 +2623,7 @@ default_imp_for_new_connector_integration_frm_record_return!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2686,6 +2709,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2799,6 +2823,7 @@ default_imp_for_new_connector_integration_connector_authentication!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index a53888414a..3e9d18d117 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -233,6 +233,7 @@ default_imp_for_complete_authorize!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -327,6 +328,7 @@ default_imp_for_webhook_source_verification!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -421,6 +423,7 @@ default_imp_for_create_customer!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -505,6 +508,7 @@ default_imp_for_connector_redirect_response!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -584,6 +588,7 @@ default_imp_for_connector_request_id!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -682,6 +687,7 @@ default_imp_for_accept_dispute!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -799,6 +805,7 @@ default_imp_for_file_upload!(
connector::Tsys,
connector::Volt,
connector::Opennode,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -894,6 +901,7 @@ default_imp_for_submit_evidence!(
connector::Tsys,
connector::Volt,
connector::Opennode,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -990,6 +998,7 @@ default_imp_for_defend_dispute!(
connector::Tsys,
connector::Volt,
connector::Opennode,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1091,6 +1100,7 @@ default_imp_for_pre_processing_steps!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1171,6 +1181,7 @@ default_imp_for_post_processing_steps!(
connector::Threedsecureio,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1246,6 +1257,7 @@ default_imp_for_payouts!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Worldline,
connector::Worldpay,
connector::Zen,
@@ -1339,6 +1351,7 @@ default_imp_for_payouts_create!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Worldline,
connector::Worldpay,
connector::Zen,
@@ -1435,6 +1448,7 @@ default_imp_for_payouts_retrieve!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -1534,6 +1548,7 @@ default_imp_for_payouts_eligibility!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Worldline,
connector::Worldpay,
connector::Zen,
@@ -1624,6 +1639,7 @@ default_imp_for_payouts_fulfill!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Worldline,
connector::Worldpay,
connector::Zen,
@@ -1718,6 +1734,7 @@ default_imp_for_payouts_cancel!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Worldline,
connector::Worldpay,
connector::Zen,
@@ -1814,6 +1831,7 @@ default_imp_for_payouts_quote!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Worldline,
connector::Worldpay,
connector::Zen,
@@ -1909,6 +1927,7 @@ default_imp_for_payouts_recipient!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Worldline,
connector::Worldpay,
connector::Zen,
@@ -2008,6 +2027,7 @@ default_imp_for_payouts_recipient_account!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2105,6 +2125,7 @@ default_imp_for_approve!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2202,6 +2223,7 @@ default_imp_for_reject!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2281,6 +2303,7 @@ default_imp_for_fraud_check!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2378,6 +2401,7 @@ default_imp_for_frm_sale!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2475,6 +2499,7 @@ default_imp_for_frm_checkout!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2572,6 +2597,7 @@ default_imp_for_frm_transaction!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2669,6 +2695,7 @@ default_imp_for_frm_fulfillment!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2766,6 +2793,7 @@ default_imp_for_frm_record_return!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2862,6 +2890,7 @@ default_imp_for_incremental_authorization!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -2955,6 +2984,7 @@ default_imp_for_revoking_mandates!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -3108,6 +3138,7 @@ default_imp_for_connector_authentication!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
@@ -3200,6 +3231,7 @@ default_imp_for_authorize_session_token!(
connector::Trustpay,
connector::Tsys,
connector::Volt,
+ connector::Wellsfargo,
connector::Wise,
connector::Worldline,
connector::Worldpay,
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 727fe158fd..b2858b23d5 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -501,6 +501,9 @@ impl ConnectorData {
}
enums::Connector::Tsys => Ok(ConnectorEnum::Old(Box::new(&connector::Tsys))),
enums::Connector::Volt => Ok(ConnectorEnum::Old(Box::new(connector::Volt::new()))),
+ // enums::Connector::Wellsfargo => {
+ // Ok(ConnectorEnum::Old(Box::new(connector::Wellsfargo::new())))
+ // }
enums::Connector::Zen => Ok(ConnectorEnum::Old(Box::new(&connector::Zen))),
enums::Connector::Zsl => Ok(ConnectorEnum::Old(Box::new(&connector::Zsl))),
enums::Connector::Plaid => {
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 64ad3aff03..4805356d3e 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -297,6 +297,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
api_enums::Connector::Trustpay => Self::Trustpay,
api_enums::Connector::Tsys => Self::Tsys,
api_enums::Connector::Volt => Self::Volt,
+ // api_enums::Connector::Wellsfargo => Self::Wellsfargo,
api_enums::Connector::Wise => Self::Wise,
api_enums::Connector::Worldline => Self::Worldline,
api_enums::Connector::Worldpay => Self::Worldpay,
diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs
index 2b8d011cb7..bbf2077f0c 100644
--- a/crates/router/tests/connectors/main.rs
+++ b/crates/router/tests/connectors/main.rs
@@ -71,6 +71,7 @@ mod trustpay;
mod tsys;
mod utils;
mod volt;
+mod wellsfargo;
#[cfg(feature = "payouts")]
mod wise;
mod worldline;
diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.toml
index a39b799b82..0df5cc09b0 100644
--- a/crates/router/tests/connectors/sample_auth.toml
+++ b/crates/router/tests/connectors/sample_auth.toml
@@ -248,4 +248,9 @@ api_secret = "Razorpay Id"
key2 = "Razorpay Secret"
[itaubank]
-api_key="API Key"
\ No newline at end of file
+api_key="API Key"
+
+[wellsfargo]
+api_key = "MyApiKey"
+key1 = "Merchant id"
+api_secret = "Secret key"
\ No newline at end of file
diff --git a/crates/router/tests/connectors/wellsfargo.rs b/crates/router/tests/connectors/wellsfargo.rs
new file mode 100644
index 0000000000..300a5fbb37
--- /dev/null
+++ b/crates/router/tests/connectors/wellsfargo.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 WellsfargoTest;
+impl ConnectorActions for WellsfargoTest {}
+impl utils::Connector for WellsfargoTest {
+ fn get_data(&self) -> api::ConnectorData {
+ use router::connector::Wellsfargo;
+ utils::construct_connector_data_old(
+ Box::new(Wellsfargo::new()),
+ types::Connector::Plaid,
+ api::GetToken::Connector,
+ None,
+ )
+ }
+
+ fn get_auth_token(&self) -> types::ConnectorAuthType {
+ utils::to_connector_auth_type(
+ connector_auth::ConnectorAuthentication::new()
+ .wellsfargo
+ .expect("Missing connector authentication configuration")
+ .into(),
+ )
+ }
+
+ fn get_name(&self) -> String {
+ "wellsfargo".to_string()
+ }
+}
+
+static CONNECTOR: WellsfargoTest = WellsfargoTest {};
+
+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: 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/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs
index b190c00981..13d7da931f 100644
--- a/crates/test_utils/src/connector_auth.rs
+++ b/crates/test_utils/src/connector_auth.rs
@@ -75,6 +75,7 @@ pub struct ConnectorAuthentication {
pub trustpay: Option<SignatureKey>,
pub tsys: Option<SignatureKey>,
pub volt: Option<HeaderKey>,
+ pub wellsfargo: Option<HeaderKey>,
pub wise: Option<BodyKey>,
pub worldpay: Option<BodyKey>,
pub worldline: Option<SignatureKey>,
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index a1fe73bc43..f080fd550d 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -145,6 +145,7 @@ trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/"
tsys.base_url = "https://stagegw.transnox.com/"
volt.base_url = "https://api.sandbox.volt.io/"
+wellsfargo.base_url = "https://apitest.cybersource.com/"
worldline.base_url = "https://eu.sandbox.api-ingenico.com/"
worldpay.base_url = "https://try.access.worldpay.com/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
@@ -216,6 +217,7 @@ cards = [
"trustpay",
"tsys",
"volt",
+ "wellsfargo",
"wise",
"worldline",
"worldpay",
diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh
index 4590346192..62a6140fcc 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 applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans dlocal dummyconnector ebanx fiserv forte globalpay globepay gocardless gpayments helcim iatapay itaubank klarna mifinity mollie multisafepay netcetera nexinets noon nuvei opayo opennode payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe threedsecureio trustpay tsys volt wise worldline worldpay zsl "$1")
+ connectors=(aci adyen adyenplatform airwallex applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans dlocal dummyconnector ebanx fiserv forte globalpay globepay gocardless gpayments helcim iatapay itaubank klarna mifinity mollie multisafepay netcetera nexinets noon nuvei opayo opennode payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe threedsecureio trustpay tsys volt wellsfargo wise worldline worldpay zsl "$1")
IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS
res=`echo ${sorted[@]}`
sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp