Class: Creditcard
- Includes:
- ActiveMerchant::Billing::CreditCardMethods
- Defined in:
- app/models/creditcard.rb
Defined Under Namespace
Classes: ExpiryDate
Class Method Summary collapse
Instance Method Summary collapse
-
#brand ⇒ Object
needed for some of the ActiveMerchant gateways (eg. Protx).
- #expired? ⇒ Boolean
- #expiry_date ⇒ Object
- #first_name? ⇒ Boolean
-
#last_digits ⇒ Object
Show the card number, with all but last 4 numbers replace with “X”.
- #last_name? ⇒ Boolean
- #name ⇒ Object
- #name? ⇒ Boolean
- #validate ⇒ Object
- #verification_value? ⇒ Boolean
Class Method Details
.requires_verification_value? ⇒ Boolean
85 86 87 88 |
# File 'app/models/creditcard.rb', line 85 def self.requires_verification_value? true #require_verification_value end |
Instance Method Details
#brand ⇒ Object
needed for some of the ActiveMerchant gateways (eg. Protx)
73 74 75 |
# File 'app/models/creditcard.rb', line 73 def brand cc_type end |
#expired? ⇒ Boolean
39 40 41 |
# File 'app/models/creditcard.rb', line 39 def expired? expiry_date.expired? end |
#expiry_date ⇒ Object
35 36 37 |
# File 'app/models/creditcard.rb', line 35 def expiry_date ExpiryDate.new(Time.now.month, Time.now.year) end |
#first_name? ⇒ Boolean
47 48 49 |
# File 'app/models/creditcard.rb', line 47 def first_name? !@first_name.blank? end |
#last_digits ⇒ Object
Show the card number, with all but last 4 numbers replace with “X”. (XXXX-XXXX-XXXX-4338) def display_number
self.class.mask(number)
end
68 69 70 |
# File 'app/models/creditcard.rb', line 68 def last_digits self.class.last_digits(number) end |
#last_name? ⇒ Boolean
51 52 53 |
# File 'app/models/creditcard.rb', line 51 def last_name? !@last_name.blank? end |
#name ⇒ Object
55 56 57 |
# File 'app/models/creditcard.rb', line 55 def name "#{@first_name} #{@last_name}" end |
#name? ⇒ Boolean
43 44 45 |
# File 'app/models/creditcard.rb', line 43 def name? first_name? && last_name? end |
#validate ⇒ Object
77 78 79 80 81 82 83 |
# File 'app/models/creditcard.rb', line 77 def validate validate_essential_attributes validate_card_type #validate_card_number #validate_verification_value #validate_switch_or_solo_attributes end |
#verification_value? ⇒ Boolean
59 60 61 |
# File 'app/models/creditcard.rb', line 59 def verification_value? !verification_value.blank? end |