Class: Fe::Payment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/fe/payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def address
  @address
end

#card_numberObject

Returns the value of attribute card_number.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def card_number
  @card_number
end

#card_typeObject

Returns the value of attribute card_type.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def card_type
  @card_type
end

#cityObject

Returns the value of attribute city.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def city
  @city
end

#expiration_monthObject

Returns the value of attribute expiration_month.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def expiration_month
  @expiration_month
end

#expiration_yearObject

Returns the value of attribute expiration_year.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def expiration_year
  @expiration_year
end

#first_nameObject

Returns the value of attribute first_name.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def last_name
  @last_name
end

#payment_typeObject

Returns the value of attribute payment_type.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def payment_type
  @payment_type
end

#security_codeObject

Returns the value of attribute security_code.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def security_code
  @security_code
end

#staff_firstObject

Returns the value of attribute staff_first.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def staff_first
  @staff_first
end

#staff_lastObject

Returns the value of attribute staff_last.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def staff_last
  @staff_last
end

#stateObject

Returns the value of attribute state.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def state
  @state
end

#zipObject

Returns the value of attribute zip.



5
6
7
# File 'app/models/fe/payment.rb', line 5

def zip
  @zip
end

Instance Method Details

#approve!Object



40
41
42
43
# File 'app/models/fe/payment.rb', line 40

def approve!
  self.status = 'Approved'
  self.save!
end

#approved?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/fe/payment.rb', line 36

def approved?
  self.status == 'Approved'
end

#check_answer_sheet_completeObject



22
23
24
25
26
# File 'app/models/fe/payment.rb', line 22

def check_answer_sheet_complete
  if self.approved?
    self.answer_sheet.complete
  end
end

#credit?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/fe/payment.rb', line 28

def credit?
  self.payment_type == 'Credit Card'
end

#get_card_typeObject



45
46
47
48
49
# File 'app/models/fe/payment.rb', line 45

def get_card_type
  card =  ActiveMerchant::Billing::CreditCard.new(:number => card_number)
  card.valid?
  card.type
end

#staff?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/fe/payment.rb', line 32

def staff?
  self.payment_type == 'Staff'
end

#validateObject



14
15
16
17
18
19
20
# File 'app/models/fe/payment.rb', line 14

def validate
  if credit?
    errors.add_on_empty([:first_name, :last_name, :address, :city, :state, :zip, :card_number,
                         :expiration_month, :expiration_year, :security_code])
    errors.add(:card_number, "is invalid.") if get_card_type.nil?
  end
end