Class: Creditcard

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ActiveMerchant::Billing::CreditCardMethods
Defined in:
app/models/creditcard.rb

Defined Under Namespace

Classes: ExpiryDate

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.requires_verification_value?Boolean

Returns:

  • (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

#brandObject

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

Returns:

  • (Boolean)


39
40
41
# File 'app/models/creditcard.rb', line 39

def expired?
  expiry_date.expired?
end

#expiry_dateObject



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

Returns:

  • (Boolean)


47
48
49
# File 'app/models/creditcard.rb', line 47

def first_name?
  !@first_name.blank?
end

#last_digitsObject

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

Returns:

  • (Boolean)


51
52
53
# File 'app/models/creditcard.rb', line 51

def last_name?
  !@last_name.blank?
end

#nameObject



55
56
57
# File 'app/models/creditcard.rb', line 55

def name
  "#{@first_name} #{@last_name}"
end

#name?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/models/creditcard.rb', line 43

def name?
  first_name? && last_name?
end

#validateObject



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

Returns:

  • (Boolean)


59
60
61
# File 'app/models/creditcard.rb', line 59

def verification_value?
  !verification_value.blank?
end