Class: ActiveMerchant::Billing::LitleGateway::LitleCardToken
- Inherits:
-
Object
- Object
- ActiveMerchant::Billing::LitleGateway::LitleCardToken
- Includes:
- Validateable
- Defined in:
- lib/active_merchant/billing/gateways/litle.rb
Overview
A LitleCardToken
object represents a tokenized credit card, and is capable of validating the various data associated with these.
Example Usage
token = LitleCardToken.new(
:token => '1234567890123456',
:month => '9',
:year => '2010',
:brand => 'visa',
:verification_value => '123'
)
token.valid? # => true
cc.exp_date # => 0910
Instance Attribute Summary collapse
-
#brand ⇒ String
Returns or sets the credit card brand.
-
#month ⇒ Integer
Returns or sets the expiry month for the card associated with token.
-
#token ⇒ String
Returns or sets the token.
-
#verification_value ⇒ String
Returns or sets the card verification value.
-
#year ⇒ Integer
Returns or sets the expiry year for the card associated with token.
Instance Method Summary collapse
- #check? ⇒ Boolean
-
#exp_date ⇒ String
Returns the card token expiration date in MMYY format.
-
#exp_date? ⇒ Boolean
Returns true if the expiration date is set.
-
#type ⇒ String
Returns the Litle credit card type identifier.
-
#validate ⇒ Object
Validates the card token details.
Instance Attribute Details
#brand ⇒ String
Returns or sets the credit card brand. (optional)
Valid card types are
-
‘visa’
-
‘master’
-
‘discover’
-
‘american_express’
-
‘diners_club’
-
‘jcb’
-
‘switch’
-
‘solo’
-
‘dankort’
-
‘maestro’
-
‘forbrugsforeningen’
-
‘laser’
443 444 445 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 443 def brand @brand end |
#month ⇒ Integer
Returns or sets the expiry month for the card associated with token. (optional)
413 414 415 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 413 def month @month end |
#token ⇒ String
Returns or sets the token. (required)
408 409 410 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 408 def token @token end |
#verification_value ⇒ String
Returns or sets the card verification value. (optional)
423 424 425 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 423 def verification_value @verification_value end |
#year ⇒ Integer
Returns or sets the expiry year for the card associated with token. (optional)
418 419 420 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 418 def year @year end |
Instance Method Details
#check? ⇒ Boolean
482 483 484 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 482 def check? false end |
#exp_date ⇒ String
Returns the card token expiration date in MMYY format.
462 463 464 465 466 467 468 469 470 471 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 462 def exp_date result = '' if exp_date? exp_date_yr = year.to_s[2..3] exp_date_mo = '%02d' % month.to_i result = exp_date_mo + exp_date_yr end result end |
#exp_date? ⇒ Boolean
Returns true if the expiration date is set.
455 456 457 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 455 def exp_date? !month.to_i.zero? && !year.to_i.zero? end |
#type ⇒ String
Returns the Litle credit card type identifier.
448 449 450 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 448 def type CARD_TYPE[brand] unless brand.blank? end |
#validate ⇒ Object
Validates the card token details.
Any validation errors are added to the #errors attribute.
476 477 478 479 480 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 476 def validate validate_card_token validate_expiration_date validate_card_brand end |