From e9f5d414ba805c7faa4c66e17976d6301dfc8b6a Mon Sep 17 00:00:00 2001 From: sumanmaji4 Date: Mon, 21 Oct 2024 18:30:20 +0530 Subject: [PATCH 1/3] nomupay_payouts_template --- api-reference-v2/openapi_spec.json | 3 +- api-reference/openapi_spec.json | 1 + config/config.example.toml | 1 + config/deployments/integration_test.toml | 1 + config/deployments/production.toml | 1 + config/deployments/sandbox.toml | 1 + config/development.toml | 2 + config/docker_compose.toml | 2 + crates/api_models/src/connector_enums.rs | 2 + crates/common_enums/src/connector_enums.rs | 1 + .../hyperswitch_connectors/src/connectors.rs | 7 +- .../src/connectors/nomupay.rs | 563 ++++++++++++++++++ .../src/connectors/nomupay/transformers.rs | 228 +++++++ .../src/default_implementations.rs | 31 + .../src/default_implementations_v2.rs | 22 + crates/hyperswitch_interfaces/src/configs.rs | 1 + crates/router/src/connector.rs | 11 +- .../connector_integration_v2_impls.rs | 3 + crates/router/src/core/payments/flows.rs | 4 + crates/router/src/types/api.rs | 1 + crates/router/src/types/transformers.rs | 1 + crates/router/tests/connectors/main.rs | 1 + crates/router/tests/connectors/nomupay.rs | 427 +++++++++++++ .../router/tests/connectors/sample_auth.toml | 3 + crates/test_utils/src/connector_auth.rs | 1 + loadtest/config/development.toml | 2 + scripts/add_connector.sh | 2 +- 27 files changed, 1313 insertions(+), 10 deletions(-) create mode 100644 crates/hyperswitch_connectors/src/connectors/nomupay.rs create mode 100644 crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs create mode 100644 crates/router/tests/connectors/nomupay.rs diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 84562b99343d..bcb5fc0635fa 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -17814,6 +17814,7 @@ "nexinets", "nexixpay", "nmi", + "nomupay", "noon", "novalnet", "nuvei", @@ -17962,7 +17963,7 @@ "profile_id" ], "properties": { - "name": { + "name": { "type": "string" }, "description": { diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 733ba96237c4..57661c38f601 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -22504,6 +22504,7 @@ "nexinets", "nexixpay", "nmi", + "nomupay", "noon", "novalnet", "nuvei", diff --git a/config/config.example.toml b/config/config.example.toml index ea458238ebe8..815687b81113 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -231,6 +231,7 @@ netcetera.base_url = "https://{{merchant_endpoint_prefix}}.3ds-server.prev.netce nexinets.base_url = "https://apitest.payengine.de/v1" nexixpay.base_url = "https://xpaysandbox.nexigroup.com/api/phoenix-0.0/psp/api/v1" nmi.base_url = "https://secure.nmi.com/" +nomupay.base_url = "https://payout-api.sandbox.nomupay.com" noon.base_url = "https://api-test.noonpayments.com/" novalnet.base_url = "https://payport.novalnet.de/v2" noon.key_mode = "Test" diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 73444e966c6d..024f7373f5e2 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -72,6 +72,7 @@ multisafepay.base_url = "https://testapi.multisafepay.com/" nexinets.base_url = "https://apitest.payengine.de/v1" nexixpay.base_url = "https://xpaysandbox.nexigroup.com/api/phoenix-0.0/psp/api/v1" nmi.base_url = "https://secure.nmi.com/" +nomupay.base_url = "https://payout-api.sandbox.nomupay.com" noon.base_url = "https://api-test.noonpayments.com/" noon.key_mode = "Test" novalnet.base_url = "https://payport.novalnet.de/v2" diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 0a12f06f1a5d..3dd46e68509f 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -76,6 +76,7 @@ multisafepay.base_url = "https://testapi.multisafepay.com/" nexinets.base_url = "https://api.payengine.de/v1" nexixpay.base_url = "https://xpay.nexigroup.com/api/phoenix-0.0/psp/api/v1" nmi.base_url = "https://secure.nmi.com/" +nomupay.base_url = "https://payout-api.nomupay.com" noon.base_url = "https://api.noonpayments.com/" noon.key_mode = "Live" novalnet.base_url = "https://payport.novalnet.de/v2" diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index a110bd990185..88f215678d7e 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -76,6 +76,7 @@ multisafepay.base_url = "https://testapi.multisafepay.com/" nexinets.base_url = "https://apitest.payengine.de/v1" nexixpay.base_url = "https://xpaysandbox.nexigroup.com/api/phoenix-0.0/psp/api/v1" nmi.base_url = "https://secure.nmi.com/" +nomupay.base_url = "https://payout-api.sandbox.nomupay.com" noon.base_url = "https://api-test.noonpayments.com/" noon.key_mode = "Test" novalnet.base_url = "https://payport.novalnet.de/v2" diff --git a/config/development.toml b/config/development.toml index e52cf1dff1ae..8f3ffdbcbb59 100644 --- a/config/development.toml +++ b/config/development.toml @@ -138,6 +138,7 @@ cards = [ "nexinets", "nexixpay", "nmi", + "nomupay", "noon", "novalnet", "nuvei", @@ -244,6 +245,7 @@ netcetera.base_url = "https://{{merchant_endpoint_prefix}}.3ds-server.prev.netce nexinets.base_url = "https://apitest.payengine.de/v1" nexixpay.base_url = "https://xpaysandbox.nexigroup.com/api/phoenix-0.0/psp/api/v1" nmi.base_url = "https://secure.nmi.com/" +nomupay.base_url = "https://payout-api.sandbox.nomupay.com" noon.base_url = "https://api-test.noonpayments.com/" novalnet.base_url = "https://payport.novalnet.de/v2" noon.key_mode = "Test" diff --git a/config/docker_compose.toml b/config/docker_compose.toml index 65fc8ec67f5a..3b4c3fa49da0 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -161,6 +161,7 @@ netcetera.base_url = "https://{{merchant_endpoint_prefix}}.3ds-server.prev.netce nexinets.base_url = "https://apitest.payengine.de/v1" nexixpay.base_url = "https://xpaysandbox.nexigroup.com/api/phoenix-0.0/psp/api/v1" nmi.base_url = "https://secure.nmi.com/" +nomupay.base_url = "https://payout-api.sandbox.nomupay.com" noon.base_url = "https://api-test.noonpayments.com/" novalnet.base_url = "https://payport.novalnet.de/v2" noon.key_mode = "Test" @@ -255,6 +256,7 @@ cards = [ "nexinets", "nexixpay", "nmi", + "nomupay", "noon", "novalnet", "nuvei", diff --git a/crates/api_models/src/connector_enums.rs b/crates/api_models/src/connector_enums.rs index 14d477f077b5..b705d88df595 100644 --- a/crates/api_models/src/connector_enums.rs +++ b/crates/api_models/src/connector_enums.rs @@ -94,6 +94,7 @@ pub enum Connector { Nexinets, Nexixpay, Nmi, + // Nomupay, Noon, Novalnet, Nuvei, @@ -231,6 +232,7 @@ impl Connector { | Self::Multisafepay | Self::Nexinets | Self::Nexixpay + // | Self::Nomupay | Self::Novalnet | Self::Nuvei | Self::Opennode diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs index 8828050052f3..fe4b2c522904 100644 --- a/crates/common_enums/src/connector_enums.rs +++ b/crates/common_enums/src/connector_enums.rs @@ -89,6 +89,7 @@ pub enum RoutableConnectors { Nexinets, Nexixpay, Nmi, + // Nomupay, Noon, Novalnet, Nuvei, diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index b748eb1120aa..2bc824500964 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -21,6 +21,7 @@ pub mod mollie; pub mod multisafepay; pub mod nexinets; pub mod nexixpay; +pub mod nomupay; pub mod novalnet; pub mod payeezy; pub mod payu; @@ -44,8 +45,8 @@ pub use self::{ deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal, elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, globepay::Globepay, helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, multisafepay::Multisafepay, - nexinets::Nexinets, nexixpay::Nexixpay, novalnet::Novalnet, payeezy::Payeezy, payu::Payu, - powertranz::Powertranz, razorpay::Razorpay, shift4::Shift4, square::Square, stax::Stax, - taxjar::Taxjar, thunes::Thunes, tsys::Tsys, volt::Volt, worldline::Worldline, + nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, novalnet::Novalnet, payeezy::Payeezy, + payu::Payu, powertranz::Powertranz, razorpay::Razorpay, shift4::Shift4, square::Square, + stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys, volt::Volt, worldline::Worldline, worldpay::Worldpay, zen::Zen, zsl::Zsl, }; diff --git a/crates/hyperswitch_connectors/src/connectors/nomupay.rs b/crates/hyperswitch_connectors/src/connectors/nomupay.rs new file mode 100644 index 000000000000..a08bbddc527a --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/nomupay.rs @@ -0,0 +1,563 @@ +pub mod transformers; + +use common_utils::{ + errors::CustomResult, + ext_traits::BytesExt, + request::{Method, Request, RequestBuilder, RequestContent}, + types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector}, +}; +use error_stack::{report, ResultExt}; +use hyperswitch_domain_models::{ + router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, + router_flow_types::{ + access_token_auth::AccessTokenAuth, + payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void}, + refunds::{Execute, RSync}, + }, + router_request_types::{ + AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData, + PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, + RefundsData, SetupMandateRequestData, + }, + router_response_types::{PaymentsResponseData, RefundsResponseData}, + types::{ + PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, + RefundSyncRouterData, RefundsRouterData, + }, +}; +use hyperswitch_interfaces::{ + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + configs::Connectors, + errors, + events::connector_api_logs::ConnectorEvent, + types::{self, Response}, + webhooks, +}; +use masking::{ExposeInterface, Mask}; +use transformers as nomupay; + +use crate::{constants::headers, types::ResponseRouterData, utils}; + +#[derive(Clone)] +pub struct Nomupay { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Nomupay { + pub fn new() -> &'static Self { + &Self { + amount_converter: &StringMinorUnitForConnector, + } + } +} + +impl api::Payment for Nomupay {} +impl api::PaymentSession for Nomupay {} +impl api::ConnectorAccessToken for Nomupay {} +impl api::MandateSetup for Nomupay {} +impl api::PaymentAuthorize for Nomupay {} +impl api::PaymentSync for Nomupay {} +impl api::PaymentCapture for Nomupay {} +impl api::PaymentVoid for Nomupay {} +impl api::Refund for Nomupay {} +impl api::RefundExecute for Nomupay {} +impl api::RefundSync for Nomupay {} +impl api::PaymentToken for Nomupay {} + +impl ConnectorIntegration + for Nomupay +{ + // Not Implemented (R) +} + +impl ConnectorCommonExt for Nomupay +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 Nomupay { + fn id(&self) -> &'static str { + "nomupay" + } + + fn get_currency_unit(&self) -> api::CurrencyUnit { + api::CurrencyUnit::Base + // TODO! Check connector documentation, on which unit they are processing the currency. + // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor, + // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base + } + + fn common_get_content_type(&self) -> &'static str { + "application/json" + } + + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { + connectors.nomupay.base_url.as_ref() + } + + fn get_auth_header( + &self, + auth_type: &ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { + let auth = nomupay::NomupayAuthType::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: nomupay::NomupayErrorResponse = res + .response + .parse_struct("NomupayErrorResponse") + .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 Nomupay { + //TODO: implement functions when support enabled +} + +impl ConnectorIntegration for Nomupay { + //TODO: implement sessions flow +} + +impl ConnectorIntegration for Nomupay {} + +impl ConnectorIntegration for Nomupay {} + +impl ConnectorIntegration for Nomupay { + 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 = nomupay::NomupayRouterData::from((amount, req)); + let connector_req = nomupay::NomupayPaymentsRequest::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: nomupay::NomupayPaymentsResponse = res + .response + .parse_struct("Nomupay 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 Nomupay { + 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: nomupay::NomupayPaymentsResponse = res + .response + .parse_struct("nomupay 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 Nomupay { + 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: nomupay::NomupayPaymentsResponse = res + .response + .parse_struct("Nomupay 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 Nomupay {} + +impl ConnectorIntegration for Nomupay { + 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 = nomupay::NomupayRouterData::from((refund_amount, req)); + let connector_req = nomupay::NomupayRefundRequest::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: nomupay::RefundResponse = res + .response + .parse_struct("nomupay 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 Nomupay { + 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: nomupay::RefundResponse = res + .response + .parse_struct("nomupay 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 Nomupay { + 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)) + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs new file mode 100644 index 000000000000..bea8b607daea --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs @@ -0,0 +1,228 @@ +use common_enums::enums; +use common_utils::types::StringMinorUnit; +use hyperswitch_domain_models::{ + payment_method_data::PaymentMethodData, + router_data::{ConnectorAuthType, RouterData}, + router_flow_types::refunds::{Execute, RSync}, + router_request_types::ResponseId, + router_response_types::{PaymentsResponseData, RefundsResponseData}, + types::{PaymentsAuthorizeRouterData, RefundsRouterData}, +}; +use hyperswitch_interfaces::errors; +use masking::Secret; +use serde::{Deserialize, Serialize}; + +use crate::{ + types::{RefundsResponseRouterData, ResponseRouterData}, + utils::PaymentsAuthorizeRequestData, +}; + +//TODO: Fill the struct with respective fields +pub struct NomupayRouterData { + pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc. + pub router_data: T, +} + +impl From<(StringMinorUnit, T)> for NomupayRouterData { + 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 NomupayPaymentsRequest { + amount: StringMinorUnit, + card: NomupayCard, +} + +#[derive(Default, Debug, Serialize, Eq, PartialEq)] +pub struct NomupayCard { + number: cards::CardNumber, + expiry_month: Secret, + expiry_year: Secret, + cvc: Secret, + complete: bool, +} + +impl TryFrom<&NomupayRouterData<&PaymentsAuthorizeRouterData>> for NomupayPaymentsRequest { + type Error = error_stack::Report; + fn try_from( + item: &NomupayRouterData<&PaymentsAuthorizeRouterData>, + ) -> Result { + match item.router_data.request.payment_method_data.clone() { + PaymentMethodData::Card(req_card) => { + let card = NomupayCard { + 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 NomupayAuthType { + pub(super) api_key: Secret, +} + +impl TryFrom<&ConnectorAuthType> for NomupayAuthType { + 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 NomupayPaymentStatus { + Succeeded, + Failed, + #[default] + Processing, +} + +impl From for common_enums::AttemptStatus { + fn from(item: NomupayPaymentStatus) -> Self { + match item { + NomupayPaymentStatus::Succeeded => Self::Charged, + NomupayPaymentStatus::Failed => Self::Failure, + NomupayPaymentStatus::Processing => Self::Authorizing, + } + } +} + +//TODO: Fill the struct with respective fields +#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct NomupayPaymentsResponse { + status: NomupayPaymentStatus, + 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, + charge_id: None, + }), + ..item.data + }) + } +} + +//TODO: Fill the struct with respective fields +// REFUND : +// Type definition for RefundRequest +#[derive(Default, Debug, Serialize)] +pub struct NomupayRefundRequest { + pub amount: StringMinorUnit, +} + +impl TryFrom<&NomupayRouterData<&RefundsRouterData>> for NomupayRefundRequest { + type Error = error_stack::Report; + fn try_from(item: &NomupayRouterData<&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 NomupayErrorResponse { + 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 0662b9d8ae2d..418d58eb54ba 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -108,6 +108,7 @@ default_imp_for_authorize_session_token!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -167,6 +168,7 @@ default_imp_for_calculate_tax!( connectors::Multisafepay, connectors::Nexinets, connectors::Nexixpay, + connectors::Nomupay, connectors::Novalnet, connectors::Payeezy, connectors::Payu, @@ -222,6 +224,7 @@ default_imp_for_session_update!( connectors::Taxjar, connectors::Mollie, connectors::Multisafepay, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -278,6 +281,7 @@ default_imp_for_post_session_tokens!( connectors::Taxjar, connectors::Mollie, connectors::Multisafepay, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -330,6 +334,7 @@ default_imp_for_complete_authorize!( connectors::Helcim, connectors::Jpmorgan, connectors::Multisafepay, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Payeezy, @@ -381,6 +386,7 @@ default_imp_for_incremental_authorization!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -440,6 +446,7 @@ default_imp_for_create_customer!( connectors::Jpmorgan, connectors::Mollie, connectors::Multisafepay, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -497,6 +504,7 @@ default_imp_for_connector_redirect_response!( connectors::Multisafepay, connectors::Nexinets, connectors::Nexixpay, + connectors::Nomupay, connectors::Payeezy, connectors::Payu, connectors::Powertranz, @@ -546,6 +554,7 @@ default_imp_for_pre_processing_steps!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Payeezy, @@ -601,6 +610,7 @@ default_imp_for_post_processing_steps!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -658,6 +668,7 @@ default_imp_for_approve!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -715,6 +726,7 @@ default_imp_for_reject!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -772,6 +784,7 @@ default_imp_for_webhook_source_verification!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -830,6 +843,7 @@ default_imp_for_accept_dispute!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -887,6 +901,7 @@ default_imp_for_submit_evidence!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -944,6 +959,7 @@ default_imp_for_defend_dispute!( connectors::Globepay, connectors::Jpmorgan, connectors::Helcim, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1010,6 +1026,7 @@ default_imp_for_file_upload!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1069,6 +1086,7 @@ default_imp_for_payouts_create!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1128,6 +1146,7 @@ default_imp_for_payouts_retrieve!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1187,6 +1206,7 @@ default_imp_for_payouts_eligibility!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1246,6 +1266,7 @@ default_imp_for_payouts_fulfill!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1305,6 +1326,7 @@ default_imp_for_payouts_cancel!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1364,6 +1386,7 @@ default_imp_for_payouts_quote!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1423,6 +1446,7 @@ default_imp_for_payouts_recipient!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1482,6 +1506,7 @@ default_imp_for_payouts_recipient_account!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1541,6 +1566,7 @@ default_imp_for_frm_sale!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1600,6 +1626,7 @@ default_imp_for_frm_checkout!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1659,6 +1686,7 @@ default_imp_for_frm_transaction!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1718,6 +1746,7 @@ default_imp_for_frm_fulfillment!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1777,6 +1806,7 @@ default_imp_for_frm_record_return!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1833,6 +1863,7 @@ default_imp_for_revoking_mandates!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index b338c72ded0e..d747d65d73a1 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -224,6 +224,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -282,6 +283,7 @@ default_imp_for_new_connector_integration_refund!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -335,6 +337,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -394,6 +397,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -452,6 +456,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -510,6 +515,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -578,6 +584,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -638,6 +645,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -698,6 +706,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -758,6 +767,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -818,6 +828,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -878,6 +889,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -938,6 +950,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -998,6 +1011,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1058,6 +1072,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1116,6 +1131,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1176,6 +1192,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1236,6 +1253,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1296,6 +1314,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1356,6 +1375,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1416,6 +1436,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, @@ -1473,6 +1494,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Globepay, connectors::Helcim, connectors::Jpmorgan, + connectors::Nomupay, connectors::Novalnet, connectors::Nexinets, connectors::Nexixpay, diff --git a/crates/hyperswitch_interfaces/src/configs.rs b/crates/hyperswitch_interfaces/src/configs.rs index 0ac433e53dbd..58810a0cb347 100644 --- a/crates/hyperswitch_interfaces/src/configs.rs +++ b/crates/hyperswitch_interfaces/src/configs.rs @@ -57,6 +57,7 @@ pub struct Connectors { pub nexinets: ConnectorParams, pub nexixpay: ConnectorParams, pub nmi: ConnectorParams, + pub nomupay: ConnectorParams, pub noon: ConnectorParamsWithModeType, pub novalnet: ConnectorParams, pub nuvei: ConnectorParams, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index b240899c54bc..7913d6543c85 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -52,11 +52,12 @@ pub use hyperswitch_connectors::connectors::{ elavon, elavon::Elavon, fiserv, fiserv::Fiserv, fiservemea, fiservemea::Fiservemea, fiuu, fiuu::Fiuu, forte, forte::Forte, globepay, globepay::Globepay, helcim, helcim::Helcim, jpmorgan, jpmorgan::Jpmorgan, mollie, mollie::Mollie, multisafepay, multisafepay::Multisafepay, - nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, novalnet, novalnet::Novalnet, - payeezy, payeezy::Payeezy, payu, payu::Payu, powertranz, powertranz::Powertranz, razorpay, - razorpay::Razorpay, shift4, shift4::Shift4, square, square::Square, stax, stax::Stax, taxjar, - taxjar::Taxjar, thunes, thunes::Thunes, tsys, tsys::Tsys, volt, volt::Volt, worldline, - worldline::Worldline, worldpay, worldpay::Worldpay, zen, zen::Zen, zsl, zsl::Zsl, + nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay, + novalnet, novalnet::Novalnet, payeezy, payeezy::Payeezy, payu, payu::Payu, powertranz, + powertranz::Powertranz, razorpay, razorpay::Razorpay, shift4, shift4::Shift4, square, + square::Square, stax, stax::Stax, taxjar, taxjar::Taxjar, thunes, thunes::Thunes, tsys, + tsys::Tsys, volt, volt::Volt, worldline, worldline::Worldline, worldpay, worldpay::Worldpay, + zen, zen::Zen, zsl, zsl::Zsl, }; #[cfg(feature = "dummy_connector")] 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 5d6915316331..94c531a09630 100644 --- a/crates/router/src/core/payments/connector_integration_v2_impls.rs +++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs @@ -1152,6 +1152,7 @@ default_imp_for_new_connector_integration_payouts!( connector::Nexinets, connector::Nexixpay, connector::Nmi, + connector::Nomupay, connector::Noon, connector::Novalnet, connector::Nuvei, @@ -1798,6 +1799,7 @@ default_imp_for_new_connector_integration_frm!( connector::Nexinets, connector::Nexixpay, connector::Nmi, + connector::Nomupay, connector::Noon, connector::Novalnet, connector::Nuvei, @@ -2292,6 +2294,7 @@ default_imp_for_new_connector_integration_connector_authentication!( connector::Nexinets, connector::Nexixpay, connector::Nmi, + connector::Nomupay, connector::Noon, connector::Novalnet, connector::Nuvei, diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 3fed81a890f7..e0023b8d1391 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -491,6 +491,7 @@ default_imp_for_connector_request_id!( connector::Netcetera, connector::Nexixpay, connector::Nmi, + connector::Nomupay, connector::Noon, connector::Novalnet, connector::Nuvei, @@ -1018,6 +1019,7 @@ default_imp_for_payouts!( connector::Nexinets, connector::Nexixpay, connector::Nmi, + connector::Nomupay, connector::Noon, connector::Novalnet, connector::Nuvei, @@ -1815,6 +1817,7 @@ default_imp_for_fraud_check!( connector::Nexinets, connector::Nexixpay, connector::Nmi, + connector::Nomupay, connector::Noon, connector::Novalnet, connector::Nuvei, @@ -2476,6 +2479,7 @@ default_imp_for_connector_authentication!( connector::Nexinets, connector::Nexixpay, connector::Nmi, + connector::Nomupay, connector::Noon, connector::Novalnet, connector::Nuvei, diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 6db9d29daabd..45036c13a930 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -445,6 +445,7 @@ impl ConnectorData { Ok(ConnectorEnum::Old(Box::new(connector::Nexixpay::new()))) } enums::Connector::Nmi => Ok(ConnectorEnum::Old(Box::new(connector::Nmi::new()))), + // enums::Connector::Nomupay => Ok(ConnectorEnum::Old(Box::new(connector::Nomupay))), enums::Connector::Noon => Ok(ConnectorEnum::Old(Box::new(connector::Noon::new()))), enums::Connector::Novalnet => { Ok(ConnectorEnum::Old(Box::new(connector::Novalnet::new()))) diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 2507fa6170aa..a7e951c53f73 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -295,6 +295,7 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Nexinets => Self::Nexinets, api_enums::Connector::Nexixpay => Self::Nexixpay, api_enums::Connector::Nmi => Self::Nmi, + // api_enums::Connector::Nomupay => Self::Nomupay, api_enums::Connector::Noon => Self::Noon, api_enums::Connector::Novalnet => Self::Novalnet, api_enums::Connector::Nuvei => Self::Nuvei, diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs index 19e3971cbb9e..9bb079b7a168 100644 --- a/crates/router/tests/connectors/main.rs +++ b/crates/router/tests/connectors/main.rs @@ -52,6 +52,7 @@ mod netcetera; mod nexinets; mod nexixpay; mod nmi; +mod nomupay; mod noon; mod novalnet; mod nuvei; diff --git a/crates/router/tests/connectors/nomupay.rs b/crates/router/tests/connectors/nomupay.rs new file mode 100644 index 000000000000..fd5face6577a --- /dev/null +++ b/crates/router/tests/connectors/nomupay.rs @@ -0,0 +1,427 @@ +use hyperswitch_domain_models::payment_method_data::{Card, PaymentMethodData}; +use masking::Secret; +use router::types::{self, api, storage::enums}; +use test_utils::connector_auth; + +use crate::utils::{self, ConnectorActions}; + +#[derive(Clone, Copy)] +struct NomupayTest; +impl ConnectorActions for NomupayTest {} +impl utils::Connector for NomupayTest { + fn get_data(&self) -> api::ConnectorData { + use router::connector::Nomupay; + utils::construct_connector_data_old( + Box::new(Nomupay::new()), + types::Connector::Plaid, + api::GetToken::Connector, + None, + ) + // api::ConnectorData { + // connector: Box::new(Nomupay::new()), + // connector_name: types::Connector::Nomupay, + // get_token: types::api::GetToken::Connector, + // merchant_connector_id: None, + // } + } + + fn get_auth_token(&self) -> types::ConnectorAuthType { + utils::to_connector_auth_type( + connector_auth::ConnectorAuthentication::new() + .nomupay + .expect("Missing connector authentication configuration") + .into(), + ) + } + + fn get_name(&self) -> String { + "nomupay".to_string() + } +} + +static CONNECTOR: NomupayTest = NomupayTest {}; + +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: PaymentMethodData::Card(Card { + card_cvc: Secret::new("12345".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's security code is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry month. +#[actix_web::test] +async fn should_fail_payment_for_invalid_exp_month() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: PaymentMethodData::Card(Card { + card_exp_month: Secret::new("20".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration month is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry year. +#[actix_web::test] +async fn should_fail_payment_for_incorrect_expiry_year() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: PaymentMethodData::Card(Card { + card_exp_year: Secret::new("2000".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration year is invalid.".to_string(), + ); +} + +// Voids a payment using automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_fail_void_payment_for_auto_capture() { + let authorize_response = CONNECTOR + .make_payment(payment_method_details(), get_default_payment_info()) + .await + .unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + assert_ne!(txn_id, None, "Empty connector transaction id"); + let void_response = CONNECTOR + .void_payment(txn_id.unwrap(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + void_response.response.unwrap_err().message, + "You cannot cancel this PaymentIntent because it has a status of succeeded." + ); +} + +// Captures a payment using invalid connector payment id. +#[actix_web::test] +async fn should_fail_capture_for_invalid_payment() { + let capture_response = CONNECTOR + .capture_payment("123456789".to_string(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + capture_response.response.unwrap_err().message, + String::from("No such payment_intent: '123456789'") + ); +} + +// Refunds a payment with refund amount higher than payment amount. +#[actix_web::test] +async fn should_fail_for_refund_amount_higher_than_payment_amount() { + let response = CONNECTOR + .make_payment_and_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 150, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Refund amount (₹1.50) is greater than charge amount (₹1.00)", + ); +} + +// Connector dependent test cases goes here + +// [#478]: add unit tests for non 3DS, wallets & webhooks in connector tests diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.toml index f36436b6ccb3..d2eec724597b 100644 --- a/crates/router/tests/connectors/sample_auth.toml +++ b/crates/router/tests/connectors/sample_auth.toml @@ -291,4 +291,7 @@ api_key="API Key" api_key="API Key" [elavon] +api_key="API Key" + +[nomupay] api_key="API Key" \ 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 d23560300f34..be02e5720fb6 100644 --- a/crates/test_utils/src/connector_auth.rs +++ b/crates/test_utils/src/connector_auth.rs @@ -57,6 +57,7 @@ pub struct ConnectorAuthentication { pub netcetera: Option, pub nexinets: Option, pub nexixpay: Option, + pub nomupay: Option, pub noon: Option, pub novalnet: Option, pub nmi: Option, diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 6ef82db0f211..934b072f14a3 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -127,6 +127,7 @@ netcetera.base_url = "https://{{merchant_endpoint_prefix}}.3ds-server.prev.netce nexinets.base_url = "https://apitest.payengine.de/v1" nexixpay.base_url = "https://xpaysandbox.nexigroup.com/api/phoenix-0.0/psp/api/v1" nmi.base_url = "https://secure.nmi.com/" +nomupay.base_url = "https://payout-api.sandbox.nomupay.com" noon.base_url = "https://api-test.noonpayments.com/" noon.key_mode = "Test" novalnet.base_url = "https://payport.novalnet.de/v2" @@ -221,6 +222,7 @@ cards = [ "nexinets", "nexixpay", "nmi", + "nomupay", "noon", "novalnet", "nuvei", diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh index 1915cd65cdd6..0ed38e8ef5dc 100755 --- a/scripts/add_connector.sh +++ b/scripts/add_connector.sh @@ -6,7 +6,7 @@ function find_prev_connector() { git checkout $self cp $self $self.tmp # Add new connector to existing list and sort it - connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte globalpay globepay gocardless gpayments helcim iatapay itaubank jpmorgan klarna mifinity mollie multisafepay netcetera nexinets nexixpay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys volt wellsfargo wellsfargopayout wise worldline worldpay zsl "$1") + connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte globalpay globepay gocardless gpayments helcim iatapay itaubank jpmorgan klarna mifinity mollie multisafepay netcetera nexinets nexixpay nomupay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys volt wellsfargo wellsfargopayout 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 From 689f3641a84c2ff00d7a0dca0173670f5010e0bd Mon Sep 17 00:00:00 2001 From: sumanmaji4 Date: Wed, 6 Nov 2024 16:23:55 +0530 Subject: [PATCH 2/3] comment resolved --- crates/router/tests/connectors/nomupay.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crates/router/tests/connectors/nomupay.rs b/crates/router/tests/connectors/nomupay.rs index fd5face6577a..dbf892b3b046 100644 --- a/crates/router/tests/connectors/nomupay.rs +++ b/crates/router/tests/connectors/nomupay.rs @@ -17,12 +17,6 @@ impl utils::Connector for NomupayTest { api::GetToken::Connector, None, ) - // api::ConnectorData { - // connector: Box::new(Nomupay::new()), - // connector_name: types::Connector::Nomupay, - // get_token: types::api::GetToken::Connector, - // merchant_connector_id: None, - // } } fn get_auth_token(&self) -> types::ConnectorAuthType { From 95cde367d4a1ea0c3d33386c149d30afef5655fb Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2024 07:43:32 +0000 Subject: [PATCH 3/3] docs(openapi): re-generate OpenAPI specification --- api-reference-v2/openapi_spec.json | 3 +-- api-reference/openapi_spec.json | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index bcb5fc0635fa..84562b99343d 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -17814,7 +17814,6 @@ "nexinets", "nexixpay", "nmi", - "nomupay", "noon", "novalnet", "nuvei", @@ -17963,7 +17962,7 @@ "profile_id" ], "properties": { - "name": { + "name": { "type": "string" }, "description": { diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 57661c38f601..733ba96237c4 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -22504,7 +22504,6 @@ "nexinets", "nexixpay", "nmi", - "nomupay", "noon", "novalnet", "nuvei",