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



468
469
470
# File 'lib/active_merchant/billing/gateways/litle.rb', line 468

def brand
  @brand
end

#monthInteger

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

Returns:

  • (Integer)


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

def month
  @month
end

#tokenString

Returns or sets the token. (required)

Returns:

  • (String)


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

def token
  @token
end

#verification_valueString

Returns or sets the card verification value. (optional)

Returns:

  • (String)

    the verification value



448
449
450
# File 'lib/active_merchant/billing/gateways/litle.rb', line 448

def verification_value
  @verification_value
end

#yearInteger

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

Returns:

  • (Integer)


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

def year
  @year
end

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


507
508
509
# File 'lib/active_merchant/billing/gateways/litle.rb', line 507

def check?
  false
end

#exp_dateString

Returns the card token expiration date in MMYY format.

Returns:

  • (String)

    the expiration date in MMYY format



487
488
489
490
491
492
493
494
495
496
# File 'lib/active_merchant/billing/gateways/litle.rb', line 487

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)


480
481
482
# File 'lib/active_merchant/billing/gateways/litle.rb', line 480

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



473
474
475
# File 'lib/active_merchant/billing/gateways/litle.rb', line 473

def type
  CARD_TYPE[brand] unless brand.blank?
end

#validateObject

Validates the card token details.

Any validation errors are added to the #errors attribute.



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

def validate
  validate_card_token
  validate_expiration_date
  validate_card_brand
end