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): [Nomupay] Implement nomupay payouts flows (#6511)

Suman Maji501365c8dc16
diff --git a/Cargo.lock b/Cargo.lock
index b6b54a66a2..9c4861f263 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4014,7 +4014,7 @@ dependencies = [
"hyperswitch_domain_models",
"hyperswitch_interfaces",
"image",
- "josekit",
+ "josekit 0.8.6",
"lazy_static",
"masking",
"mime",
@@ -4494,6 +4494,23 @@ dependencies = [
"libc",
]
+[[package]]
+name = "josekit"
+version = "0.8.6"
+source = "git+https://github.com/sumanmaji4/josekit-rs.git?rev=5ab54876c29a84f86aef8c169413a46026883efe#5ab54876c29a84f86aef8c169413a46026883efe"
+dependencies = [
+ "anyhow",
+ "base64 0.21.7",
+ "flate2",
+ "once_cell",
+ "openssl",
+ "regex",
+ "serde",
+ "serde_json",
+ "thiserror",
+ "time",
+]
+
[[package]]
name = "josekit"
version = "0.8.7"
@@ -6603,7 +6620,7 @@ dependencies = [
"infer",
"iso_currency",
"isocountry",
- "josekit",
+ "josekit 0.8.7",
"jsonwebtoken",
"kgraph_utils",
"masking",
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index f81eca420a..082a554dd9 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -7425,6 +7425,7 @@
"nexinets",
"nexixpay",
"nmi",
+ "nomupay",
"noon",
"novalnet",
"nuvei",
@@ -17215,6 +17216,7 @@
"adyenplatform",
"cybersource",
"ebanx",
+ "nomupay",
"payone",
"paypal",
"stripe",
@@ -20029,6 +20031,7 @@
"nexinets",
"nexixpay",
"nmi",
+ "nomupay",
"noon",
"novalnet",
"nuvei",
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 56ade32524..7f7d97ce11 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -9615,6 +9615,7 @@
"nexinets",
"nexixpay",
"nmi",
+ "nomupay",
"noon",
"novalnet",
"nuvei",
@@ -21439,6 +21440,7 @@
"adyenplatform",
"cybersource",
"ebanx",
+ "nomupay",
"payone",
"paypal",
"stripe",
@@ -24536,6 +24538,7 @@
"nexinets",
"nexixpay",
"nmi",
+ "nomupay",
"noon",
"novalnet",
"nuvei",
diff --git a/config/development.toml b/config/development.toml
index ddd1a8bc96..aa63f76b88 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -674,7 +674,7 @@ nexixpay = { payment_method = "card" }
[connector_customer]
connector_list = "gocardless,stax,stripe"
-payout_connector_list = "stripe,wise"
+payout_connector_list = "nomupay,stripe,wise"
[dummy_connector]
enabled = true
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 4a1931632c..048bf6dd96 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -268,7 +268,6 @@ cards = [
"nexinets",
"nexixpay",
"nmi",
- "nomupay",
"noon",
"novalnet",
"nuvei",
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index f3c3f24245..d5606004d9 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -48,6 +48,7 @@ pub enum PayoutConnectors {
Adyenplatform,
Cybersource,
Ebanx,
+ Nomupay,
Payone,
Paypal,
Stripe,
@@ -62,6 +63,7 @@ impl From<PayoutConnectors> for RoutableConnectors {
PayoutConnectors::Adyenplatform => Self::Adyenplatform,
PayoutConnectors::Cybersource => Self::Cybersource,
PayoutConnectors::Ebanx => Self::Ebanx,
+ PayoutConnectors::Nomupay => Self::Nomupay,
PayoutConnectors::Payone => Self::Payone,
PayoutConnectors::Paypal => Self::Paypal,
PayoutConnectors::Stripe => Self::Stripe,
@@ -78,6 +80,7 @@ impl From<PayoutConnectors> for Connector {
PayoutConnectors::Adyenplatform => Self::Adyenplatform,
PayoutConnectors::Cybersource => Self::Cybersource,
PayoutConnectors::Ebanx => Self::Ebanx,
+ PayoutConnectors::Nomupay => Self::Nomupay,
PayoutConnectors::Payone => Self::Payone,
PayoutConnectors::Paypal => Self::Paypal,
PayoutConnectors::Stripe => Self::Stripe,
@@ -95,6 +98,7 @@ impl TryFrom<Connector> for PayoutConnectors {
Connector::Adyenplatform => Ok(Self::Adyenplatform),
Connector::Cybersource => Ok(Self::Cybersource),
Connector::Ebanx => Ok(Self::Ebanx),
+ Connector::Nomupay => Ok(Self::Nomupay),
Connector::Payone => Ok(Self::Payone),
Connector::Paypal => Ok(Self::Paypal),
Connector::Stripe => Ok(Self::Stripe),
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs
index c52bb6816d..47f2ddadc9 100644
--- a/crates/common_enums/src/connector_enums.rs
+++ b/crates/common_enums/src/connector_enums.rs
@@ -98,7 +98,7 @@ pub enum RoutableConnectors {
Nexinets,
Nexixpay,
Nmi,
- // Nomupay,
+ Nomupay,
Noon,
Novalnet,
Nuvei,
@@ -239,7 +239,7 @@ pub enum Connector {
Nexinets,
Nexixpay,
Nmi,
- // Nomupay,
+ Nomupay,
Noon,
Novalnet,
Nuvei,
@@ -289,6 +289,7 @@ impl Connector {
(Self::Paypal, Some(PayoutType::Wallet))
| (_, Some(PayoutType::Card))
| (Self::Adyenplatform, _)
+ | (Self::Nomupay, _)
)
}
#[cfg(feature = "payouts")]
@@ -309,7 +310,7 @@ impl Connector {
}
#[cfg(feature = "payouts")]
pub fn supports_vendor_disburse_account_create_for_payout(self) -> bool {
- matches!(self, Self::Stripe)
+ matches!(self, Self::Stripe | Self::Nomupay)
}
pub fn supports_access_token(self, payment_method: PaymentMethod) -> bool {
matches!(
@@ -389,7 +390,7 @@ impl Connector {
| Self::Multisafepay
| Self::Nexinets
| Self::Nexixpay
- // | Self::Nomupay
+ | Self::Nomupay
| Self::Novalnet
| Self::Nuvei
| Self::Opennode
@@ -519,6 +520,7 @@ impl From<RoutableConnectors> for Connector {
RoutableConnectors::Nexinets => Self::Nexinets,
RoutableConnectors::Nexixpay => Self::Nexixpay,
RoutableConnectors::Nmi => Self::Nmi,
+ RoutableConnectors::Nomupay => Self::Nomupay,
RoutableConnectors::Noon => Self::Noon,
RoutableConnectors::Novalnet => Self::Novalnet,
RoutableConnectors::Nuvei => Self::Nuvei,
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index 2d1d2e4ede..ff4152c514 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -209,6 +209,7 @@ pub struct ConnectorConfig {
pub nexinets: Option<ConnectorTomlConfig>,
pub nexixpay: Option<ConnectorTomlConfig>,
pub nmi: Option<ConnectorTomlConfig>,
+ pub nomupay_payout: Option<ConnectorTomlConfig>,
pub noon: Option<ConnectorTomlConfig>,
pub novalnet: Option<ConnectorTomlConfig>,
pub nuvei: Option<ConnectorTomlConfig>,
@@ -281,6 +282,7 @@ impl ConnectorConfig {
PayoutConnectors::Adyenplatform => Ok(connector_data.adyenplatform_payout),
PayoutConnectors::Cybersource => Ok(connector_data.cybersource_payout),
PayoutConnectors::Ebanx => Ok(connector_data.ebanx_payout),
+ PayoutConnectors::Nomupay => Ok(connector_data.nomupay_payout),
PayoutConnectors::Payone => Ok(connector_data.payone_payout),
PayoutConnectors::Paypal => Ok(connector_data.paypal_payout),
PayoutConnectors::Stripe => Ok(connector_data.stripe_payout),
@@ -375,6 +377,7 @@ impl ConnectorConfig {
Connector::Nexixpay => Ok(connector_data.nexixpay),
Connector::Prophetpay => Ok(connector_data.prophetpay),
Connector::Nmi => Ok(connector_data.nmi),
+ Connector::Nomupay => Err("Use get_payout_connector_config".to_string()),
Connector::Novalnet => Ok(connector_data.novalnet),
Connector::Noon => Ok(connector_data.noon),
Connector::Nuvei => Ok(connector_data.nuvei),
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index ba54730681..6e0297e2e1 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -4052,6 +4052,19 @@ key1 = "Adyen Account Id"
[stripe_payout.connector_auth.HeaderKey]
api_key = "Stripe API Key"
+[nomupay_payout]
+[[nomupay_payout.bank_transfer]]
+ payment_method_type = "sepa"
+[nomupay_payout.connector_auth.BodyKey]
+api_key = "Nomupay kid"
+key1 = "Nomupay eid"
+[nomupay_payout.metadata.private_key]
+name="Private key for signature generation"
+label="Enter your private key"
+placeholder="------BEGIN PRIVATE KEY-------"
+required=true
+type="Text"
+
[wise_payout]
[[wise_payout.bank_transfer]]
payment_method_type = "ach"
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index 88bba56c82..81a9d50c72 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -3475,4 +3475,17 @@ api_key="API Key"
api_key="API Key"
key1="API Token"
[inespay.connector_webhook_details]
-merchant_secret="API Key"
\ No newline at end of file
+merchant_secret="API Key"
+
+[nomupay_payout]
+[[nomupay_payout.bank_transfer]]
+ payment_method_type = "sepa"
+[nomupay_payout.connector_auth.BodyKey]
+api_key = "Nomupay kid"
+key1 = "Nomupay eid"
+[nomupay_payout.metadata.private_key]
+name="Private key for signature generation"
+label="Enter your private key"
+placeholder="------BEGIN PRIVATE KEY-------"
+required=true
+type="Text"
\ No newline at end of file
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index db440656fb..258d78969d 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -3992,6 +3992,19 @@ type="Text"
[stripe_payout.connector_auth.HeaderKey]
api_key = "Stripe API Key"
+[nomupay_payout]
+[[nomupay_payout.bank_transfer]]
+ payment_method_type = "sepa"
+[nomupay_payout.connector_auth.BodyKey]
+api_key = "Nomupay kid"
+key1 = "Nomupay eid"
+[nomupay_payout.metadata.private_key]
+name="Private key for signature generation"
+label="Enter your private key"
+placeholder="------BEGIN PRIVATE KEY-------"
+required=true
+type="Text"
+
[wise_payout]
[[wise_payout.bank_transfer]]
payment_method_type = "ach"
diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml
index 915b87a918..7785bf5721 100644
--- a/crates/hyperswitch_connectors/Cargo.toml
+++ b/crates/hyperswitch_connectors/Cargo.toml
@@ -22,7 +22,7 @@ error-stack = "0.4.1"
hex = "0.4.3"
http = "0.2.12"
image = { version = "0.25.1", default-features = false, features = ["png"] }
-josekit = "0.8.6"
+josekit = { git = "https://github.com/sumanmaji4/josekit-rs.git", rev = "5ab54876c29a84f86aef8c169413a46026883efe", features = ["support-empty-payload"]}
mime = "0.3.17"
once_cell = "1.19.0"
qrcode = "0.14.0"
diff --git a/crates/hyperswitch_connectors/src/connectors/nomupay.rs b/crates/hyperswitch_connectors/src/connectors/nomupay.rs
index 9ed1e501cf..a6a5b0357e 100644
--- a/crates/hyperswitch_connectors/src/connectors/nomupay.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nomupay.rs
@@ -1,10 +1,17 @@
pub mod transformers;
+use std::time::{Duration, SystemTime, UNIX_EPOCH};
+
use common_utils::{
errors::CustomResult,
ext_traits::BytesExt,
- request::{Method, Request, RequestBuilder, RequestContent},
- types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
+ pii,
+ request::{Method, RequestContent},
+};
+#[cfg(feature = "payouts")]
+use common_utils::{
+ request::{Request, RequestBuilder},
+ types::{AmountConvertor, FloatMajorUnit, FloatMajorUnitForConnector},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
@@ -20,37 +27,137 @@ use hyperswitch_domain_models::{
RefundsData, SetupMandateRequestData,
},
router_response_types::{PaymentsResponseData, RefundsResponseData},
- types::{
- PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
- RefundSyncRouterData, RefundsRouterData,
+};
+#[cfg(feature = "payouts")]
+use hyperswitch_domain_models::{
+ router_flow_types::payouts::{
+ PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount,
+ PoSync,
},
+ router_request_types::PayoutsData,
+ router_response_types::PayoutsResponseData,
+ types::PayoutsRouterData,
};
+#[cfg(feature = "payouts")]
+use hyperswitch_interfaces::types;
use hyperswitch_interfaces::{
api::{
- self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,
- ConnectorValidation,
+ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse,
+ ConnectorSpecifications, ConnectorValidation,
},
configs::Connectors,
+ consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE},
errors,
events::connector_api_logs::ConnectorEvent,
- types::{self, Response},
+ types::Response,
webhooks,
};
+use josekit::{
+ jws::{JwsHeader, ES256},
+ jwt::{self, JwtPayload},
+ Map, Value,
+};
use masking::{ExposeInterface, Mask};
+#[cfg(feature = "payouts")]
+use router_env::{instrument, tracing};
+use serde_json::json;
use transformers as nomupay;
-use crate::{constants::headers, types::ResponseRouterData, utils};
+use crate::{constants::headers, utils};
+#[cfg(feature = "payouts")]
+use crate::{types::ResponseRouterData, utils::RouterData as RouterDataTrait};
#[derive(Clone)]
pub struct Nomupay {
- amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
+ #[cfg(feature = "payouts")]
+ amount_converter: &'static (dyn AmountConvertor<Output = FloatMajorUnit> + Sync),
}
impl Nomupay {
pub fn new() -> &'static Self {
&Self {
- amount_converter: &StringMinorUnitForConnector,
+ #[cfg(feature = "payouts")]
+ amount_converter: &FloatMajorUnitForConnector,
+ }
+ }
+}
+
+fn get_private_key(
+ metadata: &Option<pii::SecretSerdeValue>,
+) -> Result<String, errors::ConnectorError> {
+ match nomupay::NomupayMetadata::try_from(metadata.as_ref()) {
+ Ok(nomupay_metadata) => Ok(nomupay_metadata.private_key.expose()),
+ Err(_e) => Err(errors::ConnectorError::NoConnectorMetaData),
+ }
+}
+
+fn box_to_jwt_payload(
+ body: Box<dyn masking::ErasedMaskSerialize + Send>,
+) -> CustomResult<JwtPayload, errors::ConnectorError> {
+ let str_result = serde_json::to_string(&body)
+ .change_context(errors::ConnectorError::ProcessingStepFailed(None))?;
+
+ let parsed_json: Map<String, Value> = serde_json::from_str(&str_result)
+ .change_context(errors::ConnectorError::ProcessingStepFailed(None))?;
+
+ let jwt_payload = JwtPayload::from_map(parsed_json)
+ .change_context(errors::ConnectorError::ProcessingStepFailed(None))?;
+
+ Ok(jwt_payload)
+}
+
+fn get_signature(
+ metadata: &Option<pii::SecretSerdeValue>,
+ auth: nomupay::NomupayAuthType,
+ body: RequestContent,
+ method: &str,
+ path: String,
+) -> CustomResult<String, errors::ConnectorError> {
+ match body {
+ RequestContent::Json(masked_json) => {
+ let expiration_time = SystemTime::now() + Duration::from_secs(4 * 60);
+ let expires_in = match expiration_time.duration_since(UNIX_EPOCH) {
+ Ok(duration) => duration.as_secs(),
+ Err(_e) => 0,
+ };
+
+ let mut option_map = Map::new();
+ option_map.insert("alg".to_string(), json!(format!("ES256")));
+ option_map.insert("aud".to_string(), json!(format!("{} {}", method, path)));
+ option_map.insert("exp".to_string(), json!(expires_in));
+ option_map.insert("kid".to_string(), json!(auth.kid));
+
+ let header = JwsHeader::from_map(option_map)
+ .change_context(errors::ConnectorError::ProcessingStepFailed(None))?;
+
+ let payload = match method {
+ "GET" => JwtPayload::new(),
+ _ => box_to_jwt_payload(masked_json)
+ .change_context(errors::ConnectorError::ProcessingStepFailed(None))?,
+ };
+
+ let private_key = get_private_key(metadata)?;
+
+ let signer = ES256
+ .signer_from_pem(&private_key)
+ .change_context(errors::ConnectorError::ProcessingStepFailed(None))?;
+
+ let nomupay_jwt = jwt::encode_with_signer(&payload, &header, &signer)
+ .change_context(errors::ConnectorError::ProcessingStepFailed(None))?;
+
+ let jws_blocks: Vec<&str> = nomupay_jwt.split('.').collect();
+
+ let jws_detached = jws_blocks
+ .first()
+ .zip(jws_blocks.get(2))
+ .map(|(first, third)| format!("{}..{}", first, third))
+ .ok_or_else(|| errors::ConnectorError::MissingRequiredField {
+ field_name: "JWS blocks not sufficient for detached payload",
+ })?;
+
+ Ok(jws_detached)
}
+ _ => Err(errors::ConnectorError::ProcessingStepFailed(None).into()),
}
}
@@ -70,7 +177,6 @@ impl api::PaymentToken for Nomupay {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
for Nomupay
{
- // Not Implemented (R)
}
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Nomupay
@@ -80,18 +186,49 @@ where
fn build_headers(
&self,
req: &RouterData<Flow, Request, Response>,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ let is_post_req = matches!(self.get_http_method(), Method::Post);
+ let body = self.get_request_body(req, connectors)?;
+ let auth = nomupay::NomupayAuthType::try_from(&req.connector_auth_type)
+ .change_context(errors::ConnectorError::FailedToObtainAuthType)?;
+ let base_url = connectors.nomupay.base_url.as_str();
+ let path: String = self
+ .get_url(req, connectors)?
+ .chars()
+ .skip(base_url.len())
+ .collect();
+ let req_method = if is_post_req { "POST" } else { "GET" };
+
+ let sign = get_signature(&req.connector_meta_data, auth, body, req_method, path)?;
+
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
self.get_content_type().to_string().into(),
)];
+ header.push((
+ headers::X_SIGNATURE.to_string(),
+ masking::Maskable::Normal(sign),
+ ));
+
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut api_key);
+
Ok(header)
}
}
+impl TryFrom<Option<&pii::SecretSerdeValue>> for nomupay::NomupayMetadata {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(meta_data: Option<&pii::SecretSerdeValue>) -> Result<Self, Self::Error> {
+ let metadata: Self = utils::to_connector_meta_from_secret::<Self>(meta_data.cloned())
+ .change_context(errors::ConnectorError::InvalidConnectorConfig {
+ config: "metadata",
+ })?;
+ Ok(metadata)
+ }
+}
+
impl ConnectorCommon for Nomupay {
fn id(&self) -> &'static str {
"nomupay"
@@ -99,9 +236,6 @@ impl ConnectorCommon for 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 {
@@ -120,7 +254,7 @@ impl ConnectorCommon for Nomupay {
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
- auth.api_key.expose().into_masked(),
+ auth.kid.expose().into_masked(),
)])
}
@@ -137,100 +271,166 @@ impl ConnectorCommon for Nomupay {
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,
- })
+ match (
+ response.status,
+ response.code,
+ response.error,
+ response.status_code,
+ response.detail,
+ ) {
+ (Some(status), Some(code), _, _, _) => Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: code.to_string(),
+ message: status,
+ reason: None,
+ attempt_status: None,
+ connector_transaction_id: None,
+ }),
+ (None, None, Some(nomupay_inner_error), _, _) => {
+ match (
+ nomupay_inner_error.error_description,
+ nomupay_inner_error.validation_errors,
+ ) {
+ (Some(error_description), _) => Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: nomupay_inner_error.error_code,
+ message: error_description,
+ reason: None,
+ attempt_status: None,
+ connector_transaction_id: None,
+ }),
+ (_, Some(validation_errors)) => Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: nomupay_inner_error.error_code,
+ message: validation_errors
+ .first()
+ .map(|m| m.message.clone())
+ .unwrap_or_default(),
+ reason: Some(
+ validation_errors
+ .first()
+ .map(|m| m.field.clone())
+ .unwrap_or_default(),
+ ),
+ attempt_status: None,
+ connector_transaction_id: None,
+ }),
+ (None, None) => Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: NO_ERROR_CODE.to_string(),
+ message: NO_ERROR_MESSAGE.to_string(),
+ reason: None,
+ attempt_status: None,
+ connector_transaction_id: None,
+ }),
+ }
+ }
+ (None, None, None, Some(status_code), Some(detail)) => Ok(ErrorResponse {
+ status_code,
+ code: detail
+ .get(1)
+ .map(|d| d.error_type.clone())
+ .unwrap_or_default(),
+ message: status_code.to_string(),
+ reason: None,
+ attempt_status: None,
+ connector_transaction_id: None,
+ }),
+ _ => Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: NO_ERROR_CODE.to_string(),
+ message: NO_ERROR_MESSAGE.to_string(),
+ reason: None,
+ attempt_status: None,
+ connector_transaction_id: None,
+ }),
+ }
}
}
-impl ConnectorValidation for Nomupay {
- //TODO: implement functions when support enabled
-}
-
-impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Nomupay {
- //TODO: implement sessions flow
-}
+impl ConnectorValidation for Nomupay {}
+impl ConnectorRedirectResponse for Nomupay {}
+impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Nomupay {}
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Nomupay {}
-
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Nomupay {}
+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Nomupay {}
+impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Nomupay {}
+impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Nomupay {}
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Nomupay {}
+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Nomupay {}
+impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Nomupay {}
+
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoQuote, PayoutsData, PayoutsResponseData> for Nomupay {}
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoCreate, PayoutsData, PayoutsResponseData> for Nomupay {}
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoCancel, PayoutsData, PayoutsResponseData> for Nomupay {}
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoEligibility, PayoutsData, PayoutsResponseData> for Nomupay {}
+
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoSync, PayoutsData, PayoutsResponseData> for Nomupay {
+ fn get_url(
+ &self,
+ req: &PayoutsRouterData<PoSync>,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ let nomupay_payout_id = req
+ .request
+ .connector_payout_id
+ .clone()
+ .ok_or_else(utils::missing_field_err("connector_payout_id"))?;
+ Ok(format!(
+ "{}/v1alpha1/payments/{}",
+ self.base_url(connectors),
+ nomupay_payout_id
+ ))
+ }
-impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Nomupay {
fn get_headers(
&self,
- req: &PaymentsAuthorizeRouterData,
+ req: &PayoutsRouterData<PoSync>,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
- fn get_content_type(&self) -> &'static str {
- self.common_get_content_type()
- }
-
- fn get_url(
- &self,
- _req: &PaymentsAuthorizeRouterData,
- _connectors: &Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
- }
-
- fn get_request_body(
- &self,
- req: &PaymentsAuthorizeRouterData,
- _connectors: &Connectors,
- ) -> CustomResult<RequestContent, errors::ConnectorError> {
- let amount = utils::convert_amount(
- self.amount_converter,
- req.request.minor_amount,
- req.request.currency,
- )?;
-
- let connector_router_data = nomupay::NomupayRouterData::from((amount, req));
- let connector_req = nomupay::NomupayPaymentsRequest::try_from(&connector_router_data)?;
- Ok(RequestContent::Json(Box::new(connector_req)))
+ fn get_http_method(&self) -> Method {
+ Method::Get
}
fn build_request(
&self,
- req: &PaymentsAuthorizeRouterData,
+ req: &PayoutsRouterData<PoSync>,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
- Ok(Some(
- RequestBuilder::new()
- .method(Method::Post)
- .url(&types::PaymentsAuthorizeType::get_url(
- self, req, connectors,
- )?)
- .attach_default_headers()
- .headers(types::PaymentsAuthorizeType::get_headers(
- self, req, connectors,
- )?)
- .set_body(types::PaymentsAuthorizeType::get_request_body(
- self, req, connectors,
- )?)
- .build(),
- ))
+ let request = RequestBuilder::new()
+ .method(Method::Get)
+ .url(&types::PayoutSyncType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PayoutSyncType::get_headers(self, req, connectors)?)
+ .build();
+
+ Ok(Some(request))
}
+ #[instrument(skip_all)]
fn handle_response(
&self,
- data: &PaymentsAuthorizeRouterData,
+ data: &PayoutsRouterData<PoSync>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
- let response: nomupay::NomupayPaymentsResponse = res
+ ) -> CustomResult<PayoutsRouterData<PoSync>, errors::ConnectorError> {
+ let response: nomupay::NomupayPaymentResponse = res
.response
- .parse_struct("Nomupay PaymentsAuthorizeResponse")
+ .parse_struct("NomupayPaymentResponse")
.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(),
@@ -247,131 +447,89 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
}
}
-impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Nomupay {
- fn get_headers(
- &self,
- req: &PaymentsSyncRouterData,
- connectors: &Connectors,
- ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- self.build_headers(req, connectors)
- }
-
- fn get_content_type(&self) -> &'static str {
- self.common_get_content_type()
- }
-
+#[cfg(feature = "payouts")]
+impl api::Payouts for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutCancel for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutCreate for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutEligibility for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutFulfill for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutQuote for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutRecipient for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutRecipientAccount for Nomupay {}
+#[cfg(feature = "payouts")]
+impl api::PayoutSync for Nomupay {}
+
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoRecipient, PayoutsData, PayoutsResponseData> for Nomupay {
fn get_url(
&self,
- _req: &PaymentsSyncRouterData,
- _connectors: &Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
- }
-
- fn build_request(
- &self,
- req: &PaymentsSyncRouterData,
+ _req: &PayoutsRouterData<PoRecipient>,
connectors: &Connectors,
- ) -> CustomResult<Option<Request>, errors::ConnectorError> {
- Ok(Some(
- RequestBuilder::new()
- .method(Method::Get)
- .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
- .attach_default_headers()
- .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
- .build(),
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!(
+ "{}/v1alpha1/sub-account",
+ connectors.nomupay.base_url
))
}
- fn handle_response(
- &self,
- data: &PaymentsSyncRouterData,
- event_builder: Option<&mut ConnectorEvent>,
- res: Response,
- ) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
- 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<ErrorResponse, errors::ConnectorError> {
- self.build_error_response(res, event_builder)
- }
-}
-
-impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Nomupay {
fn get_headers(
&self,
- req: &PaymentsCaptureRouterData,
+ req: &PayoutsRouterData<PoRecipient>,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
- fn get_content_type(&self) -> &'static str {
- self.common_get_content_type()
- }
-
- fn get_url(
- &self,
- _req: &PaymentsCaptureRouterData,
- _connectors: &Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
- }
-
fn get_request_body(
&self,
- _req: &PaymentsCaptureRouterData,
+ req: &PayoutsRouterData<PoRecipient>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
+ let connector_req = nomupay::OnboardSubAccountRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
- req: &PaymentsCaptureRouterData,
+ req: &PayoutsRouterData<PoRecipient>,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
- Ok(Some(
- RequestBuilder::new()
- .method(Method::Post)
- .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
- .attach_default_headers()
- .headers(types::PaymentsCaptureType::get_headers(
- self, req, connectors,
- )?)
- .set_body(types::PaymentsCaptureType::get_request_body(
- self, req, connectors,
- )?)
- .build(),
- ))
+ let request = RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PayoutRecipientType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PayoutRecipientType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::PayoutRecipientType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build();
+
+ Ok(Some(request))
}
fn handle_response(
&self,
- data: &PaymentsCaptureRouterData,
+ data: &PayoutsRouterData<PoRecipient>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
- let response: nomupay::NomupayPaymentsResponse = res
+ ) -> CustomResult<PayoutsRouterData<PoRecipient>, errors::ConnectorError> {
+ let response: nomupay::OnboardSubAccountResponse = res
.response
- .parse_struct("Nomupay PaymentsCaptureResponse")
+ .parse_struct("OnboardSubAccountResponse")
.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(),
@@ -388,76 +546,74 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
}
}
-impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Nomupay {}
-
-impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Nomupay {
- fn get_headers(
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoRecipientAccount, PayoutsData, PayoutsResponseData> for Nomupay {
+ fn get_url(
&self,
- req: &RefundsRouterData<Execute>,
+ req: &PayoutsRouterData<PoRecipientAccount>,
connectors: &Connectors,
- ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- self.build_headers(req, connectors)
- }
+ ) -> CustomResult<String, errors::ConnectorError> {
+ let sid = req.get_connector_customer_id()?;
- fn get_content_type(&self) -> &'static str {
- self.common_get_content_type()
+ Ok(format!(
+ "{}/v1alpha1/sub-account/{}/transfer-method",
+ connectors.nomupay.base_url, sid
+ ))
}
- fn get_url(
+ fn get_headers(
&self,
- _req: &RefundsRouterData<Execute>,
- _connectors: &Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ req: &PayoutsRouterData<PoRecipientAccount>,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
}
fn get_request_body(
&self,
- req: &RefundsRouterData<Execute>,
+ req: &PayoutsRouterData<PoRecipientAccount>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let refund_amount = utils::convert_amount(
- self.amount_converter,
- req.request.minor_refund_amount,
- req.request.currency,
- )?;
-
- let connector_router_data = nomupay::NomupayRouterData::from((refund_amount, req));
- let connector_req = nomupay::NomupayRefundRequest::try_from(&connector_router_data)?;
+ let connector_req = nomupay::OnboardTransferMethodRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
- req: &RefundsRouterData<Execute>,
+ req: &PayoutsRouterData<PoRecipientAccount>,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
let request = RequestBuilder::new()
.method(Method::Post)
- .url(&types::RefundExecuteType::get_url(self, req, connectors)?)
+ .url(&types::PayoutRecipientAccountType::get_url(
+ self, req, connectors,
+ )?)
.attach_default_headers()
- .headers(types::RefundExecuteType::get_headers(
+ .headers(types::PayoutRecipientAccountType::get_headers(
self, req, connectors,
)?)
- .set_body(types::RefundExecuteType::get_request_body(
+ .set_body(types::PayoutRecipientAccountType::get_request_body(
self, req, connectors,
)?)
.build();
+
Ok(Some(request))
}
fn handle_response(
&self,
- data: &RefundsRouterData<Execute>,
+ data: &PayoutsRouterData<PoRecipientAccount>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
- let response: nomupay::RefundResponse = res
+ ) -> CustomResult<PayoutsRouterData<PoRecipientAccount>, errors::ConnectorError> {
+ let response: nomupay::OnboardTransferMethodResponse = res
.response
- .parse_struct("nomupay RefundResponse")
+ .parse_struct("OnboardTransferMethodResponse")
.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(),
@@ -474,57 +630,73 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Nomupay
}
}
-impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Nomupay {
+#[cfg(feature = "payouts")]
+impl ConnectorIntegration<PoFulfill, PayoutsData, PayoutsResponseData> for Nomupay {
+ fn get_url(
+ &self,
+ _req: &PayoutsRouterData<PoFulfill>,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!("{}/v1alpha1/payments", connectors.nomupay.base_url))
+ }
+
fn get_headers(
&self,
- req: &RefundSyncRouterData,
+ req: &PayoutsRouterData<PoFulfill>,
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(
+ fn get_request_body(
&self,
- _req: &RefundSyncRouterData,
+ req: &PayoutsRouterData<PoFulfill>,
_connectors: &Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount,
+ req.request.destination_currency,
+ )?;
+ let connector_req = nomupay::NomupayPaymentRequest::try_from((req, amount))?;
+
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
- req: &RefundSyncRouterData,
+ req: &PayoutsRouterData<PoFulfill>,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
- Ok(Some(
- RequestBuilder::new()
- .method(Method::Get)
- .url(&types::RefundSyncType::get_url(self, req, connectors)?)
- .attach_default_headers()
- .headers(types::RefundSyncType::get_headers(self, req, connectors)?)
- .set_body(types::RefundSyncType::get_request_body(
- self, req, connectors,
- )?)
- .build(),
- ))
+ let request = RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PayoutFulfillType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PayoutFulfillType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::PayoutFulfillType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build();
+
+ Ok(Some(request))
}
fn handle_response(
&self,
- data: &RefundSyncRouterData,
+ data: &PayoutsRouterData<PoFulfill>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
- ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
- let response: nomupay::RefundResponse = res
+ ) -> CustomResult<PayoutsRouterData<PoFulfill>, errors::ConnectorError> {
+ let response: nomupay::NomupayPaymentResponse = res
.response
- .parse_struct("nomupay RefundSyncResponse")
+ .parse_struct("NomupayPaymentResponse")
.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(),
diff --git a/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs
index 93b3800157..9a1a50e864 100644
--- a/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs
@@ -1,30 +1,30 @@
-use common_enums::enums;
-use common_utils::types::StringMinorUnit;
+#[cfg(feature = "payouts")]
+use common_enums::enums::PayoutEntityType;
+use common_enums::{enums, Currency, PayoutStatus};
+use common_utils::{pii::Email, types::FloatMajorUnit};
+use hyperswitch_domain_models::router_data::ConnectorAuthType;
+#[cfg(feature = "payouts")]
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},
+ router_response_types::PayoutsResponseData, types::PayoutsRouterData,
};
use hyperswitch_interfaces::errors;
use masking::Secret;
use serde::{Deserialize, Serialize};
-use crate::{
- types::{RefundsResponseRouterData, ResponseRouterData},
- utils::PaymentsAuthorizeRequestData,
-};
+#[cfg(feature = "payouts")]
+use crate::utils::PayoutFulfillRequestData;
+#[cfg(feature = "payouts")]
+use crate::{types::PayoutsResponseRouterData, utils::RouterData as UtilsRouterData};
+
+pub const PURPOSE_OF_PAYMENT_IS_OTHER: &str = "OTHER";
-//TODO: Fill the struct with respective fields
pub struct NomupayRouterData<T> {
- pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
+ pub amount: FloatMajorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
pub router_data: T,
}
-impl<T> From<(StringMinorUnit, T)> for NomupayRouterData<T> {
- fn from((amount, item): (StringMinorUnit, T)) -> Self {
+impl<T> From<(FloatMajorUnit, T)> for NomupayRouterData<T> {
+ fn from((amount, item): (FloatMajorUnit, T)) -> Self {
//Todo : use utils to convert the amount to the type of amount that a connector accepts
Self {
amount,
@@ -33,196 +33,500 @@ impl<T> From<(StringMinorUnit, T)> for NomupayRouterData<T> {
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, PartialEq)]
-pub struct NomupayPaymentsRequest {
- amount: StringMinorUnit,
- card: NomupayCard,
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct Address {
+ pub country: enums::CountryAlpha2,
+ pub state_province: Secret<String>,
+ pub street: Secret<String>,
+ pub city: String,
+ pub postal_code: Secret<String>,
}
-#[derive(Default, Debug, Serialize, Eq, PartialEq)]
-pub struct NomupayCard {
- number: cards::CardNumber,
- expiry_month: Secret<String>,
- expiry_year: Secret<String>,
- cvc: Secret<String>,
- complete: bool,
+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum ProfileType {
+ #[default]
+ Individual,
+ Businness,
}
-impl TryFrom<&NomupayRouterData<&PaymentsAuthorizeRouterData>> for NomupayPaymentsRequest {
- type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(
- item: &NomupayRouterData<&PaymentsAuthorizeRouterData>,
- ) -> Result<Self, Self::Error> {
- 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()),
+#[cfg(feature = "payouts")]
+impl From<PayoutEntityType> for ProfileType {
+ fn from(entity: PayoutEntityType) -> Self {
+ match entity {
+ PayoutEntityType::Personal
+ | PayoutEntityType::NaturalPerson
+ | PayoutEntityType::Individual => Self::Individual,
+ _ => Self::Businness,
}
}
}
-//TODO: Fill the struct with respective fields
-// Auth Struct
+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
+pub enum NomupayGender {
+ Male,
+ Female,
+ #[default]
+ Other,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct Profile {
+ pub profile_type: ProfileType,
+ pub first_name: Secret<String>,
+ pub last_name: Secret<String>,
+ pub date_of_birth: Secret<String>,
+ pub gender: NomupayGender,
+ pub email_address: Email,
+ pub phone_number_country_code: Option<String>,
+ pub phone_number: Option<Secret<String>>,
+ pub address: Address,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct OnboardSubAccountRequest {
+ pub account_id: Secret<String>,
+ pub client_sub_account_id: Secret<String>,
+ pub profile: Profile,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct BankAccount {
+ pub bank_id: Option<Secret<String>>,
+ pub account_id: Secret<String>,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct VirtualAccountsType {
+ pub country_code: String,
+ pub currency_code: String,
+ pub bank_id: Secret<String>,
+ pub bank_account_id: Secret<String>,
+}
+
+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum TransferMethodType {
+ #[default]
+ BankAccount,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct OnboardTransferMethodRequest {
+ pub country_code: enums::CountryAlpha2,
+ pub currency_code: Currency,
+ #[serde(rename = "type")]
+ pub transfer_method_type: TransferMethodType,
+ pub display_name: Secret<String>,
+ pub bank_account: BankAccount,
+ pub profile: Profile,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct NomupayPaymentRequest {
+ pub source_id: Secret<String>,
+ pub destination_id: Secret<String>,
+ pub payment_reference: String,
+ pub amount: FloatMajorUnit,
+ pub currency_code: Currency,
+ pub purpose: String,
+ pub description: Option<String>,
+ pub internal_memo: Option<String>,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct QuoteRequest {
+ pub source_id: Secret<String>,
+ pub source_currency_code: Currency,
+ pub destination_currency_code: Currency,
+ pub amount: FloatMajorUnit,
+ pub include_fee: String,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct CommitRequest {
+ pub source_id: Secret<String>,
+ pub id: String,
+ pub destination_id: Secret<String>,
+ pub payment_reference: String,
+ pub amount: FloatMajorUnit,
+ pub currency_code: Currency,
+ pub purpose: String,
+ pub description: String,
+ pub internal_memo: String,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct OnboardSubAccountResponse {
+ pub account_id: Secret<String>,
+ pub id: String,
+ pub client_sub_account_id: Secret<String>,
+ pub profile: Profile,
+ pub virtual_accounts: Vec<VirtualAccountsType>,
+ pub status: String,
+ pub created_on: String,
+ pub last_updated: String,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct OnboardTransferMethodResponse {
+ pub parent_id: Secret<String>,
+ pub account_id: Secret<String>,
+ pub sub_account_id: Secret<String>,
+ pub id: String,
+ pub status: String,
+ pub created_on: String,
+ pub last_updated: String,
+ pub country_code: String,
+ pub currency_code: Currency,
+ pub display_name: String,
+ #[serde(rename = "type")]
+ pub transfer_method_type: String,
+ pub profile: Profile,
+ pub bank_account: BankAccount,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct NomupayPaymentResponse {
+ pub id: String,
+ pub status: NomupayPaymentStatus,
+ pub created_on: String,
+ pub last_updated: String,
+ pub source_id: Secret<String>,
+ pub destination_id: Secret<String>,
+ pub payment_reference: String,
+ pub amount: FloatMajorUnit,
+ pub currency_code: String,
+ pub purpose: String,
+ pub description: String,
+ pub internal_memo: String,
+ pub release_on: String,
+ pub expire_on: String,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct FeesType {
+ #[serde(rename = "type")]
+ pub fees_type: String,
+ pub fees: FloatMajorUnit,
+ pub currency_code: Currency,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct PayoutQuoteResponse {
+ pub source_id: Secret<String>,
+ pub destination_currency_code: Currency,
+ pub amount: FloatMajorUnit,
+ pub source_currency_code: Currency,
+ pub include_fee: bool,
+ pub fees: Vec<FeesType>,
+ pub payment_reference: String,
+}
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct CommitResponse {
+ pub id: String,
+ pub status: String,
+ pub created_on: String,
+ pub last_updated: String,
+ pub source_id: Secret<String>,
+ pub destination_id: Secret<String>,
+ pub payment_reference: String,
+ pub amount: FloatMajorUnit,
+ pub currency_code: Currency,
+ pub purpose: String,
+ pub description: String,
+ pub internal_memo: String,
+ pub release_on: String,
+ pub expire_on: String,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+pub struct NomupayMetadata {
+ pub private_key: Secret<String>,
+}
+
+#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "camelCase")]
+pub struct ValidationError {
+ pub field: String,
+ pub message: String,
+}
+
+#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "camelCase")]
+pub struct DetailsType {
+ pub loc: Vec<String>,
+ #[serde(rename = "type")]
+ pub error_type: String,
+}
+
+#[derive(Debug, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "camelCase")]
+pub struct NomupayInnerError {
+ pub error_code: String,
+ pub error_description: Option<String>,
+ pub validation_errors: Option<Vec<ValidationError>>,
+}
+
+#[derive(Debug, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "camelCase")]
+pub struct NomupayErrorResponse {
+ pub status: Option<String>,
+ pub code: Option<u64>,
+ pub error: Option<NomupayInnerError>,
+ pub status_code: Option<u16>,
+ pub detail: Option<Vec<DetailsType>>,
+}
+
pub struct NomupayAuthType {
- pub(super) api_key: Secret<String>,
+ pub(super) kid: Secret<String>,
+ #[cfg(feature = "payouts")]
+ pub(super) eid: Secret<String>,
}
impl TryFrom<&ConnectorAuthType> for NomupayAuthType {
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(),
+ #[cfg(feature = "payouts")]
+ ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {
+ kid: api_key.to_owned(),
+ eid: key1.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")]
+#[serde(rename_all = "UPPERCASE")]
pub enum NomupayPaymentStatus {
- Succeeded,
+ Pending,
+ Processed,
Failed,
#[default]
Processing,
+ Scheduled,
+ PendingAccountActivation,
+ PendingTransferMethodCreation,
+ PendingAccountKyc,
}
-impl From<NomupayPaymentStatus> for common_enums::AttemptStatus {
+impl From<NomupayPaymentStatus> for PayoutStatus {
fn from(item: NomupayPaymentStatus) -> Self {
match item {
- NomupayPaymentStatus::Succeeded => Self::Charged,
- NomupayPaymentStatus::Failed => Self::Failure,
- NomupayPaymentStatus::Processing => Self::Authorizing,
+ NomupayPaymentStatus::Processed => Self::Success,
+ NomupayPaymentStatus::Failed => Self::Failed,
+ NomupayPaymentStatus::Processing
+ | NomupayPaymentStatus::Pending
+ | NomupayPaymentStatus::Scheduled
+ | NomupayPaymentStatus::PendingAccountActivation
+ | NomupayPaymentStatus::PendingTransferMethodCreation
+ | NomupayPaymentStatus::PendingAccountKyc => Self::Pending,
}
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
-pub struct NomupayPaymentsResponse {
- status: NomupayPaymentStatus,
- id: String,
+#[cfg(feature = "payouts")]
+fn get_profile<F>(
+ item: &PayoutsRouterData<F>,
+ entity_type: PayoutEntityType,
+) -> Result<Profile, error_stack::Report<errors::ConnectorError>> {
+ let my_address = Address {
+ country: item.get_billing_country()?,
+ state_province: item.get_billing_state()?,
+ street: item.get_billing_line1()?,
+ city: item.get_billing_city()?,
+ postal_code: item.get_billing_zip()?,
+ };
+
+ Ok(Profile {
+ profile_type: ProfileType::from(entity_type),
+ first_name: item.get_billing_first_name()?,
+ last_name: item.get_billing_last_name()?,
+ date_of_birth: Secret::new("1991-01-01".to_string()), // Query raised with Nomupay regarding why this field is required
+ gender: NomupayGender::Other, // Query raised with Nomupay regarding why this field is required
+ email_address: item.get_billing_email()?,
+ phone_number_country_code: item
+ .get_billing_phone()
+ .map(|phone| phone.country_code.clone())?,
+ phone_number: Some(item.get_billing_phone_number()?),
+ address: my_address,
+ })
}
-impl<F, T> TryFrom<ResponseRouterData<F, NomupayPaymentsResponse, T, PaymentsResponseData>>
- for RouterData<F, T, PaymentsResponseData>
-{
+// PoRecipient Request
+#[cfg(feature = "payouts")]
+impl<F> TryFrom<&PayoutsRouterData<F>> for OnboardSubAccountRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &PayoutsRouterData<F>) -> Result<Self, Self::Error> {
+ let request = item.request.to_owned();
+ let payout_type = request.payout_type;
+
+ let profile = get_profile(item, request.entity_type)?;
+
+ let nomupay_auth_type = NomupayAuthType::try_from(&item.connector_auth_type)?;
+
+ match payout_type {
+ Some(common_enums::PayoutType::Bank) => Ok(Self {
+ account_id: nomupay_auth_type.eid,
+ client_sub_account_id: Secret::new(request.payout_id),
+ profile,
+ }),
+ _ => Err(errors::ConnectorError::NotImplemented(
+ "This payment method is not implemented for Nomupay".to_string(),
+ )
+ .into()),
+ }
+ }
+}
+
+// PoRecipient Response
+#[cfg(feature = "payouts")]
+impl<F> TryFrom<PayoutsResponseRouterData<F, OnboardSubAccountResponse>> for PayoutsRouterData<F> {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: ResponseRouterData<F, NomupayPaymentsResponse, T, PaymentsResponseData>,
+ item: PayoutsResponseRouterData<F, OnboardSubAccountResponse>,
) -> Result<Self, Self::Error> {
+ let response: OnboardSubAccountResponse = item.response;
+
Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status),
- response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(item.response.id),
- redirection_data: Box::new(None),
- mandate_reference: Box::new(None),
- connector_metadata: None,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- charges: None,
+ response: Ok(PayoutsResponseData {
+ status: Some(PayoutStatus::RequiresVendorAccountCreation),
+ connector_payout_id: Some(response.id.to_string()),
+ payout_eligible: None,
+ should_add_next_step_to_process_tracker: false,
+ error_code: None,
+ error_message: 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<F> TryFrom<&NomupayRouterData<&RefundsRouterData<F>>> for NomupayRefundRequest {
+// PoRecipientAccount Request
+#[cfg(feature = "payouts")]
+impl<F> TryFrom<&PayoutsRouterData<F>> for OnboardTransferMethodRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &NomupayRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
- Ok(Self {
- amount: item.amount.to_owned(),
- })
- }
-}
+ fn try_from(item: &PayoutsRouterData<F>) -> Result<Self, Self::Error> {
+ let payout_method_data = item.get_payout_method_data()?;
+ match payout_method_data {
+ api_models::payouts::PayoutMethodData::Bank(bank) => match bank {
+ api_models::payouts::Bank::Sepa(bank_details) => {
+ let bank_account = BankAccount {
+ bank_id: bank_details.bic,
+ account_id: bank_details.iban,
+ };
-// Type definition for Refund Response
+ let country_iso2_code = item
+ .get_billing_country()
+ .unwrap_or(enums::CountryAlpha2::CA);
-#[allow(dead_code)]
-#[derive(Debug, Serialize, Default, Deserialize, Clone)]
-pub enum RefundStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
-}
+ let profile = get_profile(item, item.request.entity_type)?;
-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
+ Ok(Self {
+ country_code: country_iso2_code,
+ currency_code: item.request.destination_currency,
+ transfer_method_type: TransferMethodType::BankAccount,
+ display_name: item.get_billing_full_name()?,
+ bank_account,
+ profile,
+ })
+ }
+ other_bank => Err(errors::ConnectorError::NotSupported {
+ message: format!("{:?} is not supported", other_bank),
+ connector: "nomupay",
+ }
+ .into()),
+ },
+ _ => Err(errors::ConnectorError::NotImplemented(
+ "This payment method is not implemented for Nomupay".to_string(),
+ )
+ .into()),
}
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize)]
-pub struct RefundResponse {
- id: String,
- status: RefundStatus,
-}
-
-impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
+// PoRecipientAccount response
+#[cfg(feature = "payouts")]
+impl<F> TryFrom<PayoutsResponseRouterData<F, OnboardTransferMethodResponse>>
+ for PayoutsRouterData<F>
+{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<Execute, RefundResponse>,
+ item: PayoutsResponseRouterData<F, OnboardTransferMethodResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
+ response: Ok(PayoutsResponseData {
+ status: Some(PayoutStatus::RequiresCreation),
+ connector_payout_id: Some(item.response.id),
+ payout_eligible: None,
+ should_add_next_step_to_process_tracker: false,
+ error_code: None,
+ error_message: None,
}),
..item.data
})
}
}
-impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
+// PoFulfill Request
+#[cfg(feature = "payouts")]
+impl<F> TryFrom<(&PayoutsRouterData<F>, FloatMajorUnit)> for NomupayPaymentRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<RSync, RefundResponse>,
+ (item, amount): (&PayoutsRouterData<F>, FloatMajorUnit),
) -> Result<Self, Self::Error> {
+ let nomupay_auth_type = NomupayAuthType::try_from(&item.connector_auth_type)?;
+ let destination = item.request.clone().get_connector_transfer_method_id()?;
+
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
- ..item.data
+ source_id: nomupay_auth_type.eid,
+ destination_id: Secret::new(destination),
+ payment_reference: item.request.clone().payout_id,
+ amount,
+ currency_code: item.request.destination_currency,
+ purpose: PURPOSE_OF_PAYMENT_IS_OTHER.to_string(),
+ description: item.description.clone(),
+ internal_memo: item.description.clone(),
})
}
}
-//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<String>,
+// PoFulfill response
+#[cfg(feature = "payouts")]
+impl<F> TryFrom<PayoutsResponseRouterData<F, NomupayPaymentResponse>> for PayoutsRouterData<F> {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: PayoutsResponseRouterData<F, NomupayPaymentResponse>,
+ ) -> Result<Self, Self::Error> {
+ let response: NomupayPaymentResponse = item.response;
+
+ Ok(Self {
+ response: Ok(PayoutsResponseData {
+ status: Some(PayoutStatus::from(response.status)),
+ connector_payout_id: Some(response.id),
+ payout_eligible: None,
+ should_add_next_step_to_process_tracker: false,
+ error_code: None,
+ error_message: None,
+ }),
+ ..item.data
+ })
+ }
}
diff --git a/crates/hyperswitch_connectors/src/constants.rs b/crates/hyperswitch_connectors/src/constants.rs
index b41dcf3422..bf2f4c2584 100644
--- a/crates/hyperswitch_connectors/src/constants.rs
+++ b/crates/hyperswitch_connectors/src/constants.rs
@@ -30,6 +30,7 @@ pub(crate) mod headers {
pub(crate) const SOURCE: &str = "Source";
pub(crate) const USER_AGENT: &str = "User-Agent";
pub(crate) const KEY: &str = "key";
+ pub(crate) const X_SIGNATURE: &str = "X-Signature";
}
/// Unsupported response type error message
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index b2df2d15f7..146175801f 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -718,7 +718,6 @@ default_imp_for_connector_redirect_response!(
connectors::Multisafepay,
connectors::Nexinets,
connectors::Nexixpay,
- connectors::Nomupay,
connectors::Payeezy,
connectors::Payu,
connectors::Placetopay,
@@ -1578,7 +1577,6 @@ default_imp_for_payouts!(
connectors::Nexinets,
connectors::Nexixpay,
connectors::Paybox,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nuvei,
connectors::Payeezy,
@@ -1659,7 +1657,6 @@ default_imp_for_payouts_create!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
@@ -1748,7 +1745,6 @@ default_imp_for_payouts_retrieve!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
@@ -1837,7 +1833,6 @@ default_imp_for_payouts_eligibility!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
@@ -1925,7 +1920,6 @@ default_imp_for_payouts_fulfill!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
@@ -2014,7 +2008,6 @@ default_imp_for_payouts_cancel!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
@@ -2103,7 +2096,6 @@ default_imp_for_payouts_quote!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
@@ -2192,7 +2184,6 @@ default_imp_for_payouts_recipient!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
@@ -2281,7 +2272,6 @@ default_imp_for_payouts_recipient_account!(
connectors::Itaubank,
connectors::Jpmorgan,
connectors::Klarna,
- connectors::Nomupay,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
diff --git a/crates/hyperswitch_interfaces/src/api/payouts.rs b/crates/hyperswitch_interfaces/src/api/payouts.rs
index 5fc0280f19..c1c878d948 100644
--- a/crates/hyperswitch_interfaces/src/api/payouts.rs
+++ b/crates/hyperswitch_interfaces/src/api/payouts.rs
@@ -45,6 +45,7 @@ pub trait PayoutRecipientAccount:
/// trait PayoutSync
pub trait PayoutSync: ConnectorIntegration<PoSync, PayoutsData, PayoutsResponseData> {}
+#[cfg(feature = "payouts")]
/// trait Payouts
pub trait Payouts:
ConnectorCommon
@@ -58,3 +59,7 @@ pub trait Payouts:
+ PayoutSync
{
}
+
+/// Empty trait for when payouts feature is disabled
+#[cfg(not(feature = "payouts"))]
+pub trait Payouts {}
diff --git a/crates/hyperswitch_interfaces/src/api/payouts_v2.rs b/crates/hyperswitch_interfaces/src/api/payouts_v2.rs
index 9027152f02..925ba275fe 100644
--- a/crates/hyperswitch_interfaces/src/api/payouts_v2.rs
+++ b/crates/hyperswitch_interfaces/src/api/payouts_v2.rs
@@ -60,6 +60,7 @@ pub trait PayoutSyncV2:
{
}
+#[cfg(feature = "payouts")]
/// trait Payouts
pub trait PayoutsV2:
ConnectorCommon
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index bc93b9c53e..2ad07d0d22 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1458,6 +1458,10 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {
nmi::transformers::NmiAuthType::try_from(self.auth_type)?;
Ok(())
}
+ api_enums::Connector::Nomupay => {
+ nomupay::transformers::NomupayAuthType::try_from(self.auth_type)?;
+ Ok(())
+ }
api_enums::Connector::Noon => {
noon::transformers::NoonAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 43556eb581..1bc9339495 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -471,7 +471,9 @@ 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::Nomupay => {
+ Ok(ConnectorEnum::Old(Box::new(connector::Nomupay::new())))
+ }
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 a05020856b..5bd6e74603 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -273,7 +273,7 @@ impl ForeignTryFrom<api_enums::Connector> 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::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/nomupay.rs b/crates/router/tests/connectors/nomupay.rs
index dbf892b3b0..4d2f9cff03 100644
--- a/crates/router/tests/connectors/nomupay.rs
+++ b/crates/router/tests/connectors/nomupay.rs
@@ -1,13 +1,14 @@
-use hyperswitch_domain_models::payment_method_data::{Card, PaymentMethodData};
+use api_models::payments::{Address, AddressDetails};
use masking::Secret;
-use router::types::{self, api, storage::enums};
+use router::types::{self, api, storage::enums, PaymentAddress};
use test_utils::connector_auth;
-use crate::utils::{self, ConnectorActions};
+use crate::utils::{self, ConnectorActions, PaymentInfo};
#[derive(Clone, Copy)]
struct NomupayTest;
impl ConnectorActions for NomupayTest {}
+
impl utils::Connector for NomupayTest {
fn get_data(&self) -> api::ConnectorData {
use router::connector::Nomupay;
@@ -33,389 +34,107 @@ impl utils::Connector for NomupayTest {
}
}
-static CONNECTOR: NomupayTest = NomupayTest {};
-
-fn get_default_payment_info() -> Option<utils::PaymentInfo> {
- None
-}
-
-fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
- None
-}
-
-// Cards Positive Tests
-// Creates a payment using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_only_authorize_payment() {
- let response = CONNECTOR
- .authorize_payment(payment_method_details(), get_default_payment_info())
- .await
- .expect("Authorize payment response");
- assert_eq!(response.status, enums::AttemptStatus::Authorized);
-}
-
-// Captures a payment using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_capture_authorized_payment() {
- let response = CONNECTOR
- .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info())
- .await
- .expect("Capture payment response");
- assert_eq!(response.status, enums::AttemptStatus::Charged);
-}
-
-// Partially captures a payment using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_partially_capture_authorized_payment() {
- let response = CONNECTOR
- .authorize_and_capture_payment(
- payment_method_details(),
- Some(types::PaymentsCaptureData {
- amount_to_capture: 50,
- ..utils::PaymentCaptureType::default().0
- }),
- get_default_payment_info(),
- )
- .await
- .expect("Capture payment response");
- assert_eq!(response.status, enums::AttemptStatus::Charged);
-}
-
-// Synchronizes a payment using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_sync_authorized_payment() {
- let authorize_response = CONNECTOR
- .authorize_payment(payment_method_details(), get_default_payment_info())
- .await
- .expect("Authorize payment response");
- let txn_id = utils::get_connector_transaction_id(authorize_response.response);
- let response = CONNECTOR
- .psync_retry_till_status_matches(
- enums::AttemptStatus::Authorized,
- Some(types::PaymentsSyncData {
- connector_transaction_id: types::ResponseId::ConnectorTransactionId(
- txn_id.unwrap(),
- ),
- ..Default::default()
- }),
- get_default_payment_info(),
- )
- .await
- .expect("PSync response");
- assert_eq!(response.status, enums::AttemptStatus::Authorized,);
-}
-
-// Voids a payment using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_void_authorized_payment() {
- let response = CONNECTOR
- .authorize_and_void_payment(
- payment_method_details(),
- Some(types::PaymentsCancelData {
- connector_transaction_id: String::from(""),
- cancellation_reason: Some("requested_by_customer".to_string()),
- ..Default::default()
- }),
- get_default_payment_info(),
- )
- .await
- .expect("Void payment response");
- assert_eq!(response.status, enums::AttemptStatus::Voided);
-}
-
-// Refunds a payment using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_refund_manually_captured_payment() {
- let response = CONNECTOR
- .capture_payment_and_refund(
- payment_method_details(),
- None,
- None,
- get_default_payment_info(),
- )
- .await
- .unwrap();
- assert_eq!(
- response.response.unwrap().refund_status,
- enums::RefundStatus::Success,
- );
-}
-
-// Partially refunds a payment using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_partially_refund_manually_captured_payment() {
- let response = CONNECTOR
- .capture_payment_and_refund(
- payment_method_details(),
- None,
- Some(types::RefundsData {
- refund_amount: 50,
- ..utils::PaymentRefundType::default().0
- }),
- get_default_payment_info(),
- )
- .await
- .unwrap();
- assert_eq!(
- response.response.unwrap().refund_status,
- enums::RefundStatus::Success,
- );
-}
-
-// Synchronizes a refund using the manual capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_sync_manually_captured_refund() {
- let refund_response = CONNECTOR
- .capture_payment_and_refund(
- payment_method_details(),
- None,
- None,
- get_default_payment_info(),
- )
- .await
- .unwrap();
- let response = CONNECTOR
- .rsync_retry_till_status_matches(
- enums::RefundStatus::Success,
- refund_response.response.unwrap().connector_refund_id,
- None,
- get_default_payment_info(),
- )
- .await
- .unwrap();
- assert_eq!(
- response.response.unwrap().refund_status,
- enums::RefundStatus::Success,
- );
-}
-
-// Creates a payment using the automatic capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_make_payment() {
- let authorize_response = CONNECTOR
- .make_payment(payment_method_details(), get_default_payment_info())
- .await
- .unwrap();
- assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
-}
-
-// Synchronizes a payment using the automatic capture flow (Non 3DS).
-#[actix_web::test]
-async fn should_sync_auto_captured_payment() {
- let authorize_response = CONNECTOR
- .make_payment(payment_method_details(), get_default_payment_info())
- .await
- .unwrap();
- assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);
- let txn_id = utils::get_connector_transaction_id(authorize_response.response);
- assert_ne!(txn_id, None, "Empty connector transaction id");
- let response = CONNECTOR
- .psync_retry_till_status_matches(
- enums::AttemptStatus::Charged,
- Some(types::PaymentsSyncData {
- connector_transaction_id: types::ResponseId::ConnectorTransactionId(
- txn_id.unwrap(),
+impl NomupayTest {
+ fn get_payout_info() -> Option<PaymentInfo> {
+ Some(PaymentInfo {
+ currency: Some(enums::Currency::GBP),
+ address: Some(PaymentAddress::new(
+ None,
+ Some(
+ Address {
+ address: Some(AddressDetails {
+ country: Some(api_models::enums::CountryAlpha2::GB),
+ city: Some("London".to_string()),
+ zip: Some(Secret::new("10025".to_string())),
+ line1: Some(Secret::new("50 Branson Ave".to_string())),
+ ..Default::default()
+ }),
+ phone: None,
+ email: None,
+ }
+ .into(),
),
- capture_method: Some(enums::CaptureMethod::Automatic),
- ..Default::default()
- }),
- get_default_payment_info(),
- )
- .await
- .unwrap();
- assert_eq!(response.status, enums::AttemptStatus::Charged,);
+ None,
+ None,
+ )),
+ payout_method_data: Some(api::PayoutMethodData::Bank(api::payouts::BankPayout::Sepa(
+ api::SepaBankTransfer {
+ bank_name: Some("Deutsche Bank".to_string()),
+ bank_country_code: Some(enums::CountryAlpha2::DE),
+ bank_city: Some("Munich".to_string()),
+ iban: Secret::new("DE57331060435647542639".to_string()),
+ bic: Some(Secret::new("DEUTDE5M551".to_string())),
+ },
+ ))),
+ ..Default::default()
+ })
+ }
}
-// 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,
- );
-}
+static CONNECTOR: NomupayTest = NomupayTest {};
-// 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,
- );
-}
+/******************** Payouts test cases ********************/
+// Creates a recipient at connector's end
-// 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();
+async fn should_create_payout_recipient() {
+ let payout_type = enums::PayoutType::Bank;
+ let payment_info = NomupayTest::get_payout_info();
let response = CONNECTOR
- .rsync_retry_till_status_matches(
- enums::RefundStatus::Success,
- refund_response.response.unwrap().connector_refund_id,
- None,
- get_default_payment_info(),
- )
+ .create_payout_recipient(payout_type, payment_info)
.await
- .unwrap();
+ .expect("Payout recipient creation response");
assert_eq!(
- response.response.unwrap().refund_status,
- enums::RefundStatus::Success,
+ response.status.unwrap(),
+ enums::PayoutStatus::RequiresCreation
);
}
-// 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(),
- );
-}
+// Create SEPA payout
-// 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(),
- )
+async fn should_create_bacs_payout() {
+ let payout_type = enums::PayoutType::Bank;
+ let payout_info = NomupayTest::get_payout_info();
+ // Create recipient
+ let recipient_res = CONNECTOR
+ .create_payout_recipient(payout_type.to_owned(), payout_info.to_owned())
.await
- .unwrap();
+ .expect("Payout recipient response");
assert_eq!(
- response.response.unwrap_err().message,
- "Your card's expiration month is invalid.".to_string(),
+ recipient_res.status.unwrap(),
+ enums::PayoutStatus::RequiresCreation
);
-}
-// 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(),
- )
+ // Create payout
+ let create_res: types::PayoutsResponseData = CONNECTOR
+ .create_payout(recipient_res.connector_payout_id, payout_type, payout_info)
.await
- .unwrap();
+ .expect("Payout bank creation response");
assert_eq!(
- response.response.unwrap_err().message,
- "Your card's expiration year is invalid.".to_string(),
+ create_res.status.unwrap(),
+ enums::PayoutStatus::RequiresFulfillment
);
}
-// 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."
- );
-}
+// Create and fulfill SEPA payout
-// 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())
+async fn should_create_and_fulfill_bacs_payout() {
+ let payout_type = enums::PayoutType::Bank;
+ let payout_info = NomupayTest::get_payout_info();
+ // Create recipient
+ let recipient_res = CONNECTOR
+ .create_payout_recipient(payout_type.to_owned(), payout_info.to_owned())
.await
- .unwrap();
+ .expect("Payout recipient response");
assert_eq!(
- capture_response.response.unwrap_err().message,
- String::from("No such payment_intent: '123456789'")
+ recipient_res.status.unwrap(),
+ enums::PayoutStatus::RequiresCreation
);
-}
-
-// 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(),
- )
+ .create_and_fulfill_payout(recipient_res.connector_payout_id, payout_type, payout_info)
.await
- .unwrap();
- assert_eq!(
- response.response.unwrap_err().message,
- "Refund amount (₹1.50) is greater than charge amount (₹1.00)",
- );
+ .expect("Payout bank creation and fulfill response");
+ assert_eq!(response.status.unwrap(), enums::PayoutStatus::Success);
}
-
-// 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 4677417104..45ac315f24 100644
--- a/crates/router/tests/connectors/sample_auth.toml
+++ b/crates/router/tests/connectors/sample_auth.toml
@@ -304,7 +304,8 @@ key1 ="Client Secret"
api_key="API Key"
[nomupay]
-api_key="API Key"
+api_key="kid"
+key1="eid"
[unified_authentication_service]
api_key="API Key"
diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs
index 7a5b48f03a..0f4e7250fa 100644
--- a/crates/test_utils/src/connector_auth.rs
+++ b/crates/test_utils/src/connector_auth.rs
@@ -62,7 +62,7 @@ pub struct ConnectorAuthentication {
pub netcetera: Option<HeaderKey>,
pub nexinets: Option<BodyKey>,
pub nexixpay: Option<HeaderKey>,
- pub nomupay: Option<HeaderKey>,
+ pub nomupay: Option<BodyKey>,
pub noon: Option<SignatureKey>,
pub novalnet: Option<HeaderKey>,
pub nmi: Option<HeaderKey>,
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Nomupay.js b/cypress-tests/cypress/e2e/configs/Payout/Nomupay.js
new file mode 100644
index 0000000000..cc25d6424f
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/Payout/Nomupay.js
@@ -0,0 +1,207 @@
+function get_billing(x) {
+ return {
+ address: {
+ line1: "1467",
+ line2: "Harrison Street",
+ line3: "Harrison Street",
+ city: "Munich",
+ state: "CA",
+ zip: "80331",
+ country: "DE",
+ first_name: "John",
+ last_name: "Doe",
+ },
+ phone: {
+ number: "9123456789",
+ country_code: "+91",
+ },
+ email: `payout_customer${Date.now() + x}@example.com`,
+ };
+}
+
+const card_data = {
+ card_number: "4111111111111111",
+ expiry_month: "3",
+ expiry_year: "2030",
+ card_holder_name: "John Smith",
+};
+
+const payment_card_data = {
+ card_number: "4111111111111111",
+ card_exp_month: "03",
+ card_exp_year: "2030",
+ card_holder_name: "John Doe",
+};
+
+const bank = {
+ iban: "DE57331060435647542639",
+ bic: "DEUTDE5M551",
+ bank_name: "Deutsche Bank",
+ bank_country_code: "DE",
+ bank_city: "Munich",
+};
+
+const error = {
+ code: "IR_04",
+ message: "Missing required param: connector_customer_id",
+ type: "invalid_request",
+};
+
+export const connectorDetails = {
+ card_pm: {
+ Create: {
+ Request: {
+ payout_method_data: {
+ card: card_data,
+ },
+ payout_type: "card",
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: error,
+ },
+ },
+ },
+ Confirm: {
+ Request: {
+ payout_method_data: {
+ card: card_data,
+ },
+ payout_type: "card",
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: error,
+ },
+ },
+ },
+ Fulfill: {
+ Request: {
+ payout_method_data: {
+ card: card_data,
+ },
+ currency: "EUR",
+ payout_type: "card",
+ recurring: true,
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: error,
+ },
+ },
+ },
+ SavePayoutMethod: {
+ Request: {
+ payment_method: "card",
+ payment_method_type: "credit",
+ card: payment_card_data,
+ metadata: {
+ city: "NY",
+ unit: "245",
+ },
+ },
+ Response: {
+ status: 200,
+ },
+ },
+ Token: {
+ Request: {
+ payout_token: "token",
+ payout_type: "card",
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: error,
+ },
+ },
+ },
+ },
+ bank_transfer_pm: {
+ sepa: {
+ Create: {
+ Request: {
+ currency: "EUR",
+ payout_type: "bank",
+ payout_method_data: {
+ bank: bank,
+ },
+ billing: get_billing(1),
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_confirmation",
+ payout_type: "bank",
+ },
+ },
+ },
+ Confirm: {
+ Request: {
+ payout_type: "bank",
+ payout_method_data: {
+ bank: bank,
+ },
+ billing: get_billing(2),
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_fulfillment",
+ payout_type: "bank",
+ },
+ },
+ },
+ Fulfill: {
+ Request: {
+ currency: "EUR",
+ payout_type: "bank",
+ payout_method_data: {
+ bank: bank,
+ },
+ billing: get_billing(3),
+ recurring: true,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ payout_type: "bank",
+ },
+ },
+ },
+ SavePayoutMethod: {
+ Request: {
+ payment_method: "bank_transfer",
+ payment_method_type: "sepa",
+ bank_transfer: bank,
+ },
+ Response: {
+ status: 200,
+ body: {
+ payment_method: "bank_transfer",
+ payment_method_type: "sepa",
+ },
+ },
+ },
+ Token: {
+ Request: {
+ payout_token: "token",
+ payout_type: "bank",
+ billing: get_billing(4),
+ recurring: true,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "pending",
+ payout_type: "bank",
+ },
+ },
+ },
+ },
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payout/Utils.js b/cypress-tests/cypress/e2e/configs/Payout/Utils.js
index c97e29e644..4cff8760be 100644
--- a/cypress-tests/cypress/e2e/configs/Payout/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payout/Utils.js
@@ -4,12 +4,14 @@ import { connectorDetails as adyenConnectorDetails } from "./Adyen.js";
import { connectorDetails as adyenPlatformConnectorDetails } from "./AdyenPlatform.js";
import { connectorDetails as CommonConnectorDetails } from "./Commons.js";
import { connectorDetails as wiseConnectorDetails } from "./Wise.js";
+import { connectorDetails as nomupayConnectorDetails } from "./Nomupay.js";
const connectorDetails = {
adyen: adyenConnectorDetails,
adyenplatform: adyenPlatformConnectorDetails,
commons: CommonConnectorDetails,
wise: wiseConnectorDetails,
+ nomupay: nomupayConnectorDetails,
};
export function getConnectorDetails(connectorId) {
diff --git a/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js
index 174b257a48..95da27f5eb 100644
--- a/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payout/00004-BankTransfer.cy.js
@@ -118,6 +118,10 @@ describe("[Payout] [Bank Transfer - SEPA]", () => {
}
});
+ it("create customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
it("confirm-payout-call-with-manual-fulfill-test", () => {
const data = utils.getConnectorDetails(globalState.get("connectorId"))[
"bank_transfer_pm"
diff --git a/cypress-tests/cypress/e2e/spec/Payout/00006-PayoutUsingPayoutMethodId.cy.js b/cypress-tests/cypress/e2e/spec/Payout/00006-PayoutUsingPayoutMethodId.cy.js
new file mode 100644
index 0000000000..50b1ce0f12
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payout/00006-PayoutUsingPayoutMethodId.cy.js
@@ -0,0 +1,131 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import * as utils from "../../configs/Payout/Utils";
+
+let globalState;
+let payoutBody;
+
+describe("[Payout] Saved Bank transfer", () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+
+ // Check if the connector supports card payouts (based on the connector configuration in creds)
+ if (!globalState.get("payoutsExecution")) {
+ shouldContinue = false;
+ }
+ });
+ });
+
+ after("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ context(
+ "[Payout] [Bank Transfer] Onboard Customer Prior to Transaction",
+ () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+ beforeEach("reset payoutBody", () => {
+ payoutBody = Cypress._.cloneDeep(fixtures.createPayoutBody);
+ });
+
+ it("create customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("create payment method", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["sepa"]["SavePayoutMethod"];
+
+ cy.createPaymentMethodTest(globalState, data);
+ });
+
+ it("list customer payment methods", () => {
+ cy.listCustomerPMCallTest(globalState);
+ });
+
+ it("[Payout] [Bank transfer] [SEPA] Fulfill using Token", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["sepa"]["Token"];
+
+ cy.createConfirmWithTokenPayoutTest(
+ payoutBody,
+ data,
+ true,
+ true,
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-call-test", () => {
+ cy.retrievePayoutCallTest(globalState);
+ });
+ }
+ );
+
+ context(
+ "[Payout] [Bank Transfer] Save payment method after successful transaction",
+ () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("create customer", () => {
+ cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
+ });
+
+ it("confirm-payout-call-with-auto-fulfill-test", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["sepa"]["Fulfill"];
+
+ cy.createConfirmPayoutTest(payoutBody, data, true, true, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("list customer payment methods", () => {
+ cy.listCustomerPMCallTest(globalState);
+ });
+
+ it("[Payout] [Bank transfer] [SEPA] Fulfill using payout_method_id", () => {
+ const data = utils.getConnectorDetails(globalState.get("connectorId"))[
+ "bank_transfer_pm"
+ ]["sepa"]["Token"];
+
+ cy.createConfirmWithPayoutMethodIdTest(
+ payoutBody,
+ data,
+ true,
+ true,
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("retrieve-payout-call-test", () => {
+ cy.retrievePayoutCallTest(globalState);
+ });
+ }
+ );
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 2257b9ffe5..bf5ed37004 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -3203,6 +3203,49 @@ Cypress.Commands.add(
}
);
+Cypress.Commands.add(
+ "createConfirmWithPayoutMethodIdTest",
+ (createConfirmPayoutBody, data, confirm, auto_fulfill, globalState) => {
+ const { Request: reqData, Response: resData } = data || {};
+
+ for (const key in reqData) {
+ createConfirmPayoutBody[key] = reqData[key];
+ }
+ createConfirmPayoutBody.customer_id = globalState.get("customerId");
+ createConfirmPayoutBody.auto_fulfill = auto_fulfill;
+ createConfirmPayoutBody.confirm = confirm;
+ createConfirmPayoutBody.payout_method_id = globalState.data.paymentMethodId;
+ delete createConfirmPayoutBody.payout_token;
+
+ cy.request({
+ method: "POST",
+ url: `${globalState.get("baseUrl")}/payouts/create`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("apiKey"),
+ },
+ failOnStatusCode: false,
+ body: createConfirmPayoutBody,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.headers["content-type"]).to.include("application/json");
+
+ if (response.status === 200) {
+ globalState.set("payoutAmount", createConfirmPayoutBody.amount);
+ globalState.set("payoutID", response.body.payout_id);
+ for (const key in resData.body) {
+ expect(resData.body[key]).to.equal(response.body[key]);
+ }
+ } else {
+ defaultErrorHandler(response, resData);
+ }
+ });
+ });
+ }
+);
+
Cypress.Commands.add(
"fulfillPayoutCallTest",
(payoutFulfillBody, data, globalState) => {
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 7c999401f6..212819e0c3 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -234,7 +234,6 @@ cards = [
"nexinets",
"nexixpay",
"nmi",
- "nomupay",
"noon",
"novalnet",
"nuvei",