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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): [Payshield] Add sanlam_payshield pre-FRM support for bank debit payments (#13595)
Saptak Duttab96b63a1a3cb
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 4b72660647..dc98f50d84 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -18629,6 +18629,7 @@"signifyd","plaid","riskified",+ "sanlam_payshield","xendit","zen","zift",@@ -44434,6 +44435,7 @@"redsys","revolv3","riskified",+ "sanlam_payshield","santander","shift4","signifyd",diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex d11c4d5048..967ccdf588 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -12481,6 +12481,7 @@"signifyd","plaid","riskified",+ "sanlam_payshield","xendit","zen","zift",@@ -32031,6 +32032,7 @@"redsys","revolv3","riskified",+ "sanlam_payshield","santander","shift4","signifyd",diff --git a/config/config.example.toml b/config/config.example.tomlindex 03894cd8f7..f7eaa541c0 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -398,6 +398,7 @@ recurly.base_url = "https://v3.recurly.com"redsys.base_url = "https://sis-t.redsys.es:25443"revolv3.base_url = "https://api-sandbox.revolv3.com"riskified.base_url = "https://sandbox.riskified.com/api"+sanlam_payshield.base_url = "dev"santander.base_url = "https://trust-pix-h.santander.com.br/"santander.secondary_base_url = "https://trust-open-h.api.santander.com.br/"shift4.base_url = "https://api.shift4.com/"diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 1dd254e97d..681aa9088c 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -161,6 +161,7 @@ sift.base_url = "https://api.sift.com/v205"silverflow.base_url = "https://api-sbx.silverflow.co/v1"signifyd.base_url = "https://api.signifyd.com/"riskified.base_url = "https://sandbox.riskified.com/api"+sanlam_payshield.base_url = "sbx"square.base_url = "https://connect.squareupsandbox.com/"square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 9f5dfb74bf..bcb6719258 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -158,6 +158,7 @@ recurly.base_url = "https://v3.recurly.com"redsys.base_url = "https://sis.redsys.es"revolv3.base_url = "https://api.revolv3.com"riskified.base_url = "https://wh.riskified.com/api/"+sanlam_payshield.base_url = "live"santander.base_url = "https://trust-pix.santander.com.br/"santander.secondary_base_url = "https://trust-open.api.santander.com.br/"shift4.base_url = "https://api.shift4.com/"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex 25cc2dc4ea..4957fee4c0 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -158,6 +158,7 @@ recurly.base_url = "https://v3.recurly.com"redsys.base_url = "https://sis-t.redsys.es:25443"revolv3.base_url = "https://api-sandbox.revolv3.com"riskified.base_url = "https://sandbox.riskified.com/api"+sanlam_payshield.base_url = "sbx"santander.base_url = "https://trust-pix-h.santander.com.br/"santander.secondary_base_url = "https://trust-open-h.api.santander.com.br/"shift4.base_url = "https://api.shift4.com/"diff --git a/config/development.toml b/config/development.tomlindex 65a37b2515..427f57e038 100644--- a/config/development.toml+++ b/config/development.toml@@ -422,6 +422,7 @@ recurly.base_url = "https://v3.recurly.com"redsys.base_url = "https://sis-t.redsys.es:25443"revolv3.base_url = "https://api-sandbox.revolv3.com"riskified.base_url = "https://sandbox.riskified.com/api"+sanlam_payshield.base_url = "dev"santander.base_url = "https://trust-pix-h.santander.com.br/"santander.secondary_base_url = "https://trust-open-h.api.santander.com.br/"shift4.base_url = "https://api.shift4.com/"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex b26ef47460..0f4ac9a114 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -321,6 +321,7 @@ recurly.base_url = "https://v3.recurly.com"redsys.base_url = "https://sis-t.redsys.es:25443"revolv3.base_url = "https://api-sandbox.revolv3.com"riskified.base_url = "https://sandbox.riskified.com/api"+sanlam_payshield.base_url = "dev"santander.base_url = "https://trust-pix-h.santander.com.br/"santander.secondary_base_url = "https://trust-open-h.api.santander.com.br/"shift4.base_url = "https://api.shift4.com/"diff --git a/config/superposition_seed.toml b/config/superposition_seed.tomlindex 771e3800b4..280caba0ff 100644--- a/config/superposition_seed.toml+++ b/config/superposition_seed.toml@@ -2689,6 +2689,10 @@ should_schedule_modular_backward_compat = { value = false, schema = { type = "bo"region2",], type = "string" }, description = "3DS routing region for UAS (Unified Authentication Service) per organization", change_reason = "Initial setup" }"vaulting.should_perform_sdk_vaulting" = { value = true, schema = { type = "boolean" }, description = "Org level override on top of should_call_pm_modular_service; when false the SDK skips vaulting", change_reason = "Initial setup" }+"frm.pre_frm_failure_mode" = { value = "fail_open", schema = { enum = [+ "fail_open",+ "fail_closed"+], type = "string" }, description = "Controls whether payment processing continues when an applicable pre-FRM check fails", change_reason = "Initial setup" }[dimensions]diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rsindex 8a0d6516de..4ee1cfaca9 100644--- a/crates/api_models/src/enums.rs+++ b/crates/api_models/src/enums.rs@@ -200,6 +200,7 @@ pub enum FrmConnectors {Signifyd,Riskified,Cybersourcedecisionmanager,+ SanlamPayshield,}#[derive(diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rsindex 39975122b3..54e7337c1b 100644--- a/crates/common_enums/src/connector_enums.rs+++ b/crates/common_enums/src/connector_enums.rs@@ -211,6 +211,7 @@ pub enum Connector {Signifyd,Plaid,Riskified,+ SanlamPayshield,Xendit,Zen,Zift,@@ -452,6 +453,7 @@ impl Connector {| Self::Plaid| Self::Razorpay| Self::Riskified+ | Self::SanlamPayshield| Self::Threedsecureio| Self::Netcetera| Self::CtpMastercarddiff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex d326cdc4b4..1ece7276ab 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -584,6 +584,22 @@ pub enum FraudCheckStatus {TransactionFailure,}+impl FraudCheckStatus {+ pub fn should_stop_payment(&self, failure_mode: &PreFrmFailureMode) -> bool {+ matches!(self, Self::Fraud)+ || (matches!(self, Self::TransactionFailure)+ && matches!(failure_mode, PreFrmFailureMode::FailClosed))+ }+}++#[derive(Debug, Clone, Default, strum::Display, strum::EnumString)]+#[strum(serialize_all = "snake_case")]+pub enum PreFrmFailureMode {+ #[default]+ FailOpen,+ FailClosed,+}+#[derive(Clone,Copy,diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex 9cdb992a7b..3af5229731 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -396,6 +396,7 @@ pub struct ConnectorConfig {pub rapyd: Option<ConnectorTomlConfig>,pub redsys: Option<ConnectorTomlConfig>,pub revolv3: Option<ConnectorTomlConfig>,+ pub sanlam_payshield: Option<ConnectorTomlConfig>,pub santander: Option<ConnectorTomlConfig>,pub santander_payout: Option<ConnectorTomlConfig>,pub shift4: Option<ConnectorTomlConfig>,@@ -665,6 +666,7 @@ impl ConnectorConfig {Connector::Redsys => Ok(connector_data.redsys),Connector::Revolv3 => Ok(connector_data.revolv3),Connector::Riskified => Ok(connector_data.riskified),+ Connector::SanlamPayshield => Ok(connector_data.sanlam_payshield),Connector::Santander => Ok(connector_data.santander),Connector::Shift4 => Ok(connector_data.shift4),Connector::Signifyd => Ok(connector_data.signifyd),diff --git a/crates/euclid/src/enums.rs b/crates/euclid/src/enums.rsindex 1feb4b51d4..aeb027a944 100644--- a/crates/euclid/src/enums.rs+++ b/crates/euclid/src/enums.rs@@ -332,6 +332,7 @@ pub enum RoutableConnectors {Redsys,Revolv3,Riskified,+ SanlamPayshield,Santander,Shift4,Signifyd,@@ -494,6 +495,7 @@ impl TryFrom<Connector> for RoutableConnectors {Connector::Santander => Ok(Self::Santander),Connector::Shift4 => Ok(Self::Shift4),Connector::Signifyd => Ok(Self::Signifyd),+ Connector::SanlamPayshield => Ok(Self::SanlamPayshield),Connector::Silverflow => Ok(Self::Silverflow),Connector::Square => Ok(Self::Square),Connector::Stax => Ok(Self::Stax),@@ -712,6 +714,7 @@ impl From<RoutableConnectors> for Connector {RoutableConnectors::Vgs => Self::Vgs,RoutableConnectors::Cardinal => Self::Cardinal,RoutableConnectors::Threedsecureio => Self::Threedsecureio,+ RoutableConnectors::SanlamPayshield => Self::SanlamPayshield,}}}diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rsindex a950ba9a5f..9abe1da22e 100644--- a/crates/hyperswitch_connectors/src/connectors.rs+++ b/crates/hyperswitch_connectors/src/connectors.rs@@ -116,6 +116,7 @@ pub mod recurly;pub mod redsys;pub mod revolv3;pub mod riskified;+pub mod sanlam_payshield;pub mod santander;pub mod shift4;pub mod sift;@@ -184,12 +185,12 @@ pub use self::{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, 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,+ recurly::Recurly, redsys::Redsys, revolv3::Revolv3, riskified::Riskified,+ 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/absa_sanlam.rs b/crates/hyperswitch_connectors/src/connectors/absa_sanlam.rsindex 2bab88de00..c2567e8c9f 100644--- a/crates/hyperswitch_connectors/src/connectors/absa_sanlam.rs+++ b/crates/hyperswitch_connectors/src/connectors/absa_sanlam.rs@@ -431,4 +431,21 @@ impl ConnectorSpecifications for AbsaSanlam {fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {Some(&ABSA_SANLAM_SUPPORTED_WEBHOOK_FLOWS)}++ #[cfg(feature = "frm")]+ fn get_frm_metadata(+ &self,+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+ ) -> CustomResult<Option<common_utils::pii::SecretSerdeValue>, errors::ConnectorError> {+ let metadata = absa_sanlam::AbsaSanlamFrmMetadata {+ profile_id: payment_attempt.profile_id.get_string_repr().to_owned(),+ connector_id: payment_attempt+ .merchant_connector_id+ .as_ref()+ .map(|id| id.get_string_repr().to_owned()),+ };+ serde_json::to_value(metadata)+ .change_context(errors::ConnectorError::RequestEncodingFailed)+ .map(|value| Some(hyperswitch_masking::Secret::new(value)))+ }}diff --git a/crates/hyperswitch_connectors/src/connectors/absa_sanlam/transformers.rs b/crates/hyperswitch_connectors/src/connectors/absa_sanlam/transformers.rsindex 5fad56fa15..f2b0b5c110 100644--- a/crates/hyperswitch_connectors/src/connectors/absa_sanlam/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/absa_sanlam/transformers.rs@@ -12,6 +12,12 @@ use serde::{Deserialize, Serialize};use crate::{types::ResponseRouterData, utils};+#[derive(Debug, Serialize, Deserialize)]+pub struct AbsaSanlamFrmMetadata {+ pub profile_id: String,+ pub connector_id: Option<String>,+}+pub struct AbsaSanlamAuthType {pub(super) api_key: Secret<String>,pub(super) merchant_id: Secret<String>,diff --git a/crates/hyperswitch_connectors/src/connectors/sanlam_payshield.rs b/crates/hyperswitch_connectors/src/connectors/sanlam_payshield.rsnew file mode 100644index 0000000000..e271629721--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/sanlam_payshield.rs@@ -0,0 +1,310 @@+pub mod transformers;++use common_utils::{+ errors::CustomResult,+ ext_traits::BytesExt,+ request::{Method, Request, RequestBuilder, RequestContent},+};+use error_stack::ResultExt;+use hyperswitch_domain_models::{+ router_data::{ConnectorAuthType, ErrorResponse, RouterData},+ router_flow_types::{+ access_token_auth::AccessTokenAuth,+ payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},+ refunds::{Execute, RSync},+ Checkout, Fulfillment, RecordReturn, Sale, Transaction,+ },+ router_request_types::{+ fraud_check::{+ FraudCheckCheckoutData, FraudCheckFulfillmentData, FraudCheckRecordReturnData,+ FraudCheckSaleData, FraudCheckTransactionData,+ },+ AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,+ PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,+ RefundsData, SetupMandateRequestData,+ },+ router_response_types::{+ fraud_check::FraudCheckResponseData, PaymentsResponseData, RefundsResponseData,+ },+};+use hyperswitch_interfaces::{+ api::{+ ConnectorAccessToken, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration,+ ConnectorSpecifications, ConnectorValidation, FraudCheck, FraudCheckCheckout,+ FraudCheckFulfillment, FraudCheckRecordReturn, FraudCheckSale, FraudCheckTransaction,+ MandateSetup, Payment, PaymentAuthorize, PaymentCapture, PaymentSession, PaymentSync,+ PaymentToken, PaymentVoid, Refund, RefundExecute, RefundSync,+ },+ configs::Connectors,+ consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE},+ errors::ConnectorError,+ events::connector_api_logs::ConnectorEvent,+ types::Response,+ webhooks,+};+use hyperswitch_masking::{ExposeInterface, Mask, Maskable};+use transformers as sanlam_payshield;++use crate::{+ constants::headers,+ types::{FrmCheckoutRouterData, FrmCheckoutType, ResponseRouterData},+};++#[derive(Clone)]+pub struct SanlamPayshield;++impl SanlamPayshield {+ pub fn new() -> &'static Self {+ &Self+ }+}++impl<Flow, RequestData, ResponseData> ConnectorCommonExt<Flow, RequestData, ResponseData>+ for SanlamPayshield+where+ Self: ConnectorIntegration<Flow, RequestData, ResponseData>,+{+ fn build_headers(+ &self,+ req: &RouterData<Flow, RequestData, ResponseData>,+ _connectors: &Connectors,+ ) -> CustomResult<Vec<(String, Maskable<String>)>, ConnectorError> {+ let mut headers = vec![(+ headers::CONTENT_TYPE.to_string(),+ self.get_content_type().to_string().into(),+ )];+ headers.append(&mut self.get_auth_header(&req.connector_auth_type)?);+ Ok(headers)+ }+}++impl ConnectorCommon for SanlamPayshield {+ fn id(&self) -> &'static str {+ "sanlam_payshield"+ }++ fn common_get_content_type(&self) -> &'static str {+ "application/json"+ }++ fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {+ connectors.sanlam_payshield.base_url.as_ref()+ }++ fn get_auth_header(+ &self,+ auth_type: &ConnectorAuthType,+ ) -> CustomResult<Vec<(String, Maskable<String>)>, ConnectorError> {+ let auth = sanlam_payshield::SanlamPayshieldAuthType::try_from(auth_type)+ .change_context(ConnectorError::FailedToObtainAuthType)?;+ Ok(vec![(+ headers::X_API_KEY.to_string(),+ auth.api_key.expose().into_masked(),+ )])+ }++ fn build_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, ConnectorError> {+ let response: sanlam_payshield::SanlamPayshieldErrorResponse = res+ .response+ .parse_struct("SanlamPayshieldErrorResponse")+ .change_context(ConnectorError::ResponseDeserializationFailed)?;++ event_builder.map(|event| event.set_error_response_body(&response));+ router_env::logger::info!(connector_response=?response);++ Ok(ErrorResponse {+ status_code: res.status_code,+ code: response+ .error_code+ .map_or(NO_ERROR_CODE.to_string(), |v| v.to_string()),+ message: response+ .error_message+ .clone()+ .or(response.message.clone())+ .unwrap_or(NO_ERROR_MESSAGE.to_string()),+ reason: response.reason(),+ attempt_status: None,+ connector_transaction_id: None,+ connector_response_reference_id: None,+ network_advice_code: None,+ network_decline_code: None,+ network_error_message: None,+ connector_metadata: None,+ })+ }+}++impl ConnectorIntegration<Checkout, FraudCheckCheckoutData, FraudCheckResponseData>+ for SanlamPayshield+{+ fn get_headers(+ &self,+ req: &FrmCheckoutRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, Maskable<String>)>, ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &FrmCheckoutRouterData,+ connectors: &Connectors,+ ) -> CustomResult<String, ConnectorError> {+ let merchant_id = _req.merchant_id.get_string_repr();+ Ok(format!(+ "{}/payshield/v1/check/{}",+ self.base_url(connectors).to_owned(),+ merchant_id+ ))+ }++ fn get_request_body(+ &self,+ req: &FrmCheckoutRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<RequestContent, ConnectorError> {+ Ok(RequestContent::Json(Box::new(+ sanlam_payshield::SanlamPayshieldCheckoutRequest::try_from(req)?,+ )))+ }++ fn build_request(+ &self,+ req: &FrmCheckoutRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Post)+ .url(&FrmCheckoutType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(FrmCheckoutType::get_headers(self, req, connectors)?)+ .set_body(FrmCheckoutType::get_request_body(self, req, connectors)?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &FrmCheckoutRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<FrmCheckoutRouterData, ConnectorError> {+ let response: sanlam_payshield::SanlamPayshieldCheckoutResponse = res+ .response+ .parse_struct("SanlamPayshieldCheckoutResponse")+ .change_context(ConnectorError::ResponseDeserializationFailed)?;++ event_builder.map(|event| event.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);++ FrmCheckoutRouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<Sale, FraudCheckSaleData, FraudCheckResponseData> for SanlamPayshield {}+impl ConnectorIntegration<Transaction, FraudCheckTransactionData, FraudCheckResponseData>+ for SanlamPayshield+{+}+impl ConnectorIntegration<Fulfillment, FraudCheckFulfillmentData, FraudCheckResponseData>+ for SanlamPayshield+{+}+impl ConnectorIntegration<RecordReturn, FraudCheckRecordReturnData, FraudCheckResponseData>+ for SanlamPayshield+{+}++impl FraudCheck for SanlamPayshield {}+impl FraudCheckCheckout for SanlamPayshield {}+impl FraudCheckSale for SanlamPayshield {}+impl FraudCheckTransaction for SanlamPayshield {}+impl FraudCheckFulfillment for SanlamPayshield {}+impl FraudCheckRecordReturn for SanlamPayshield {}++impl Payment for SanlamPayshield {}+impl PaymentSession for SanlamPayshield {}+impl ConnectorAccessToken for SanlamPayshield {}+impl MandateSetup for SanlamPayshield {}+impl PaymentAuthorize for SanlamPayshield {}+impl PaymentSync for SanlamPayshield {}+impl PaymentCapture for SanlamPayshield {}+impl PaymentVoid for SanlamPayshield {}+impl Refund for SanlamPayshield {}+impl RefundExecute for SanlamPayshield {}+impl RefundSync for SanlamPayshield {}+impl PaymentToken for SanlamPayshield {}+impl ConnectorValidation for SanlamPayshield {}+impl ConnectorSpecifications for SanlamPayshield {}+#[async_trait::async_trait]+impl webhooks::IncomingWebhook for SanlamPayshield {+ fn get_webhook_object_reference_id(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<api_models::webhooks::ObjectReferenceId, ConnectorError> {+ Err(ConnectorError::WebhooksNotImplemented.into())+ }++ fn get_webhook_event_type(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ _context: Option<&webhooks::WebhookContext>,+ ) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, ConnectorError> {+ Err(ConnectorError::WebhooksNotImplemented.into())+ }++ fn get_webhook_resource_object(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<Box<dyn hyperswitch_masking::ErasedMaskSerialize>, ConnectorError> {+ Err(ConnectorError::WebhooksNotImplemented.into())+ }+}++impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for SanlamPayshield {}+impl+ ConnectorIntegration<+ AccessTokenAuth,+ AccessTokenRequestData,+ hyperswitch_domain_models::router_data::AccessToken,+ > for SanlamPayshield+{+}+impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>+ for SanlamPayshield+{+}+impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>+ for SanlamPayshield+{+}+impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for SanlamPayshield {}+impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for SanlamPayshield {}+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for SanlamPayshield {}+impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>+ for SanlamPayshield+{+}+impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for SanlamPayshield {}+impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for SanlamPayshield {}diff --git a/crates/hyperswitch_connectors/src/connectors/sanlam_payshield/transformers.rs b/crates/hyperswitch_connectors/src/connectors/sanlam_payshield/transformers.rsnew file mode 100644index 0000000000..2b70347c6b--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/sanlam_payshield/transformers.rs@@ -0,0 +1,226 @@+use api_models::payments::{additional_info::BankDebitAdditionalData, AdditionalPaymentData};+use common_enums::FraudCheckStatus;+use common_utils::{ext_traits::ValueExt, pii::SecretSerdeValue};+use error_stack::ResultExt;+use hyperswitch_domain_models::{+ router_data::ConnectorAuthType, router_request_types::ResponseId,+ router_response_types::fraud_check::FraudCheckResponseData,+};+use hyperswitch_interfaces::errors::ConnectorError;+use hyperswitch_masking::Secret;+use serde::{Deserialize, Serialize};++use crate::{+ types::{FrmCheckoutRouterData, ResponseRouterData},+ utils::get_unimplemented_payment_method_error_message,+};++pub struct SanlamPayshieldAuthType {+ pub(super) api_key: Secret<String>,+}++impl TryFrom<&ConnectorAuthType> for SanlamPayshieldAuthType {+ type Error = error_stack::Report<ConnectorError>;++ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {+ match auth_type {+ ConnectorAuthType::HeaderKey { api_key } => Ok(Self {+ api_key: api_key.to_owned(),+ }),+ _ => Err(ConnectorError::FailedToObtainAuthType.into()),+ }+ }+}++#[derive(Debug, Serialize, Deserialize)]+pub struct SanlamPayshieldFrmMetadata {+ pub profile_id: String,+ pub connector_id: Option<String>,+}++#[derive(Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct SanlamPayshieldCheckoutRequest {+ request_id: String,+ profile_id: String,+ connector_id: String,+ connector_type: ConnectorType,+ transaction: Transaction,+ metadata: Option<SecretSerdeValue>,+}++#[derive(Debug, Serialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum ConnectorType {+ Payin,+ Payout,+}++#[derive(Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct Transaction {+ payment_id: String,+ amount_in_cents: String,+ currency: String,+ payment_method_type: PaymentMethodType,+ created_at: String,+}++#[derive(Debug, Serialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum PaymentMethodType {+ EftDebitOrder,+}++impl TryFrom<&FrmCheckoutRouterData> for SanlamPayshieldCheckoutRequest {+ type Error = error_stack::Report<ConnectorError>;++ fn try_from(data: &FrmCheckoutRouterData) -> Result<Self, Self::Error> {+ let SanlamPayshieldFrmMetadata {+ profile_id,+ connector_id,+ } = data+ .request+ .gateway_metadata+ .clone()+ .ok_or(ConnectorError::MissingRequiredField {+ field_name: "gateway_metadata".into(),+ })?+ .parse_value("SanlamPayshieldFrmMetadata")+ .change_context(ConnectorError::RequestEncodingFailed)+ .attach_printable("Failed to parse SanlamPayshieldFrmMetadata")?;++ let connector_id = connector_id.ok_or(ConnectorError::MissingRequiredField {+ field_name: "connector_id".into(),+ })?;++ let currency = data+ .request+ .currency+ .ok_or(ConnectorError::MissingRequiredField {+ field_name: "currency".into(),+ })?;++ let payment_method_type = match data.request.payment_method_data.as_ref() {+ Some(AdditionalPaymentData::BankDebit {+ details: Some(BankDebitAdditionalData::EftDebitOrder { .. }),+ }) => Ok(PaymentMethodType::EftDebitOrder),++ _ => Err(ConnectorError::NotImplemented(+ get_unimplemented_payment_method_error_message("sanlam_paysheild"),+ )),+ }?;++ Ok(Self {+ request_id: data.connector_request_reference_id.clone(),+ profile_id,+ connector_id,+ connector_type: ConnectorType::Payin,+ transaction: Transaction {+ payment_id: data.payment_id.clone(),+ amount_in_cents: data.request.amount.to_string(),+ currency: currency.to_string(),+ payment_method_type,+ created_at: get_current_time()?,+ },+ metadata: data.frm_metadata.clone(),+ })+ }+}++fn get_current_time() -> Result<String, error_stack::Report<ConnectorError>> {+ let format = time::macros::format_description!(+ "[year]-[month]-[day]T[hour]:[minute]:[second][offset_hour sign:mandatory]:[offset_minute]"+ );++ let time = time::OffsetDateTime::now_utc()+ .to_offset(time::macros::offset!(+2))+ .format(&format)+ .change_context(ConnectorError::RequestEncodingFailed)?;++ Ok(time)+}++#[derive(Clone, Debug, Deserialize, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct SanlamPayshieldCheckoutResponse {+ request_id: String,+ decision: Decision,+ severity: i32,+ reason_codes: Option<Vec<String>>,+ reason: Option<String>,+ rule_config_version: Option<String>,+ evaluated_checks: Vec<String>,+}++#[derive(Clone, Copy, Debug, Deserialize, Serialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum Decision {+ Accept,+ Reject,+}++impl From<Decision> for FraudCheckStatus {+ fn from(decision: Decision) -> Self {+ match decision {+ Decision::Accept => Self::Legit,+ Decision::Reject => Self::Fraud,+ }+ }+}++impl+ TryFrom<+ ResponseRouterData<+ hyperswitch_domain_models::router_flow_types::Checkout,+ SanlamPayshieldCheckoutResponse,+ hyperswitch_domain_models::router_request_types::fraud_check::FraudCheckCheckoutData,+ FraudCheckResponseData,+ >,+ > for FrmCheckoutRouterData+{+ type Error = error_stack::Report<ConnectorError>;++ fn try_from(+ item: ResponseRouterData<+ hyperswitch_domain_models::router_flow_types::Checkout,+ SanlamPayshieldCheckoutResponse,+ hyperswitch_domain_models::router_request_types::fraud_check::FraudCheckCheckoutData,+ FraudCheckResponseData,+ >,+ ) -> Result<Self, Self::Error> {+ let connector_metadata = serde_json::json!({+ "reasonCodes": item.response.reason_codes,+ "evaluatedChecks": item.response.evaluated_checks,+ });++ Ok(Self {+ response: Ok(FraudCheckResponseData::TransactionResponse {+ resource_id: ResponseId::ConnectorTransactionId(item.response.request_id),+ status: item.response.decision.into(),+ connector_metadata: Some(connector_metadata),+ reason: item.response.reason.map(serde_json::Value::String),+ score: Some(item.response.severity),+ }),+ ..item.data+ })+ }+}++#[derive(Debug, Deserialize, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct SanlamPayshieldErrorResponse {+ pub error_code: Option<i64>,+ pub error_message: Option<String>,+ #[serde(default)]+ pub inner_errors: Vec<Self>,+ pub message: Option<String>,+}++impl SanlamPayshieldErrorResponse {+ pub fn reason(&self) -> Option<String> {+ (!self.inner_errors.is_empty())+ .then(|| serde_json::to_string(&self.inner_errors).ok())+ .flatten()+ }+}diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rsindex 86d83e8efd..92239498fd 100644--- a/crates/hyperswitch_connectors/src/default_implementations.rs+++ b/crates/hyperswitch_connectors/src/default_implementations.rs@@ -320,6 +320,7 @@ default_imp_for_authorize_session_token!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Shift4,connectors::Sift,connectors::Silverflow,@@ -488,6 +489,7 @@ default_imp_for_payment_settlement_split_create!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -657,6 +659,7 @@ default_imp_for_calculate_tax!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -780,6 +783,7 @@ default_imp_for_session_update!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -949,6 +953,7 @@ default_imp_for_post_session_tokens!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1114,6 +1119,7 @@ default_imp_for_create_order!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1296,6 +1302,7 @@ default_imp_for_update_post_confirm!(connectors::Redsys,connectors::Revolv3,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Shift4,connectors::Sift,connectors::Silverflow,@@ -1515,6 +1522,7 @@ default_imp_for_update_metadata!(connectors::Powertranz,connectors::Prophetpay,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1692,6 +1700,7 @@ default_imp_for_cancel_post_capture!(connectors::Powertranz,connectors::Prophetpay,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -1871,6 +1880,7 @@ default_imp_for_cancel_post_capture_sync!(connectors::Powertranz,connectors::Prophetpay,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2001,6 +2011,7 @@ default_imp_for_complete_authorize!(connectors::Razorpay,connectors::Recurly,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Sift,connectors::Signifyd,@@ -2164,6 +2175,7 @@ default_imp_for_incremental_authorization!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2349,6 +2361,7 @@ default_imp_for_extend_authorization!(connectors::Powertranz,connectors::Prophetpay,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -2490,6 +2503,7 @@ default_imp_for_create_customer!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2645,6 +2659,7 @@ default_imp_for_connector_redirect_response!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2802,6 +2817,7 @@ default_imp_for_pre_authenticate_steps!(connectors::Razorpay,connectors::Recurly,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Sift,connectors::Signifyd,@@ -2968,6 +2984,7 @@ default_imp_for_authenticate_steps!(connectors::Razorpay,connectors::Recurly,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3135,6 +3152,7 @@ default_imp_for_post_authenticate_steps!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3295,6 +3313,7 @@ default_imp_for_pre_processing_steps!(connectors::Razorpay,connectors::Recurly,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Sift,connectors::Signifyd,@@ -3459,6 +3478,7 @@ default_imp_for_post_processing_steps!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3630,6 +3650,7 @@ default_imp_for_approve!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3801,6 +3822,7 @@ default_imp_for_reject!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3972,6 +3994,7 @@ default_imp_for_webhook_source_verification!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4140,6 +4163,7 @@ default_imp_for_accept_dispute!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4307,6 +4331,7 @@ default_imp_for_submit_evidence!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4474,6 +4499,7 @@ default_imp_for_defend_dispute!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4645,6 +4671,7 @@ default_imp_for_fetch_disputes!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4815,6 +4842,7 @@ default_imp_for_dispute_sync!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4992,6 +5020,7 @@ default_imp_for_file_upload!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5143,6 +5172,7 @@ default_imp_for_payouts!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5302,6 +5332,7 @@ default_imp_for_payouts_create!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5468,6 +5499,7 @@ default_imp_for_payouts_retrieve!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5635,6 +5667,7 @@ default_imp_for_payouts_eligibility!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5796,6 +5829,7 @@ default_imp_for_payouts_fulfill!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5960,6 +5994,7 @@ default_imp_for_payouts_cancel!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -6127,6 +6162,7 @@ default_imp_for_payouts_quote!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -6297,6 +6333,7 @@ default_imp_for_payouts_recipient!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -6466,6 +6503,7 @@ default_imp_for_payouts_recipient_account!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -7485,6 +7523,7 @@ default_imp_for_revoking_mandates!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -7654,6 +7693,7 @@ default_imp_for_uas_pre_authentication!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -7822,6 +7862,7 @@ default_imp_for_uas_webhook!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -7990,6 +8031,7 @@ default_imp_for_uas_post_authentication!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -8159,6 +8201,7 @@ default_imp_for_uas_authentication_confirmation!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -8319,6 +8362,7 @@ default_imp_for_connector_request_id!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -8674,6 +8718,7 @@ default_imp_for_connector_authentication!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -8841,6 +8886,7 @@ default_imp_for_uas_authentication!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -9021,6 +9067,7 @@ default_imp_for_revenue_recovery_dispute_record_back!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -9178,6 +9225,7 @@ default_imp_for_revenue_recovery!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -9399,6 +9447,7 @@ default_imp_for_subscriptions!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -9570,6 +9619,7 @@ default_imp_for_billing_connector_payment_sync!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -9733,6 +9783,7 @@ default_imp_for_revenue_recovery_record_back!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -9903,6 +9954,7 @@ default_imp_for_billing_connector_invoice_sync!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Signifyd,connectors::Shift4,@@ -10067,6 +10119,7 @@ default_imp_for_external_vault!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Signifyd,connectors::Shift4,@@ -10236,6 +10289,7 @@ default_imp_for_external_vault_insert!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Signifyd,connectors::Shift4,@@ -10402,6 +10456,7 @@ default_imp_for_gift_card_balance_check!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -10573,6 +10628,7 @@ default_imp_for_external_vault_retrieve!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Signifyd,connectors::Shift4,@@ -10742,6 +10798,7 @@ default_imp_for_external_vault_delete!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Signifyd,connectors::Shift4,@@ -10912,6 +10969,7 @@ default_imp_for_external_vault_create!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Signifyd,connectors::Shift4,@@ -11082,6 +11140,7 @@ default_imp_for_connector_authentication_token!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Sift,connectors::Signifyd,@@ -11251,6 +11310,7 @@ default_imp_for_external_vault_proxy_payments_create!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -11431,6 +11491,7 @@ default_imp_for_connector_webhook_register!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Shift4,connectors::Sift,connectors::Silverflow,@@ -12420,6 +12481,7 @@ default_imp_for_generate_qr_flow!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Shift4,connectors::Sift,connectors::Silverflow,@@ -12590,6 +12652,7 @@ default_imp_for_push_notification_flow!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Shift4,connectors::Sift,connectors::Silverflow,@@ -12781,6 +12844,7 @@ default_imp_for_pre_authorize_void!(connectors::Powertranz,connectors::Prophetpay,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Threedsecureio,connectors::Thunes,connectors::Tokenex,@@ -12951,6 +13015,7 @@ default_imp_for_refund_void_post_refund!(connectors::Redsys,connectors::Revolv3,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rsindex 399ac94e49..ca433ac86f 100644--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs@@ -501,6 +501,7 @@ default_imp_for_new_connector_integration_payment!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -680,6 +681,7 @@ default_imp_for_new_connector_integration_refund!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -840,6 +842,7 @@ default_imp_for_new_connector_integration_connector_authentication_token!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1005,6 +1008,7 @@ default_imp_for_new_connector_integration_connector_access_token!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1176,6 +1180,7 @@ default_imp_for_new_connector_integration_accept_dispute!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1347,6 +1352,7 @@ default_imp_for_new_connector_integration_fetch_disputes!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1519,6 +1525,7 @@ default_imp_for_new_connector_integration_dispute_sync!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1691,6 +1698,7 @@ default_imp_for_new_connector_integration_defend_dispute!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -1861,6 +1869,7 @@ default_imp_for_new_connector_integration_submit_evidence!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2042,6 +2051,7 @@ default_imp_for_new_connector_integration_file_upload!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2215,6 +2225,7 @@ default_imp_for_new_connector_integration_payouts_create!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2388,6 +2399,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2561,6 +2573,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2734,6 +2747,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -2907,6 +2921,7 @@ default_imp_for_new_connector_integration_payouts_quote!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3080,6 +3095,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3253,6 +3269,7 @@ default_imp_for_new_connector_integration_payouts_sync!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3426,6 +3443,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3597,6 +3615,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3770,6 +3789,7 @@ default_imp_for_new_connector_integration_frm_sale!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -3943,6 +3963,7 @@ default_imp_for_new_connector_integration_frm_checkout!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4116,6 +4137,7 @@ default_imp_for_new_connector_integration_frm_transaction!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4289,6 +4311,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4462,6 +4485,7 @@ default_imp_for_new_connector_integration_frm_record_return!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4631,6 +4655,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4771,6 +4796,7 @@ default_imp_for_new_connector_integration_frm!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -4939,6 +4965,7 @@ default_imp_for_new_connector_integration_connector_authentication!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5108,6 +5135,7 @@ default_imp_for_new_connector_integration_revenue_recovery!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5303,6 +5331,7 @@ default_imp_for_new_connector_integration_external_vault!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5473,6 +5502,7 @@ default_imp_for_new_connector_integration_external_vault_proxy!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,@@ -5655,6 +5685,7 @@ default_imp_for_new_connector_integration_webhook_register!(connectors::Revolv3,connectors::TsysTransit,connectors::Riskified,+ connectors::SanlamPayshield,connectors::Santander,connectors::Shift4,connectors::Sift,diff --git a/crates/hyperswitch_domain_models/src/connector_endpoints.rs b/crates/hyperswitch_domain_models/src/connector_endpoints.rsindex 6c345675a5..c78c6f8f8e 100644--- a/crates/hyperswitch_domain_models/src/connector_endpoints.rs+++ b/crates/hyperswitch_domain_models/src/connector_endpoints.rs@@ -132,6 +132,7 @@ pub struct Connectors {pub revolv3: ConnectorParams,pub riskified: ConnectorParams,pub santander: ConnectorParams,+ pub sanlam_payshield: ConnectorParams,pub shift4: ConnectorParams,pub sift: ConnectorParams,pub silverflow: 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.rsindex 3879ca751c..096504c56c 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@@ -32,6 +32,7 @@ pub struct FraudCheckCheckoutData {pub browser_info: Option<router_request_types::BrowserInformation>,pub payment_method_data: Option<api_models::payments::AdditionalPaymentData>,pub gateway: Option<String>,+ pub gateway_metadata: Option<common_utils::pii::SecretSerdeValue>,pub client_ip: Option<std::net::IpAddr>,pub customer_id: Option<common_utils::id_type::CustomerId>,pub email: Option<Email>,diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rsindex 86cdad5209..22f8caa813 100644--- a/crates/hyperswitch_interfaces/src/api.rs+++ b/crates/hyperswitch_interfaces/src/api.rs@@ -543,6 +543,16 @@ pub trait ConnectorSpecifications {ConnectorCustomerAction::NoAction}+ /// Gateway specific metadata required for FRM requests.+ /// Connectors should override this method if they need to send connector specific metadata as part of the FRM request.+ #[cfg(feature = "frm")]+ fn get_frm_metadata(+ &self,+ _payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+ ) -> CustomResult<Option<common_utils::pii::SecretSerdeValue>, errors::ConnectorError> {+ Ok(None)+ }+/// Validate if another operation is requiredfn is_payment_recurrence_operation_needed(&self,diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rsindex 67cfb2e539..03fad67173 100644--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs@@ -840,6 +840,17 @@ impl ConnectorSpecifications for ConnectorEnum {}}+ #[cfg(feature = "frm")]+ fn get_frm_metadata(+ &self,+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+ ) -> CustomResult<Option<common_utils::pii::SecretSerdeValue>, errors::ConnectorError> {+ match self {+ Self::Old(connector) => connector.get_frm_metadata(payment_attempt),+ Self::New(connector) => connector.get_frm_metadata(payment_attempt),+ }+ }+fn is_payment_recurrence_operation_needed(&self,setup_future_usage: Option<common_enums::FutureUsage>,diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rsindex c5105a33f3..4dc86c6d9b 100644--- a/crates/router/src/connector.rs+++ b/crates/router/src/connector.rs@@ -45,12 +45,13 @@ pub use hyperswitch_connectors::connectors::{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, 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,+ redsys::Redsys, revolv3, revolv3::Revolv3, riskified, riskified::Riskified, 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,tsys, tsys::Tsys, tsys_transit, tsys_transit::TsysTransit, unified_authentication_service,unified_authentication_service::UnifiedAuthenticationService, vgs, vgs::Vgs, volt, volt::Volt,diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex c12a9c876d..90e70d8dcb 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -514,6 +514,8 @@ pub mod superposition {pub const INCOMING_WEBHOOK_DISABLED_EVENTS: &str = "webhooks.incoming_webhook_disabled_events";/// save wallet decrypted data in lockerpub const SAVE_WALLET_DECRYPTED_DATA: &str = "vaulting.save_wallet_decrypted_data";+ /// Pre-FRM failure handling mode+ pub const PRE_FRM_FAILURE_MODE: &str = "frm.pre_frm_failure_mode";}/// The value substituted for sensitive webhook header values in event retrieval responses.diff --git a/crates/router/src/core/configs/dimension_config.rs b/crates/router/src/core/configs/dimension_config.rsindex b04dc110fd..6da57fce6f 100644--- a/crates/router/src/core/configs/dimension_config.rs+++ b/crates/router/src/core/configs/dimension_config.rs@@ -968,3 +968,21 @@ config! {impl DatabaseBackedConfig for AccountUpdaterCredentialSource {const KEY: &'static str = "account_updater_credential_source";}++config! {+ superposition_key = PRE_FRM_FAILURE_MODE,+ output = common_enums::PreFrmFailureMode,+ default = common_enums::PreFrmFailureMode::FailOpen,+ string_enum = true,+ requires = dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,+ targeting_key = id_type::ProfileId+}++impl DatabaseBackedConfig for PreFrmFailureMode {+ const KEY: &'static str = "pre_frm_failure_mode";+ fn db_key(dimensions: &impl dimension_state::DimensionsBase) -> Option<String> {+ dimensions+ .get_profile_id()+ .map(|id| format!("{}_{}", Self::KEY, id.get_string_repr()))+ }+}diff --git a/crates/router/src/core/connector_validation.rs b/crates/router/src/core/connector_validation.rsindex 7c78521215..29f6fb5d53 100644--- a/crates/router/src/core/connector_validation.rs+++ b/crates/router/src/core/connector_validation.rs@@ -650,6 +650,10 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {riskified::transformers::RiskifiedAuthType::try_from(self.auth_type)?;Ok(())}+ api_enums::Connector::SanlamPayshield => {+ sanlam_payshield::transformers::SanlamPayshieldAuthType::try_from(self.auth_type)?;+ Ok(())+ }api_enums::Connector::Cybersourcedecisionmanager => {cybersourcedecisionmanager::transformers::CybersourcedecisionmanagerAuthType::try_from(self.auth_type)?;Ok(())diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rsindex 52ac9ced2e..87b42ce905 100644--- a/crates/router/src/core/fraud_check.rs+++ b/crates/router/src/core/fraud_check.rs@@ -1,7 +1,7 @@use std::fmt::Debug;use api_models::{self, enums as api_enums};-use common_enums::CaptureMethod;+use common_enums::{CaptureMethod, PreFrmFailureMode};use error_stack::ResultExt;use hyperswitch_masking::PeekInterface;use router_env::{@@ -19,11 +19,12 @@ use self::{use super::errors::{ConnectorErrorExt, RouterResponse};use crate::{core::{+ configs::dimension_state::DimensionsWithProcessorAndProviderMerchantIdAndProfileId,errors::{self, RouterResult},payments::{self, flows::ConstructFlowSpecificData, operations::BoxedOperation},},db::StorageInterface,- routes::{app::ReqState, SessionState},+ routes::{app::ReqState, metrics, SessionState},services,types::{self as oss_types,@@ -495,6 +496,7 @@ pub async fn pre_payment_frm_core<F, Req, D>(should_continue_transaction: &mut bool,should_continue_capture: &mut bool,operation: &BoxedOperation<'_, F, Req, D>,+ failure_mode: &PreFrmFailureMode,) -> RouterResult<Option<FrmData>>whereF: Send + Clone,@@ -541,7 +543,7 @@ where.await?;let frm_fraud_check = frm_data_updated.fraud_check.clone();payment_data.set_frm_message(frm_fraud_check.clone());- if matches!(frm_fraud_check.frm_status, FraudCheckStatus::Fraud) {+ if frm_fraud_check.frm_status.should_stop_payment(failure_mode) {*should_continue_transaction = false;frm_info.suggested_action = Some(FrmSuggestion::FrmCancelTransaction);}@@ -570,6 +572,63 @@ whereOk(frm_data)}+#[allow(clippy::too_many_arguments)]+async fn decide_and_run_pre_frm<F, Req, D>(+ operation: &BoxedOperation<'_, F, Req, D>,+ platform: &domain::Platform,+ payment_data: &mut D,+ state: &SessionState,+ frm_info: &mut Option<FrmInfo<F, D>>,+ should_continue_transaction: &mut bool,+ should_continue_capture: &mut bool,+ failure_mode: &PreFrmFailureMode,+) -> RouterResult<Option<FrmConfigsObject>>+where+ F: Send + Clone,+ D: payments::OperationSessionGetters<F>+ + payments::OperationSessionSetters<F>+ + Send+ + Sync+ + Clone,+{+ let (is_frm_enabled, frm_routing_algorithm, frm_connector_label, frm_configs) =+ should_call_frm(platform, payment_data, state).await?;+ if let Some((frm_routing_algorithm_val, profile_id)) =+ frm_routing_algorithm.zip(frm_connector_label)+ {+ if let Some(frm_configs) = frm_configs.clone() {+ let mut updated_frm_info = Box::pin(make_frm_data_and_fraud_check_operation(+ &*state.store,+ state,+ platform,+ payment_data.to_owned(),+ frm_routing_algorithm_val,+ profile_id,+ frm_configs.clone(),+ ))+ .await?;++ if is_frm_enabled {+ Box::pin(pre_payment_frm_core(+ state,+ platform,+ payment_data,+ &mut updated_frm_info,+ frm_configs,+ should_continue_transaction,+ should_continue_capture,+ operation,+ failure_mode,+ ))+ .await?;+ }+ *frm_info = Some(updated_frm_info);+ }+ }+ logger::debug!("frm_configs: {:?} {:?}", frm_configs, is_frm_enabled);+ Ok(frm_configs)+}+#[allow(clippy::too_many_arguments)]pub async fn post_payment_frm_core<F, D>(state: &SessionState,@@ -661,6 +720,7 @@ pub async fn call_frm_before_connector_call<F, Req, D>(frm_info: &mut Option<FrmInfo<F, D>>,should_continue_transaction: &mut bool,should_continue_capture: &mut bool,+ dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,) -> RouterResult<Option<FrmConfigsObject>>whereF: Send + Clone,@@ -670,39 +730,56 @@ where+ Sync+ Clone,{- let (is_frm_enabled, frm_routing_algorithm, frm_connector_label, frm_configs) =- should_call_frm(platform, payment_data, state).await?;- if let Some((frm_routing_algorithm_val, profile_id)) =- frm_routing_algorithm.zip(frm_connector_label)- {- if let Some(frm_configs) = frm_configs.clone() {- let mut updated_frm_info = Box::pin(make_frm_data_and_fraud_check_operation(- &*state.store,- state,- platform,- payment_data.to_owned(),- frm_routing_algorithm_val,- profile_id,- frm_configs.clone(),- ))- .await?;+ let failure_mode = dimensions+ .get_pre_frm_failure_mode(+ state.store.as_ref(),+ state.superposition_service.as_ref(),+ None,+ )+ .await;- if is_frm_enabled {- Box::pin(pre_payment_frm_core(- state,- platform,- payment_data,- &mut updated_frm_info,- frm_configs,- should_continue_transaction,- should_continue_capture,- operation,- ))- .await?;+ let frm_configs = match Box::pin(decide_and_run_pre_frm(+ operation,+ platform,+ payment_data,+ state,+ frm_info,+ should_continue_transaction,+ should_continue_capture,+ &failure_mode,+ ))+ .await+ {+ Ok(frm_configs) => Ok(frm_configs),+ Err(e) => {+ match failure_mode {+ PreFrmFailureMode::FailOpen => {+ // Log the error+ logger::info!(+ "FRM actions before connector call failed, continuing due to FailOpen mode. Error: {:?}",+ e+ );+ metrics::FRM_FAILURE.add(+ 1,+ router_env::metric_attributes!(+ (+ "merchant_id",+ platform.get_processor().get_account().get_id().clone()+ ),+ ("error_type", e.current_context().to_string())+ ),+ );+ // Continue with default values+ Ok(None)+ }+ PreFrmFailureMode::FailClosed => {+ logger::info!("FRM actions before connector call failed, propagating error due to FailClosed mode");+ Err(e)+ }}- *frm_info = Some(updated_frm_info);}- }+ }?;+let fraud_capture_method = frm_info.as_ref().and_then(|frm_info| {frm_info.frm_data@@ -724,7 +801,6 @@ wherefraud_capture_method);};- logger::debug!("frm_configs: {:?} {:?}", frm_configs, is_frm_enabled);Ok(frm_configs)}diff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rsindex 1644aa9e61..5d643f195a 100644--- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs+++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs@@ -10,6 +10,7 @@ use crate::{errors::{ConnectorErrorExt, RouterResult},fraud_check::types::FrmData,payments::{self, helpers},+ utils::get_gateway_frm_metadata,},errors, services,types::{@@ -140,6 +141,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudCemail,phone,phone_country_code,+ gateway_metadata: get_gateway_frm_metadata(&state.conf, &self.payment_attempt)?,},response: Ok(FraudCheckResponseData::TransactionResponse {resource_id: ResponseId::ConnectorTransactionId("".to_string()),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.rsindex a878c375fc..b4dd592475 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@@ -258,6 +258,7 @@ whereemail: router_data.request.email,phone: router_data.request.phone,phone_country_code: router_data.request.phone_country_code,+ gateway_metadata: router_data.request.gateway_metadata,})),response: FrmResponse::Checkout(router_data.response),})diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 206cb611cb..a72d3d9b41 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -873,7 +873,7 @@ wherelet mut should_continue_capture: bool = true;#[cfg(feature = "frm")]let frm_configs = if state.conf.frm.enabled {- match Box::pin(frm_core::call_frm_before_connector_call(+ Box::pin(frm_core::call_frm_before_connector_call(&operation,platform,&mut payment_data,@@ -881,31 +881,9 @@ where&mut frm_info,&mut should_continue_transaction,&mut should_continue_capture,+ &dimensions,))- .await- {- Ok(configs) => configs,- Err(e) => {- // Log the error- logger::info!(- "FRM call before connector failed : payment_id={:?}, error={:?}",- payment_data.get_payment_intent().payment_id,- e- );- metrics::FRM_FAILURE.add(- 1,- router_env::metric_attributes!(- (- "merchant_id",- platform.get_processor().get_account().get_id().clone()- ),- ("error_type", e.current_context().to_string())- ),- );- // Continue with default values- None- }- }+ .await?} else {None};diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex ad22977757..a6583fe224 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -2645,7 +2645,15 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forfrm_message.map_or((None, None), |fraud_check| {(Some(Some(fraud_check.frm_status.to_string())),- Some(fraud_check.frm_reason.map(|reason| reason.to_string())),+ Some(+ fraud_check+ .frm_reason+ .map(|reason| match reason {+ serde_json::Value::String(s) => s,+ other => other.to_string(),+ })+ .or(fraud_check.frm_error),+ ),)}),),diff --git a/crates/router/src/core/payments/operations/payment_recurrence.rs b/crates/router/src/core/payments/operations/payment_recurrence.rsindex 7d3ac0068a..52c32b03dc 100644--- a/crates/router/src/core/payments/operations/payment_recurrence.rs+++ b/crates/router/src/core/payments/operations/payment_recurrence.rs@@ -549,7 +549,15 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forfrm_message.map_or((None, None), |fraud_check| {(Some(Some(fraud_check.frm_status.to_string())),- Some(fraud_check.frm_reason.map(|reason| reason.to_string())),+ Some(+ fraud_check+ .frm_reason+ .map(|reason| match reason {+ serde_json::Value::String(s) => s,+ other => other.to_string(),+ })+ .or(fraud_check.frm_error),+ ),)}),),diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex edb043b9ab..1f89bf1a67 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -255,7 +255,15 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, PaymentsCancelRequest> fo.map_or((None, None), |fraud_check| {(Some(Some(fraud_check.frm_status.to_string())),- Some(fraud_check.frm_reason.map(|reason| reason.to_string())),+ Some(+ fraud_check+ .frm_reason+ .map(|reason| match reason {+ serde_json::Value::String(s) => s,+ other => other.to_string(),+ })+ .or(fraud_check.frm_error),+ ),)});let attempt_status_update = storage::PaymentAttemptUpdate::RejectUpdate {diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex 6908527360..6e78576cd4 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -2136,6 +2136,32 @@ pub fn get_payout_connector_request_reference_id(}}+#[cfg(feature = "frm")]+pub fn get_gateway_frm_metadata(+ conf: &Settings,+ payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,+) -> CustomResult<Option<common_utils::pii::SecretSerdeValue>, errors::ApiErrorResponse> {+ match &payment_attempt.connector {+ Some(connector_name) => {+ let connector_data = api::ConnectorData::get_connector_by_name(+ &conf.connectors,+ connector_name,+ api::GetToken::Connector,+ payment_attempt.merchant_connector_id.clone(),+ )+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable_lazy(|| "Failed to construct connector data")?;++ connector_data+ .connector+ .get_frm_metadata(payment_attempt)+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable_lazy(|| "Failed to construct FRM gateway metadata")+ }+ None => Ok(None),+ }+}+// TODO: Based on the connector configuration, the connector_request_reference_id should be generated#[cfg(feature = "v2")]pub fn get_connector_request_reference_id(diff --git a/crates/router/src/types/api/connector_mapping.rs b/crates/router/src/types/api/connector_mapping.rsindex df19bb4119..fa9f786e24 100644--- a/crates/router/src/types/api/connector_mapping.rs+++ b/crates/router/src/types/api/connector_mapping.rs@@ -520,6 +520,7 @@ impl ConnectorData {}enums::Connector::Signifyd| enums::Connector::Riskified+ | enums::Connector::SanlamPayshield| enums::Connector::Cybersourcedecisionmanager| enums::Connector::Gpayments| enums::Connector::Threedsecureiodiff --git a/crates/router/src/types/api/feature_matrix.rs b/crates/router/src/types/api/feature_matrix.rsindex 51f1b23245..5c7da38338 100644--- a/crates/router/src/types/api/feature_matrix.rs+++ b/crates/router/src/types/api/feature_matrix.rs@@ -454,6 +454,9 @@ impl FeatureMatrixConnectorData {enums::Connector::Riskified => {Ok(ConnectorEnum::Old(Box::new(connector::Riskified::new())))}+ enums::Connector::SanlamPayshield => Ok(ConnectorEnum::Old(Box::new(+ connector::SanlamPayshield::new(),+ ))),enums::Connector::Cybersourcedecisionmanager => Ok(ConnectorEnum::Old(Box::new(connector::Cybersourcedecisionmanager::new(),))),diff --git a/crates/router/src/types/api/fraud_check.rs b/crates/router/src/types/api/fraud_check.rsindex 67e2141d04..abcc3e1462 100644--- a/crates/router/src/types/api/fraud_check.rs+++ b/crates/router/src/types/api/fraud_check.rs@@ -68,6 +68,9 @@ impl FraudCheckConnectorData {enums::FrmConnectors::Cybersourcedecisionmanager => Ok(ConnectorEnum::Old(Box::new(connector::Cybersourcedecisionmanager::new(),))),+ enums::FrmConnectors::SanlamPayshield => Ok(ConnectorEnum::Old(Box::new(+ connector::SanlamPayshield::new(),+ ))),}}}diff --git a/crates/router/src/types/connector_transformers.rs b/crates/router/src/types/connector_transformers.rsindex c79e64ebac..07e66f0fc4 100644--- a/crates/router/src/types/connector_transformers.rs+++ b/crates/router/src/types/connector_transformers.rs@@ -167,6 +167,11 @@ impl ForeignTryFrom<api_enums::Connector> for euclid::enums::RoutableConnectorsmessage: "riskified is not a routable connector".to_string(),})?}+ api_enums::Connector::SanlamPayshield => {+ Err(common_utils::errors::ValidationError::InvalidValue {+ message: "sanlam_payshield is not a routable connector".to_string(),+ })?+ }api_enums::Connector::Square => Self::Square,api_enums::Connector::Stax => Self::Stax,api_enums::Connector::Stripe => Self::Stripe,