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’
462 463 464 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 462 def brand @brand end |
#month ⇒ Integer
Returns or sets the expiry month for the card associated with token. (optional)
432 433 434 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 432 def month @month end |
#token ⇒ String
Returns or sets the token. (required)
427 428 429 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 427 def token @token end |
#verification_value ⇒ String
Returns or sets the card verification value. (optional)
442 443 444 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 442 def verification_value @verification_value end |
#year ⇒ Integer
Returns or sets the expiry year for the card associated with token. (optional)
437 438 439 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 437 def year @year end |
Instance Method Details
#check? ⇒ Boolean
501 502 503 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 501 def check? false end |
#exp_date ⇒ String
Returns the card token expiration date in MMYY format.
481 482 483 484 485 486 487 488 489 490 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 481 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.
474 475 476 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 474 def exp_date? !month.to_i.zero? && !year.to_i.zero? end |
#type ⇒ String
Returns the Litle credit card type identifier.
467 468 469 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 467 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.
495 496 497 498 499 |
# File 'lib/active_merchant/billing/gateways/litle.rb', line 495 def validate validate_card_token validate_expiration_date validate_card_brand end |