diff --git a/app/controllers/concerns/idv/verify_info_concern.rb b/app/controllers/concerns/idv/verify_info_concern.rb index f1770be8e92..3bbb468f91b 100644 --- a/app/controllers/concerns/idv/verify_info_concern.rb +++ b/app/controllers/concerns/idv/verify_info_concern.rb @@ -171,6 +171,11 @@ def process_async_state(current_async_state) def async_state_done(current_async_state) add_proofing_costs(current_async_state.result) + + create_fraud_review_request_if_needed(current_async_state.result) + + track_attempts_api_fraud_check_event_if_needed(current_async_state.result) + form_response = idv_result_to_form_response( result: current_async_state.result, state: pii[:state], @@ -297,6 +302,33 @@ def log_idv_verification_submitted_event(success: false) ) end + def create_fraud_review_request_if_needed(result) + return unless FeatureManagement.proofing_device_profiling_collecting_enabled? + + threatmetrix_result = result.dig(:context, :stages, :threatmetrix) + return unless threatmetrix_result + + return if threatmetrix_result[:review_status] == 'pass' + + FraudReviewRequest.create( + user: current_user, + login_session_id: Digest::SHA1.hexdigest(current_user.unique_session_id.to_s), + ) + end + + def track_attempts_api_fraud_check_event_if_needed(result) + return unless FeatureManagement.proofing_device_profiling_collecting_enabled? + + threatmetrix_result = result.dig(:context, :stages, :threatmetrix) + return unless threatmetrix_result + + success = threatmetrix_result[:review_status] == 'pass' + + irs_attempts_api_tracker.idv_tmx_fraud_check( + success: success, + ) + end + def move_applicant_to_idv_session idv_session.applicant = pii idv_session.applicant[:ssn] = idv_session.ssn @@ -317,24 +349,18 @@ def add_proofing_costs(results) next if hash[:vendor_name] == 'UnsupportedJurisdiction' # transaction_id comes from TransactionLocatorId add_cost(:aamva, transaction_id: hash[:transaction_id]) - track_aamva elsif stage == :threatmetrix # transaction_id comes from request_id - tmx_id = hash[:transaction_id] - log_irs_tmx_fraud_check_event(hash, current_user) if tmx_id - add_cost(:threatmetrix, transaction_id: tmx_id) if tmx_id + if hash[:transaction_id] + add_cost( + :threatmetrix, + transaction_id: hash[:transaction_id], + ) + end end end end - def track_aamva - return unless IdentityConfig.store.state_tracking_enabled - doc_auth_log = DocAuthLog.find_by(user_id: current_user.id) - return unless doc_auth_log - doc_auth_log.aamva = true - doc_auth_log.save! - end - def add_cost(token, transaction_id: nil) Db::SpCost::AddSpCost.call(current_sp, token, transaction_id: transaction_id) end diff --git a/app/models/doc_auth_log.rb b/app/models/doc_auth_log.rb index 498147064e9..468f95a4705 100644 --- a/app/models/doc_auth_log.rb +++ b/app/models/doc_auth_log.rb @@ -11,6 +11,7 @@ class DocAuthLog < ApplicationRecord # rubocop:disable Rails/UnusedIgnoredColumns self.ignored_columns = [ + :aamva, :email_sent_view_at, :email_sent_view_count, :send_link_view_at, diff --git a/app/services/idv/steps/threat_metrix_step_helper.rb b/app/services/idv/steps/threat_metrix_step_helper.rb index 95c719ab2d8..cb4bbab8eea 100644 --- a/app/services/idv/steps/threat_metrix_step_helper.rb +++ b/app/services/idv/steps/threat_metrix_step_helper.rb @@ -48,23 +48,6 @@ def threatmetrix_iframe_url(session_id) session_id: session_id, ) end - - def log_irs_tmx_fraud_check_event(result, user) - return unless FeatureManagement.proofing_device_profiling_collecting_enabled? - - success = result[:review_status] == 'pass' - - unless success - FraudReviewRequest.create( - user: user, - login_session_id: Digest::SHA1.hexdigest(user.unique_session_id.to_s), - ) - end - - irs_attempts_api_tracker.idv_tmx_fraud_check( - success: success, - ) - end end end end diff --git a/spec/features/idv/doc_auth/verify_info_step_spec.rb b/spec/features/idv/doc_auth/verify_info_step_spec.rb index 1a8fd3cf682..fa4c295f89e 100644 --- a/spec/features/idv/doc_auth/verify_info_step_spec.rb +++ b/spec/features/idv/doc_auth/verify_info_step_spec.rb @@ -299,8 +299,6 @@ complete_ssn_step complete_verify_step - - expect(DocAuthLog.find_by(user_id: user.id).aamva).not_to be_nil end end @@ -322,8 +320,6 @@ complete_ssn_step complete_verify_step - - expect(DocAuthLog.find_by(user_id: user.id).aamva).to be_nil end end end diff --git a/spec/features/idv/end_to_end_idv_spec.rb b/spec/features/idv/end_to_end_idv_spec.rb index 71f95b6b145..b26d4f711b7 100644 --- a/spec/features/idv/end_to_end_idv_spec.rb +++ b/spec/features/idv/end_to_end_idv_spec.rb @@ -255,7 +255,6 @@ def validate_verify_info_submit(user) expect(page).to have_content(t('doc_auth.forms.doc_success')) expect(user.proofing_component.resolution_check).to eq(Idp::Constants::Vendors::LEXIS_NEXIS) expect(user.proofing_component.source_check).to eq(Idp::Constants::Vendors::AAMVA) - expect(DocAuthLog.find_by(user_id: user.id).aamva).to eq(true) end def validate_phone_page