mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
REPP: Fix domain renew
This commit is contained in:
parent
312f199504
commit
bf4fa216bf
1 changed files with 14 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue