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(Generic): [FRM] Implementing FRM framework flows (#13987)

Ritam Kabiraj18325a5c3e8e
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 1ceac6b7d5..7c1e768746 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -19776,6 +19776,7 @@
"worldpayxml",
"worldpaymodular",
"signifyd",
+ "nsure",
"plaid",
"riskified",
"sanlam_payshield",
@@ -45734,6 +45735,7 @@
"santander",
"shift4",
"signifyd",
+ "nsure",
"silverflow",
"square",
"stax",
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index adebc50b34..6685561d9b 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -12487,6 +12487,7 @@
"worldpayxml",
"worldpaymodular",
"signifyd",
+ "nsure",
"plaid",
"riskified",
"sanlam_payshield",
@@ -32102,6 +32103,7 @@
"santander",
"shift4",
"signifyd",
+ "nsure",
"silverflow",
"square",
"stax",
diff --git a/config/config.example.toml b/config/config.example.toml
index 48a6799f32..c96ab2501b 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -380,6 +380,7 @@ nomupay.base_url = "https://payout-api.sandbox.nomupay.com"
noon.base_url = "https://api-test{{region}}.noonpayments.com/"
nordea.base_url = "https://api.nordeaopenbanking.com"
novalnet.base_url = "https://payport.novalnet.de/v2"
+nsure.base_url = "https://sandbox.nsureapi.com"
noon.key_mode = "Test"
nuvei.base_url = "https://ppp-test.nuvei.com/"
opayo.base_url = "https://pi-test.sagepay.com/"
@@ -1500,7 +1501,7 @@ admin_secret = "" # Shared secret sent as x-admin-secret o
base_url = "http://localhost:8000" # Unified Connector Service Base URL
connection_timeout = 10 # Connection Timeout Duration in Seconds
request_timeout = 35 # Per-RPC Request Timeout in Seconds
-ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, dlocal, barclaycard, tsys_transit, jpmorgan, datatrans, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante" # Comma-separated list of connectors that use UCS only
+ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, dlocal, barclaycard, tsys_transit, jpmorgan, datatrans, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante, nsure" # Comma-separated list of connectors that use UCS only
ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call
[grpc_client.recovery_decider_client] # Revenue recovery client base url
diff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.toml
index 1ce9915d80..8b950531aa 100644
--- a/config/deployments/env_specific.toml
+++ b/config/deployments/env_specific.toml
@@ -475,7 +475,7 @@ payment_method = "payment_method_types" # <payment_method> = comma-separated clo
base_url = "http://localhost:8000" # Unified Connector Service Base URL
connection_timeout = 10 # Connection Timeout Duration in Seconds
request_timeout = 35 # Per-RPC Request Timeout in Seconds
-ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, jpmorgan, datatrans, tsys_transit, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante" # Comma-separated list of connectors that use UCS only
+ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, jpmorgan, datatrans, tsys_transit, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante, nsure" # Comma-separated list of connectors that use UCS only
ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call
[revenue_recovery]
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 87a6ff5d9e..b21b001015 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -135,6 +135,7 @@ noon.base_url = "https://api-test{{region}}.noonpayments.com/"
nordea.base_url = "https://api.nordeaopenbanking.com"
noon.key_mode = "Test"
novalnet.base_url = "https://payport.novalnet.de/v2"
+nsure.base_url = "https://sandbox.nsureapi.com"
nuvei.base_url = "https://ppp-test.nuvei.com/"
opayo.base_url = "https://pi-test.sagepay.com/"
opennode.base_url = "https://dev-api.opennode.com"
@@ -1074,7 +1075,7 @@ connector_list = "juspaythreedsserver, ctp_mastercard, ctp_visa"
connector_list = "worldpayvantiv"
[grpc_client.unified_connector_service]
-ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, tsys_transit, jpmorgan, datatrans, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante" # Comma-separated list of connectors that use UCS only
+ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, tsys_transit, jpmorgan, datatrans, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante, nsure" # Comma-separated list of connectors that use UCS only
ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call
# Merchant Advice Code Configuration
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index dab21c8d3b..894a9b57ce 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -142,6 +142,7 @@ noon.base_url = "https://api{{region}}.noonpayments.com/"
nordea.base_url = "https://open.nordeaopenbanking.com"
noon.key_mode = "Live"
novalnet.base_url = "https://payport.novalnet.de/v2"
+nsure.base_url = "https://service.nsureapi.com"
nuvei.base_url = "https://secure.safecharge.com/"
opayo.base_url = "https://pi-live.sagepay.com/"
opennode.base_url = "https://api.opennode.com"
@@ -1086,7 +1087,7 @@ click_to_pay = {connector_list = "adyen, cybersource, trustpay"}
connector_list = "juspaythreedsserver, ctp_mastercard, ctp_visa"
[grpc_client.unified_connector_service]
-ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, jpmorgan, datatrans, tsys_transit, givepayments, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante" # Comma-separated list of connectors that use UCS only
+ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, jpmorgan, datatrans, tsys_transit, givepayments, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante, nsure" # Comma-separated list of connectors that use UCS only
ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call
# Merchant Advice Code Configuration
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 966b75bf48..82e1a70d3a 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -138,6 +138,7 @@ noon.base_url = "https://api-test{{region}}.noonpayments.com/"
nordea.base_url = "https://api.nordeaopenbanking.com"
noon.key_mode = "Test"
novalnet.base_url = "https://payport.novalnet.de/v2"
+nsure.base_url = "https://sandbox.nsureapi.com"
nuvei.base_url = "https://ppp-test.nuvei.com/"
opayo.base_url = "https://pi-test.sagepay.com/"
opennode.base_url = "https://dev-api.opennode.com"
@@ -1093,7 +1094,7 @@ connector_list = "juspaythreedsserver, ctp_mastercard, ctp_visa"
connector_list = "worldpayvantiv"
[grpc_client.unified_connector_service]
-ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, jpmorgan, datatrans, tsys_transit, givepayments, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante" # Comma-separated list of connectors that use UCS only
+ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, jpmorgan, datatrans, tsys_transit, givepayments, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante, nsure" # Comma-separated list of connectors that use UCS only
ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call
# Merchant Advice Code Configuration
diff --git a/config/development.toml b/config/development.toml
index 05e56740f3..6ba2292ff3 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -121,7 +121,7 @@ default_hash_ttl = 900
use_legacy_version = false
stream_read_count = 1
auto_pipeline = true
-broadcast_channel_capacity = 32
+broadcast_channel_capacity = 32
disable_auto_backpressure = false
max_in_flight_commands = 5000
default_command_timeout = 30
@@ -408,6 +408,7 @@ nomupay.base_url = "https://payout-api.sandbox.nomupay.com"
noon.base_url = "https://api-test{{region}}.noonpayments.com/"
nordea.base_url = "https://api.nordeaopenbanking.com"
novalnet.base_url = "https://payport.novalnet.de/v2"
+nsure.base_url = "https://sandbox.nsureapi.com"
noon.key_mode = "Test"
nuvei.base_url = "https://ppp-test.nuvei.com/"
opayo.base_url = "https://pi-test.sagepay.com/"
@@ -1626,7 +1627,7 @@ enabled = "true"
base_url = "http://localhost:8000"
connection_timeout = 10
request_timeout = 35
-ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, tsys_transit, jpmorgan, datatrans, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante" # Comma-separated list of connectors that use UCS only
+ucs_only_connectors = "imerchantsolutions, paytm, phonepe, hyperpg, revolv3, fiservcommercehub, absa_sanlam, interpayments, payconex, dlocal, barclaycard, tsys_transit, jpmorgan, datatrans, givepayments, tesouro, citigate, ilixium, moneris, elavon, worldpayraft, globalpay, rapyd, paynearme, jpmorgan_orbital, saferpay, d24, etisalat, globalpayments_heartland, paydotcom, merchante, nsure" # Comma-separated list of connectors that use UCS only
ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call
[revenue_recovery]
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index f468233bb0..e018945466 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -303,6 +303,7 @@ nomupay.base_url = "https://payout-api.sandbox.nomupay.com"
noon.base_url = "https://api-test{{region}}.noonpayments.com/"
nordea.base_url = "https://api.nordeaopenbanking.com"
novalnet.base_url = "https://payport.novalnet.de/v2"
+nsure.base_url = "https://sandbox.nsureapi.com"
noon.key_mode = "Test"
nuvei.base_url = "https://ppp-test.nuvei.com/"
opayo.base_url = "https://pi-test.sagepay.com/"
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 4ee1cfaca9..0f77408a55 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -201,6 +201,9 @@ pub enum FrmConnectors {
Riskified,
Cybersourcedecisionmanager,
SanlamPayshield,
+ /// nSure.ai. Executed via the Unified Connector Service, not in-process.
+ /// Official docs: https://docs.nsure.ai/
+ Nsure,
}
#[derive(
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs
index 5276df7ea1..7811c1a78e 100644
--- a/crates/common_enums/src/connector_enums.rs
+++ b/crates/common_enums/src/connector_enums.rs
@@ -217,6 +217,7 @@ pub enum Connector {
Worldpayxml,
Worldpaymodular,
Signifyd,
+ Nsure,
Plaid,
Riskified,
SanlamPayshield,
@@ -468,6 +469,7 @@ impl Connector {
| Self::Zen
| Self::Zsl
| Self::Signifyd
+ | Self::Nsure
| Self::Plaid
| Self::Razorpay
| Self::Riskified
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index aa132ee069..de797b5d45 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -417,6 +417,7 @@ pub struct ConnectorConfig {
#[cfg(feature = "payouts")]
pub stripe_payout: Option<ConnectorTomlConfig>,
pub stripebilling: Option<ConnectorTomlConfig>,
+ pub nsure: Option<ConnectorTomlConfig>,
pub signifyd: Option<ConnectorTomlConfig>,
pub tersouro: Option<ConnectorTomlConfig>,
pub tokenex: Option<ConnectorTomlConfig>,
@@ -686,6 +687,7 @@ impl ConnectorConfig {
Connector::SanlamPayshield => Ok(connector_data.sanlam_payshield),
Connector::Santander => Ok(connector_data.santander),
Connector::Shift4 => Ok(connector_data.shift4),
+ Connector::Nsure => Ok(connector_data.nsure),
Connector::Signifyd => Ok(connector_data.signifyd),
Connector::Silverflow => Ok(connector_data.silverflow),
Connector::Square => Ok(connector_data.square),
diff --git a/crates/euclid/src/enums.rs b/crates/euclid/src/enums.rs
index ec3f23c0b4..46e74365ea 100644
--- a/crates/euclid/src/enums.rs
+++ b/crates/euclid/src/enums.rs
@@ -344,6 +344,7 @@ pub enum RoutableConnectors {
Santander,
Shift4,
Signifyd,
+ Nsure,
Silverflow,
Square,
Stax,
@@ -512,6 +513,7 @@ impl TryFrom<Connector> for RoutableConnectors {
Connector::Shift4 => Ok(Self::Shift4),
Connector::Signifyd => Ok(Self::Signifyd),
Connector::SanlamPayshield => Ok(Self::SanlamPayshield),
+ Connector::Nsure => Ok(Self::Nsure),
Connector::Silverflow => Ok(Self::Silverflow),
Connector::Square => Ok(Self::Square),
Connector::Stax => Ok(Self::Stax),
@@ -696,6 +698,7 @@ impl From<RoutableConnectors> for Connector {
RoutableConnectors::Santander => Self::Santander,
RoutableConnectors::Shift4 => Self::Shift4,
RoutableConnectors::Signifyd => Self::Signifyd,
+ RoutableConnectors::Nsure => Self::Nsure,
RoutableConnectors::Silverflow => Self::Silverflow,
RoutableConnectors::Square => Self::Square,
RoutableConnectors::Stax => Self::Stax,
diff --git a/crates/external_services/src/grpc_client/unified_connector_service.rs b/crates/external_services/src/grpc_client/unified_connector_service.rs
index cb7f3e75a5..e11291c51a 100644
--- a/crates/external_services/src/grpc_client/unified_connector_service.rs
+++ b/crates/external_services/src/grpc_client/unified_connector_service.rs
@@ -60,6 +60,8 @@ pub struct UnifiedConnectorServiceClient {
pub payout_service_client: payments_grpc::payout_service_client::PayoutServiceClient<UcsChannel>,
/// The Surcharge Service Client
pub surcharge_service_client: payments_grpc::surcharge_service_client::SurchargeServiceClient<UcsChannel>,
+ /// The Fraud and Risk Management Service Client
+ pub frm_service_client: payments_grpc::fraud_and_risk_management_service_client::FraudAndRiskManagementServiceClient<UcsChannel>,
}
/// Contains the Unified Connector Service Client config
@@ -402,6 +404,16 @@ impl UnifiedConnectorServiceClient {
request_timeout
);
+ let frm_service_client = build_grpc_client!(
+ payments_grpc::fraud_and_risk_management_service_client::FraudAndRiskManagementServiceClient<
+ UcsChannel,
+ >,
+ "frm_service_client",
+ uri,
+ connection_timeout,
+ request_timeout
+ );
+
// Replay connected nothing — the boundary stands in for every channel — so the
// usual claim would be false there. Every other mode performed the same eager
// connect it always did.
@@ -429,6 +441,7 @@ impl UnifiedConnectorServiceClient {
payment_method_authentication_service_client,
payout_service_client,
surcharge_service_client,
+ frm_service_client,
})
}
None => {
@@ -1565,7 +1578,12 @@ impl UnifiedConnectorServiceClient {
.clone()
.calculate(request)
.await
- .change_context(UnifiedConnectorServiceError::SurchargeCalculateFailure)
+ .map_err(|error| {
+ error_stack::Report::new(UnifiedConnectorServiceError::from_grpc_error(
+ &error,
+ &connector_name,
+ ))
+ })
.inspect_err(|error| {
logger::error!(
grpc_error=?error,
@@ -1576,6 +1594,47 @@ impl UnifiedConnectorServiceClient {
})
}
+ /// Performs a pre-authorization risk check via the FRM Service.
+ pub async fn frm_pre_risk_check(
+ &self,
+ pre_risk_check_request: payments_grpc::FrmServicePreRiskCheckRequest,
+ connector_auth_metadata: ConnectorAuthMetadata,
+ grpc_headers: GrpcHeadersUcs,
+ ) -> UnifiedConnectorServiceResult<tonic::Response<payments_grpc::FrmServicePreRiskCheckResponse>>
+ {
+ let mut request = tonic::Request::new(pre_risk_check_request);
+
+ let connector_name = connector_auth_metadata.connector_name.clone();
+ // FRM providers are onboarded as `payment_vas`, which the shared builder
+ // maps to `x-frm-connector`.
+ let metadata = build_unified_connector_service_grpc_headers_for_connector_type(
+ connector_auth_metadata,
+ grpc_headers,
+ ConnectorType::PaymentVas,
+ )?;
+
+ *request.metadata_mut() = metadata;
+
+ self.frm_service_client
+ .clone()
+ .pre_risk_check(request)
+ .await
+ .map_err(|error| {
+ error_stack::Report::new(UnifiedConnectorServiceError::from_grpc_error(
+ &error,
+ &connector_name,
+ ))
+ })
+ .inspect_err(|error| {
+ logger::error!(
+ grpc_error=?error,
+ method="frm_pre_risk_check",
+ connector_name=?connector_name,
+ "UCS frm_pre_risk_check gRPC call failed"
+ )
+ })
+ }
+
/// Performs notify connector via the Event Service
pub async fn notify_connector(
&self,
@@ -1640,6 +1699,9 @@ fn build_unified_connector_service_grpc_headers_for_connector_type(
ConnectorType::PaymentProcessor => consts::UCS_HEADER_CONNECTOR,
ConnectorType::PayoutProcessor => consts::UCS_HEADER_PAYOUT_CONNECTOR,
ConnectorType::SurchargeProcessor => consts::UCS_HEADER_SURCHARGE_CONNECTOR,
+ // FRM providers are onboarded as `payment_vas` and are selected by
+ // `x-frm-connector`, the same way surcharge uses its own header.
+ ConnectorType::PaymentVas => consts::UCS_HEADER_FRM_CONNECTOR,
connector_type => {
return Err(
UnifiedConnectorServiceError::RequestEncodingFailedWithReason(format!(
@@ -1857,12 +1919,21 @@ pub fn build_unified_connector_service_grpc_headers_for_notify_connector(
// Remove the default connector header
metadata.remove(consts::UCS_HEADER_CONNECTOR);
- // Choose header based on event type
+ // Choose header based on event type. FRM events are routed by
+ // `x-frm-connector` (mirroring the risk-check path); surcharge events by
+ // `x-surcharge-connector`; everything else by the default `x-connector`.
let is_surcharge_event = matches!(
event_type,
payments_grpc::NotifyEventType::SurchargePaymentSucceeded
| payments_grpc::NotifyEventType::SurchargeRefundSucceeded
);
+ let is_frm_event = matches!(
+ event_type,
+ payments_grpc::NotifyEventType::FrmPaymentSucceeded
+ | payments_grpc::NotifyEventType::FrmPaymentFailure
+ | payments_grpc::NotifyEventType::FrmRefundProcessed
+ | payments_grpc::NotifyEventType::FrmChargebackReceived
+ );
let connector_name = meta.connector_name.clone();
let connector_value = connector_name
@@ -1882,6 +1953,8 @@ pub fn build_unified_connector_service_grpc_headers_for_notify_connector(
if is_surcharge_event {
metadata.append(consts::UCS_HEADER_SURCHARGE_CONNECTOR, connector_value);
+ } else if is_frm_event {
+ metadata.append(consts::UCS_HEADER_FRM_CONNECTOR, connector_value);
} else {
metadata.append(consts::UCS_HEADER_CONNECTOR, connector_value);
}
diff --git a/crates/external_services/src/lib.rs b/crates/external_services/src/lib.rs
index b3d873d0c2..49f2744227 100644
--- a/crates/external_services/src/lib.rs
+++ b/crates/external_services/src/lib.rs
@@ -80,6 +80,7 @@ pub mod consts {
/// Header key used to specify the surcharge connector name in UCS requests.
pub(crate) const UCS_HEADER_SURCHARGE_CONNECTOR: &str = "x-surcharge-connector";
+ pub(crate) const UCS_HEADER_FRM_CONNECTOR: &str = "x-frm-connector";
/// Header key used to indicate the authentication type being used.
pub(crate) const UCS_HEADER_AUTH_TYPE: &str = "x-auth";
diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs
index 5d419bf0fa..3bae0b387f 100644
--- a/crates/hyperswitch_connectors/src/connectors.rs
+++ b/crates/hyperswitch_connectors/src/connectors.rs
@@ -93,6 +93,7 @@ pub mod nomupay;
pub mod noon;
pub mod nordea;
pub mod novalnet;
+pub mod nsure;
pub mod nuvei;
pub mod opayo;
pub mod opennode;
@@ -189,18 +190,19 @@ pub use self::{
katapult::Katapult, klarna::Klarna, loonio::Loonio, merchante::Merchante, mifinity::Mifinity,
mollie::Mollie, moneris::Moneris, mpgs::Mpgs, multisafepay::Multisafepay, netcetera::Netcetera,
nexinets::Nexinets, nexixpay::Nexixpay, nmi::Nmi, nomupay::Nomupay, noon::Noon, nordea::Nordea,
- novalnet::Novalnet, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox,
- payconex::Payconex, paydotcom::Paydotcom, payeezy::Payeezy, payjustnow::Payjustnow,
- payjustnowinstore::Payjustnowinstore, payload::Payload, payme::Payme, paynearme::Paynearme,
- payone::Payone, paypal::Paypal, paysafe::Paysafe, paystack::Paystack, paytm::Paytm, payu::Payu,
- peachpayments::Peachpayments, phonepe::Phonepe, placetopay::Placetopay, plaid::Plaid,
- powertranz::Powertranz, prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay,
- recurly::Recurly, redsys::Redsys, revolv3::Revolv3, riskified::Riskified, saferpay::Saferpay,
- sanlam_payshield::SanlamPayshield, santander::Santander, shift4::Shift4, sift::Sift,
- signifyd::Signifyd, silverflow::Silverflow, square::Square, stax::Stax, stripe::Stripe,
- stripebilling::Stripebilling, taxjar::Taxjar, tesouro::Tesouro, threedsecureio::Threedsecureio,
- thunes::Thunes, tokenex::Tokenex, tokenio::Tokenio, truelayer::Truelayer, trustly::Trustly,
- trustpay::Trustpay, trustpayments::Trustpayments, tsys::Tsys, tsys_transit::TsysTransit,
+ novalnet::Novalnet, nsure::Nsure, nuvei::Nuvei, opayo::Opayo, opennode::Opennode,
+ paybox::Paybox, payconex::Payconex, paydotcom::Paydotcom, payeezy::Payeezy,
+ payjustnow::Payjustnow, payjustnowinstore::Payjustnowinstore, payload::Payload, payme::Payme,
+ paynearme::Paynearme, payone::Payone, paypal::Paypal, paysafe::Paysafe, paystack::Paystack,
+ paytm::Paytm, payu::Payu, peachpayments::Peachpayments, phonepe::Phonepe,
+ placetopay::Placetopay, plaid::Plaid, powertranz::Powertranz, prophetpay::Prophetpay,
+ rapyd::Rapyd, razorpay::Razorpay, recurly::Recurly, redsys::Redsys, revolv3::Revolv3,
+ riskified::Riskified, saferpay::Saferpay, sanlam_payshield::SanlamPayshield,
+ santander::Santander, shift4::Shift4, sift::Sift, signifyd::Signifyd, silverflow::Silverflow,
+ square::Square, stax::Stax, stripe::Stripe, stripebilling::Stripebilling, taxjar::Taxjar,
+ tesouro::Tesouro, threedsecureio::Threedsecureio, thunes::Thunes, tokenex::Tokenex,
+ tokenio::Tokenio, truelayer::Truelayer, trustly::Trustly, trustpay::Trustpay,
+ trustpayments::Trustpayments, tsys::Tsys, tsys_transit::TsysTransit,
unified_authentication_service::UnifiedAuthenticationService, vgs::Vgs, volt::Volt,
wellsfargo::Wellsfargo, wellsfargopayout::Wellsfargopayout, wise::Wise, worldline::Worldline,
worldpay::Worldpay, worldpaymodular::Worldpaymodular, worldpayraft::Worldpayraft,
diff --git a/crates/hyperswitch_connectors/src/connectors/nsure.rs b/crates/hyperswitch_connectors/src/connectors/nsure.rs
new file mode 100644
index 0000000000..571c4e1b7e
--- /dev/null
+++ b/crates/hyperswitch_connectors/src/connectors/nsure.rs
@@ -0,0 +1,199 @@
+//! nSure.ai fraud and risk management.
+//!
+//! nSure has no in-process integration: its risk evaluation runs on the
+//! Unified Connector Service, which owns the provider-specific transformation.
+//! This type exists so nSure is a first-class `Connector` for routing, MCA
+//! validation and the FRM gateway, the same way UCS-only payment connectors
+//! ship a stub. Every flow below falls through to the `ConnectorIntegration`
+//! defaults, which return `NotImplemented`.
+
+use common_utils::{errors::CustomResult, request::Request};
+use error_stack::report;
+use hyperswitch_domain_models::{
+ router_data::{AccessToken, RouterData},
+ router_flow_types::{
+ AccessTokenAuth, Authorize, Capture, Execute, PSync, PaymentMethodToken, RSync, Session,
+ SetupMandate, Void,
+ },
+ router_request_types::{
+ AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
+ PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
+ RefundsData, SetupMandateRequestData,
+ },
+ router_response_types::{
+ ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods,
+ },
+};
+#[cfg(feature = "frm")]
+use hyperswitch_domain_models::{
+ router_flow_types::{Checkout, Fulfillment, PoFrm, RecordReturn, Sale, Transaction},
+ router_request_types::fraud_check::{
+ FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckPayoutData,
+ FraudCheckRecordReturnData, FraudCheckSaleData, FraudCheckTransactionData,
+ },
+ router_response_types::fraud_check::FraudCheckResponseData,
+};
+#[cfg(feature = "frm")]
+use hyperswitch_interfaces::api::{
+ FraudCheck, FraudCheckCheckout, FraudCheckFulfillment, FraudCheckPayout,
+ FraudCheckRecordReturn, FraudCheckSale, FraudCheckTransaction,
+};
+use hyperswitch_interfaces::{
+ api::{
+ ConnectorAccessToken, ConnectorCommon, ConnectorIntegration, ConnectorSpecifications,
+ ConnectorValidation, MandateSetup, Payment, PaymentAuthorize, PaymentCapture,
+ PaymentSession, PaymentSync, PaymentToken, PaymentVoid, Refund, RefundExecute, RefundSync,
+ },
+ configs::Connectors,
+ errors::ConnectorError,
+ webhooks,
+};
+
+#[derive(Clone)]
+pub struct Nsure;
+
+impl Nsure {
+ pub fn new() -> &'static Self {
+ &Self
+ }
+}
+
+impl ConnectorCommon for Nsure {
+ fn id(&self) -> &'static str {
+ "nsure"
+ }
+
+ fn common_get_content_type(&self) -> &'static str {
+ "application/json"
+ }
+
+ fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
+ connectors.nsure.base_url.as_ref()
+ }
+}
+
+impl Payment for Nsure {}
+impl PaymentAuthorize for Nsure {}
+impl PaymentSync for Nsure {}
+impl PaymentVoid for Nsure {}
+impl PaymentCapture for Nsure {}
+impl PaymentSession for Nsure {}
+impl MandateSetup for Nsure {}
+impl ConnectorAccessToken for Nsure {}
+impl PaymentToken for Nsure {}
+impl Refund for Nsure {}
+impl RefundExecute for Nsure {}
+impl RefundSync for Nsure {}
+impl ConnectorValidation for Nsure {}
+impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
+ for Nsure
+{
+}
+impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Nsure {}
+impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for Nsure {}
+impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Nsure {}
+impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Nsure {}
+impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Nsure {}
+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Nsure {}
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Nsure {}
+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Nsure {}
+impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Nsure {}
+
+#[cfg(feature = "frm")]
+impl FraudCheck for Nsure {}
+#[cfg(feature = "frm")]
+impl FraudCheckSale for Nsure {}
+#[cfg(feature = "frm")]
+impl FraudCheckCheckout for Nsure {}
+#[cfg(feature = "frm")]
+impl FraudCheckTransaction for Nsure {}
+#[cfg(feature = "frm")]
+impl FraudCheckFulfillment for Nsure {}
+#[cfg(feature = "frm")]
+impl FraudCheckRecordReturn for Nsure {}
+#[cfg(feature = "frm")]
+impl FraudCheckPayout for Nsure {}
+
+// The FRM flows must fail loudly on the direct path rather than inherit the
+// trait default, which returns `Ok(None)` and lets the flow complete as a no-op
+// with the seeded `Pending` status. That would let a payment through unscored
+// even under `PreFrmFailureMode::FailClosed`. Returning an error here routes
+// the case through the existing fail-open/fail-closed handling instead.
+#[cfg(feature = "frm")]
+macro_rules! ucs_only_frm_flow {
+ ($flow:ty, $request:ty) => {
+ impl ConnectorIntegration<$flow, $request, FraudCheckResponseData> for Nsure {
+ fn build_request(
+ &self,
+ _req: &RouterData<$flow, $request, FraudCheckResponseData>,
+ _connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, ConnectorError> {
+ Err(ConnectorError::NotImplemented(
+ "nsure runs on the Unified Connector Service and has no direct integration"
+ .to_string(),
+ )
+ .into())
+ }
+ }
+ };
+}
+
+#[cfg(feature = "frm")]
+ucs_only_frm_flow!(Sale, FraudCheckSaleData);
+#[cfg(feature = "frm")]
+ucs_only_frm_flow!(Checkout, FraudCheckCheckoutData);
+#[cfg(feature = "frm")]
+ucs_only_frm_flow!(Transaction, FraudCheckTransactionData);
+#[cfg(feature = "frm")]
+ucs_only_frm_flow!(Fulfillment, FraudCheckFulfillmentData);
+#[cfg(feature = "frm")]
+ucs_only_frm_flow!(RecordReturn, FraudCheckRecordReturnData);
+#[cfg(feature = "frm")]
+ucs_only_frm_flow!(PoFrm, FraudCheckPayoutData);
+
+#[async_trait::async_trait]
+impl webhooks::IncomingWebhook for Nsure {
+ fn get_webhook_object_reference_id(
+ &self,
+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<api_models::webhooks::ObjectReferenceId, ConnectorError> {
+ Err(report!(ConnectorError::WebhooksNotImplemented))
+ }
+
+ fn get_webhook_event_type(
+ &self,
+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ _context: Option<&webhooks::WebhookContext>,
+ ) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, ConnectorError> {
+ Err(report!(ConnectorError::WebhooksNotImplemented))
+ }
+
+ fn get_webhook_resource_object(
+ &self,
+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<Box<dyn hyperswitch_masking::ErasedMaskSerialize>, ConnectorError> {
+ Err(report!(ConnectorError::WebhooksNotImplemented))
+ }
+}
+
+static NSURE_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
+ display_name: "nSure",
+ description:
+ "nSure.ai fraud and risk management provider. Executed via the Unified Connector Service.",
+ connector_type: common_enums::HyperswitchConnectorCategory::FraudAndRiskManagementProvider,
+ integration_status: common_enums::ConnectorIntegrationStatus::Sandbox,
+};
+
+impl ConnectorSpecifications for Nsure {
+ fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
+ Some(&NSURE_CONNECTOR_INFO)
+ }
+
+ fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
+ None
+ }
+
+ fn get_supported_webhook_flows(&self) -> Option<&'static [common_enums::enums::EventClass]> {
+ None
+ }
+}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index f7edad748e..45097ba09a 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -335,6 +335,7 @@ default_imp_for_authorize_session_token!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Stripe,
connectors::Stripebilling,
@@ -513,6 +514,7 @@ default_imp_for_payment_settlement_split_create!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -691,6 +693,7 @@ default_imp_for_calculate_tax!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -820,6 +823,7 @@ default_imp_for_session_update!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stripe,
connectors::Stax,
connectors::Square,
@@ -998,6 +1002,7 @@ default_imp_for_post_session_tokens!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripe,
@@ -1172,6 +1177,7 @@ default_imp_for_create_order!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripe,
@@ -1363,6 +1369,7 @@ default_imp_for_update_post_confirm!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripe,
@@ -1524,6 +1531,7 @@ default_imp_for_update_metadata!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripebilling,
@@ -1712,6 +1720,7 @@ default_imp_for_cancel_post_capture!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripe,
@@ -1898,6 +1907,7 @@ default_imp_for_cancel_post_capture_sync!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripe,
@@ -2103,6 +2113,7 @@ default_imp_for_complete_authorize!(
connectors::Santander,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -2277,6 +2288,7 @@ default_imp_for_incremental_authorization!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -2401,6 +2413,7 @@ default_imp_for_extend_authorization!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripe,
@@ -2621,6 +2634,7 @@ default_imp_for_create_customer!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stripebilling,
connectors::Taxjar,
@@ -2785,6 +2799,7 @@ default_imp_for_connector_redirect_response!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -2949,6 +2964,7 @@ default_imp_for_pre_authenticate_steps!(
connectors::Santander,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Silverflow,
connectors::Square,
connectors::Stax,
@@ -3125,6 +3141,7 @@ default_imp_for_authenticate_steps!(
connectors::Shift4,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Silverflow,
connectors::Square,
connectors::Stax,
@@ -3301,6 +3318,7 @@ default_imp_for_post_authenticate_steps!(
connectors::Shift4,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Silverflow,
connectors::Square,
connectors::Stax,
@@ -3469,6 +3487,7 @@ default_imp_for_pre_processing_steps!(
connectors::Santander,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -3644,6 +3663,7 @@ default_imp_for_post_processing_steps!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -3824,6 +3844,7 @@ default_imp_for_approve!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -4004,6 +4025,7 @@ default_imp_for_reject!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -4184,6 +4206,7 @@ default_imp_for_webhook_source_verification!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -4361,6 +4384,7 @@ default_imp_for_accept_dispute!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -4537,6 +4561,7 @@ default_imp_for_submit_evidence!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -4713,6 +4738,7 @@ default_imp_for_defend_dispute!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -4893,6 +4919,7 @@ default_imp_for_fetch_disputes!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -5072,6 +5099,7 @@ default_imp_for_dispute_sync!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -5258,6 +5286,7 @@ default_imp_for_file_upload!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -5418,6 +5447,7 @@ default_imp_for_payouts!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripebilling,
@@ -5586,6 +5616,7 @@ default_imp_for_payouts_create!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -5761,6 +5792,7 @@ default_imp_for_payouts_retrieve!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -5937,6 +5969,7 @@ default_imp_for_payouts_eligibility!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -6107,6 +6140,7 @@ default_imp_for_payouts_fulfill!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -6280,6 +6314,7 @@ default_imp_for_payouts_cancel!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -6456,6 +6491,7 @@ default_imp_for_payouts_quote!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -6635,6 +6671,7 @@ default_imp_for_payouts_recipient!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -6813,6 +6850,7 @@ default_imp_for_payouts_recipient_account!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
@@ -8062,6 +8100,7 @@ default_imp_for_revoking_mandates!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -8240,6 +8279,7 @@ default_imp_for_uas_pre_authentication!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stripe,
connectors::Stax,
connectors::Square,
@@ -8417,6 +8457,7 @@ default_imp_for_uas_webhook!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stripe,
connectors::Stax,
connectors::Square,
@@ -8594,6 +8635,7 @@ default_imp_for_uas_post_authentication!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stripe,
connectors::Stax,
connectors::Square,
@@ -8772,6 +8814,7 @@ default_imp_for_uas_authentication_confirmation!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -8941,6 +8984,7 @@ default_imp_for_connector_request_id!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -9313,6 +9357,7 @@ default_imp_for_connector_authentication!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -9489,6 +9534,7 @@ default_imp_for_uas_authentication!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -9677,6 +9723,7 @@ default_imp_for_revenue_recovery_dispute_record_back!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Stripe,
connectors::Square,
@@ -9844,6 +9891,7 @@ default_imp_for_revenue_recovery!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Stripe,
connectors::Square,
@@ -10074,6 +10122,7 @@ default_imp_for_subscriptions!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Stripe,
connectors::Square,
@@ -10254,6 +10303,7 @@ default_imp_for_billing_connector_payment_sync!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stripe,
connectors::Stax,
connectors::Square,
@@ -10426,6 +10476,7 @@ default_imp_for_revenue_recovery_record_back!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stripe,
connectors::Stax,
connectors::Square,
@@ -10602,6 +10653,7 @@ default_imp_for_billing_connector_invoice_sync!(
connectors::SanlamPayshield,
connectors::Santander,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Shift4,
connectors::Sift,
connectors::Silverflow,
@@ -10775,6 +10827,7 @@ default_imp_for_external_vault!(
connectors::SanlamPayshield,
connectors::Santander,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Shift4,
connectors::Sift,
connectors::Silverflow,
@@ -10953,6 +11006,7 @@ default_imp_for_external_vault_insert!(
connectors::SanlamPayshield,
connectors::Santander,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Shift4,
connectors::Sift,
connectors::Silverflow,
@@ -11130,6 +11184,7 @@ default_imp_for_gift_card_balance_check!(
connectors::Shift4,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Silverflow,
connectors::Square,
connectors::Stax,
@@ -11308,6 +11363,7 @@ default_imp_for_external_vault_retrieve!(
connectors::SanlamPayshield,
connectors::Santander,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Shift4,
connectors::Sift,
connectors::Silverflow,
@@ -11486,6 +11542,7 @@ default_imp_for_external_vault_delete!(
connectors::SanlamPayshield,
connectors::Santander,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Shift4,
connectors::Sift,
connectors::Silverflow,
@@ -11665,6 +11722,7 @@ default_imp_for_external_vault_create!(
connectors::SanlamPayshield,
connectors::Santander,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Shift4,
connectors::Sift,
connectors::Silverflow,
@@ -11845,6 +11903,7 @@ default_imp_for_connector_authentication_token!(
connectors::Santander,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Shift4,
connectors::Silverflow,
connectors::Stax,
@@ -12025,6 +12084,7 @@ default_imp_for_external_vault_proxy_payments_create!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -12213,6 +12273,7 @@ default_imp_for_connector_webhook_register!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Stripe,
connectors::Stripebilling,
@@ -13219,6 +13280,7 @@ default_imp_for_generate_qr_flow!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -13398,6 +13460,7 @@ default_imp_for_push_notification_flow!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Stax,
connectors::Square,
connectors::Stripe,
@@ -13534,6 +13597,7 @@ default_imp_for_pre_authorize_void!(
connectors::Sift,
connectors::Silverflow,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Square,
connectors::Stax,
connectors::Stripe,
@@ -13776,6 +13840,7 @@ default_imp_for_refund_void_post_refund!(
connectors::Shift4,
connectors::Sift,
connectors::Signifyd,
+ connectors::Nsure,
connectors::Silverflow,
connectors::Square,
connectors::Stax,
diff --git a/crates/hyperswitch_domain_models/src/connector_endpoints.rs b/crates/hyperswitch_domain_models/src/connector_endpoints.rs
index 8040b80c18..4a0c9c2166 100644
--- a/crates/hyperswitch_domain_models/src/connector_endpoints.rs
+++ b/crates/hyperswitch_domain_models/src/connector_endpoints.rs
@@ -110,6 +110,7 @@ pub struct Connectors {
pub noon: ConnectorParamsWithModeType,
pub nordea: ConnectorParams,
pub novalnet: ConnectorParams,
+ pub nsure: ConnectorParams,
pub nuvei: ConnectorParams,
pub opayo: ConnectorParams,
pub opennode: ConnectorParams,
diff --git a/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs b/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs
index d41e108476..a04ff883ca 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs
@@ -8,7 +8,7 @@ use hyperswitch_masking::Secret;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
-use crate::router_request_types;
+use crate::{payment_method_data::PaymentMethodData, router_request_types};
#[derive(Debug, Clone)]
pub struct FraudCheckSaleData {
@@ -24,7 +24,13 @@ pub struct FraudCheckSaleData {
pub payment_method_data: Option<api_models::payments::AdditionalPaymentData>,
}
-#[derive(Debug, Clone)]
+/// `Serialize` is here only to satisfy the `Req: Serialize` bound on
+/// `execute_payment_gateway`. `payment_method_data_full` carries the full
+/// instrument, and `Secret`/`CardNumber` mask **only** under
+/// `hyperswitch_masking::masked_serialize` — a plain serializer (e.g.
+/// `serde_json::to_string`, `json!`) emits the raw PAN. Never feed this type
+/// to a raw serializer or a `?`-formatted log.
+#[derive(Debug, Clone, Serialize)]
pub struct FraudCheckCheckoutData {
pub amount: MinorUnit,
pub order_details: Option<Vec<OrderDetailsWithAmount>>,
@@ -38,6 +44,14 @@ pub struct FraudCheckCheckoutData {
pub email: Option<Email>,
pub phone: Option<Secret<String>>,
pub phone_country_code: Option<String>,
+ /// Buyer's full name from the intent's customer details. Risk providers
+ /// match buyer history on it alongside `email`/`phone`.
+ pub customer_name: Option<Secret<String>>,
+ /// The full instrument being scored (card BIN, last four, expiry). The
+ /// `payment_method_data` above is the thinner `AdditionalPaymentData`
+ /// shape the in-process connectors consume; UCS-backed providers need the
+ /// domain type.
+ pub payment_method_data_full: Option<PaymentMethodData>,
}
#[derive(Debug, Clone)]
diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs
index c3d63e0d2e..58244e4f63 100644
--- a/crates/router/src/connector.rs
+++ b/crates/router/src/connector.rs
@@ -38,21 +38,21 @@ pub use hyperswitch_connectors::connectors::{
mollie::Mollie, moneris, moneris::Moneris, mpgs, mpgs::Mpgs, multisafepay,
multisafepay::Multisafepay, netcetera, netcetera::Netcetera, nexinets, nexinets::Nexinets,
nexixpay, nexixpay::Nexixpay, nmi, nmi::Nmi, nomupay, nomupay::Nomupay, noon, noon::Noon,
- nordea, nordea::Nordea, novalnet, novalnet::Novalnet, nuvei, nuvei::Nuvei, opayo, opayo::Opayo,
- opennode, opennode::Opennode, paybox, paybox::Paybox, payconex, payconex::Payconex, paydotcom,
- paydotcom::Paydotcom, payeezy, payeezy::Payeezy, payjustnow, payjustnow::Payjustnow,
- payjustnowinstore, payjustnowinstore::Payjustnowinstore, payload, payload::Payload, payme,
- payme::Payme, paynearme, paynearme::Paynearme, payone, payone::Payone, paypal, paypal::Paypal,
- paysafe, paysafe::Paysafe, paystack, paystack::Paystack, paytm, paytm::Paytm, payu, payu::Payu,
- peachpayments, peachpayments::Peachpayments, phonepe, phonepe::Phonepe, placetopay,
- placetopay::Placetopay, plaid, plaid::Plaid, powertranz, powertranz::Powertranz, prophetpay,
- prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay, razorpay::Razorpay, recurly,
- recurly::Recurly, redsys, redsys::Redsys, revolv3, revolv3::Revolv3, riskified,
- riskified::Riskified, saferpay, saferpay::Saferpay, sanlam_payshield,
- sanlam_payshield::SanlamPayshield, santander, santander::Santander, shift4, shift4::Shift4,
- sift, sift::Sift, signifyd, signifyd::Signifyd, silverflow, silverflow::Silverflow, square,
- square::Square, stax, stax::Stax, stripe, stripe::Stripe, stripebilling,
- stripebilling::Stripebilling, taxjar, taxjar::Taxjar, tesouro, tesouro::Tesouro,
+ nordea, nordea::Nordea, novalnet, novalnet::Novalnet, nsure, nsure::Nsure, nuvei, nuvei::Nuvei,
+ opayo, opayo::Opayo, opennode, opennode::Opennode, paybox, paybox::Paybox, payconex,
+ payconex::Payconex, paydotcom, paydotcom::Paydotcom, payeezy, payeezy::Payeezy, payjustnow,
+ payjustnow::Payjustnow, payjustnowinstore, payjustnowinstore::Payjustnowinstore, payload,
+ payload::Payload, payme, payme::Payme, paynearme, paynearme::Paynearme, payone, payone::Payone,
+ paypal, paypal::Paypal, paysafe, paysafe::Paysafe, paystack, paystack::Paystack, paytm,
+ paytm::Paytm, payu, payu::Payu, peachpayments, peachpayments::Peachpayments, phonepe,
+ phonepe::Phonepe, placetopay, placetopay::Placetopay, plaid, plaid::Plaid, powertranz,
+ powertranz::Powertranz, prophetpay, prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay,
+ razorpay::Razorpay, recurly, recurly::Recurly, redsys, redsys::Redsys, revolv3,
+ revolv3::Revolv3, riskified, riskified::Riskified, saferpay, saferpay::Saferpay,
+ sanlam_payshield, sanlam_payshield::SanlamPayshield, santander, santander::Santander, shift4,
+ shift4::Shift4, sift, sift::Sift, signifyd, signifyd::Signifyd, silverflow,
+ silverflow::Silverflow, square, square::Square, stax, stax::Stax, stripe, stripe::Stripe,
+ stripebilling, stripebilling::Stripebilling, taxjar, taxjar::Taxjar, tesouro, tesouro::Tesouro,
threedsecureio, threedsecureio::Threedsecureio, thunes, thunes::Thunes, tokenex,
tokenex::Tokenex, tokenio, tokenio::Tokenio, truelayer, truelayer::Truelayer, trustly,
trustly::Trustly, trustpay, trustpay::Trustpay, trustpayments, trustpayments::Trustpayments,
diff --git a/crates/router/src/core/connector_validation.rs b/crates/router/src/core/connector_validation.rs
index 4c2879f6c1..ff040ad951 100644
--- a/crates/router/src/core/connector_validation.rs
+++ b/crates/router/src/core/connector_validation.rs
@@ -668,6 +668,20 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {
zsl::transformers::ZslAuthType::try_from(self.auth_type)?;
Ok(())
}
+ api_enums::Connector::Nsure => {
+ // Executed via UCS, so there is no in-process auth type to
+ // delegate to. nSure needs the authorization key plus the
+ // portal Application ID.
+ match self.auth_type {
+ hyperswitch_domain_models::router_data::ConnectorAuthType::BodyKey {
+ ..
+ }
+ | hyperswitch_domain_models::router_data::ConnectorAuthType::HeaderKey {
+ ..
+ } => Ok(()),
+ _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
+ }
+ }
api_enums::Connector::Signifyd => {
signifyd::transformers::SignifydAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rs
index b8d138ed1c..c4fc4970f6 100644
--- a/crates/router/src/core/fraud_check.rs
+++ b/crates/router/src/core/fraud_check.rs
@@ -52,6 +52,8 @@ use crate::{
utils::ValueExt,
};
pub mod flows;
+#[cfg(feature = "v1")]
+pub mod gateway;
pub mod operation;
pub mod types;
@@ -158,6 +160,70 @@ where
frm_data.fraud_check.last_step = FraudCheckLastStep::TransactionOrRecordRefund
}
+ // UCS-backed FRM providers (e.g. nSure) have no in-process connector: the
+ // risk evaluation is executed by the connector-service, which owns the
+ // provider-specific transformation. Only the pre-authorization risk
+ // evaluation is routed there; the notify-style flows have no UCS equivalent
+ // yet and always resolve to the direct path.
+ //
+ // `pre_payment_frm_core` invokes `call_frm_service` twice for a Pre flow —
+ // once for Checkout and once for Transaction — and both carry
+ // `FraudCheckType::PreFrm`. Only the first is a risk *evaluation*; the
+ // second is a notification whose result is discarded by the caller. Gating
+ // on `last_step == Processing` (set at row insert, advanced to
+ // `CheckoutOrSale` after the first call) ensures nSure is asked exactly once
+ // per payment, so the provider is not billed twice and does not see a
+ // repeated `uniqueRequestId`.
+ let is_pre_risk_evaluation = matches!(
+ frm_data.fraud_check.frm_transaction_type,
+ FraudCheckType::PreFrm
+ ) && matches!(
+ frm_data.fraud_check.last_step,
+ FraudCheckLastStep::Processing
+ );
+
+ // Same routing decision every UCS flow makes. A UCS-only FRM provider is a
+ // `ConnectorIntegrationType::UcsConnector` (listed in `ucs_only_connectors`),
+ // for which `decide_execution_path` returns UCS unconditionally and the kill
+ // switch is skipped — there is no direct integration to divert to.
+ // Everything else resolves to Direct.
+ let execution_path = if is_pre_risk_evaluation {
+ crate::core::unified_connector_service::should_call_unified_connector_service(
+ state,
+ platform.get_processor(),
+ &router_data,
+ None,
+ payments::CallConnectorAction::Trigger,
+ None,
+ common_enums::TransactionType::Payment,
+ )
+ .await?
+ .0
+ } else {
+ common_enums::ExecutionPath::Direct
+ };
+
+ let gateway_context = payments::gateway::context::RouterGatewayContext {
+ creds_identifier: None,
+ processor: platform.get_processor().clone(),
+ header_payload: hyperswitch_domain_models::payments::HeaderPayload::default(),
+ lineage_ids: external_services::grpc_client::LineageIds::new(
+ platform.get_processor().get_account().get_id().clone(),
+ frm_data.connector_details.profile_id.clone(),
+ ),
+ merchant_connector_account,
+ execution_path,
+ execution_mode: match execution_path {
+ common_enums::ExecutionPath::UnifiedConnectorService => {
+ common_enums::ExecutionMode::Primary
+ }
+ common_enums::ExecutionPath::ShadowUnifiedConnectorService => {
+ common_enums::ExecutionMode::Shadow
+ }
+ common_enums::ExecutionPath::Direct => common_enums::ExecutionMode::NotApplicable,
+ },
+ };
+
let connector =
FraudCheckConnectorData::get_connector_by_name(&frm_data.connector_details.connector_name)?;
let router_data_res = router_data
@@ -166,6 +232,7 @@ where
&connector,
payments::CallConnectorAction::Trigger,
platform,
+ gateway_context,
)
.await?;
@@ -314,12 +381,22 @@ pub async fn pre_payouts_frm_core(
)
.await?;
+ // Payout FRM has no UCS path; always the direct connector.
+ let gateway_context = payments::gateway::context::RouterGatewayContext::direct(
+ platform.get_processor().clone(),
+ (*applicability.frm_merchant_connector_account).clone(),
+ platform.get_processor().get_account().get_id().clone(),
+ payout_data.business_profile.get_id().clone(),
+ None,
+ );
+
router_data = router_data
.decide_frm_flows(
state,
&frm_connector,
payments::CallConnectorAction::Trigger,
platform,
+ gateway_context,
)
.await?;
@@ -685,6 +762,8 @@ where
connector_details: frm_connector_details.clone(),
order_details,
frm_metadata: payment_data.get_payment_intent().frm_metadata.clone(),
+ payment_method_data: payment_data.get_payment_method_data().cloned(),
+ payment_method_token: payment_data.get_payment_method_token().cloned(),
};
let fraud_check_operation: operation::BoxedFraudCheckOperation<F, D> =
@@ -1192,3 +1271,167 @@ pub async fn make_fulfillment_api_call(
})?;
Ok(services::ApplicationResponse::Json(fulfillment_response))
}
+
+/// Notify the FRM provider that a chargeback was opened against a payment it
+/// previously scored.
+///
+/// Self-contained entry point for the dispute webhook flow: resolves the
+/// `fraud_check` row for the payment, checks the provider is UCS-backed and
+/// configured, and sends `FRM_CHARGEBACK_RECEIVED`.
+///
+/// Best-effort by design — a chargeback has already happened, so failing to
+/// inform the provider must never fail the webhook. Errors are logged and
+/// swallowed, matching how the pre-connector FRM call is treated.
+#[cfg(all(feature = "v1", feature = "frm"))]
+#[allow(clippy::too_many_arguments)]
+pub async fn notify_frm_of_chargeback(
+ state: &SessionState,
+ platform: &domain::Platform,
+ payment_id: &common_utils::id_type::PaymentId,
+ profile_id: &common_utils::id_type::ProfileId,
+ amount: common_utils::types::MinorUnit,
+ currency: common_enums::Currency,
+ connector_dispute_id: Option<String>,
+ merchant_dispute_id: Option<String>,
+ chargeback_reason: Option<String>,
+) {
+ use std::str::FromStr;
+
+ use crate::core::unified_connector_service::{self, frm as ucs_frm};
+
+ let processor = platform.get_processor();
+
+ // Only payments that actually went through FRM have a row to notify against.
+ // The FRM row is keyed by the attempt's `active_frm_id`, so resolve the
+ // intent → active attempt → frm_id chain the same way `frm_fulfillment_core`
+ // does; a `None` frm_id means no fraud check ran for this payment.
+ let db = &*state.store;
+ let payment_intent = match db
+ .find_payment_intent_by_payment_id_processor_merchant_id(
+ payment_id,
+ processor.get_account().get_id(),
+ processor.get_key_store(),
+ processor.get_account().storage_scheme,
+ )
+ .await
+ {
+ Ok(intent) => intent,
+ Err(error) => {
+ logger::warn!(?error, "Failed to look up the payment for a chargeback");
+ return;
+ }
+ };
+ let payment_attempt = match db
+ .find_payment_attempt_by_payment_id_processor_merchant_id_attempt_id(
+ &payment_intent.payment_id,
+ processor.get_account().get_id(),
+ &payment_intent.active_attempt.get_id(),
+ processor.get_account().storage_scheme,
+ processor.get_key_store(),
+ )
+ .await
+ {
+ Ok(attempt) => attempt,
+ Err(error) => {
+ logger::warn!(
+ ?error,
+ "Failed to look up the payment attempt for a chargeback"
+ );
+ return;
+ }
+ };
+ let Some(frm_id) = payment_attempt.active_frm_id.clone() else {
+ logger::debug!(
+ payment_id = ?payment_id,
+ "No FRM record for this payment; skipping chargeback notification"
+ );
+ return;
+ };
+ let fraud_check = match db.find_fraud_check_by_frm_id(frm_id).await {
+ Ok(fraud_check) => fraud_check,
+ Err(error) => {
+ logger::warn!(?error, "Failed to look up the FRM record for a chargeback");
+ return;
+ }
+ };
+
+ let connector_name = fraud_check.frm_name.clone();
+
+ // No router data on this path, so ask the two framework pieces the shared
+ // decision is built from: is the connector UCS-only, and is UCS up.
+ let is_ucs_backed = match common_enums::connector_enums::Connector::from_str(&connector_name) {
+ Ok(connector) => matches!(
+ unified_connector_service::determine_connector_integration_type(state, connector).await,
+ Ok(common_enums::ConnectorIntegrationType::UcsConnector)
+ ),
+ Err(_) => false,
+ };
+ if !is_ucs_backed
+ || !matches!(
+ unified_connector_service::check_ucs_availability(state).await,
+ common_enums::UcsAvailability::Enabled
+ )
+ {
+ logger::debug!(
+ connector = %connector_name,
+ "FRM provider is not UCS-backed or UCS is unavailable; skipping chargeback notification"
+ );
+ return;
+ }
+
+ let merchant_connector_account = match get_merchant_connector_account(
+ state,
+ processor,
+ None,
+ profile_id,
+ &connector_name,
+ None,
+ )
+ .await
+ {
+ Ok(mca) => mca,
+ Err(error) => {
+ logger::warn!(?error, connector = %connector_name,
+ "Failed to resolve the FRM connector account for a chargeback");
+ return;
+ }
+ };
+
+ let context = ucs_frm::FrmNotificationContext {
+ amount,
+ currency,
+ connector_transaction_id: None,
+ // Correlation id from the original risk check — without it the provider
+ // cannot tie this chargeback to the transaction it scored.
+ frm_transaction_id: fraud_check.frm_transaction_id.clone(),
+ profile_id,
+ };
+
+ let notification = ucs_frm::FrmNotification::ChargebackReceived {
+ connector_dispute_id,
+ merchant_dispute_id,
+ chargeback_reason,
+ };
+
+ match ucs_frm::call_unified_connector_service_for_frm_notification(
+ state,
+ processor,
+ merchant_connector_account,
+ connector_name.clone(),
+ context,
+ notification,
+ )
+ .await
+ {
+ Ok(()) => logger::info!(
+ connector = %connector_name,
+ payment_id = ?payment_id,
+ "Notified the FRM provider of a chargeback"
+ ),
+ Err(error) => logger::warn!(
+ ?error,
+ connector = %connector_name,
+ "Failed to notify the FRM provider of a chargeback"
+ ),
+ }
+}
diff --git a/crates/router/src/core/fraud_check/flows.rs b/crates/router/src/core/fraud_check/flows.rs
index e96b355a3e..4cda6a82b4 100644
--- a/crates/router/src/core/fraud_check/flows.rs
+++ b/crates/router/src/core/fraud_check/flows.rs
@@ -24,12 +24,19 @@ use crate::{
#[async_trait]
pub trait FeatureFrm<F, T> {
+ /// Execute this flow against the connector.
+ ///
+ /// `gateway_context` carries the execution path decided by
+ /// `should_call_unified_connector_service`. Flows with a UCS equivalent
+ /// dispatch on it through `execute_payment_gateway`; the notify-style flows
+ /// have none and stay on the direct path regardless.
async fn decide_frm_flows<'a>(
self,
state: &SessionState,
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
platform: &domain::Platform,
+ gateway_context: payments::gateway::context::RouterGatewayContext,
) -> RouterResult<Self>
where
Self: Sized,
diff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rs
index 35bb25436e..0448020377 100644
--- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs
@@ -2,6 +2,8 @@ use async_trait::async_trait;
use common_utils::ext_traits::ValueExt;
use error_stack::ResultExt;
use hyperswitch_domain_models::payments::payment_intent;
+#[cfg(feature = "v1")]
+use hyperswitch_interfaces::api::gateway;
use hyperswitch_masking::ExposeInterface;
use super::{ConstructFlowSpecificData, FeatureFrm};
@@ -9,7 +11,7 @@ use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
fraud_check::types::FrmData,
- payments::{self, helpers},
+ payments::{self, gateway::context::RouterGatewayContext, helpers},
utils::get_gateway_frm_metadata,
},
errors, services,
@@ -146,6 +148,8 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC
&state.conf.connectors,
&self.payment_attempt,
)?,
+ customer_name: customer_details.as_ref().and_then(|c| c.name.clone()),
+ payment_method_data_full: self.payment_method_data.clone(),
},
response: Ok(FraudCheckResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId("".to_string()),
@@ -157,7 +161,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC
access_token: None,
session_token: None,
reference_id: None,
- payment_method_token: None,
+ payment_method_token: self.payment_method_token.clone(),
connector_customer: None,
preprocessing_id: None,
connector_request_reference_id: common_utils::generate_uuid_v4().to_string(),
@@ -213,17 +217,62 @@ impl FeatureFrm<frm_api::Checkout, FraudCheckCheckoutData> for FrmCheckoutRouter
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
platform: &domain::Platform,
+ gateway_context: RouterGatewayContext,
) -> RouterResult<Self> {
- decide_frm_flow(&mut self, state, connector, call_connector_action, platform).await
+ decide_frm_flow(
+ &mut self,
+ state,
+ connector,
+ call_connector_action,
+ platform,
+ gateway_context,
+ )
+ .await
}
}
+/// Dispatches on `gateway_context.execution_path`: `Direct` runs the in-process
+/// connector via `DirectGateway`, `UnifiedConnectorService` runs the UCS
+/// gateway in `core::fraud_check::gateway` under `ucs_logging_wrapper_granular`.
+#[cfg(feature = "v1")]
pub async fn decide_frm_flow(
router_data: &mut FrmCheckoutRouterData,
state: &SessionState,
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
_platform: &domain::Platform,
+ gateway_context: RouterGatewayContext,
+) -> RouterResult<FrmCheckoutRouterData> {
+ let connector_integration: services::BoxedFrmConnectorIntegrationInterface<
+ frm_api::Checkout,
+ FraudCheckCheckoutData,
+ FraudCheckResponseData,
+ > = connector.connector.get_connector_integration();
+ let resp = gateway::execute_payment_gateway(
+ state,
+ connector_integration,
+ router_data,
+ call_connector_action,
+ None,
+ None,
+ gateway_context,
+ )
+ .await
+ .to_payment_failed_response()?;
+
+ Ok(resp)
+}
+
+/// The FRM UCS gateway is v1-only (v2 `call_frm_service` is unimplemented), so
+/// v2 keeps the direct call.
+#[cfg(feature = "v2")]
+pub async fn decide_frm_flow(
+ router_data: &mut FrmCheckoutRouterData,
+ state: &SessionState,
+ connector: &FraudCheckConnectorData,
+ call_connector_action: payments::CallConnectorAction,
+ _platform: &domain::Platform,
+ _gateway_context: RouterGatewayContext,
) -> RouterResult<FrmCheckoutRouterData> {
let connector_integration: services::BoxedFrmConnectorIntegrationInterface<
frm_api::Checkout,
diff --git a/crates/router/src/core/fraud_check/flows/po_frm_flow.rs b/crates/router/src/core/fraud_check/flows/po_frm_flow.rs
index f5aa1ef648..ce4bc3fc37 100644
--- a/crates/router/src/core/fraud_check/flows/po_frm_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/po_frm_flow.rs
@@ -147,6 +147,8 @@ impl FeatureFrm<frm_api::PoFrm, FraudCheckPayoutData> for PoFrmRouterData {
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
platform: &domain::Platform,
+ // No UCS equivalent for payout FRM; always direct.
+ _gateway_context: payments::gateway::context::RouterGatewayContext,
) -> RouterResult<Self> {
decide_frm_flow(&mut self, state, connector, call_connector_action, platform).await
}
diff --git a/crates/router/src/core/fraud_check/flows/record_return.rs b/crates/router/src/core/fraud_check/flows/record_return.rs
index 3cf2c2098d..54c9680301 100644
--- a/crates/router/src/core/fraud_check/flows/record_return.rs
+++ b/crates/router/src/core/fraud_check/flows/record_return.rs
@@ -163,6 +163,8 @@ impl FeatureFrm<RecordReturn, FraudCheckRecordReturnData> for FrmRecordReturnRou
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
platform: &domain::Platform,
+ // No UCS equivalent for this flow; always direct.
+ _gateway_context: payments::gateway::context::RouterGatewayContext,
) -> RouterResult<Self> {
decide_frm_flow(&mut self, state, connector, call_connector_action, platform).await
}
diff --git a/crates/router/src/core/fraud_check/flows/sale_flow.rs b/crates/router/src/core/fraud_check/flows/sale_flow.rs
index 98455a01e6..5d9e3e4121 100644
--- a/crates/router/src/core/fraud_check/flows/sale_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/sale_flow.rs
@@ -215,6 +215,8 @@ impl FeatureFrm<frm_api::Sale, FraudCheckSaleData> for FrmSaleRouterData {
connector: &FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
platform: &domain::Platform,
+ // No UCS equivalent for this flow; always direct.
+ _gateway_context: payments::gateway::context::RouterGatewayContext,
) -> RouterResult<Self> {
decide_frm_flow(&mut self, state, connector, call_connector_action, platform).await
}
diff --git a/crates/router/src/core/fraud_check/flows/transaction_flow.rs b/crates/router/src/core/fraud_check/flows/transaction_flow.rs
index ff7ac0a838..a3ad51fef8 100644
--- a/crates/router/src/core/fraud_check/flows/transaction_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/transaction_flow.rs
@@ -182,6 +182,8 @@ impl FeatureFrm<frm_api::Transaction, FraudCheckTransactionData> for FrmTransact
connector: &frm_api::FraudCheckConnectorData,
call_connector_action: payments::CallConnectorAction,
platform: &domain::Platform,
+ // No UCS equivalent for this flow; always direct.
+ _gateway_context: payments::gateway::context::RouterGatewayContext,
) -> RouterResult<Self> {
decide_frm_flow(&mut self, state, connector, call_connector_action, platform).await
}
diff --git a/crates/router/src/core/fraud_check/gateway.rs b/crates/router/src/core/fraud_check/gateway.rs
new file mode 100644
index 0000000000..d07830da72
--- /dev/null
+++ b/crates/router/src/core/fraud_check/gateway.rs
@@ -0,0 +1,195 @@
+//! Gateway implementations for FRM flows.
+//!
+//! Mirrors `core::payments::gateway`: each flow that can execute on the Unified
+//! Connector Service implements [`PaymentGateway`] for the UCS path and
+//! [`FlowGateway`] to select between that and [`DirectGateway`].
+//!
+//! Only `Checkout` — the pre-authorization risk evaluation — has a UCS
+//! equivalent today. The notify-style flows (`Transaction`, `Sale`,
+//! `Fulfillment`, `RecordReturn`) stay on the direct path.
+
+use async_trait::async_trait;
+use common_enums::{CallConnectorAction, ExecutionPath};
+use common_utils::{errors::CustomResult, request::Request};
+use error_stack::ResultExt;
+use hyperswitch_domain_models::{
+ router_data::RouterData, router_flow_types::fraud_check as frm_api,
+ router_request_types::fraud_check::FraudCheckCheckoutData,
+ router_response_types::fraud_check::FraudCheckResponseData,
+};
+use hyperswitch_interfaces::{
+ api::gateway as payment_gateway,
+ connector_integration_interface::{BoxedConnectorIntegrationInterface, RouterDataConversion},
+ errors::ConnectorError,
+};
+use unified_connector_service_client::payments as payments_grpc;
+
+use crate::{
+ core::{
+ payments::gateway::context::RouterGatewayContext,
+ unified_connector_service::{self, frm as ucs_frm},
+ },
+ routes::SessionState,
+ services::logger,
+ types::transformers::ForeignTryFrom,
+};
+
+/// UCS gateway for the FRM `Checkout` flow.
+#[async_trait]
+impl<RCD>
+ payment_gateway::PaymentGateway<
+ SessionState,
+ RCD,
+ Self,
+ FraudCheckCheckoutData,
+ FraudCheckResponseData,
+ RouterGatewayContext,
+ > for frm_api::Checkout
+where
+ RCD: Clone
+ + Send
+ + Sync
+ + 'static
+ + RouterDataConversion<Self, FraudCheckCheckoutData, FraudCheckResponseData>,
+{
+ async fn execute(
+ self: Box<Self>,
+ state: &SessionState,
+ _connector_integration: BoxedConnectorIntegrationInterface<
+ Self,
+ RCD,
+ FraudCheckCheckoutData,
+ FraudCheckResponseData,
+ >,
+ router_data: &RouterData<Self, FraudCheckCheckoutData, FraudCheckResponseData>,
+ _call_connector_action: CallConnectorAction,
+ _connector_request: Option<Request>,
+ _return_raw_connector_response: Option<bool>,
+ context: RouterGatewayContext,
+ ) -> CustomResult<
+ RouterData<Self, FraudCheckCheckoutData, FraudCheckResponseData>,
+ ConnectorError,
+ > {
+ let processor = &context.processor;
+ let execution_mode = context.execution_mode;
+
+ let client = state
+ .grpc_client
+ .unified_connector_service_client
+ .clone()
+ .ok_or(ConnectorError::RequestEncodingFailed)
+ .attach_printable("Failed to fetch Unified Connector Service client")?;
+
+ // Bearer-authenticated providers (Kount) need an OAuth token in
+ // `state.access_token`; static-key providers (nSure) get `None` and
+ // ignore it. Failure here is non-fatal — the connector surfaces a
+ // clear auth error rather than us guessing.
+ let mut router_data = router_data.clone();
+ if router_data.access_token.is_none() {
+ router_data.access_token = ucs_frm::get_frm_access_token(state, &router_data, &context)
+ .await
+ .unwrap_or_else(|err| {
+ logger::warn!(
+ error = ?err,
+ "Failed to obtain an FRM access token; continuing without one"
+ );
+ None
+ });
+ }
+
+ let pre_risk_check_request =
+ payments_grpc::FrmServicePreRiskCheckRequest::foreign_try_from(&router_data)
+ .change_context(ConnectorError::RequestEncodingFailed)
+ .attach_printable("Failed to construct FRM pre risk check request")?;
+
+ let connector_auth_metadata =
+ unified_connector_service::build_unified_connector_service_auth_metadata(
+ context.merchant_connector_account,
+ processor.get_account().get_id(),
+ router_data.connector.clone(),
+ )
+ .change_context(ConnectorError::RequestEncodingFailed)
+ .attach_printable("Failed to construct request metadata")?;
+
+ let header_payload = state
+ .get_grpc_headers_ucs(execution_mode)
+ .external_vault_proxy_metadata(None)
+ .merchant_reference_id(None)
+ .resource_id(None)
+ .lineage_ids(context.lineage_ids);
+
+ Box::pin(unified_connector_service::ucs_logging_wrapper_granular(
+ router_data,
+ state,
+ pre_risk_check_request,
+ header_payload,
+ execution_mode,
+ |mut router_data, pre_risk_check_request, grpc_headers| async move {
+ let response = match Box::pin(client.frm_pre_risk_check(
+ pre_risk_check_request,
+ connector_auth_metadata,
+ grpc_headers,
+ ))
+ .await
+ {
+ Ok(resp) => resp,
+ // UCS connector errors are handled by the wrapper — see `ucs_logging_wrapper_granular`.
+ Err(report) => {
+ return Err(report.attach_printable("Failed to run FRM pre risk check"));
+ }
+ };
+
+ let pre_risk_check_response = response.into_inner();
+
+ let (frm_response, status_code) =
+ unified_connector_service::handle_unified_connector_service_response_for_frm_pre_risk_check(
+ pre_risk_check_response.clone(),
+ )
+ .attach_printable("Failed to deserialize UCS response")?;
+
+ router_data.response = frm_response;
+ router_data.connector_http_status_code = Some(status_code);
+
+ Ok((router_data, (), pre_risk_check_response))
+ },
+ ))
+ .await
+ .map(|(router_data, _)| router_data)
+ .map_err(payment_gateway::convert_ucs_error_to_connector_error)
+ }
+}
+
+impl<RCD>
+ payment_gateway::FlowGateway<
+ SessionState,
+ RCD,
+ FraudCheckCheckoutData,
+ FraudCheckResponseData,
+ RouterGatewayContext,
+ > for frm_api::Checkout
+where
+ RCD: Clone
+ + Send
+ + Sync
+ + 'static
+ + RouterDataConversion<Self, FraudCheckCheckoutData, FraudCheckResponseData>,
+{
+ fn get_gateway(
+ execution_path: ExecutionPath,
+ ) -> Box<
+ dyn payment_gateway::PaymentGateway<
+ SessionState,
+ RCD,
+ Self,
+ FraudCheckCheckoutData,
+ FraudCheckResponseData,
+ RouterGatewayContext,
+ >,
+ > {
+ match execution_path {
+ ExecutionPath::Direct => Box::new(payment_gateway::DirectGateway),
+ ExecutionPath::UnifiedConnectorService
+ | ExecutionPath::ShadowUnifiedConnectorService => Box::new(Self),
+ }
+ }
+}
diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
index f6776b67fb..444b17b346 100644
--- a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
+++ b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs
@@ -149,6 +149,8 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPost {
order_details: payment_data.order_details,
refund: None,
frm_metadata: payment_data.frm_metadata,
+ payment_method_data: payment_data.payment_method_data,
+ payment_method_token: payment_data.payment_method_token,
};
Ok(Some(frm_data))
}
diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
index 527d8a4932..476ef3f032 100644
--- a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
+++ b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
@@ -138,6 +138,8 @@ impl GetTracker<PaymentToFrmData> for FraudCheckPre {
order_details: payment_data.order_details,
refund: None,
frm_metadata: payment_data.frm_metadata,
+ payment_method_data: payment_data.payment_method_data,
+ payment_method_token: payment_data.payment_method_token,
};
Ok(Some(frm_data))
}
@@ -252,6 +254,8 @@ where
phone: router_data.request.phone,
phone_country_code: router_data.request.phone_country_code,
gateway_metadata: router_data.request.gateway_metadata,
+ customer_name: router_data.request.customer_name,
+ payment_method_data_full: router_data.request.payment_method_data_full,
})),
response: FrmResponse::Checkout(router_data.response),
})
diff --git a/crates/router/src/core/fraud_check/types.rs b/crates/router/src/core/fraud_check/types.rs
index d3199f0a0e..6edbd1cac3 100644
--- a/crates/router/src/core/fraud_check/types.rs
+++ b/crates/router/src/core/fraud_check/types.rs
@@ -11,7 +11,6 @@ use api_models::{
};
use common_enums::{FrmSuggestion, PreFrmFailureMode};
use common_utils::pii::SecretSerdeValue;
-use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
#[cfg(all(feature = "payouts", feature = "v1"))]
use hyperswitch_domain_models::{
address::Address as PayoutAddress, customer::Customer, payouts::payout_attempt::PayoutAttempt,
@@ -23,6 +22,11 @@ pub use hyperswitch_domain_models::{
},
types::OrderDetailsWithAmount,
};
+use hyperswitch_domain_models::{
+ payment_method_data::PaymentMethodData,
+ payments::{payment_attempt::PaymentAttempt, PaymentIntent},
+ router_data::PaymentMethodToken,
+};
#[cfg(feature = "payouts")]
use hyperswitch_interfaces::configs::MerchantConnectorAccountType;
use hyperswitch_masking::Serialize;
@@ -76,6 +80,11 @@ pub struct FrmData {
pub order_details: Option<Vec<OrderDetailsWithAmount>>,
pub refund: Option<RefundResponse>,
pub frm_metadata: Option<SecretSerdeValue>,
+ /// The instrument being scored, carried from payment data so UCS-backed
+ /// providers see the full card details rather than the attempt's
+ /// `AdditionalPaymentData` summary.
+ pub payment_method_data: Option<PaymentMethodData>,
+ pub payment_method_token: Option<PaymentMethodToken>,
}
#[derive(Debug)]
@@ -100,6 +109,8 @@ pub struct PaymentToFrmData {
pub connector_details: ConnectorDetailsCore,
pub order_details: Option<Vec<OrderDetailsWithAmount>>,
pub frm_metadata: Option<SecretSerdeValue>,
+ pub payment_method_data: Option<PaymentMethodData>,
+ pub payment_method_token: Option<PaymentMethodToken>,
}
#[cfg(all(feature = "payouts", feature = "v1"))]
diff --git a/crates/router/src/core/payments/gateway/access_token_gateway.rs b/crates/router/src/core/payments/gateway/access_token_gateway.rs
index bb4de5d9da..95a11843df 100644
--- a/crates/router/src/core/payments/gateway/access_token_gateway.rs
+++ b/crates/router/src/core/payments/gateway/access_token_gateway.rs
@@ -102,13 +102,49 @@ where
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
- // A merchant-authentication (access-token) call can originate from either a
- // payment or a payout. The connector type selects the UCS connector header
- // namespace, while the ids below carry the payment/payout reference context.
+ // A merchant-authentication (access-token) call can originate from a
+ // payment, a payout, or an FRM pre-risk check. The connector type selects
+ // the UCS connector header namespace, while the ids below carry the
+ // payment/payout reference context.
+ //
+ // The merchant declared the type when the connector account was created,
+ // so read it from there rather than inferring it from the connector name.
+ // Cached credentials carry no type; fall back to the name only then.
let connector_type = if router_data.payout_id.is_some() {
ConnectorType::PayoutProcessor
} else {
- ConnectorType::PaymentProcessor
+ let declared = {
+ #[cfg(feature = "v1")]
+ {
+ match &merchant_connector_account {
+ crate::core::payments::helpers::MerchantConnectorAccountType::DbVal(
+ mca,
+ ) => Some(mca.connector_type),
+ crate::core::payments::helpers::MerchantConnectorAccountType::CacheVal(
+ _,
+ ) => None,
+ }
+ }
+ #[cfg(feature = "v2")]
+ {
+ match &merchant_connector_account {
+ hyperswitch_domain_models::merchant_connector_account::MerchantConnectorAccountTypeDetails::MerchantConnectorAccount(mca) => {
+ Some(mca.connector_type)
+ }
+ hyperswitch_domain_models::merchant_connector_account::MerchantConnectorAccountTypeDetails::MerchantConnectorDetails(_) => None,
+ }
+ }
+ };
+ match declared {
+ Some(ConnectorType::PaymentVas) => ConnectorType::PaymentVas,
+ Some(_) => ConnectorType::PaymentProcessor,
+ None if api_models::enums::FrmConnectors::from_str(&router_data.connector)
+ .is_ok() =>
+ {
+ ConnectorType::PaymentVas
+ }
+ None => ConnectorType::PaymentProcessor,
+ }
};
let (merchant_reference_id, resource_id) = if let Some(payout_id) =
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index d8f1f12734..2f4a8f444d 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -30,10 +30,13 @@ use hyperswitch_domain_models::{
platform::Processor,
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, PaymentMethodToken, RouterData},
router_flow_types::refunds,
- router_request_types::RefundsData,
- router_response_types::{PaymentsResponseData, PayoutsResponseData, RefundsResponseData},
+ router_request_types::{RefundsData, ResponseId},
+ router_response_types::{
+ fraud_check::FraudCheckResponseData, PaymentsResponseData, PayoutsResponseData,
+ RefundsResponseData,
+ },
};
-use hyperswitch_interfaces::helpers as interface_helpers;
+use hyperswitch_interfaces::{consts as interface_consts, helpers as interface_helpers};
use hyperswitch_masking::{ExposeInterface, PeekInterface, Secret};
use router_env::{instrument, logger, tracing};
use unified_connector_service_cards::CardNumber;
@@ -70,6 +73,7 @@ use crate::{
};
pub mod connector_config;
+pub mod frm;
pub mod kill_switch;
pub mod transformers;
@@ -854,7 +858,7 @@ type UnifiedConnectorServiceCreateOrderResult = CustomResult<
>;
/// Checks if the Unified Connector Service (UCS) is available for use
-async fn check_ucs_availability(state: &SessionState) -> UcsAvailability {
+pub(crate) async fn check_ucs_availability(state: &SessionState) -> UcsAvailability {
let is_client_available = state.grpc_client.unified_connector_service_client.is_some();
let is_enabled = is_config_flag_enabled(state, consts::UCS_ENABLED).await;
@@ -3072,6 +3076,63 @@ pub fn handle_unified_connector_service_response_for_create_connector_customer(
Ok((connector_customer_result, status_code))
}
+/// Convert the UCS pre-risk-check response into Hyperswitch's FRM response shape.
+///
+/// Same shape as every other UCS handler: a populated `error` becomes
+/// `Err(ErrorResponse)` so the gateway surfaces a real connector error rather
+/// than a verdict; otherwise the response is a 2xx and carries a decision. A
+/// success without a parseable decision is a contract violation, not a verdict
+/// to guess at.
+pub fn handle_unified_connector_service_response_for_frm_pre_risk_check(
+ response: payments_grpc::FrmServicePreRiskCheckResponse,
+) -> CustomResult<(Result<FraudCheckResponseData, ErrorResponse>, u16), UnifiedConnectorServiceError>
+{
+ let status_code = transformers::convert_connector_service_status_code(response.status_code)?;
+
+ if let Some(error_info) = response.error.as_ref() {
+ let connector_details = error_info.connector_details.as_ref();
+ return Ok((
+ Err(ErrorResponse {
+ code: connector_details
+ .and_then(|details| details.code.clone())
+ .unwrap_or_else(|| interface_consts::NO_ERROR_CODE.to_string()),
+ message: connector_details
+ .and_then(|details| details.message.clone())
+ .unwrap_or_else(|| interface_consts::NO_ERROR_MESSAGE.to_string()),
+ reason: connector_details.and_then(|details| details.reason.clone()),
+ status_code,
+ attempt_status: None,
+ connector_transaction_id: response.frm_transaction_id.clone(),
+ connector_response_reference_id: None,
+ network_decline_code: None,
+ network_advice_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ status_code,
+ ));
+ }
+
+ // `frm_decision()` yields `Unspecified` for both an absent and an unknown
+ // value; the mapping treats that as an error.
+ let status = transformers::frm_status_from_ucs_decision(response.frm_decision())?;
+
+ Ok((
+ Ok(FraudCheckResponseData::TransactionResponse {
+ resource_id: response
+ .frm_transaction_id
+ .clone()
+ .map(ResponseId::ConnectorTransactionId)
+ .unwrap_or(ResponseId::NoResponseId),
+ status,
+ connector_metadata: None,
+ reason: response.reason.map(serde_json::Value::String),
+ score: response.risk_score,
+ }),
+ status_code,
+ ))
+}
+
pub fn handle_unified_connector_service_response_for_payment_create_order(
response: payments_grpc::PaymentServiceCreateOrderResponse,
prev_status: AttemptStatus,
diff --git a/crates/router/src/core/unified_connector_service/connector_config.rs b/crates/router/src/core/unified_connector_service/connector_config.rs
index d47e930cd8..98a9e2fb01 100644
--- a/crates/router/src/core/unified_connector_service/connector_config.rs
+++ b/crates/router/src/core/unified_connector_service/connector_config.rs
@@ -92,6 +92,13 @@ impl SantanderPayoutMetadataCompat {
}
}
+/// Optional nSure.ai settings that are not credentials, so they live on the
+/// merchant connector account metadata rather than the auth type.
+#[derive(Debug, serde::Deserialize)]
+pub struct NsureMetadata {
+ api_version: Option<String>,
+}
+
/// JP Morgan Orbital merchant provisioning facts. Neither value is a secret: they
/// travel in the request body, not in a header. `bin` selects the back-end
/// authorization host ("000001" = Stratus/US, "000002" = Tandem/Canada) and
@@ -560,6 +567,20 @@ pub enum ConnectorSpecificConfig {
payment_access_key: Secret<String>,
tariff_id: Secret<String>,
},
+ /// nSure.ai connector configuration.
+ ///
+ /// `api_key` is the authorization key, sent verbatim in the `Authorization`
+ /// header with no `Bearer`/`Basic` prefix. `app_id` is the Application ID
+ /// from the same nSure.ai portal screen. `api_version` reaches the provider
+ /// as `x-nsure-api-version`; the connector-service defaults it to 2.0.0 when
+ /// unset.
+ Nsure {
+ api_key: Secret<String>,
+ /// Optional on the connector-service side; a header-key-only account
+ /// authenticates with `api_key` alone.
+ app_id: Option<Secret<String>>,
+ api_version: Option<String>,
+ },
/// Gigadat connector configuration
Gigadat {
security_token: Secret<String>,
@@ -803,8 +824,6 @@ pub enum ConnectorSpecificConfig {
response_decryption_private_key: Secret<String>,
card_sync_key_id: String,
},
- /// Netcetera authentication connector configuration (no connector-specific config needed)
- Netcetera,
/// Santander payout connector configuration
Santander {
certificates: Secret<String>,
@@ -1571,6 +1590,32 @@ impl ForeignTryFrom<(Connector, &ConnectorAuthType, Option<&serde_json::Value>)>
}),
_ => Err(err("Novalnet requires SignatureKey auth type")),
},
+ Connector::Nsure => {
+ // Mirrors `connector_validation`, which accepts both shapes:
+ // BodyKey carries the authorization key plus the portal
+ // Application ID; HeaderKey carries the key alone, which the
+ // connector-service accepts since `app_id` is optional there.
+ let (api_key, app_id) = match auth {
+ ConnectorAuthType::BodyKey { api_key, key1 } => {
+ (api_key.clone(), Some(key1.clone()))
+ }
+ ConnectorAuthType::HeaderKey { api_key } => (api_key.clone(), None),
+ _ => return Err(err("Nsure requires BodyKey or HeaderKey auth type")),
+ };
+
+ let nsure_meta = metadata
+ .map(|m| {
+ serde_json::from_value::<NsureMetadata>(m.clone())
+ .map_err(|_| err("Invalid Nsure metadata format"))
+ })
+ .transpose()?;
+
+ Ok(Self::Nsure {
+ api_key,
+ app_id,
+ api_version: nsure_meta.and_then(|m| m.api_version),
+ })
+ }
Connector::Nuvei => match auth {
ConnectorAuthType::SignatureKey {
api_key,
@@ -2031,7 +2076,6 @@ impl ForeignTryFrom<(Connector, &ConnectorAuthType, Option<&serde_json::Value>)>
}
_ => Err(err("Juspay requires HeaderKey auth type")),
},
- Connector::Netcetera => Ok(Self::Netcetera),
Connector::Santander => match auth {
ConnectorAuthType::CertificateAuth {
certificate,
@@ -2125,20 +2169,21 @@ pub fn build_connector_config_header(
auth_type: &ConnectorAuthType,
merchant_account_metadata: Option<&serde_json::Value>,
) -> RouterResult<Option<String>> {
+ // Netcetera has no connector-specific config on the wire: connector-service's
+ // `ConnectorSpecificConfig` oneof has no `netcetera` case at all, so sending
+ // this header makes UCS hard-error on deserialization instead of falling back
+ // to the legacy auth header. Suppress it here so UCS takes the legacy-header
+ // path (`x-auth` / `x-api-key` / `x-key1`), which does work for Netcetera.
+ if matches!(connector, Connector::Netcetera) {
+ return Ok(None);
+ }
+
let config = ConnectorSpecificConfig::foreign_try_from((
connector,
auth_type,
merchant_account_metadata,
))?;
- // Netcetera has no connector-specific config on the wire (connector-service's
- // `ConnectorSpecificConfig` oneof has no `netcetera` case), so sending this header makes
- // UCS hard-error on deserialization instead of falling back to the legacy auth header.
- // Suppress it here so UCS takes the legacy-header path, which does work for Netcetera.
- if matches!(config, ConnectorSpecificConfig::Netcetera) {
- return Ok(None);
- }
-
let config_json = serde_json::to_value(&config)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to serialize connector config to JSON value")?;
diff --git a/crates/router/src/core/unified_connector_service/frm.rs b/crates/router/src/core/unified_connector_service/frm.rs
new file mode 100644
index 0000000000..5f5a41d6d0
--- /dev/null
+++ b/crates/router/src/core/unified_connector_service/frm.rs
@@ -0,0 +1,271 @@
+//! FRM-specific orchestration for the Unified Connector Service.
+//!
+//! Native FRM providers (Signifyd, Riskified, CyberSource Decision Manager) run
+//! in-process. UCS-backed providers instead have their risk evaluation executed
+//! by the connector-service, which owns the provider-specific transformation.
+//!
+//! This module holds what has no payments analogue: the access-token fetch for
+//! bearer-authenticated providers and the lifecycle notification sender. The
+//! `RouterData ──▶ FrmServicePreRiskCheckRequest` builder lives with every other
+//! request builder in `transformers.rs`, the verdict handler with its siblings
+//! in the parent module, and the gRPC call itself in `core::fraud_check::gateway`.
+
+use common_utils::{id_type, types::MinorUnit};
+use error_stack::ResultExt;
+use external_services::grpc_client::LineageIds;
+use hyperswitch_domain_models::{
+ platform::Processor,
+ router_data::{AccessToken, RouterData},
+ router_flow_types::{fraud_check as frm_api, AccessTokenAuth},
+ router_request_types::{fraud_check::FraudCheckCheckoutData, AccessTokenRequestData},
+ router_response_types::fraud_check::FraudCheckResponseData,
+};
+use hyperswitch_interfaces::api::gateway;
+use unified_connector_service_client::payments as payments_grpc;
+
+use super::{build_unified_connector_service_auth_metadata, get_ucs_client};
+use crate::{
+ core::{
+ errors::{self, RouterResult},
+ payments::{self, helpers::MerchantConnectorAccountType},
+ },
+ routes::SessionState,
+ services,
+ types::{api::FraudCheckConnectorData, transformers::ForeignTryFrom},
+};
+
+/// Fetch (and cache) the OAuth token a bearer-authenticated FRM provider needs.
+///
+/// Kount's risk API is bearer-authenticated: the connector-service reads the token from
+/// `state.access_token` and cannot mint one itself on the plain FRM service.
+/// Reads Redis first, falling back to UCS `CreateServerAuthenticationToken`.
+/// Providers using a static key (nSure) never reach this — `should_do_access_token`
+/// is connector-side, so we gate on whether UCS returns a token at all.
+#[cfg(feature = "v1")]
+pub async fn get_frm_access_token(
+ state: &SessionState,
+ router_data: &RouterData<frm_api::Checkout, FraudCheckCheckoutData, FraudCheckResponseData>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
+) -> RouterResult<Option<AccessToken>> {
+ let processor = &gateway_context.processor;
+ let merchant_connector_account = &gateway_context.merchant_connector_account;
+ let merchant_id = processor.get_account().get_id();
+ let connector_name = router_data.connector.as_str();
+
+ // Scope the cached token to the merchant connector account, the way the
+ // payments path does (`access_token::get_cached_access_token_for_ucs`).
+ // Keying on the connector name alone would make two accounts for the same
+ // FRM provider under one merchant share a token.
+ let merchant_connector_id = match merchant_connector_account {
+ MerchantConnectorAccountType::DbVal(mca) => Some(mca.get_id()),
+ MerchantConnectorAccountType::CacheVal(_) => None,
+ };
+
+ let access_token_key = common_utils::access_token::get_default_access_token_key(
+ merchant_id,
+ merchant_connector_id
+ .as_ref()
+ .map(|id| id.get_string_repr().to_string())
+ .unwrap_or_else(|| connector_name.to_string()),
+ );
+
+ if let Ok(Some(token)) = state.store.get_access_token(access_token_key.clone()).await {
+ router_env::logger::debug!(connector = connector_name, "FRM access token cache hit");
+ return Ok(Some(token));
+ }
+
+ // Same gateway the payments path uses for `create_access_token`, so the
+ // FRM token fetch runs under `ucs_logging_wrapper_granular` and gets the
+ // same request/response/timing event. The router data is re-typed to the
+ // access-token flow first (as `add_access_token` does); the gateway picks
+ // the `PaymentVas` connector namespace from the FRM connector name.
+ let access_token_request =
+ AccessTokenRequestData::try_from(router_data.connector_auth_type.clone())
+ .attach_printable(
+ "Could not create FRM access token request from connector credentials",
+ )?;
+ let access_token_router_data =
+ payments::helpers::router_data_type_conversion::<_, AccessTokenAuth, _, _, _, AccessToken>(
+ router_data.clone(),
+ access_token_request,
+ Err(hyperswitch_domain_models::router_data::ErrorResponse::default()),
+ );
+
+ let connector = FraudCheckConnectorData::get_connector_by_name(connector_name)?;
+ let connector_integration: services::BoxedAccessTokenConnectorIntegrationInterface<
+ AccessTokenAuth,
+ AccessTokenRequestData,
+ AccessToken,
+ > = connector.connector.get_connector_integration();
+
+ // The token fetch is a sub-step of the UCS pre-risk check, so it runs
+ // under the same gateway context that brought us here — same execution
+ // path, mode and account. Nothing to re-decide.
+ let token_result = gateway::execute_payment_gateway(
+ state,
+ connector_integration,
+ &access_token_router_data,
+ payments::CallConnectorAction::Trigger,
+ None,
+ None,
+ gateway_context.clone(),
+ )
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("UCS create_access_token gateway call failed for FRM")?
+ .response;
+ match token_result {
+ Ok(token) => {
+ // Best-effort cache; a write failure only costs an extra token call.
+ let _ = super::set_access_token_for_ucs(
+ state,
+ processor,
+ connector_name,
+ token.clone(),
+ merchant_connector_id.as_ref(),
+ None,
+ )
+ .await;
+ Ok(Some(token))
+ }
+ Err(err) => {
+ router_env::logger::error!(
+ connector = connector_name,
+ error = ?err,
+ "UCS returned an error for the FRM access token"
+ );
+ Ok(None)
+ }
+ }
+}
+
+// Lifecycle notifications: the connector-service exposes four FRM events
+// (payment succeeded/failure, refund processed, chargeback received) on one
+// `NotifyConnector` RPC, differing only in event type and payload variant.
+
+/// Which lifecycle event to report, plus the detail payload it carries.
+pub enum FrmNotification {
+ /// A chargeback/dispute was opened against a previously-scored payment.
+ ChargebackReceived {
+ connector_dispute_id: Option<String>,
+ merchant_dispute_id: Option<String>,
+ chargeback_reason: Option<String>,
+ },
+}
+
+impl FrmNotification {
+ fn event_type(&self) -> payments_grpc::NotifyEventType {
+ match self {
+ Self::ChargebackReceived { .. } => {
+ payments_grpc::NotifyEventType::FrmChargebackReceived
+ }
+ }
+ }
+
+ fn notification_type(self) -> payments_grpc::frm_notification_content::NotificationType {
+ match self {
+ Self::ChargebackReceived {
+ connector_dispute_id,
+ merchant_dispute_id,
+ chargeback_reason,
+ } => payments_grpc::frm_notification_content::NotificationType::Chargeback(
+ payments_grpc::FrmChargebackDetails {
+ connector_dispute_id,
+ merchant_dispute_id,
+ chargeback_reason,
+ },
+ ),
+ }
+ }
+}
+
+/// Facts shared by every FRM lifecycle notification.
+pub struct FrmNotificationContext<'a> {
+ pub amount: MinorUnit,
+ pub currency: common_enums::Currency,
+ pub connector_transaction_id: Option<String>,
+ /// Correlation id returned by the original risk check. Without it the
+ /// provider cannot tie the notification to the transaction it scored.
+ pub frm_transaction_id: Option<String>,
+ pub profile_id: &'a id_type::ProfileId,
+}
+
+/// Send an FRM lifecycle notification to the connector-service.
+///
+/// Generic over the event: the caller supplies the [`FrmNotification`] variant
+/// and this handles auth metadata, `x-frm-connector` routing, and the gRPC
+/// call.
+///
+/// Not yet wired to a call site. Before it is, bearer-authenticated providers
+/// (Kount) need the access token threaded into `NotifyConnectorRequest.state`
+/// via [`get_frm_access_token`], the way the pre-risk-check gateway does —
+/// without it the notification reaches the provider unauthenticated.
+#[cfg(feature = "v1")]
+pub async fn call_unified_connector_service_for_frm_notification(
+ state: &SessionState,
+ processor: &Processor,
+ merchant_connector_account: MerchantConnectorAccountType,
+ connector_name: String,
+ context: FrmNotificationContext<'_>,
+ notification: FrmNotification,
+) -> RouterResult<()> {
+ let ucs_client = get_ucs_client(state)?;
+
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ processor.get_account().get_id(),
+ connector_name.clone(),
+ )
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to build UCS auth metadata for the FRM notification")?;
+
+ let grpc_currency = payments_grpc::Currency::foreign_try_from(context.currency)
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to convert currency for the FRM notification")?;
+
+ let event_type = notification.event_type();
+
+ let content = payments_grpc::NotifyConnectorContent {
+ content: Some(
+ payments_grpc::notify_connector_content::Content::FrmNotification(
+ payments_grpc::FrmNotificationContent {
+ connector_transaction_id: context.connector_transaction_id.clone(),
+ amount: Some(payments_grpc::Money {
+ minor_amount: context.amount.get_amount_as_i64(),
+ currency: grpc_currency.into(),
+ }),
+ frm_transaction_id: context.frm_transaction_id.clone(),
+ notification_type: Some(notification.notification_type()),
+ ..Default::default()
+ },
+ ),
+ ),
+ };
+
+ let request = payments_grpc::NotifyConnectorRequest {
+ event_id: format!("frm-{}", common_utils::generate_id_with_default_len("evt")),
+ event_type: event_type.into(),
+ content: Some(content),
+ timestamp: common_utils::date_time::now_unix_timestamp(),
+ ..Default::default()
+ };
+
+ let grpc_headers = state
+ .get_grpc_headers_ucs(common_enums::ExecutionMode::Primary)
+ .lineage_ids(LineageIds::new(
+ processor.get_account().get_id().clone(),
+ context.profile_id.clone(),
+ ))
+ .external_vault_proxy_metadata(None)
+ .merchant_reference_id(None)
+ .resource_id(None)
+ .build();
+
+ ucs_client
+ .notify_connector(request, connector_auth_metadata, grpc_headers, event_type)
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("UCS notify_connector gRPC call failed for the FRM notification")?;
+
+ Ok(())
+}
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index 70d4d58855..0e0b293f41 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -24,20 +24,22 @@ use hyperswitch_domain_models::{
mandates::{MandateData, MandateDataType},
router_data::{AccessToken, ErrorResponse, L2L3Data, RouterData},
router_flow_types::{
+ fraud_check as frm_api,
payments::{Authorize, Capture, PSync, PreAuthorizeVoid, SetupMandate},
refunds::{Execute, RSync, VoidPostRefund},
unified_authentication_service as uas_flows, ExternalVaultProxy, IncrementalAuthorization,
Session,
},
router_request_types::{
- self, AuthenticationData, ExternalVaultProxyPaymentsData, PaymentsAuthorizeData,
- PaymentsCancelData, PaymentsCaptureData, PaymentsIncrementalAuthorizationData,
- PaymentsPreAuthorizeCancelData, PaymentsSessionData, PaymentsSyncData, RefundsData,
- SetupMandateRequestData, SyncRequestType,
+ self, fraud_check::FraudCheckCheckoutData, AuthenticationData,
+ ExternalVaultProxyPaymentsData, PaymentsAuthorizeData, PaymentsCancelData,
+ PaymentsCaptureData, PaymentsIncrementalAuthorizationData, PaymentsPreAuthorizeCancelData,
+ PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData,
+ SyncRequestType,
},
router_response_types::{
- NotifyConnectorResponseData, PaymentsResponseData, PayoutsResponseData, RedirectForm,
- RefundsResponseData,
+ fraud_check::FraudCheckResponseData, NotifyConnectorResponseData, PaymentsResponseData,
+ PayoutsResponseData, RedirectForm, RefundsResponseData,
},
ApiModelToDieselModelConvertor,
};
@@ -129,7 +131,27 @@ impl ForeignFrom<common_enums::TaxStatus> for payments_grpc::TaxStatus {
}
}
-fn build_ucs_order_details(
+/// Map a UCS FRM verdict onto Hyperswitch's fraud-check status.
+///
+/// Only reached on a 2xx with no `error` payload, so the status code is not an
+/// input. `Error`/`Unspecified` on a success response means the provider gave
+/// us nothing usable — surfaced as an error rather than silently approving or
+/// holding the payment.
+pub(super) fn frm_status_from_ucs_decision(
+ decision: payments_grpc::FrmDecision,
+) -> Result<storage_enums::FraudCheckStatus, error_stack::Report<UnifiedConnectorServiceError>> {
+ match decision {
+ payments_grpc::FrmDecision::Approve => Ok(storage_enums::FraudCheckStatus::Legit),
+ payments_grpc::FrmDecision::Reject => Ok(storage_enums::FraudCheckStatus::Fraud),
+ payments_grpc::FrmDecision::Review => Ok(storage_enums::FraudCheckStatus::ManualReview),
+ payments_grpc::FrmDecision::Error | payments_grpc::FrmDecision::Unspecified => {
+ Err(UnifiedConnectorServiceError::ResponseDeserializationFailed)
+ .attach_printable("UCS FRM pre risk check returned no usable decision")
+ }
+ }
+}
+
+pub(super) fn build_ucs_order_details(
order_details: Option<&[OrderDetailsWithAmount]>,
) -> Vec<payments_grpc::OrderDetailsWithAmount> {
order_details
@@ -10104,3 +10126,143 @@ impl transformers::ForeignTryFrom<payments_grpc::NotifyConnectorResponse>
})
}
}
+
+/// Build the pre-risk-check request from the FRM `Checkout` router data.
+///
+/// Everything the risk provider needs is already on the router data: the
+/// request carries the instrument and buyer details, and the top-level fields
+/// carry address, token, access token and `frm_metadata`.
+impl
+ transformers::ForeignTryFrom<
+ &RouterData<frm_api::Checkout, FraudCheckCheckoutData, FraudCheckResponseData>,
+ > for payments_grpc::FrmServicePreRiskCheckRequest
+{
+ type Error = error_stack::Report<UnifiedConnectorServiceError>;
+
+ fn foreign_try_from(
+ router_data: &RouterData<frm_api::Checkout, FraudCheckCheckoutData, FraudCheckResponseData>,
+ ) -> Result<Self, Self::Error> {
+ let request = &router_data.request;
+
+ let currency = request.currency.ok_or_else(|| {
+ error_stack::report!(UnifiedConnectorServiceError::MissingRequiredField {
+ field_name: "currency".into(),
+ })
+ })?;
+ let grpc_currency = payments_grpc::Currency::foreign_try_from(currency)?;
+
+ let amount = payments_grpc::Money {
+ minor_amount: request.amount.get_amount_as_i64(),
+ currency: grpc_currency.into(),
+ };
+
+ // `customer_id` is the stable merchant-side key risk providers use to
+ // build cross-transaction history for the buyer; the contact details
+ // alongside it are what they match on when the id is new.
+ let has_customer = request.customer_id.is_some()
+ || request.customer_name.is_some()
+ || request.email.is_some()
+ || request.phone.is_some();
+ let customer_info = has_customer.then(|| payments_grpc::Customer {
+ id: request
+ .customer_id
+ .as_ref()
+ .map(|id| id.get_string_repr().to_owned()),
+ // Sent as the full name; providers that want the parts split it
+ // themselves, since Hyperswitch does not store them apart.
+ name: request
+ .customer_name
+ .as_ref()
+ .map(|name| name.peek().to_owned()),
+ email: request
+ .email
+ .as_ref()
+ .map(|email| Secret::new(email.peek().to_owned())),
+ phone_number: request
+ .phone
+ .as_ref()
+ .map(|phone| Secret::new(phone.peek().to_owned())),
+ phone_country_code: request.phone_country_code.clone(),
+ ..Default::default()
+ });
+
+ // Reuses the same builder the payments UCS path uses, so the instrument
+ // is encoded identically for a risk check and for the authorization that
+ // follows it.
+ //
+ // A payment method Hyperswitch cannot encode degrades to `None` rather
+ // than failing: the FRM pre-check propagates its error with `?` in
+ // `pre_payment_frm_core`, so returning `Err` here would fail the payment
+ // outright over a risk-signal encoding problem.
+ let payment_method =
+ request
+ .payment_method_data_full
+ .as_ref()
+ .and_then(|payment_method_data| {
+ unified_connector_service::build_unified_connector_service_payment_method(
+ payment_method_data.clone(),
+ router_data.payment_method_type,
+ router_data.payment_method_token.as_ref(),
+ None,
+ )
+ .inspect_err(|error| {
+ router_env::logger::warn!(
+ ?error,
+ "Failed to encode the payment method for the FRM pre risk check; \
+ the provider will score this transaction without instrument details"
+ )
+ })
+ .ok()
+ });
+
+ // Merchant identity for risk scoring. The MCC lives on the business
+ // profile, which this path does not load, so it is left unset rather
+ // than issuing an extra fetch for a field no current provider reads.
+ let merchant_details = Some(payments_grpc::MerchantDetails {
+ merchant_id: Some(router_data.merchant_id.get_string_repr().to_owned()),
+ merchant_category_code: None,
+ });
+
+ // Same converter the payments flows use, so the provider gets the full
+ // device fingerprint (screen, timezone, OS, device model, referer) rather
+ // than a user-agent/IP subset. Fail-soft for the same reason as the
+ // payment method above: a malformed browser_info must not fail the check.
+ let browser_info = request.browser_info.as_ref().and_then(|info| {
+ payments_grpc::BrowserInformation::foreign_try_from(info.clone())
+ .inspect_err(|error| {
+ router_env::logger::warn!(
+ ?error,
+ "Failed to encode browser info for the FRM pre risk check; \
+ the provider will score this transaction without device details"
+ )
+ })
+ .ok()
+ });
+
+ let order_details = build_ucs_order_details(request.order_details.as_deref());
+
+ Ok(Self {
+ amount: Some(amount),
+ customer_info,
+ payment_method,
+ browser_info,
+ merchant_transaction_id: Some(router_data.attempt_id.clone()),
+ order_details,
+ address: Some(payments_grpc::PaymentAddress::foreign_try_from(
+ router_data.address.clone(),
+ )?),
+ merchant_details,
+ connector_feature_data: router_data
+ .frm_metadata
+ .as_ref()
+ .map(|metadata| Secret::new(metadata.clone().expose().to_string())),
+ // Bearer-authenticated providers read the token from
+ // `state.access_token`; the connector-service threads it onto FrmFlowData.
+ state: router_data
+ .access_token
+ .as_ref()
+ .map(ConnectorState::foreign_from),
+ ..Default::default()
+ })
+ }
+}
diff --git a/crates/router/src/types/api/connector_mapping.rs b/crates/router/src/types/api/connector_mapping.rs
index 01a71079b3..64917efdea 100644
--- a/crates/router/src/types/api/connector_mapping.rs
+++ b/crates/router/src/types/api/connector_mapping.rs
@@ -538,7 +538,8 @@ impl ConnectorData {
enums::Connector::Plaid => {
Ok(ConnectorEnum::Old(Box::new(connector::Plaid::new())))
}
- enums::Connector::Signifyd
+ enums::Connector::Nsure
+ | enums::Connector::Signifyd
| enums::Connector::Riskified
| enums::Connector::SanlamPayshield
| enums::Connector::Cybersourcedecisionmanager
diff --git a/crates/router/src/types/api/feature_matrix.rs b/crates/router/src/types/api/feature_matrix.rs
index d9f4727f45..7b95116fd4 100644
--- a/crates/router/src/types/api/feature_matrix.rs
+++ b/crates/router/src/types/api/feature_matrix.rs
@@ -494,7 +494,7 @@ impl FeatureMatrixConnectorData {
enums::Connector::Interpayments => Ok(ConnectorEnum::Old(Box::new(
connector::Interpayments::new(),
))),
- enums::Connector::Cardinal | enums::Connector::Juspay => {
+ enums::Connector::Cardinal | enums::Connector::Juspay | enums::Connector::Nsure => {
Err(report!(errors::ConnectorError::InvalidConnectorName)
.attach_printable(format!("invalid connector name: {connector_name}")))
.change_context(errors::ApiErrorResponse::InternalServerError)
diff --git a/crates/router/src/types/api/fraud_check.rs b/crates/router/src/types/api/fraud_check.rs
index c37379b469..24fa89441f 100644
--- a/crates/router/src/types/api/fraud_check.rs
+++ b/crates/router/src/types/api/fraud_check.rs
@@ -59,6 +59,9 @@ impl FraudCheckConnectorData {
connector_name: enums::FrmConnectors,
) -> CustomResult<ConnectorEnum, errors::ApiErrorResponse> {
match connector_name {
+ enums::FrmConnectors::Nsure => {
+ Ok(ConnectorEnum::Old(Box::new(connector::Nsure::new())))
+ }
enums::FrmConnectors::Signifyd => {
Ok(ConnectorEnum::Old(Box::new(connector::Signifyd::new())))
}
diff --git a/crates/router/src/types/connector_transformers.rs b/crates/router/src/types/connector_transformers.rs
index 2efadcf203..0c1ae7de99 100644
--- a/crates/router/src/types/connector_transformers.rs
+++ b/crates/router/src/types/connector_transformers.rs
@@ -160,6 +160,11 @@ impl ForeignTryFrom<api_enums::Connector> for euclid::enums::RoutableConnectors
api_enums::Connector::Shift4 => Self::Shift4,
api_enums::Connector::Zift => Self::Zift,
api_enums::Connector::Silverflow => Self::Silverflow,
+ api_enums::Connector::Nsure => {
+ Err(common_utils::errors::ValidationError::InvalidValue {
+ message: "nsure is not a routable connector".to_string(),
+ })?
+ }
api_enums::Connector::Signifyd => {
Err(common_utils::errors::ValidationError::InvalidValue {
message: "signifyd is not a routable connector".to_string(),
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 221b15d636..ea275a6c5c 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -222,6 +222,7 @@ noon.base_url = "https://api-test{{region}}.noonpayments.com/"
nordea.base_url = "https://api.nordeaopenbanking.com"
noon.key_mode = "Test"
novalnet.base_url = "https://payport.novalnet.de/v2"
+nsure.base_url = "https://sandbox.nsureapi.com"
nuvei.base_url = "https://ppp-test.nuvei.com/"
opayo.base_url = "https://pi-test.sagepay.com/"
opennode.base_url = "https://dev-api.opennode.com"