Class: Fe::Payment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Fe::Payment
- Defined in:
- app/models/fe/payment.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#card_number ⇒ Object
Returns the value of attribute card_number.
-
#card_type ⇒ Object
Returns the value of attribute card_type.
-
#city ⇒ Object
Returns the value of attribute city.
-
#expiration_month ⇒ Object
Returns the value of attribute expiration_month.
-
#expiration_year ⇒ Object
Returns the value of attribute expiration_year.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#payment_type ⇒ Object
Returns the value of attribute payment_type.
-
#security_code ⇒ Object
Returns the value of attribute security_code.
-
#staff_first ⇒ Object
Returns the value of attribute staff_first.
-
#staff_last ⇒ Object
Returns the value of attribute staff_last.
-
#state ⇒ Object
Returns the value of attribute state.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
- #approve! ⇒ Object
- #approved? ⇒ Boolean
- #check_answer_sheet_complete ⇒ Object
- #credit? ⇒ Boolean
- #get_card_type ⇒ Object
- #staff? ⇒ Boolean
- #validate ⇒ Object
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
5 6 7 |
# File 'app/models/fe/payment.rb', line 5 def address @address end |
#card_number ⇒ Object
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_type ⇒ Object
Returns the value of attribute card_type.
5 6 7 |
# File 'app/models/fe/payment.rb', line 5 def card_type @card_type end |
#city ⇒ Object
Returns the value of attribute city.
5 6 7 |
# File 'app/models/fe/payment.rb', line 5 def city @city end |
#expiration_month ⇒ Object
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_year ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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_type ⇒ Object
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_code ⇒ Object
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_first ⇒ Object
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_last ⇒ Object
Returns the value of attribute staff_last.
5 6 7 |
# File 'app/models/fe/payment.rb', line 5 def staff_last @staff_last end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'app/models/fe/payment.rb', line 5 def state @state end |
#zip ⇒ Object
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
36 37 38 |
# File 'app/models/fe/payment.rb', line 36 def approved? self.status == 'Approved' end |
#check_answer_sheet_complete ⇒ Object
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
28 29 30 |
# File 'app/models/fe/payment.rb', line 28 def credit? self.payment_type == 'Credit Card' end |
#get_card_type ⇒ Object
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
32 33 34 |
# File 'app/models/fe/payment.rb', line 32 def staff? self.payment_type == 'Staff' end |
#validate ⇒ Object
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 |