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

fix(frm): add feature flag for querying FRM data (#5889)

Kashif75400a3af7aa
diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs
index 38cf72a3e2..9c5b632eff 100644
--- a/crates/router/src/core/payments/operations/payment_approve.rs
+++ b/crates/router/src/core/payments/operations/payment_approve.rs
@@ -136,13 +136,17 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRequest>
payment_intent.shipping_address_id = shipping_address.clone().map(|i| i.address_id);
payment_intent.billing_address_id = billing_address.clone().map(|i| i.address_id);
- let frm_response = db
- .find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.get_id().clone())
- .await
- .change_context(errors::ApiErrorResponse::PaymentNotFound)
- .attach_printable_lazy(|| {
- format!("Error while retrieving frm_response, merchant_id: {}, payment_id: {attempt_id}", merchant_account.get_id().get_string_repr())
- });
+ let frm_response = if cfg!(feature = "frm") {
+ db.find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.get_id().clone())
+ .await
+ .change_context(errors::ApiErrorResponse::PaymentNotFound)
+ .attach_printable_lazy(|| {
+ format!("Error while retrieving frm_response, merchant_id: {}, payment_id: {attempt_id}", merchant_account.get_id().get_string_repr())
+ })
+ .ok()
+ } else {
+ None
+ };
let payment_data = PaymentData {
flow: PhantomData,
@@ -180,7 +184,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRequest>
multiple_capture_data: None,
redirect_response: None,
surcharge_details: None,
- frm_message: frm_response.ok(),
+ frm_message: frm_response,
payment_link_data: None,
incremental_authorization_details: None,
authorizations: vec![],
diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs
index 570337a555..3d67dadd34 100644
--- a/crates/router/src/core/payments/operations/payment_reject.rs
+++ b/crates/router/src/core/payments/operations/payment_reject.rs
@@ -117,13 +117,17 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, PaymentsCancelRequest> for P
let currency = payment_attempt.currency.get_required_value("currency")?;
let amount = payment_attempt.get_total_amount().into();
- let frm_response = db
- .find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.get_id().clone())
- .await
- .change_context(errors::ApiErrorResponse::PaymentNotFound)
- .attach_printable_lazy(|| {
- format!("Error while retrieving frm_response, merchant_id: {:?}, payment_id: {attempt_id}", merchant_account.get_id())
- });
+ let frm_response = if cfg!(feature = "frm") {
+ db.find_fraud_check_by_payment_id(payment_intent.payment_id.clone(), merchant_account.get_id().clone())
+ .await
+ .change_context(errors::ApiErrorResponse::PaymentNotFound)
+ .attach_printable_lazy(|| {
+ format!("Error while retrieving frm_response, merchant_id: {:?}, payment_id: {attempt_id}", merchant_account.get_id())
+ })
+ .ok()
+ } else {
+ None
+ };
let profile_id = payment_intent
.profile_id
@@ -176,7 +180,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, PaymentsCancelRequest> for P
multiple_capture_data: None,
redirect_response: None,
surcharge_details: None,
- frm_message: frm_response.ok(),
+ frm_message: frm_response,
payment_link_data: None,
incremental_authorization_details: None,
authorizations: vec![],
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index 7c2ef7a10f..d81258d667 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -348,13 +348,17 @@ async fn get_tracker_for_sync<
format!("Error while retrieving dispute list for, merchant_id: {:?}, payment_id: {payment_id:?}", merchant_account.get_id())
})?;
- let frm_response = db
- .find_fraud_check_by_payment_id(payment_id.to_owned(), merchant_account.get_id().clone())
- .await
- .change_context(errors::ApiErrorResponse::PaymentNotFound)
- .attach_printable_lazy(|| {
- format!("Error while retrieving frm_response, merchant_id: {:?}, payment_id: {payment_id:?}", merchant_account.get_id())
- });
+ let frm_response = if cfg!(feature = "frm") {
+ db.find_fraud_check_by_payment_id(payment_id.to_owned(), merchant_account.get_id().clone())
+ .await
+ .change_context(errors::ApiErrorResponse::PaymentNotFound)
+ .attach_printable_lazy(|| {
+ format!("Error while retrieving frm_response, merchant_id: {:?}, payment_id: {payment_id:?}", merchant_account.get_id())
+ })
+ .ok()
+ } else {
+ None
+ };
let contains_encoded_data = payment_attempt.encoded_data.is_some();
@@ -472,7 +476,7 @@ async fn get_tracker_for_sync<
redirect_response: None,
payment_link_data: None,
surcharge_details: None,
- frm_message: frm_response.ok(),
+ frm_message: frm_response,
incremental_authorization_details: None,
authorizations,
authentication,