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): [Novalnet] add Payment flows for cards (#5726)

Debarati Ghatak246fdc840643
diff --git a/Cargo.lock b/Cargo.lock
index ae5625ed12..ac324d9c31 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3932,6 +3932,7 @@ dependencies = [
"router_env",
"serde",
"serde_json",
+ "serde_urlencoded",
"strum 0.26.3",
"time",
"url",
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index f7b817bccc..3c2c811766 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -5000,6 +5000,7 @@
"nexinets",
"nmi",
"noon",
+ "novalnet",
"nuvei",
"opennode",
"paybox",
@@ -7105,6 +7106,18 @@
"enum": [
"user_iban"
]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "browser_language"
+ ]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "browser_ip"
+ ]
}
],
"description": "Possible field type of required fields in payment_method_data"
@@ -17100,6 +17113,7 @@
"nexinets",
"nmi",
"noon",
+ "novalnet",
"nuvei",
"opennode",
"paybox",
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 4bf7274e52..f7c19ef94b 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -8647,6 +8647,7 @@
"nexinets",
"nmi",
"noon",
+ "novalnet",
"nuvei",
"opennode",
"paybox",
@@ -10724,6 +10725,18 @@
"enum": [
"user_iban"
]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "browser_language"
+ ]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "browser_ip"
+ ]
}
],
"description": "Possible field type of required fields in payment_method_data"
@@ -21558,6 +21571,7 @@
"nexinets",
"nmi",
"noon",
+ "novalnet",
"nuvei",
"opennode",
"paybox",
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 9c89e3e487..2826608b63 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -46,7 +46,6 @@ pub enum RoutingAlgorithm {
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum Connector {
- // Novalnet,
// Nexixpay,
Adyenplatform,
#[cfg(feature = "dummy_connector")]
@@ -117,6 +116,7 @@ pub enum Connector {
Nexinets,
Nmi,
Noon,
+ Novalnet,
Nuvei,
// Opayo, added as template code for future usage
Opennode,
@@ -214,7 +214,6 @@ impl Connector {
| Self::DummyConnector7 => false,
Self::Aci
// Add Separate authentication support for connectors
- // | Self::Novalnet
// | Self::Nexixpay
// | Self::Fiuu
| Self::Adyen
@@ -251,6 +250,7 @@ impl Connector {
| Self::Mollie
| Self::Multisafepay
| Self::Nexinets
+ | Self::Novalnet
| Self::Nuvei
| Self::Opennode
| Self::Paybox
@@ -515,6 +515,8 @@ pub enum FieldType {
UserCpf,
UserCnpj,
UserIban,
+ BrowserLanguage,
+ BrowserIp,
}
impl FieldType {
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 3e85a7c336..b6500d79b8 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -228,7 +228,7 @@ pub enum RoutableConnectors {
Nexinets,
Nmi,
Noon,
- // Novalnet,
+ Novalnet,
Nuvei,
// Opayo, added as template code for future usage
Opennode,
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index cc1f881835..8c9091baf4 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -188,6 +188,7 @@ pub struct ConnectorConfig {
pub nexinets: Option<ConnectorTomlConfig>,
pub nmi: Option<ConnectorTomlConfig>,
pub noon: Option<ConnectorTomlConfig>,
+ pub novalnet: Option<ConnectorTomlConfig>,
pub nuvei: Option<ConnectorTomlConfig>,
pub paybox: Option<ConnectorTomlConfig>,
pub payme: Option<ConnectorTomlConfig>,
@@ -338,6 +339,7 @@ impl ConnectorConfig {
Connector::Nexinets => Ok(connector_data.nexinets),
Connector::Prophetpay => Ok(connector_data.prophetpay),
Connector::Nmi => Ok(connector_data.nmi),
+ Connector::Novalnet => Ok(connector_data.novalnet),
Connector::Noon => Ok(connector_data.noon),
Connector::Nuvei => Ok(connector_data.nuvei),
Connector::Paybox => Ok(connector_data.paybox),
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index 06825a107a..4120e1d7db 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -2191,6 +2191,48 @@ placeholder="Enter Google Pay Merchant Key"
required=true
type="Text"
+[novalnet]
+[[novalnet.credit]]
+ payment_method_type = "Mastercard"
+[[novalnet.credit]]
+ payment_method_type = "Visa"
+[[novalnet.credit]]
+ payment_method_type = "Interac"
+[[novalnet.credit]]
+ payment_method_type = "AmericanExpress"
+[[novalnet.credit]]
+ payment_method_type = "JCB"
+[[novalnet.credit]]
+ payment_method_type = "DinersClub"
+[[novalnet.credit]]
+ payment_method_type = "Discover"
+[[novalnet.credit]]
+ payment_method_type = "CartesBancaires"
+[[novalnet.credit]]
+ payment_method_type = "UnionPay"
+[[novalnet.debit]]
+ payment_method_type = "Mastercard"
+[[novalnet.debit]]
+ payment_method_type = "Visa"
+[[novalnet.debit]]
+ payment_method_type = "Interac"
+[[novalnet.debit]]
+ payment_method_type = "AmericanExpress"
+[[novalnet.debit]]
+ payment_method_type = "JCB"
+[[novalnet.debit]]
+ payment_method_type = "DinersClub"
+[[novalnet.debit]]
+ payment_method_type = "Discover"
+[[novalnet.debit]]
+ payment_method_type = "CartesBancaires"
+[[novalnet.debit]]
+ payment_method_type = "UnionPay"
+[novalnet.connector_auth.SignatureKey]
+api_key="Product Activation Key"
+key1="Payment Access Key"
+api_secret="Tariff ID"
+
[nuvei]
[[nuvei.credit]]
payment_method_type = "Mastercard"
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index 3fc4f8c9f0..ba2021b6cf 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -1702,6 +1702,48 @@ key1="Public Key"
[nmi.connector_webhook_details]
merchant_secret="Source verification key"
+[novalnet]
+[[novalnet.credit]]
+ payment_method_type = "Mastercard"
+[[novalnet.credit]]
+ payment_method_type = "Visa"
+[[novalnet.credit]]
+ payment_method_type = "Interac"
+[[novalnet.credit]]
+ payment_method_type = "AmericanExpress"
+[[novalnet.credit]]
+ payment_method_type = "JCB"
+[[novalnet.credit]]
+ payment_method_type = "DinersClub"
+[[novalnet.credit]]
+ payment_method_type = "Discover"
+[[novalnet.credit]]
+ payment_method_type = "CartesBancaires"
+[[novalnet.credit]]
+ payment_method_type = "UnionPay"
+[[novalnet.debit]]
+ payment_method_type = "Mastercard"
+[[novalnet.debit]]
+ payment_method_type = "Visa"
+[[novalnet.debit]]
+ payment_method_type = "Interac"
+[[novalnet.debit]]
+ payment_method_type = "AmericanExpress"
+[[novalnet.debit]]
+ payment_method_type = "JCB"
+[[novalnet.debit]]
+ payment_method_type = "DinersClub"
+[[novalnet.debit]]
+ payment_method_type = "Discover"
+[[novalnet.debit]]
+ payment_method_type = "CartesBancaires"
+[[novalnet.debit]]
+ payment_method_type = "UnionPay"
+[novalnet.connector_auth.SignatureKey]
+api_key="Product Activation Key"
+key1="Payment Access Key"
+api_secret="Tariff ID"
+
[nuvei]
[[nuvei.credit]]
payment_method_type = "Mastercard"
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 9de845f0b5..354ee78f57 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -2187,6 +2187,48 @@ placeholder="Enter Google Pay Merchant Key"
required=true
type="Text"
+[novalnet]
+[[novalnet.credit]]
+ payment_method_type = "Mastercard"
+[[novalnet.credit]]
+ payment_method_type = "Visa"
+[[novalnet.credit]]
+ payment_method_type = "Interac"
+[[novalnet.credit]]
+ payment_method_type = "AmericanExpress"
+[[novalnet.credit]]
+ payment_method_type = "JCB"
+[[novalnet.credit]]
+ payment_method_type = "DinersClub"
+[[novalnet.credit]]
+ payment_method_type = "Discover"
+[[novalnet.credit]]
+ payment_method_type = "CartesBancaires"
+[[novalnet.credit]]
+ payment_method_type = "UnionPay"
+[[novalnet.debit]]
+ payment_method_type = "Mastercard"
+[[novalnet.debit]]
+ payment_method_type = "Visa"
+[[novalnet.debit]]
+ payment_method_type = "Interac"
+[[novalnet.debit]]
+ payment_method_type = "AmericanExpress"
+[[novalnet.debit]]
+ payment_method_type = "JCB"
+[[novalnet.debit]]
+ payment_method_type = "DinersClub"
+[[novalnet.debit]]
+ payment_method_type = "Discover"
+[[novalnet.debit]]
+ payment_method_type = "CartesBancaires"
+[[novalnet.debit]]
+ payment_method_type = "UnionPay"
+[novalnet.connector_auth.SignatureKey]
+api_key="Product Activation Key"
+key1="Payment Access Key"
+api_secret="Tariff ID"
+
[nuvei]
[[nuvei.credit]]
payment_method_type = "Mastercard"
diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml
index 8eb3ddd562..2676f63722 100644
--- a/crates/hyperswitch_connectors/Cargo.toml
+++ b/crates/hyperswitch_connectors/Cargo.toml
@@ -28,6 +28,7 @@ reqwest = { version = "0.11.27" }
ring = "0.17.8"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
+serde_urlencoded = "0.7.1"
strum = { version = "0.26", features = ["derive"] }
time = "0.3.35"
url = "2.5.0"
diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs
index 83a8015e73..025e2bed2b 100644
--- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs
+++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs
@@ -1,5 +1,6 @@
pub mod transformers;
-
+use base64::Engine;
+use common_enums::enums;
use common_utils::{
errors::CustomResult,
ext_traits::BytesExt,
@@ -21,12 +22,15 @@ use hyperswitch_domain_models::{
},
router_response_types::{PaymentsResponseData, RefundsResponseData},
types::{
- PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
- RefundSyncRouterData, RefundsRouterData,
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{
- api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation},
+ api::{
+ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse,
+ ConnectorValidation,
+ },
configs::Connectors,
errors,
events::connector_api_logs::ConnectorEvent,
@@ -36,7 +40,9 @@ use hyperswitch_interfaces::{
use masking::{ExposeInterface, Mask};
use transformers as novalnet;
-use crate::{constants::headers, types::ResponseRouterData, utils};
+use crate::{
+ constants::headers, types::ResponseRouterData, utils, utils::PaymentsAuthorizeRequestData,
+};
#[derive(Clone)]
pub struct Novalnet {
@@ -95,10 +101,7 @@ impl ConnectorCommon for Novalnet {
}
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
+ api::CurrencyUnit::Minor
}
fn common_get_content_type(&self) -> &'static str {
@@ -115,9 +118,11 @@ impl ConnectorCommon for Novalnet {
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let auth = novalnet::NovalnetAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
+ let api_key: String = auth.payment_access_key.expose();
+ let encoded_api_key = common_utils::consts::BASE64_ENGINE.encode(api_key);
Ok(vec![(
- headers::AUTHORIZATION.to_string(),
- auth.api_key.expose().into_masked(),
+ headers::X_NN_ACCESS_KEY.to_string(),
+ encoded_api_key.into_masked(),
)])
}
@@ -146,7 +151,52 @@ impl ConnectorCommon for Novalnet {
}
impl ConnectorValidation for Novalnet {
- //TODO: implement functions when support enabled
+ fn validate_capture_method(
+ &self,
+ capture_method: Option<enums::CaptureMethod>,
+ _pmt: Option<enums::PaymentMethodType>,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ let capture_method = capture_method.unwrap_or_default();
+ match capture_method {
+ enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()),
+ enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err(
+ utils::construct_not_implemented_error_report(capture_method, self.id()),
+ ),
+ }
+ }
+
+ fn validate_psync_reference_id(
+ &self,
+ data: &PaymentsSyncData,
+ _is_three_ds: bool,
+ _status: enums::AttemptStatus,
+ _connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ if data.encoded_data.is_some()
+ || data
+ .connector_transaction_id
+ .get_connector_transaction_id()
+ .is_ok()
+ {
+ return Ok(());
+ }
+
+ Err(errors::ConnectorError::MissingConnectorTransactionID.into())
+ }
+}
+
+impl ConnectorRedirectResponse for Novalnet {
+ fn get_flow_type(
+ &self,
+ _query_params: &str,
+ _json_payload: Option<serde_json::Value>,
+ action: enums::PaymentAction,
+ ) -> CustomResult<enums::CallConnectorAction, errors::ConnectorError> {
+ match action {
+ enums::PaymentAction::PSync => Ok(enums::CallConnectorAction::Trigger),
+ _ => Ok(enums::CallConnectorAction::Avoid),
+ }
+ }
}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Novalnet {
@@ -175,10 +225,14 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
fn get_url(
&self,
- _req: &PaymentsAuthorizeRouterData,
- _connectors: &Connectors,
+ req: &PaymentsAuthorizeRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let endpoint = self.base_url(connectors);
+ match req.request.is_auto_capture()? {
+ true => Ok(format!("{}/payment", endpoint)),
+ false => Ok(format!("{}/authorize", endpoint)),
+ }
}
fn get_request_body(
@@ -263,9 +317,19 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Nov
fn get_url(
&self,
_req: &PaymentsSyncRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let endpoint = self.base_url(connectors);
+ Ok(format!("{}/transaction/details", endpoint))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = novalnet::NovalnetSyncRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -275,10 +339,13 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Nov
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
- .method(Method::Get)
+ .method(Method::Post)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
+ .set_body(types::PaymentsSyncType::get_request_body(
+ self, req, connectors,
+ )?)
.build(),
))
}
@@ -289,7 +356,7 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Nov
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
- let response: novalnet::NovalnetPaymentsResponse = res
+ let response: novalnet::NovalnetPSyncResponse = res
.response
.parse_struct("novalnet PaymentsSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
@@ -327,17 +394,26 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
fn get_url(
&self,
_req: &PaymentsCaptureRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let endpoint = self.base_url(connectors);
+ Ok(format!("{}/transaction/capture", endpoint))
}
fn get_request_body(
&self,
- _req: &PaymentsCaptureRouterData,
+ req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount_to_capture,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = novalnet::NovalnetRouterData::from((amount, req));
+ let connector_req = novalnet::NovalnetCaptureRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -366,7 +442,7 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
- let response: novalnet::NovalnetPaymentsResponse = res
+ let response: novalnet::NovalnetCaptureResponse = res
.response
.parse_struct("Novalnet PaymentsCaptureResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
@@ -388,8 +464,6 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
}
}
-impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Novalnet {}
-
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Novalnet {
fn get_headers(
&self,
@@ -406,9 +480,10 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Novalne
fn get_url(
&self,
_req: &RefundsRouterData<Execute>,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let endpoint = self.base_url(connectors);
+ Ok(format!("{}/transaction/refund", endpoint))
}
fn get_request_body(
@@ -452,7 +527,7 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Novalne
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
- let response: novalnet::RefundResponse = res
+ let response: novalnet::NovalnetRefundResponse = res
.response
.parse_struct("novalnet RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
@@ -490,9 +565,19 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Novalnet
fn get_url(
&self,
_req: &RefundSyncRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let endpoint = self.base_url(connectors);
+ Ok(format!("{}/transaction/details", endpoint))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &RefundSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = novalnet::NovalnetSyncRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -502,7 +587,7 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Novalnet
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
- .method(Method::Get)
+ .method(Method::Post)
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
@@ -519,7 +604,7 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Novalnet
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
- let response: novalnet::RefundResponse = res
+ let response: novalnet::NovalnetRefundSyncResponse = res
.response
.parse_struct("novalnet RefundSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
@@ -541,6 +626,85 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Novalnet
}
}
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Novalnet {
+ fn get_headers(
+ &self,
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ let endpoint = self.base_url(connectors);
+ Ok(format!("{}/transaction/cancel", endpoint))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsCancelRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = novalnet::NovalnetCancelRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
+ .set_body(types::PaymentsVoidType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsCancelRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
+ let response: novalnet::NovalnetCancelResponse = res
+ .response
+ .parse_struct("NovalnetPaymentsVoidResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
#[async_trait::async_trait]
impl webhooks::IncomingWebhook for Novalnet {
fn get_webhook_object_reference_id(
diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
index de63e9b48c..dbdbbdb643 100644
--- a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
@@ -1,31 +1,46 @@
-use common_enums::enums;
-use common_utils::types::StringMinorUnit;
+use std::collections::HashMap;
+
+use cards::CardNumber;
+use common_enums::{enums, enums as api_enums};
+use common_utils::{
+ ext_traits::OptionExt,
+ pii::{Email, IpAddress},
+ request::Method,
+ types::StringMinorUnit,
+};
+use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
- router_data::{ConnectorAuthType, RouterData},
+ router_data::{ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::refunds::{Execute, RSync},
- router_request_types::ResponseId,
- router_response_types::{PaymentsResponseData, RefundsResponseData},
- types::{PaymentsAuthorizeRouterData, RefundsRouterData},
+ router_request_types::{PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData, ResponseId},
+ router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
+ types::{
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
+ },
};
use hyperswitch_interfaces::errors;
-use masking::Secret;
+use masking::{ExposeInterface, Secret};
use serde::{Deserialize, Serialize};
+use strum::Display;
use crate::{
types::{RefundsResponseRouterData, ResponseRouterData},
- utils::PaymentsAuthorizeRequestData,
+ utils::{
+ BrowserInformationData, PaymentsAuthorizeRequestData, PaymentsCancelRequestData,
+ PaymentsCaptureRequestData, PaymentsSyncRequestData, RefundsRequestData,
+ RouterData as OtherRouterData,
+ },
};
-//TODO: Fill the struct with respective fields
pub struct NovalnetRouterData<T> {
- pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
+ pub amount: StringMinorUnit,
pub router_data: T,
}
impl<T> From<(StringMinorUnit, T)> for NovalnetRouterData<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,
@@ -33,20 +48,76 @@ impl<T> From<(StringMinorUnit, T)> for NovalnetRouterData<T> {
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, PartialEq)]
-pub struct NovalnetPaymentsRequest {
+#[derive(Debug, Copy, Serialize, Deserialize, Clone)]
+pub enum NovalNetPaymentTypes {
+ CREDITCARD,
+}
+
+#[derive(Default, Debug, Serialize, PartialEq, Clone)]
+pub struct NovalnetPaymentsRequestMerchant {
+ signature: Secret<String>,
+ tariff: Secret<String>,
+}
+
+#[derive(Default, Debug, Serialize, PartialEq, Clone)]
+pub struct NovalnetPaymentsRequestBilling {
+ house_no: Secret<String>,
+ street: Secret<String>,
+ city: String,
+ zip: Secret<String>,
+ country_code: api_enums::CountryAlpha2,
+}
+
+#[derive(Default, Debug, Serialize, PartialEq, Clone)]
+pub struct NovalnetPaymentsRequestCustomer {
+ first_name: Secret<String>,
+ last_name: Secret<String>,
+ email: Email,
+ mobile: Option<Secret<String>>,
+ billing: NovalnetPaymentsRequestBilling,
+ customer_ip: Secret<String, IpAddress>,
+}
+#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+
+pub struct NovalNetCard {
+ card_number: CardNumber,
+ card_expiry_month: Secret<String>,
+ card_expiry_year: Secret<String>,
+ card_cvc: Secret<String>,
+ card_holder: Secret<String>,
+}
+
+#[derive(Debug, Serialize, Deserialize, Clone)]
+#[serde(untagged)]
+pub enum NovalNetPaymentData {
+ PaymentCard(NovalNetCard),
+}
+
+#[derive(Default, Debug, Serialize, Clone)]
+pub struct NovalnetCustom {
+ lang: String,
+}
+
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub struct NovalnetPaymentsRequestTransaction {
+ test_mode: i8,
+ payment_type: NovalNetPaymentTypes,
amount: StringMinorUnit,
- card: NovalnetCard,
+ currency: String,
+ order_no: String,
+ payment_data: NovalNetPaymentData,
+ hook_url: Option<String>,
+ return_url: Option<String>,
+ error_return_url: Option<String>,
+ enforce_3d: Option<i8>, //NOTE: Needed for CREDITCARD, GOOGLEPAY
}
-#[derive(Default, Debug, Serialize, Eq, PartialEq)]
-pub struct NovalnetCard {
- number: cards::CardNumber,
- expiry_month: Secret<String>,
- expiry_year: Secret<String>,
- cvc: Secret<String>,
- complete: bool,
+#[derive(Debug, Serialize, Clone)]
+pub struct NovalnetPaymentsRequest {
+ merchant: NovalnetPaymentsRequestMerchant,
+ customer: NovalnetPaymentsRequestCustomer,
+ transaction: NovalnetPaymentsRequestTransaction,
+ custom: NovalnetCustom,
}
impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaymentsRequest {
@@ -56,16 +127,81 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym
) -> Result<Self, Self::Error> {
match item.router_data.request.payment_method_data.clone() {
PaymentMethodData::Card(req_card) => {
- let card = NovalnetCard {
- 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()?,
+ let auth = NovalnetAuthType::try_from(&item.router_data.connector_auth_type)?;
+
+ let merchant = NovalnetPaymentsRequestMerchant {
+ signature: auth.product_activation_key,
+ tariff: auth.tariff_id,
};
- Ok(Self {
+
+ let novalnet_card = NovalNetPaymentData::PaymentCard(NovalNetCard {
+ card_number: req_card.card_number,
+ card_expiry_month: req_card.card_exp_month,
+ card_expiry_year: req_card.card_exp_year,
+ card_cvc: req_card.card_cvc,
+ card_holder: item.router_data.get_billing_full_name()?,
+ });
+
+ let enforce_3d = match item.router_data.auth_type {
+ enums::AuthenticationType::ThreeDs => Some(1),
+ enums::AuthenticationType::NoThreeDs => None,
+ };
+ let test_mode = match item.router_data.test_mode {
+ Some(true) => 1,
+ Some(false) | None => 0,
+ };
+
+ let return_url = item.router_data.request.get_return_url().ok();
+ let hook_url = item.router_data.request.get_webhook_url().ok();
+ let transaction = NovalnetPaymentsRequestTransaction {
+ test_mode,
+ payment_type: NovalNetPaymentTypes::CREDITCARD,
amount: item.amount.clone(),
- card,
+ currency: item.router_data.request.currency.to_string(),
+ order_no: item.router_data.connector_request_reference_id.clone(),
+ hook_url,
+ return_url: return_url.clone(),
+ error_return_url: return_url.clone(),
+ payment_data: novalnet_card,
+ enforce_3d,
+ };
+
+ let billing = NovalnetPaymentsRequestBilling {
+ house_no: item.router_data.get_billing_line1()?,
+ street: item.router_data.get_billing_line2()?,
+ city: item.router_data.get_billing_city()?,
+ zip: item.router_data.get_billing_zip()?,
+ country_code: item.router_data.get_billing_country()?,
+ };
+
+ let customer_ip = item
+ .router_data
+ .request
+ .get_browser_info()?
+ .get_ip_address()?;
+
+ let customer = NovalnetPaymentsRequestCustomer {
+ first_name: item.router_data.get_billing_first_name()?,
+ last_name: item.router_data.get_billing_last_name()?,
+ email: item.router_data.get_billing_email()?,
+ mobile: item.router_data.get_billing_phone_number().ok(),
+ billing,
+ customer_ip,
+ };
+
+ let lang = item
+ .router_data
+ .request
+ .get_optional_language_from_browser_info()
+ .unwrap_or("EN".to_string());
+
+ let custom = NovalnetCustom { lang };
+
+ Ok(Self {
+ merchant,
+ transaction,
+ customer,
+ custom,
})
}
_ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
@@ -73,49 +209,105 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym
}
}
-//TODO: Fill the struct with respective fields
// Auth Struct
pub struct NovalnetAuthType {
- pub(super) api_key: Secret<String>,
+ pub(super) product_activation_key: Secret<String>,
+ pub(super) payment_access_key: Secret<String>,
+ pub(super) tariff_id: Secret<String>,
}
impl TryFrom<&ConnectorAuthType> for NovalnetAuthType {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
- ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
- api_key: api_key.to_owned(),
+ ConnectorAuthType::SignatureKey {
+ api_key,
+ key1,
+ api_secret,
+ } => Ok(Self {
+ product_activation_key: api_key.to_owned(),
+ payment_access_key: key1.to_owned(),
+ tariff_id: api_secret.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 NovalnetPaymentStatus {
- Succeeded,
- Failed,
+#[derive(Debug, Copy, Clone, Default, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum NovalnetTransactionStatus {
+ Success,
+ Failure,
+ Confirmed,
+ OnHold,
+ Pending,
+ #[default]
+ Deactivated,
+ Progress,
+}
+
+#[derive(Debug, Copy, Display, Clone, Default, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum NovalnetAPIStatus {
+ Success,
#[default]
- Processing,
+ Failure,
}
-impl From<NovalnetPaymentStatus> for common_enums::AttemptStatus {
- fn from(item: NovalnetPaymentStatus) -> Self {
+impl From<NovalnetTransactionStatus> for common_enums::AttemptStatus {
+ fn from(item: NovalnetTransactionStatus) -> Self {
match item {
- NovalnetPaymentStatus::Succeeded => Self::Charged,
- NovalnetPaymentStatus::Failed => Self::Failure,
- NovalnetPaymentStatus::Processing => Self::Authorizing,
+ NovalnetTransactionStatus::Success | NovalnetTransactionStatus::Confirmed => {
+ Self::Charged
+ }
+ NovalnetTransactionStatus::OnHold => Self::Authorized,
+ NovalnetTransactionStatus::Pending => Self::Pending,
+ NovalnetTransactionStatus::Progress => Self::AuthenticationPending,
+ NovalnetTransactionStatus::Deactivated => Self::Voided,
+ NovalnetTransactionStatus::Failure => Self::Failure,
}
}
}
-//TODO: Fill the struct with respective fields
+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct ResultData {
+ redirect_url: Option<Secret<url::Url>>,
+ status: NovalnetAPIStatus,
+ status_code: i32,
+ status_text: String,
+ additional_message: Option<String>,
+}
+
+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct TransactionData {
+ payment_type: Option<String>,
+ status_code: i32,
+ txn_secret: Option<String>,
+ tid: Option<Secret<i64>>,
+ test_mode: Option<i8>,
+ status: Option<NovalnetTransactionStatus>,
+}
+
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct NovalnetPaymentsResponse {
- status: NovalnetPaymentStatus,
- id: String,
+ result: ResultData,
+ transaction: Option<TransactionData>,
+}
+
+pub fn get_error_response(result: ResultData, status_code: u16) -> ErrorResponse {
+ let error_code = result.status;
+ let error_reason = result.status_text.clone();
+
+ ErrorResponse {
+ code: error_code.to_string(),
+ message: error_reason.clone(),
+ reason: Some(error_reason),
+ status_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ }
}
impl<F, T> TryFrom<ResponseRouterData<F, NovalnetPaymentsResponse, T, PaymentsResponseData>>
@@ -125,99 +317,669 @@ impl<F, T> TryFrom<ResponseRouterData<F, NovalnetPaymentsResponse, T, PaymentsRe
fn try_from(
item: ResponseRouterData<F, NovalnetPaymentsResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
+ match item.response.result.status {
+ NovalnetAPIStatus::Success => {
+ let redirection_data: Option<RedirectForm> =
+ item.response
+ .result
+ .redirect_url
+ .map(|url| RedirectForm::Form {
+ endpoint: url.expose().to_string(),
+ method: Method::Get,
+ form_fields: HashMap::new(),
+ });
+
+ let transaction_id = item
+ .response
+ .transaction
+ .clone()
+ .and_then(|data| data.tid.map(|tid| tid.expose().to_string()));
+ let transaction_status = item
+ .response
+ .transaction
+ .and_then(|transaction_data| transaction_data.status)
+ .unwrap_or(if redirection_data.is_some() {
+ NovalnetTransactionStatus::Progress
+ } else {
+ NovalnetTransactionStatus::Pending
+ });
+ // NOTE: if result.status is success, we should always get a redirection url for 3DS flow
+ // since Novalnet does not always send the transaction.status
+ // so default value is kept as Progress if flow is 3ds, otherwise default value is kept as Pending
+
+ Ok(Self {
+ status: common_enums::AttemptStatus::from(transaction_status),
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: transaction_id
+ .clone()
+ .map(ResponseId::ConnectorTransactionId)
+ .unwrap_or(ResponseId::NoResponseId),
+ redirection_data,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: transaction_id.clone(),
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ }),
+ ..item.data
+ })
+ }
+ NovalnetAPIStatus::Failure => {
+ let response = Err(get_error_response(item.response.result, item.http_code));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+#[derive(Serialize, Deserialize, Clone, Debug)]
+pub struct NovalnetResponseCustomer {
+ pub billing: NovalnetResponseBilling,
+ pub customer_ip: Secret<String>,
+ pub email: Secret<String>,
+ pub first_name: Secret<String>,
+ pub gender: Secret<String>,
+ pub last_name: Secret<String>,
+ pub mobile: Secret<String>,
+}
+
+#[derive(Serialize, Deserialize, Clone, Debug)]
+pub struct NovalnetResponseBilling {
+ pub city: Secret<String>,
+ pub country_code: Secret<String>,
+ pub house_no: Secret<String>,
+ pub street: Secret<String>,
+ pub zip: Secret<String>,
+}
+
+#[derive(Serialize, Deserialize, Clone, Debug)]
+pub struct NovalnetResponseMerchant {
+ pub project: u32,
+ pub vendor: u32,
+}
+
+#[derive(Serialize, Deserialize, Clone, Debug)]
+pub struct NovalnetResponseTransactionData {
+ pub amount: u32,
+ pub currency: String,
+ pub date: Option<String>,
+ pub order_no: String,
+ pub payment_data: NovalnetResponsePaymentData,
+ pub payment_type: String,
+ pub status: NovalnetTransactionStatus,
+ pub status_code: u16,
+ pub test_mode: u8,
+ pub tid: Secret<i64>,
+ pub txn_secret: Secret<String>,
+}
+
+#[derive(Debug, Serialize, Deserialize, Clone)]
+#[serde(untagged)]
+pub enum NovalnetResponsePaymentData {
+ PaymentCard(NovalnetResponseCard),
+}
+
+#[derive(Serialize, Deserialize, Clone, Debug)]
+pub struct NovalnetResponseCard {
+ pub card_brand: Secret<String>,
+ pub card_expiry_month: Secret<u8>,
+ pub card_expiry_year: Secret<u16>,
+ pub card_holder: Secret<String>,
+ pub card_number: Secret<String>,
+ pub cc_3d: Secret<u8>,
+ pub last_four: Secret<String>,
+ pub token: Option<Secret<String>>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NovalnetPSyncResponse {
+ pub customer: Option<NovalnetResponseCustomer>,
+ pub merchant: Option<NovalnetResponseMerchant>,
+ pub result: ResultData,
+ pub transaction: Option<NovalnetResponseTransactionData>,
+}
+
+#[derive(Debug, Copy, Serialize, Default, Deserialize, Clone)]
+pub enum CaptureType {
+ #[default]
+ Partial,
+ Final,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct Capture {
+ #[serde(rename = "type")]
+ cap_type: CaptureType,
+ reference: String,
+}
+#[derive(Default, Debug, Serialize)]
+pub struct NovalnetTransaction {
+ tid: String,
+ amount: Option<StringMinorUnit>,
+ capture: Capture,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct NovalnetCaptureRequest {
+ pub transaction: NovalnetTransaction,
+ pub custom: NovalnetCustom,
+}
+
+impl TryFrom<&NovalnetRouterData<&PaymentsCaptureRouterData>> for NovalnetCaptureRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &NovalnetRouterData<&PaymentsCaptureRouterData>,
+ ) -> Result<Self, Self::Error> {
+ let capture_type = CaptureType::Final;
+ let reference = item.router_data.connector_request_reference_id.clone();
+ let capture = Capture {
+ cap_type: capture_type,
+ reference,
+ };
+
+ let transaction = NovalnetTransaction {
+ tid: item.router_data.request.connector_transaction_id.clone(),
+ capture,
+ amount: Some(item.amount.to_owned()),
+ };
+
+ let custom = NovalnetCustom {
+ lang: item
+ .router_data
+ .request
+ .get_optional_language_from_browser_info()
+ .unwrap_or("EN".to_string()),
+ };
Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status),
- response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: 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
+ transaction,
+ custom,
})
}
}
-//TODO: Fill the struct with respective fields
-// REFUND :
// Type definition for RefundRequest
+#[derive(Default, Debug, Serialize)]
+pub struct NovalnetRefundTransaction {
+ tid: String,
+ amount: Option<StringMinorUnit>,
+}
+
#[derive(Default, Debug, Serialize)]
pub struct NovalnetRefundRequest {
- pub amount: StringMinorUnit,
+ pub transaction: NovalnetRefundTransaction,
+ pub custom: NovalnetCustom,
}
impl<F> TryFrom<&NovalnetRouterData<&RefundsRouterData<F>>> for NovalnetRefundRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &NovalnetRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+ let transaction = NovalnetRefundTransaction {
+ tid: item.router_data.request.connector_transaction_id.clone(),
+ amount: Some(item.amount.to_owned()),
+ };
+
+ let custom = NovalnetCustom {
+ lang: item
+ .router_data
+ .request
+ .get_optional_language_from_browser_info()
+ .unwrap_or("EN".to_string()),
+ };
Ok(Self {
- amount: item.amount.to_owned(),
+ transaction,
+ custom,
})
}
}
-// Type definition for Refund Response
+impl From<NovalnetTransactionStatus> for enums::RefundStatus {
+ fn from(item: NovalnetTransactionStatus) -> Self {
+ match item {
+ NovalnetTransactionStatus::Success | NovalnetTransactionStatus::Confirmed => {
+ Self::Success
+ }
+ NovalnetTransactionStatus::Pending => Self::Pending,
+ NovalnetTransactionStatus::Failure
+ | NovalnetTransactionStatus::OnHold
+ | NovalnetTransactionStatus::Deactivated
+ | NovalnetTransactionStatus::Progress => Self::Failure,
+ }
+ }
+}
-#[allow(dead_code)]
-#[derive(Debug, Serialize, Default, Deserialize, Clone)]
-pub enum RefundStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NovalnetRefundSyncResponse {
+ result: ResultData,
+ transaction: Option<NovalnetResponseTransactionData>,
}
-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
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NovalnetRefundsTransactionData {
+ amount: u32,
+ date: Option<String>,
+ currency: String,
+ order_no: String,
+ payment_type: String,
+ refund: RefundData,
+ refunded_amount: u32,
+ status: NovalnetTransactionStatus,
+ status_code: u16,
+ test_mode: u8,
+ tid: Option<Secret<i64>>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct RefundData {
+ amount: u32,
+ currency: String,
+ payment_type: String,
+ tid: Option<Secret<i64>>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NovalnetRefundResponse {
+ pub customer: Option<NovalnetResponseCustomer>,
+ pub merchant: Option<NovalnetResponseMerchant>,
+ pub result: ResultData,
+ pub transaction: Option<NovalnetRefundsTransactionData>,
+}
+
+impl TryFrom<RefundsResponseRouterData<Execute, NovalnetRefundResponse>>
+ for RefundsRouterData<Execute>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: RefundsResponseRouterData<Execute, NovalnetRefundResponse>,
+ ) -> Result<Self, Self::Error> {
+ match item.response.result.status {
+ NovalnetAPIStatus::Success => {
+ let refund_id = item
+ .response
+ .transaction
+ .clone()
+ .and_then(|data| data.tid.map(|tid| tid.expose().to_string()))
+ .ok_or(errors::ConnectorError::ResponseHandlingFailed)?;
+
+ let transaction_status = item
+ .response
+ .transaction
+ .map(|transaction| transaction.status)
+ .unwrap_or(NovalnetTransactionStatus::Pending);
+
+ Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: refund_id,
+ refund_status: enums::RefundStatus::from(transaction_status),
+ }),
+ ..item.data
+ })
+ }
+ NovalnetAPIStatus::Failure => {
+ let response = Err(get_error_response(item.response.result, item.http_code));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
}
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize)]
-pub struct RefundResponse {
- id: String,
- status: RefundStatus,
+#[derive(Default, Debug, Serialize, Deserialize)]
+pub struct NovolnetRedirectionResponse {
+ status: NovalnetTransactionStatus,
+ tid: Secret<String>,
+}
+
+impl TryFrom<&PaymentsSyncRouterData> for NovalnetSyncRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &PaymentsSyncRouterData) -> Result<Self, Self::Error> {
+ let transaction = if item
+ .request
+ .encoded_data
+ .clone()
+ .get_required_value("encoded_data")
+ .is_ok()
+ {
+ let encoded_data = item
+ .request
+ .encoded_data
+ .clone()
+ .get_required_value("encoded_data")
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+ let novalnet_redirection_response =
+ serde_urlencoded::from_str::<NovolnetRedirectionResponse>(encoded_data.as_str())
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ NovalnetSyncTransaction {
+ tid: novalnet_redirection_response.tid.expose(),
+ }
+ } else {
+ NovalnetSyncTransaction {
+ tid: item
+ .request
+ .get_connector_transaction_id()
+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)?,
+ }
+ };
+
+ let custom = NovalnetCustom {
+ lang: "EN".to_string(),
+ };
+ Ok(Self {
+ transaction,
+ custom,
+ })
+ }
+}
+
+impl<F>
+ TryFrom<ResponseRouterData<F, NovalnetPSyncResponse, PaymentsSyncData, PaymentsResponseData>>
+ for RouterData<F, PaymentsSyncData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<F, NovalnetPSyncResponse, PaymentsSyncData, PaymentsResponseData>,
+ ) -> Result<Self, Self::Error> {
+ match item.response.result.status {
+ NovalnetAPIStatus::Success => {
+ let transaction_id = item
+ .response
+ .transaction
+ .clone()
+ .map(|data| data.tid.expose().to_string());
+ let transaction_status = item
+ .response
+ .transaction
+ .map(|transaction_data| transaction_data.status)
+ .unwrap_or(NovalnetTransactionStatus::Pending);
+
+ Ok(Self {
+ status: common_enums::AttemptStatus::from(transaction_status),
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: transaction_id
+ .clone()
+ .map(ResponseId::ConnectorTransactionId)
+ .unwrap_or(ResponseId::NoResponseId),
+ redirection_data: None,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: transaction_id.clone(),
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ }),
+ ..item.data
+ })
+ }
+ NovalnetAPIStatus::Failure => {
+ let response = Err(get_error_response(item.response.result, item.http_code));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct CaptureTransactionData {
+ amount: Option<u32>,
+ capture: CaptureData,
+ currency: Option<String>,
+ order_no: Option<String>,
+ payment_type: Option<String>,
+ status: Option<NovalnetTransactionStatus>,
+ status_code: Option<u16>,
+ test_mode: Option<u8>,
+ tid: Option<Secret<i64>>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct CaptureData {
+ amount: Option<u32>,
+ payment_type: Option<String>,
+ status: Option<String>,
+ status_code: u16,
+ tid: Option<Secret<i64>>,
}
-impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NovalnetCaptureResponse {
+ pub result: ResultData,
+ pub transaction: Option<CaptureTransactionData>,
+}
+
+impl<F>
+ TryFrom<
+ ResponseRouterData<F, NovalnetCaptureResponse, PaymentsCaptureData, PaymentsResponseData>,
+ > for RouterData<F, PaymentsCaptureData, PaymentsResponseData>
+{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<Execute, RefundResponse>,
+ item: ResponseRouterData<
+ F,
+ NovalnetCaptureResponse,
+ PaymentsCaptureData,
+ PaymentsResponseData,
+ >,
) -> Result<Self, Self::Error> {
+ match item.response.result.status {
+ NovalnetAPIStatus::Success => {
+ let transaction_id = item
+ .response
+ .transaction
+ .clone()
+ .and_then(|data| data.tid.map(|tid| tid.expose().to_string()));
+ let transaction_status = item
+ .response
+ .transaction
+ .and_then(|transaction_data| transaction_data.status)
+ .unwrap_or(NovalnetTransactionStatus::Pending);
+
+ Ok(Self {
+ status: common_enums::AttemptStatus::from(transaction_status),
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: transaction_id
+ .clone()
+ .map(ResponseId::ConnectorTransactionId)
+ .unwrap_or(ResponseId::NoResponseId),
+ redirection_data: None,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: transaction_id.clone(),
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ }),
+ ..item.data
+ })
+ }
+ NovalnetAPIStatus::Failure => {
+ let response = Err(get_error_response(item.response.result, item.http_code));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct NovalnetSyncTransaction {
+ tid: String,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct NovalnetSyncRequest {
+ pub transaction: NovalnetSyncTransaction,
+ pub custom: NovalnetCustom,
+}
+
+impl TryFrom<&RefundSyncRouterData> for NovalnetSyncRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &RefundSyncRouterData) -> Result<Self, Self::Error> {
+ let transaction = NovalnetSyncTransaction {
+ tid: item.request.connector_transaction_id.clone(),
+ };
+
+ let custom = NovalnetCustom {
+ lang: item
+ .request
+ .get_optional_language_from_browser_info()
+ .unwrap_or("EN".to_string()),
+ };
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
- ..item.data
+ transaction,
+ custom,
})
}
}
-impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
+impl TryFrom<RefundsResponseRouterData<RSync, NovalnetRefundSyncResponse>>
+ for RefundsRouterData<RSync>
+{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<RSync, RefundResponse>,
+ item: RefundsResponseRouterData<RSync, NovalnetRefundSyncResponse>,
) -> Result<Self, Self::Error> {
+ match item.response.result.status {
+ NovalnetAPIStatus::Success => {
+ let refund_id = item
+ .response
+ .transaction
+ .clone()
+ .map(|transaction_data: NovalnetResponseTransactionData| {
+ transaction_data.tid.expose().to_string()
+ })
+ .unwrap_or("".to_string());
+ //NOTE: Mapping refund_id with "" incase we dont get any tid
+
+ let transaction_status = item
+ .response
+ .transaction
+ .map(|transaction_data| transaction_data.status)
+ .unwrap_or(NovalnetTransactionStatus::Pending);
+
+ Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: refund_id,
+ refund_status: enums::RefundStatus::from(transaction_status),
+ }),
+ ..item.data
+ })
+ }
+ NovalnetAPIStatus::Failure => {
+ let response = Err(get_error_response(item.response.result, item.http_code));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct NovalnetCancelTransaction {
+ tid: String,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct NovalnetCancelRequest {
+ pub transaction: NovalnetCancelTransaction,
+ pub custom: NovalnetCustom,
+}
+
+impl TryFrom<&PaymentsCancelRouterData> for NovalnetCancelRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {
+ let transaction = NovalnetCancelTransaction {
+ tid: item.request.connector_transaction_id.clone(),
+ };
+
+ let custom = NovalnetCustom {
+ lang: item
+ .request
+ .get_optional_language_from_browser_info()
+ .unwrap_or("EN".to_string()),
+ };
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
- ..item.data
+ transaction,
+ custom,
})
}
}
+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct NovalnetCancelResponse {
+ result: ResultData,
+ transaction: Option<TransactionData>,
+}
+
+impl<F>
+ TryFrom<ResponseRouterData<F, NovalnetCancelResponse, PaymentsCancelData, PaymentsResponseData>>
+ for RouterData<F, PaymentsCancelData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ NovalnetCancelResponse,
+ PaymentsCancelData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ match item.response.result.status {
+ NovalnetAPIStatus::Success => {
+ let transaction_id = item
+ .response
+ .transaction
+ .clone()
+ .and_then(|data| data.tid.map(|tid| tid.expose().to_string()));
+ let transaction_status = item
+ .response
+ .transaction
+ .and_then(|transaction_data| transaction_data.status)
+ .unwrap_or(NovalnetTransactionStatus::Pending);
+ Ok(Self {
+ status: if transaction_status == NovalnetTransactionStatus::Deactivated {
+ enums::AttemptStatus::Voided
+ } else {
+ enums::AttemptStatus::VoidFailed
+ },
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: transaction_id
+ .clone()
+ .map(ResponseId::ConnectorTransactionId)
+ .unwrap_or(ResponseId::NoResponseId),
+ redirection_data: None,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: transaction_id.clone(),
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ }),
+ ..item.data
+ })
+ }
+ NovalnetAPIStatus::Failure => {
+ let response = Err(get_error_response(item.response.result, item.http_code));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
//TODO: Fill the struct with respective fields
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
pub struct NovalnetErrorResponse {
diff --git a/crates/hyperswitch_connectors/src/constants.rs b/crates/hyperswitch_connectors/src/constants.rs
index 1427b567c4..86d6144b1f 100644
--- a/crates/hyperswitch_connectors/src/constants.rs
+++ b/crates/hyperswitch_connectors/src/constants.rs
@@ -9,4 +9,5 @@ pub(crate) mod headers {
pub(crate) const MESSAGE_SIGNATURE: &str = "Message-Signature";
pub(crate) const TIMESTAMP: &str = "Timestamp";
pub(crate) const X_ACCEPT_VERSION: &str = "X-Accept-Version";
+ pub(crate) const X_NN_ACCESS_KEY: &str = "X-NN-Access-Key";
}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 40aa36cc8b..ce1140394b 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -297,7 +297,6 @@ default_imp_for_connector_redirect_response!(
connectors::Fiuu,
connectors::Globepay,
connectors::Helcim,
- connectors::Novalnet,
connectors::Nexixpay,
connectors::Powertranz,
connectors::Stax,
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index 6a6f3bdc52..bda133e65b 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -179,6 +179,7 @@ pub trait RouterData {
fn get_billing_full_name(&self) -> Result<Secret<String>, Error>;
fn get_billing_last_name(&self) -> Result<Secret<String>, Error>;
fn get_billing_line1(&self) -> Result<Secret<String>, Error>;
+ fn get_billing_line2(&self) -> Result<Secret<String>, Error>;
fn get_billing_zip(&self) -> Result<Secret<String>, Error>;
fn get_billing_state(&self) -> Result<Secret<String>, Error>;
fn get_billing_state_code(&self) -> Result<Secret<String>, Error>;
@@ -425,6 +426,19 @@ impl<Flow, Request, Response> RouterData
"payment_method_data.billing.address.line1",
))
}
+ fn get_billing_line2(&self) -> Result<Secret<String>, Error> {
+ self.address
+ .get_payment_method_billing()
+ .and_then(|billing_address| {
+ billing_address
+ .clone()
+ .address
+ .and_then(|billing_details| billing_details.line2.clone())
+ })
+ .ok_or_else(missing_field_err(
+ "payment_method_data.billing.address.line2",
+ ))
+ }
fn get_billing_zip(&self) -> Result<Secret<String>, Error> {
self.address
.get_payment_method_billing()
@@ -984,6 +998,7 @@ impl PhoneDetailsData for PhoneDetails {
}
pub trait PaymentsAuthorizeRequestData {
+ fn get_optional_language_from_browser_info(&self) -> Option<String>;
fn is_auto_capture(&self) -> Result<bool, Error>;
fn get_email(&self) -> Result<Email, Error>;
fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
@@ -1025,6 +1040,12 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
.clone()
.ok_or_else(missing_field_err("browser_info"))
}
+ fn get_optional_language_from_browser_info(&self) -> Option<String> {
+ self.browser_info
+ .clone()
+ .and_then(|browser_info| browser_info.language)
+ }
+
fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error> {
self.order_details
.clone()
@@ -1156,6 +1177,7 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData {
}
pub trait PaymentsCaptureRequestData {
+ fn get_optional_language_from_browser_info(&self) -> Option<String>;
fn is_multiple_capture(&self) -> bool;
fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
}
@@ -1169,6 +1191,11 @@ impl PaymentsCaptureRequestData for PaymentsCaptureData {
.clone()
.ok_or_else(missing_field_err("browser_info"))
}
+ fn get_optional_language_from_browser_info(&self) -> Option<String> {
+ self.browser_info
+ .clone()
+ .and_then(|browser_info| browser_info.language)
+ }
}
pub trait PaymentsSyncRequestData {
@@ -1199,6 +1226,7 @@ impl PaymentsSyncRequestData for PaymentsSyncData {
}
pub trait PaymentsCancelRequestData {
+ fn get_optional_language_from_browser_info(&self) -> Option<String>;
fn get_amount(&self) -> Result<i64, Error>;
fn get_currency(&self) -> Result<enums::Currency, Error>;
fn get_cancellation_reason(&self) -> Result<String, Error>;
@@ -1222,9 +1250,15 @@ impl PaymentsCancelRequestData for PaymentsCancelData {
.clone()
.ok_or_else(missing_field_err("browser_info"))
}
+ fn get_optional_language_from_browser_info(&self) -> Option<String> {
+ self.browser_info
+ .clone()
+ .and_then(|browser_info| browser_info.language)
+ }
}
pub trait RefundsRequestData {
+ fn get_optional_language_from_browser_info(&self) -> Option<String>;
fn get_connector_refund_id(&self) -> Result<String, Error>;
fn get_webhook_url(&self) -> Result<String, Error>;
fn get_browser_info(&self) -> Result<BrowserInformation, Error>;
@@ -1248,6 +1282,11 @@ impl RefundsRequestData for RefundsData {
.clone()
.ok_or_else(missing_field_err("browser_info"))
}
+ fn get_optional_language_from_browser_info(&self) -> Option<String> {
+ self.browser_info
+ .clone()
+ .and_then(|browser_info| browser_info.language)
+ }
}
pub trait PaymentsSetupMandateRequestData {
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index 59016c71fe..acffafa6c3 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -2146,6 +2146,107 @@ impl Default for super::settings::RequiredFields {
),
}
),
+ (
+ enums::Connector::Novalnet,
+ RequiredFieldFinal {
+ mandate: HashMap::new(),
+ non_mandate: HashMap::new(),
+ common: HashMap::from(
+ [
+ (
+ "browser_info.language".to_string(),
+ RequiredFieldInfo {
+ required_field: "browser_info.language".to_string(),
+ display_name: "browser_info_language".to_string(),
+ field_type: enums::FieldType::BrowserLanguage,
+ value: None,
+ }
+ ),
+ (
+ "browser_info.ip_address".to_string(),
+ RequiredFieldInfo {
+ required_field: "browser_info.ip_address".to_string(),
+ display_name: "browser_info_ip_address".to_string(),
+ field_type: enums::FieldType::BrowserIp,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.line1".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.line1".to_string(),
+ display_name: "line1".to_string(),
+ field_type: enums::FieldType::UserAddressLine1,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.line2".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.line2".to_string(),
+ display_name: "line1".to_string(),
+ field_type: enums::FieldType::UserAddressLine2,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.city".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.city".to_string(),
+ display_name: "city".to_string(),
+ field_type: enums::FieldType::UserAddressCity,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.zip".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.zip".to_string(),
+ display_name: "zip".to_string(),
+ field_type: enums::FieldType::UserAddressPincode,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.first_name".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.first_name".to_string(),
+ display_name: "first_name".to_string(),
+ field_type: enums::FieldType::UserFullName,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.last_name".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.last_name".to_string(),
+ display_name: "last_name".to_string(),
+ field_type: enums::FieldType::UserFullName,
+ value: None,
+ }
+ ),
+ (
+ "billing.phone.country_code".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.phone.country_code".to_string(),
+ display_name: "dialing_code".to_string(),
+ field_type: enums::FieldType::UserPhoneNumberCountryCode,
+ value: None,
+ }
+ ),
+ (
+ "billing.email".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.email".to_string(),
+ display_name: "email_address".to_string(),
+ field_type: enums::FieldType::UserEmailAddress,
+ value: None,
+ }
+ ),
+ ]
+ ),
+ }
+ ),
(
enums::Connector::Nuvei,
RequiredFieldFinal {
@@ -5018,6 +5119,107 @@ impl Default for super::settings::RequiredFields {
),
}
),
+ (
+ enums::Connector::Novalnet,
+ RequiredFieldFinal {
+ mandate: HashMap::new(),
+ non_mandate: HashMap::new(),
+ common: HashMap::from(
+ [
+ (
+ "browser_info.language".to_string(),
+ RequiredFieldInfo {
+ required_field: "browser_info.language".to_string(),
+ display_name: "browser_info_language".to_string(),
+ field_type: enums::FieldType::BrowserLanguage,
+ value: None,
+ }
+ ),
+ (
+ "browser_info.ip_address".to_string(),
+ RequiredFieldInfo {
+ required_field: "browser_info.ip_address".to_string(),
+ display_name: "browser_info_ip_address".to_string(),
+ field_type: enums::FieldType::BrowserIp,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.line1".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.line1".to_string(),
+ display_name: "line1".to_string(),
+ field_type: enums::FieldType::UserAddressLine1,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.line2".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.line2".to_string(),
+ display_name: "line1".to_string(),
+ field_type: enums::FieldType::UserAddressLine2,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.city".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.city".to_string(),
+ display_name: "city".to_string(),
+ field_type: enums::FieldType::UserAddressCity,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.zip".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.zip".to_string(),
+ display_name: "zip".to_string(),
+ field_type: enums::FieldType::UserAddressPincode,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.first_name".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.first_name".to_string(),
+ display_name: "first_name".to_string(),
+ field_type: enums::FieldType::UserFullName,
+ value: None,
+ }
+ ),
+ (
+ "billing.address.last_name".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.last_name".to_string(),
+ display_name: "last_name".to_string(),
+ field_type: enums::FieldType::UserFullName,
+ value: None,
+ }
+ ),
+ (
+ "billing.phone.country_code".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.phone.country_code".to_string(),
+ display_name: "dialing_code".to_string(),
+ field_type: enums::FieldType::UserPhoneNumberCountryCode,
+ value: None,
+ }
+ ),
+ (
+ "billing.email".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.email".to_string(),
+ display_name: "email_address".to_string(),
+ field_type: enums::FieldType::UserEmailAddress,
+ value: None,
+ }
+ ),
+ ]
+ ),
+ }
+ ),
(
enums::Connector::Nuvei,
RequiredFieldFinal {
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 36e68240f5..c0cb446b38 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1393,6 +1393,10 @@ impl<'a> ConnectorAuthTypeAndMetadataValidation<'a> {
noon::transformers::NoonAuthType::try_from(self.auth_type)?;
Ok(())
}
+ api_enums::Connector::Novalnet => {
+ novalnet::transformers::NovalnetAuthType::try_from(self.auth_type)?;
+ Ok(())
+ }
api_enums::Connector::Nuvei => {
nuvei::transformers::NuveiAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index 3f7f82c779..7444fea0c3 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -1320,8 +1320,22 @@ pub fn build_redirection_form(
input type="hidden" name=(field) value=(value);
}
}
-
- (PreEscaped(format!("<script type=\"text/javascript\"> {logging_template} var frm = document.getElementById(\"payment_form\"); window.setTimeout(function () {{ frm.submit(); }}, 300); </script>")))
+ (PreEscaped(format!(r#"
+ <script type="text/javascript"> {logging_template}
+ var frm = document.getElementById("payment_form");
+ var formFields = frm.querySelectorAll("input");
+
+ if (frm.method.toUpperCase() === "GET" && formFields.length === 0) {{
+ window.setTimeout(function () {{
+ window.location.href = frm.action;
+ }}, 300);
+ }} else {{
+ window.setTimeout(function () {{
+ frm.submit();
+ }}, 300);
+ }}
+ </script>
+ "#)))
}
}
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 598db0bdcc..18f6276495 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -422,7 +422,9 @@ impl ConnectorData {
enums::Connector::Mollie => Ok(ConnectorEnum::Old(Box::new(&connector::Mollie))),
enums::Connector::Nmi => Ok(ConnectorEnum::Old(Box::new(connector::Nmi::new()))),
enums::Connector::Noon => Ok(ConnectorEnum::Old(Box::new(connector::Noon::new()))),
- // enums::Connector::Novalnet => Ok(ConnectorEnum::Old(Box::new(connector::Novalnet))),
+ enums::Connector::Novalnet => {
+ Ok(ConnectorEnum::Old(Box::new(connector::Novalnet::new())))
+ }
enums::Connector::Nuvei => Ok(ConnectorEnum::Old(Box::new(&connector::Nuvei))),
enums::Connector::Opennode => {
Ok(ConnectorEnum::Old(Box::new(&connector::Opennode)))
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 741a7d89d5..f883d1d4c5 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -305,7 +305,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
// api_enums::Connector::Nexixpay => Self::Nexixpay,
api_enums::Connector::Nmi => Self::Nmi,
api_enums::Connector::Noon => Self::Noon,
- // api_enums::Connector::Novalnet => Self::Novalnet,
+ api_enums::Connector::Novalnet => Self::Novalnet,
api_enums::Connector::Nuvei => Self::Nuvei,
api_enums::Connector::Opennode => Self::Opennode,
api_enums::Connector::Paybox => Self::Paybox,
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
index cfb136acd1..eff36cf502 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Commons.js
@@ -17,7 +17,7 @@ function normalise(input) {
paybox: "Paybox",
paypal: "Paypal",
wellsfargo: "Wellsfargo",
- fiuu: "Fiuu"
+ fiuu: "Fiuu",
// Add more known exceptions here
};
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Novalnet.js b/cypress-tests/cypress/e2e/PaymentUtils/Novalnet.js
new file mode 100644
index 0000000000..6fe7dc6392
--- /dev/null
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Novalnet.js
@@ -0,0 +1,218 @@
+const successfulNo3DSCardDetails = {
+ card_number: "4200000000000000",
+ card_exp_month: "12",
+ card_exp_year: "25",
+ card_holder_name: "Max Mustermann",
+ card_cvc: "123",
+};
+
+const successfulThreeDSTestCardDetails = {
+ card_number: "4000000000001091",
+ card_exp_month: "12",
+ card_exp_year: "25",
+ card_holder_name: "Max Mustermann",
+ card_cvc: "123",
+};
+
+export const connectorDetails = {
+ card_pm: {
+ PaymentIntent: {
+ Request: {
+ currency: "EUR",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ },
+ "3DSManualCapture": {
+ Request: {
+ payment_method: "card",
+ billing: {
+ address: {
+ line1: "1467",
+ line2: "CA",
+ line3: "CA",
+ city: "Musterhausen",
+ state: "California",
+ zip: "12345",
+ country: "DE",
+ first_name: "Max",
+ last_name: "Mustermann"
+ },
+ email: "[email protected]",
+ phone: {
+ number: "9123456789",
+ country_code: "+91"
+ }
+ },
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ "3DSAutoCapture": {
+ Request: {
+ payment_method: "card",
+ billing: {
+ address: {
+ line1: "1467",
+ line2: "CA",
+ line3: "CA",
+ city: "Musterhausen",
+ state: "California",
+ zip: "12345",
+ country: "DE",
+ first_name: "Max",
+ last_name: "Mustermann"
+ },
+ email: "[email protected]",
+ phone: {
+ number: "9123456789",
+ country_code: "+91"
+ }
+ },
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ },
+ //TODO: Add No3DSManualCapture, No3DSAutoCapture
+ // No3DSManualCapture: {
+ // Request: {
+ // payment_method: "card",
+ // payment_method_data: {
+ // card: successfulNo3DSCardDetails,
+ // },
+ // customer_acceptance: null,
+ // setup_future_usage: "on_session",
+ // },
+ // Response: {
+ // status: 200,
+ // body: {
+ // status: "requires_capture",
+ // },
+ // },
+ // },
+ // No3DSAutoCapture: {
+ // Request: {
+ // payment_method: "card",
+ // payment_method_data: {
+ // card: successfulNo3DSCardDetails,
+ // },
+ // customer_acceptance: null,
+ // setup_future_usage: "on_session",
+ // },
+ // Response: {
+ // status: 200,
+ // body: {
+ // status: "succeeded",
+ // },
+ // },
+ // },
+ Capture: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ customer_acceptance: null,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ amount: 6500,
+ amount_capturable: 0,
+ amount_received: 6500,
+ },
+ },
+ },
+ PartialCapture: {
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "partially_captured",
+ amount: 6500,
+ amount_capturable: 0,
+ amount_received: 100,
+ },
+ },
+ },
+ Void: {
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "cancelled",
+ },
+ },
+ },
+ Refund: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ customer_acceptance: null,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ PartialRefund: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ customer_acceptance: null,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ SyncRefund: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ customer_acceptance: null,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ },
+};
diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js b/cypress-tests/cypress/e2e/PaymentUtils/Utils.js
index 8c643f9cd8..03fc7fe972 100644
--- a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js
+++ b/cypress-tests/cypress/e2e/PaymentUtils/Utils.js
@@ -11,6 +11,7 @@ import { connectorDetails as fiservemeaConnectorDetails } from "./Fiservemea.js"
import { connectorDetails as iatapayConnectorDetails } from "./Iatapay.js";
import { connectorDetails as itaubankConnectorDetails } from "./ItauBank.js";
import { connectorDetails as nmiConnectorDetails } from "./Nmi.js";
+import { connectorDetails as novalnetConnectorDetails } from "./Novalnet.js";
import { connectorDetails as payboxConnectorDetails } from "./Paybox.js";
import { connectorDetails as paypalConnectorDetails } from "./Paypal.js";
import { connectorDetails as stripeConnectorDetails } from "./Stripe.js";
@@ -28,6 +29,7 @@ const connectorDetails = {
iatapay: iatapayConnectorDetails,
itaubank: itaubankConnectorDetails,
nmi: nmiConnectorDetails,
+ novalnet: novalnetConnectorDetails,
paybox: payboxConnectorDetails,
paypal: paypalConnectorDetails,
stripe: stripeConnectorDetails,
diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js
index 6540632c89..b493d11fee 100644
--- a/cypress-tests/cypress/support/redirectionHandler.js
+++ b/cypress-tests/cypress/support/redirectionHandler.js
@@ -320,6 +320,12 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) {
});
});
});
+ } else if (connectorId === "novalnet") {
+ cy.get("form", { timeout: WAIT_TIME })
+ .should("exist")
+ .then((form) => {
+ cy.get('input[id="submit"]').click();
+ });
} else if (connectorId === "stripe") {
cy.get("iframe", { timeout: TIMEOUT })
.its("0.contentDocument.body")