Class: RubyPsigate::CreditCard

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from HashVariables

included

Methods included from Utils

#requires!

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(options={})
  requires!(options, :number, :month, :year, :name)
  @number = options[:number]
  @month  = options[:month]
  @year   = options[:year]
  @verification_value = options[:verification_value]
  @name   = options[:name]
  
  validate_credit_card!
end

Instance Attribute Details

#monthObject 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

#nameObject 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

#numberObject 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

#typeObject (readonly)

Returns the value of attribute type.



22
23
24
# File 'lib/ruby_psigate/credit_card.rb', line 22

def type
  @type
end

#verification_valueObject 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

#yearObject

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

#cardexpyearObject

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

#paymenttypeObject

For hashable



39
40
41
# File 'lib/ruby_psigate/credit_card.rb', line 39

def paymenttype
  "CC"
end