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

This commit is contained in:
Kashif
2024-09-17 16:28:58 +05:30
committed by GitHub
parent f72abe4b97
commit 75400a3af7
3 changed files with 36 additions and 24 deletions

View File

@ -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())
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![],

View File

@ -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())
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![],

View File

@ -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())
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,