diff --git a/app/forms/journeys/early_years_payment/provider/start/email_address_form.rb b/app/forms/journeys/early_years_payment/provider/start/email_address_form.rb index f29d1f59b9..89e21d5baf 100644 --- a/app/forms/journeys/early_years_payment/provider/start/email_address_form.rb +++ b/app/forms/journeys/early_years_payment/provider/start/email_address_form.rb @@ -13,6 +13,9 @@ def save ) journey_session.save! ClaimMailer.early_years_payment_provider_email(answers, otp_code(email_address), email_address).deliver_now + else + journey_session.answers.assign_attributes(email_address: email_address) + journey_session.save! end end diff --git a/app/models/journeys/early_years_payment/provider/start/slug_sequence.rb b/app/models/journeys/early_years_payment/provider/start/slug_sequence.rb index ae1a2e7afc..518e943d34 100644 --- a/app/models/journeys/early_years_payment/provider/start/slug_sequence.rb +++ b/app/models/journeys/early_years_payment/provider/start/slug_sequence.rb @@ -6,6 +6,7 @@ class SlugSequence SLUGS = %w[ email-address check-your-email + ineligible ].freeze def self.start_page_url diff --git a/app/models/policies/early_years_payments/policy_eligibility_checker.rb b/app/models/policies/early_years_payments/policy_eligibility_checker.rb index d1d7a09e04..cf73e2575c 100644 --- a/app/models/policies/early_years_payments/policy_eligibility_checker.rb +++ b/app/models/policies/early_years_payments/policy_eligibility_checker.rb @@ -16,12 +16,24 @@ def status end def ineligible? - return false if answers.is_a?(Journeys::EarlyYearsPayment::Provider::Start::SessionAnswers) - ineligibility_reason.present? end def ineligibility_reason + start_ineligibility_reason || authenticated_ineligibility_reason + end + + def start_ineligibility_reason + return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Provider::Start::SessionAnswers) + + if !EligibleEyProvider.eligible_email?(answers.email_address) + :email_not_on_whitelist + end + end + + def authenticated_ineligibility_reason + return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Provider::Authenticated::SessionAnswers) + if answers.nursery_urn.to_s == "none_of_the_above" :nursery_is_not_listed elsif answers.child_facing_confirmation_given == false diff --git a/app/views/early_years_payment/provider/start/claims/_ineligibility_email_not_on_whitelist.html.erb b/app/views/early_years_payment/provider/start/claims/_ineligibility_email_not_on_whitelist.html.erb new file mode 100644 index 0000000000..9266bab88d --- /dev/null +++ b/app/views/early_years_payment/provider/start/claims/_ineligibility_email_not_on_whitelist.html.erb @@ -0,0 +1,14 @@ +<% content_for(:page_title, page_title("You do not have access to this service", journey: current_journey_routing_name)) %> +<% @backlink_path = claim_path(current_journey_routing_name, "email-address") %> + +
+ This email address does not have access to this service. Check the email address you entered and try again. +
++ To request access, contact us at <%= govuk_mail_to t("early_years_payment_provider_start.feedback_email") %>. +
+