Class: RubyPsigate::CreditCard
- Inherits:
-
Object
- Object
- RubyPsigate::CreditCard
- Includes:
- HashVariables, Utils
- Defined in:
- lib/ruby_psigate/credit_card.rb
Constant Summary collapse
- VALID_TYPES =
Psigate only supports these three types of cards
%w( visa mastercard american_express )
Instance Attribute Summary collapse
-
#month ⇒ Object
(also: #cardexpmonth)
Returns the value of attribute month.
-
#name ⇒ Object
(also: #cardholder)
Returns the value of attribute name.
-
#number ⇒ Object
(also: #cardnumber)
Returns the value of attribute number.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#verification_value ⇒ Object
(also: #cardidnumber)
Returns the value of attribute verification_value.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#cardexpyear ⇒ Object
Returns the last 2 digits of the expiry year.
-
#initialize(options = {}) ⇒ CreditCard
constructor
A new instance of CreditCard.
-
#paymenttype ⇒ Object
For hashable.
Methods included from HashVariables
Methods included from Utils
Constructor Details
#initialize(options = {}) ⇒ CreditCard
Returns a new instance of CreditCard.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_psigate/credit_card.rb', line 27 def initialize(={}) requires!(, :number, :month, :year, :name) @number = [:number] @month = [:month] @year = [:year] @verification_value = [:verification_value] @name = [:name] validate_credit_card! end |
Instance Attribute Details
#month ⇒ Object Also known as: cardexpmonth
Returns the value of attribute month.
21 22 23 |
# File 'lib/ruby_psigate/credit_card.rb', line 21 def month @month end |
#name ⇒ Object Also known as: cardholder
Returns the value of attribute name.
21 22 23 |
# File 'lib/ruby_psigate/credit_card.rb', line 21 def name @name end |
#number ⇒ Object Also known as: cardnumber
Returns the value of attribute number.
21 22 23 |
# File 'lib/ruby_psigate/credit_card.rb', line 21 def number @number end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/ruby_psigate/credit_card.rb', line 22 def type @type end |
#verification_value ⇒ Object Also known as: cardidnumber
Returns the value of attribute verification_value.
21 22 23 |
# File 'lib/ruby_psigate/credit_card.rb', line 21 def verification_value @verification_value end |
#year ⇒ Object
Returns the value of attribute year.
21 22 23 |
# File 'lib/ruby_psigate/credit_card.rb', line 21 def year @year end |
Instance Method Details
#cardexpyear ⇒ Object
Returns the last 2 digits of the expiry year
44 45 46 |
# File 'lib/ruby_psigate/credit_card.rb', line 44 def cardexpyear year[2..3] end |
#paymenttype ⇒ Object
For hashable
39 40 41 |
# File 'lib/ruby_psigate/credit_card.rb', line 39 def paymenttype "CC" end |