Class: ActiveMerchant::Billing::LitleGateway::LitleCardToken

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

Instance Method Summary collapse

Instance Attribute Details

#brandString

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’

Returns:

  • (String)

    the credit card brand



462
463
464
# File 'lib/active_merchant/billing/gateways/litle.rb', line 462

def brand
  @brand
end

#monthInteger

Returns or sets the expiry month for the card associated with token. (optional)

Returns:

  • (Integer)


432
433
434
# File 'lib/active_merchant/billing/gateways/litle.rb', line 432

def month
  @month
end

#tokenString

Returns or sets the token. (required)

Returns:

  • (String)


427
428
429
# File 'lib/active_merchant/billing/gateways/litle.rb', line 427

def token
  @token
end

#verification_valueString

Returns or sets the card verification value. (optional)

Returns:

  • (String)

    the verification value



442
443
444
# File 'lib/active_merchant/billing/gateways/litle.rb', line 442

def verification_value
  @verification_value
end

#yearInteger

Returns or sets the expiry year for the card associated with token. (optional)

Returns:

  • (Integer)


437
438
439
# File 'lib/active_merchant/billing/gateways/litle.rb', line 437

def year
  @year
end

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


501
502
503
# File 'lib/active_merchant/billing/gateways/litle.rb', line 501

def check?
  false
end

#exp_dateString

Returns the card token expiration date in MMYY format.

Returns:

  • (String)

    the 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.

Returns:

  • (Boolean)


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

#typeString

Returns the Litle credit card type identifier.

Returns:

  • (String)

    the 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

#validateObject

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