diff --git a/Gemfile.lock b/Gemfile.lock index ff3180e668e..b7f51286c27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,7 +13,7 @@ GIT GIT remote: https://github.com/18F/identity-proofer-gem.git - revision: c671e7964a1e4693b500da6fdde7c023beda71b1 + revision: 4d0d90c06c102361d310e02edba8a64e4d25cc39 branch: master specs: proofer (1.0.0) @@ -221,7 +221,7 @@ GEM rails (>= 3.1.1) diff-lcs (1.2.5) docile (1.1.5) - dotenv (2.1.1) + dotenv (2.1.2) dotiw (3.1.1) actionpack (>= 3) i18n diff --git a/app/services/idv/financials_step.rb b/app/services/idv/financials_step.rb index 7bf88739f7d..804b19dd8c4 100644 --- a/app/services/idv/financials_step.rb +++ b/app/services/idv/financials_step.rb @@ -29,6 +29,10 @@ def vendor_errors vendor_validator.errors if form_valid? end + def vendor_reasons + vendor_validator.reasons if form_valid? + end + def vendor_params finance_type = idv_form.finance_type { finance_type => idv_form.idv_params[finance_type] } @@ -37,7 +41,8 @@ def vendor_params def result { success: success, - errors: errors + errors: errors, + vendor: { reasons: vendor_reasons } } end end diff --git a/app/services/idv/phone_step.rb b/app/services/idv/phone_step.rb index e7a962598c9..8184be42711 100644 --- a/app/services/idv/phone_step.rb +++ b/app/services/idv/phone_step.rb @@ -28,6 +28,10 @@ def vendor_errors vendor_validator.errors if form_valid? end + def vendor_reasons + vendor_validator.reasons if form_valid? + end + def update_idv_session idv_session.phone_confirmation = true idv_session.params = idv_form.idv_params diff --git a/app/services/idv/profile_step.rb b/app/services/idv/profile_step.rb index 09f72a6d322..969f8d36ab0 100644 --- a/app/services/idv/profile_step.rb +++ b/app/services/idv/profile_step.rb @@ -40,11 +40,17 @@ def vendor_errors idv_session.resolution.try(:errors) end + def vendor_reasons + resolution = idv_session.resolution + resolution.vendor_resp.reasons if resolution + end + def analytics_result { success: complete?, idv_attempts_exceeded: attempts_exceeded?, - errors: errors + errors: errors, + vendor: { reasons: vendor_reasons } } end diff --git a/app/services/idv/step.rb b/app/services/idv/step.rb index e448ab0d1c5..fb585948f2f 100644 --- a/app/services/idv/step.rb +++ b/app/services/idv/step.rb @@ -58,7 +58,7 @@ def analytics_event end def analytics_result - { success: complete?, errors: errors } + { success: complete?, errors: errors, vendor: { reasons: vendor_reasons } } end def track_event diff --git a/app/services/idv/vendor_validator.rb b/app/services/idv/vendor_validator.rb index 4d216a8a1d8..7db160d3b13 100644 --- a/app/services/idv/vendor_validator.rb +++ b/app/services/idv/vendor_validator.rb @@ -9,6 +9,10 @@ def initialize(idv_session:, vendor_params:) @vendor_params = vendor_params end + def reasons + result.vendor_resp.reasons + end + def validate raise NotImplementedError "Must implement validate for #{self}" end diff --git a/spec/controllers/verify/finance_controller_spec.rb b/spec/controllers/verify/finance_controller_spec.rb index 2f580b6d43d..2cef8e9f3d0 100644 --- a/spec/controllers/verify/finance_controller_spec.rb +++ b/spec/controllers/verify/finance_controller_spec.rb @@ -77,7 +77,7 @@ put :create, idv_finance_form: { finance_type: :ccn, ccn: '12345678' } - result = { success: true, errors: {} } + result = { success: true, errors: {}, vendor: { reasons: ['Good number'] } } expect(@analytics).to have_received(:track_event).with( Analytics::IDV_FINANCE_CONFIRMATION, result @@ -135,7 +135,8 @@ result = { success: true, - errors: {} + errors: {}, + vendor: { reasons: ['Good number'] } } expect(@analytics).to have_received(:track_event).with( @@ -150,7 +151,8 @@ result = { success: false, - errors: { ccn: ['The ccn could not be verified.'] } + errors: { ccn: ['The ccn could not be verified.'] }, + vendor: { reasons: ['Bad number'] } } expect(@analytics).to have_received(:track_event). @@ -166,7 +168,8 @@ result = { success: false, - errors: { ccn: ['Credit card number should be only last 8 digits.'] } + errors: { ccn: ['Credit card number should be only last 8 digits.'] }, + vendor: { reasons: nil } } expect(@analytics).to have_received(:track_event). diff --git a/spec/controllers/verify/sessions_controller_spec.rb b/spec/controllers/verify/sessions_controller_spec.rb index 687f79fbaf8..665d2173238 100644 --- a/spec/controllers/verify/sessions_controller_spec.rb +++ b/spec/controllers/verify/sessions_controller_spec.rb @@ -89,7 +89,8 @@ result = { success: false, idv_attempts_exceeded: false, - errors: { ssn: [t('idv.errors.duplicate_ssn')] } + errors: { ssn: [t('idv.errors.duplicate_ssn')] }, + vendor: { reasons: nil } } expect(@analytics).to receive(:track_event). @@ -140,7 +141,8 @@ idv_attempts_exceeded: false, errors: { first_name: ['Unverified first name.'] - } + }, + vendor: { reasons: ['The name was suspicious'] } } expect(@analytics).to have_received(:track_event). @@ -166,7 +168,8 @@ result = { success: true, idv_attempts_exceeded: false, - errors: {} + errors: {}, + vendor: { reasons: ['Everything looks good'] } } expect(@analytics).to have_received(:track_event). diff --git a/spec/services/idv/financials_step_spec.rb b/spec/services/idv/financials_step_spec.rb index a8e70fbc916..aec5dd193b6 100644 --- a/spec/services/idv/financials_step_spec.rb +++ b/spec/services/idv/financials_step_spec.rb @@ -24,7 +24,8 @@ def build_step(params) result = { success: false, - errors: { ccn: [t('idv.errors.invalid_ccn')] } + errors: { ccn: [t('idv.errors.invalid_ccn')] }, + vendor: { reasons: nil } } expect(step.submit).to eq result @@ -36,7 +37,8 @@ def build_step(params) result = { success: true, - errors: {} + errors: {}, + vendor: { reasons: ['Good number'] } } expect(step.submit).to eq result @@ -49,7 +51,8 @@ def build_step(params) result = { success: false, - errors: { ccn: ['The ccn could not be verified.'] } + errors: { ccn: ['The ccn could not be verified.'] }, + vendor: { reasons: ['Bad number'] } } expect(step.submit).to eq result diff --git a/spec/services/idv/profile_step_spec.rb b/spec/services/idv/profile_step_spec.rb index 8ee3fa84399..200945ec732 100644 --- a/spec/services/idv/profile_step_spec.rb +++ b/spec/services/idv/profile_step_spec.rb @@ -45,7 +45,8 @@ def expect_analytics_result(result) result = { success: true, idv_attempts_exceeded: false, - errors: {} + errors: {}, + vendor: { reasons: ['Everything looks good'] } } expect_analytics_result(result) @@ -62,7 +63,8 @@ def expect_analytics_result(result) idv_attempts_exceeded: false, errors: { ssn: ['Unverified SSN.'] - } + }, + vendor: { reasons: ['The SSN was suspicious'] } } expect_analytics_result(result) @@ -79,7 +81,8 @@ def expect_analytics_result(result) idv_attempts_exceeded: false, errors: { first_name: ['Unverified first name.'] - } + }, + vendor: { reasons: ['The name was suspicious'] } } expect_analytics_result(result) @@ -98,7 +101,8 @@ def expect_analytics_result(result) result = { success: false, idv_attempts_exceeded: true, - errors: {} + errors: {}, + vendor: { reasons: nil } } expect_analytics_result(result)