Class | ActiveMerchant::Billing::CreditCard |
In: |
lib/active_merchant/billing/credit_card.rb
lib/active_merchant/billing/expiry_date.rb |
Parent: | Object |
A CreditCard object represents a physical credit card, and is capable of validating the various data associated with these.
At the moment, the following credit card types are supported:
For testing purposes, use the ‘bogus’ credit card type. This skips the vast majority of validations, allowing you to focus on your core concerns until you‘re ready to be more concerned with the details of particular credit cards or your gateway.
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’.
For details, see {CreditCardMethods::ClassMethods#valid_number?}
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
type | -> | brand |
first_name | [RW] |
Returns or sets the first name of the
card holder.
@return [String] |
issue_number | [RW] | Required for Switch / Solo cards |
last_name | [RW] |
Returns or sets the last name of the
card holder.
@return [String] |
month | [RW] |
Returns or sets the expiry month for the card.
@return [Integer] |
number | [RW] |
Returns or sets the credit card number.
@return [String] |
start_month | [RW] | Required for Switch / Solo cards |
start_year | [RW] | Required for Switch / Solo cards |
type | [RW] |
Returns or sets the credit card type.
Valid card types are
Or, if you wish to test your implementation, +’bogus’+. @return (String) the credit card type |
verification_value | [RW] |
Returns or sets the card verification value.
This attribute is optional but recommended. The verification value is a card security code. If provided, the gateway will attempt to validate the value. @return [String] the verification value |
year | [RW] |
Returns or sets the expiry year for the card.
@return [Integer] |
Returns a display-friendly version of the card number.
All but the last 4 numbers are replaced with an "X", and hyphens are inserted in order to improve legibility.
@example
credit_card = CreditCard.new(:number => "2132542376824338") credit_card.display_number # "XXXX-XXXX-XXXX-4338"
@return [String] a display-friendly version of the card number