Class: Braintree::CreditCard

### Home Classes Methods

### In Files

- lib/braintree/credit_card.rb

### Parent

Object

### Namespace

- MODULE Braintree::CreditCard::CardType
- MODULE Braintree::CreditCard::CustomerLocation

### Methods

- ::create
- ::create!
- ::create_credit_card_url
- ::create_from_transparent_redirect
- ::credit
- ::credit!
- ::delete
- ::expired
- ::expiring_between
- ::find
- ::sale
- ::sale!
- ::update
- ::update!
- ::update_credit_card_url
- ::update_from_transparent_redirect
- #==
- #credit
- #credit!
- #default?
- #delete
- #expiration_date
- #expired?
- #masked_number
- #sale
- #sale!
- #update
- #update!

### Class/Module Index

Quicksearch

- Braintree
- Braintree::AddOn
- Braintree::AddOnGateway
- Braintree::Address
- Braintree::AddressGateway
- Braintree::AdvancedSearch
- Braintree::AdvancedSearch::MultipleValueOrTextNode
- Braintree::AuthenticationError
- Braintree::AuthorizationError
- Braintree::BraintreeError
- Braintree::Configuration
- Braintree::ConfigurationError
- Braintree::CreditCard
- Braintree::CreditCard::CardType
- Braintree::CreditCard::CustomerLocation
- Braintree::CreditCardVerification
- Braintree::CreditCardVerification::Status
- Braintree::Customer
- Braintree::Discount
- Braintree::DiscountGateway
- Braintree::DownForMaintenanceError
- Braintree::ErrorCodes
- Braintree::ErrorCodes::Address
- Braintree::ErrorCodes::CreditCard
- Braintree::ErrorCodes::CreditCard::Options
- Braintree::ErrorCodes::Customer
- Braintree::ErrorCodes::Descriptor
- Braintree::ErrorCodes::SettlementBatchSummary
- Braintree::ErrorCodes::Subscription
- Braintree::ErrorCodes::Subscription::Modification
- Braintree::ErrorCodes::Transaction
- Braintree::ErrorCodes::Transaction::Options
- Braintree::ErrorResult
- Braintree::Errors
- Braintree::ForgedQueryString
- Braintree::NotFoundError
- Braintree::Plan
- Braintree::SSLCertificateError
- Braintree::ServerError
- Braintree::SettlementBatchSummary
- Braintree::SettlementBatchSummaryGateway
- Braintree::Subscription
- Braintree::Subscription::Status
- Braintree::Subscription::TrialDurationUnit
- Braintree::SuccessfulResult
- Braintree::Test
- Braintree::Test::CreditCardNumbers
- Braintree::Test::CreditCardNumbers::FailsSandboxVerification
- Braintree::Test::TransactionAmounts
- Braintree::Transaction
- Braintree::Transaction::CreatedUsing
- Braintree::Transaction::GatewayRejectionReason
- Braintree::Transaction::Source
- Braintree::Transaction::Status
- Braintree::TransparentRedirect
- Braintree::TransparentRedirectGateway
- Braintree::UnexpectedError
- Braintree::UpgradeRequiredError
- Braintree::ValidationError
- Braintree::ValidationErrorCollection
- Braintree::ValidationsFailed
- Braintree::Version

No matching classes.

# Braintree::CreditCard

See www.braintreepayments.com/docs/ruby

### Attributes

billing_address[R]
bin[R]
card_type[R]
cardholder_name[R]
created_at[R]
customer_id[R]
expiration_month[R]
expiration_year[R]
last_4[R]
subscriptions[R]
token[R]
updated_at[R]

### Public Class Methods

create(attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/create

    # File lib/braintree/credit_card.rb, line 33
    def self.create(attributes)
      Configuration.gateway.credit_card.create(attributes)
    end

create!(attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/create

    # File lib/braintree/credit_card.rb, line 38
    def self.create!(attributes)
      return_object_or_raise(:credit_card) { create(attributes) }
    end

create_credit_card_url() click to toggle source

Deprecated. Use Braintree::TransparentRedirect.url See www.braintreepayments.com/docs/ruby/credit_cards/create_tr

    # File lib/braintree/credit_card.rb, line 44
    def self.create_credit_card_url
      warn "[DEPRECATED] CreditCard.create_credit_card_url is deprecated. Please use TransparentRedirect.url"
      Configuration.gateway.credit_card.create_credit_card_url
    end

create_from_transparent_redirect(query_string) click to toggle source

Deprecated. Use Braintree::TransparentRedirect.confirm See www.braintreepayments.com/docs/ruby/credit_cards/create_tr

    # File lib/braintree/credit_card.rb, line 51
    def self.create_from_transparent_redirect(query_string)
      warn "[DEPRECATED] CreditCard.create_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm"
      Configuration.gateway.credit_card.create_from_transparent_redirect(query_string)
    end

credit(token, transaction_attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 57
    def self.credit(token, transaction_attributes)
      Transaction.credit(transaction_attributes.merge(:payment_method_token => token))
    end

credit!(token, transaction_attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 62
    def self.credit!(token, transaction_attributes)
      return_object_or_raise(:transaction) { credit(token, transaction_attributes) }
    end

delete(token) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/delete

    # File lib/braintree/credit_card.rb, line 67
    def self.delete(token)
      Configuration.gateway.credit_card.delete(token)
    end

expired(options = {}) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/search

    # File lib/braintree/credit_card.rb, line 72
    def self.expired(options = {})
      Configuration.gateway.credit_card.expired(options)
    end

expiring_between(start_date, end_date, options = {}) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/search

    # File lib/braintree/credit_card.rb, line 77
    def self.expiring_between(start_date, end_date, options = {})
      Configuration.gateway.credit_card.expiring_between(start_date, end_date, options)
    end

find(token) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/search

    # File lib/braintree/credit_card.rb, line 82
    def self.find(token)
      Configuration.gateway.credit_card.find(token)
    end

sale(token, transaction_attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 87
    def self.sale(token, transaction_attributes)
      Configuration.gateway.transaction.sale(transaction_attributes.merge(:payment_method_token => token))
    end

sale!(token, transaction_attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 92
    def self.sale!(token, transaction_attributes)
      return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
    end

update(token, attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/update

    # File lib/braintree/credit_card.rb, line 97
    def self.update(token, attributes)
      Configuration.gateway.credit_card.update(token, attributes)
    end

update!(token, attributes) click to toggle source

See www.braintreepayments.com/docs/ruby/credit_cards/update

    # File lib/braintree/credit_card.rb, line 102
    def self.update!(token, attributes)
      return_object_or_raise(:credit_card) { update(token, attributes) }
    end

update_credit_card_url() click to toggle source

Deprecated. Use Braintree::TransparentRedirect.url

See www.braintreepayments.com/docs/ruby/credit_cards/update_tr

    # File lib/braintree/credit_card.rb, line 117
    def self.update_credit_card_url
      warn "[DEPRECATED] CreditCard.update_credit_card_url is deprecated. Please use TransparentRedirect.url"
      Configuration.gateway.credit_card.update_credit_card_url
    end

update_from_transparent_redirect(query_string) click to toggle source

Deprecated. Use Braintree::TransparentRedirect.confirm

See www.braintreepayments.com/docs/ruby/credit_cards/update_tr

    # File lib/braintree/credit_card.rb, line 109
    def self.update_from_transparent_redirect(query_string)
      warn "[DEPRECATED] CreditCard.update_via_transparent_redirect_request is deprecated. Please use TransparentRedirect.confirm"
      Configuration.gateway.credit_card.update_from_transparent_redirect(query_string)
    end

### Public Instance Methods

==(other) click to toggle source

Returns true if `other` is a `CreditCard` with the same token.

    # File lib/braintree/credit_card.rb, line 218
    def ==(other)
      return false unless other.is_a?(CreditCard)
      token == other.token
    end

credit(transaction_attributes) click to toggle source

Deprecated. Use Braintree::CreditCard.credit

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 132
    def credit(transaction_attributes)
      warn "[DEPRECATED] credit as an instance method is deprecated. Please use CreditCard.credit"
      @gateway.transaction.credit(transaction_attributes.merge(:payment_method_token => token))
    end

credit!(transaction_attributes) click to toggle source

Deprecated. Use Braintree::CreditCard.credit!

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 140
    def credit!(transaction_attributes)
      warn "[DEPRECATED] credit! as an instance method is deprecated. Please use CreditCard.credit!"
      return_object_or_raise(:transaction) { credit(transaction_attributes) }
    end

default?() click to toggle source

Returns true if this credit card is the customer's default.

    # File lib/braintree/credit_card.rb, line 154
    def default?
      @default
    end

delete() click to toggle source

Deprecated. Use Braintree::CreditCard.delete

www.braintreepayments.com/docs/ruby/credit_cards/delete

    # File lib/braintree/credit_card.rb, line 148
    def delete
      warn "[DEPRECATED] delete as an instance method is deprecated. Please use CreditCard.delete"
      @gateway.credit_card.delete(token)
    end

expiration_date() click to toggle source

Expiration date formatted as MM/YYYY

    # File lib/braintree/credit_card.rb, line 159
    def expiration_date
      "#{expiration_month}/#{expiration_year}"
    end

expired?() click to toggle source

Returns true if the credit card is expired.

    # File lib/braintree/credit_card.rb, line 164
    def expired?
      @expired
    end

masked_number() click to toggle source

    # File lib/braintree/credit_card.rb, line 177
    def masked_number
      "#{bin}******#{last_4}"
    end

sale(transaction_attributes) click to toggle source

Deprecated. Use Braintree::CreditCard.sale

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 184
    def sale(transaction_attributes)
      warn "[DEPRECATED] sale as an instance method is deprecated. Please use CreditCard.sale"
      @gateway.transaction.sale(transaction_attributes.merge(:payment_method_token => token))
    end

sale!(transaction_attributes) click to toggle source

Deprecated. Use Braintree::CreditCard.sale!

See www.braintreepayments.com/docs/ruby/transactions/create_from_vault

    # File lib/braintree/credit_card.rb, line 192
    def sale!(transaction_attributes)
      warn "[DEPRECATED] sale! as an instance method is deprecated. Please use CreditCard.sale!"
      return_object_or_raise(:transaction) { sale(transaction_attributes) }
    end

update(attributes) click to toggle source

Deprecated. Use Braintree::CreditCard.update

See www.braintreepayments.com/docs/ruby/credit_cards/update

    # File lib/braintree/credit_card.rb, line 200
    def update(attributes)
      warn "[DEPRECATED] update as an instance method is deprecated. Please use CreditCard.update"
      result = @gateway.credit_card.update(token, attributes)
      if result.success?
        copy_instance_variables_from_object result.credit_card
      end
      result
    end

update!(attributes) click to toggle source

Deprecated. Use Braintree::CreditCard.update!

See www.braintreepayments.com/docs/ruby/credit_cards/update

    # File lib/braintree/credit_card.rb, line 212
    def update!(attributes)
      warn "[DEPRECATED] update! as an instance method is deprecated. Please use CreditCard.update!"
      return_object_or_raise(:credit_card) { update(attributes) }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.