REPP: Fix domain renew

This commit is contained in:
Karl Erik Õunapuu 2021-02-05 16:22:54 +02:00
parent 312f199504
commit bf4fa216bf
No known key found for this signature in database
GPG key ID: C9DD647298A34764

View file

@ -9,16 +9,26 @@ module Domains
string :unit
def execute
return domain_pricelist.price.amount if domain_pricelist.try(:price)
if domain_pricelist.try(:price)
price = domain_pricelist.price.amount
return price if balance_ok?(price)
domain.add_epp_error(2104, nil, nil, I18n.t(:not_enough_funds))
errors.add(:domain, I18n.t(:billing_failure_credit_balance_low, domain: domain.name))
else
domain.add_epp_error(2104, nil, nil, I18n.t(:active_price_missing_for_this_operation))
errors.add(:domain, I18n.t(:active_price_missing_for_operation_with_domain, domain: domain.name))
end
domain.add_epp_error(2104, nil, nil, I18n.t(:active_price_missing_for_this_operation))
errors.add(:domain, I18n.t(:active_price_missing_for_operation_with_domain,
domain: domain.name))
false
end
private
def balance_ok?(price)
domain.registrar.cash_account.balance >= price
end
def domain_pricelist
domain.pricelist(operation, period.try(:to_i), unit)
end