class TrPayment < ActiveRecord::Base
  belongs_to :donator_transaction
  belongs_to :tr_payment_type
  belongs_to :tr_payment_bank_account
  
  before_validation do
    self.verify
    self.iban = self.iban.to_s.gsub(/\s+/, "")
    
  end
  
      	
    protected
      def verify(size=16)
      	if !self.token
      		s = ""
      		size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
      		self.token = s
        end
      end
  
  
end
