Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
class Sale < ActiveRecord::Base
  def validate_on_create
    ...
    amount_to_auth = self.total_price - self.voucher_total
    
    self.payment_transaction = self.payment_method.authorize(amount_to_auth) if amount_to_auth > 0
    ...
  rescue PaymentMethodError => error
    errors.add_to_base(error.message)
    return false
  end
end