Class | ActiveMerchant::Billing::CreditCard
In: | lib/active_merchant/billing/credit_card.rb lib/active_merchant/billing/expiry_date.rb
Parent: | Object

## Description

This credit card object can be used as a stand alone object. It acts just like an ActiveRecord object but doesn‘t support the .save method as its not backed by a database.

For testing purposes, use the ‘bogus’ credit card type. This card skips the vast majority of validations. This allows you to focus on your core concerns until you‘re ready to be more concerned with the details of particular creditcards or your gateway.

## Testing With CreditCard

Often when testing we don‘t care about the particulars of a given card type. When using the ‘test’ mode in your Gateway, there are six different valid card numbers: 1, 2, 3, ‘success’, ‘fail’, and ‘error’.

## Example Usage

      cc = CreditCard.new(
        :first_name => 'Steve',
        :last_name  => 'Smith',
        :month      => '9',
        :year       => '2010',
        :type       => 'visa',
        :number     => '4242424242424242'
      )

      cc.valid? # => true
      cc.display_number # => XXXX-XXXX-XXXX-4242

### Methods

display_number expired? expiry_date first_name? last_digits last_name? name name? requires_verification_value? validate verification_value?

### Included Modules

CreditCardMethods Validateable

### Attributes

first_name | [RW] | Essential attributes for a valid, non-bogus creditcards
issue_number | [RW] | Required for Switch / Solo cards
last_name | [RW] | Essential attributes for a valid, non-bogus creditcards
month | [RW] | Essential attributes for a valid, non-bogus creditcards
number | [RW] | Essential attributes for a valid, non-bogus creditcards
start_month | [RW] | Required for Switch / Solo cards
start_year | [RW] | Required for Switch / Solo cards
type | [RW] | Essential attributes for a valid, non-bogus creditcards
verification_value | [RW] | Optional verification_value (CVV, CVV2 etc). Gateways will try their best to run validation on the passed in value if it is supplied
year | [RW] | Essential attributes for a valid, non-bogus creditcards

### Public Class methods

requires_verification_value?()

### Public Instance methods

display_number()

Show the card number, with all but last 4 numbers replace with "X". (XXXX-XXXX-XXXX-4338)

expired?()
expiry_date()

Provides proxy access to an expiry date object

first_name?()
last_digits()
last_name?()
name()
name?()
validate()
verification_value?()

[Validate]