diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 656e51874..80b7d8843 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -72,7 +72,7 @@ module Epp def renew authorize! :renew, @domain - @domain.validate_exp_dates(params[:parsed_frame].css('curExpDate').text) + return handle_errors(@domain) if invalid_expiry_date? registrar_id = current_user.registrar.id renew_params = ::Deserializers::Xml::Domain.new(params[:parsed_frame], @@ -228,6 +228,11 @@ module Epp statuses == [::DomainStatus::CLIENT_HOLD] end + def invalid_expiry_date? + @domain.validate_exp_dates(params[:parsed_frame].css('curExpDate').text) + @domain.errors[:epp_errors].any? + end + def balance_ok?(operation, period = nil, unit = nil) @domain_pricelist = @domain.pricelist(operation, period.try(:to_i), unit) if @domain_pricelist.try(:price) # checking if price list is not found diff --git a/app/interactions/domains/bulk_renew/single_domain_renew.rb b/app/interactions/domains/bulk_renew/single_domain_renew.rb index 66c6244b3..bcfc5b451 100644 --- a/app/interactions/domains/bulk_renew/single_domain_renew.rb +++ b/app/interactions/domains/bulk_renew/single_domain_renew.rb @@ -9,6 +9,7 @@ module Domains def execute in_transaction_with_retries do + check_balance success = domain.renew(domain.valid_to, period, unit) if success check_balance diff --git a/app/models/actions/domain_renew.rb b/app/models/actions/domain_renew.rb index 3e9740335..1069e4a66 100644 --- a/app/models/actions/domain_renew.rb +++ b/app/models/actions/domain_renew.rb @@ -15,6 +15,11 @@ module Actions end def renew + if !domain.renewable? || domain.invalid? + domain.add_renew_epp_errors + return + end + task = Domains::BulkRenew::SingleDomainRenew.run(domain: domain, period: params[:period], unit: params[:period_unit],