Fix domain renew porting to actions

This commit is contained in:
Karl Erik Õunapuu 2021-01-27 11:30:44 +02:00
parent 9a7827107f
commit 988af6c91c
No known key found for this signature in database
GPG key ID: C9DD647298A34764
3 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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],