class Braintree::CreditCard

Constants

Commercial

Attributes

billing_address[R]
bin[R]
card_type[R]
cardholder_name[R]
commercial[R]
country_of_issuance[R]
created_at[R]
customer_id[R]
debit[R]
durbin_regulated[R]
expiration_month[R]
expiration_year[R]
healthcare[R]
image_url[R]
issuing_bank[R]
last_4[R]
payroll[R]
prepaid[R]
product_id[R]
subscriptions[R]
token[R]
unique_number_identifier[R]
updated_at[R]
verification[R]

Public Class Methods

_attributes() click to toggle source
# File lib/braintree/credit_card.rb, line 200
def self._attributes
  [
    :billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month,
    :expiration_year, :last_4, :token, :updated_at, :prepaid, :payroll, :product_id, :commercial, :debit, :durbin_regulated,
    :healthcare, :country_of_issuance, :issuing_bank, :image_url, :is_network_tokenized?
  ]
end
_new(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 208
def self._new(*args)
  self.new(*args)
end
create(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 76
def self.create(*args)
  Configuration.gateway.credit_card.create(*args)
end
create!(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 80
def self.create!(*args)
  Configuration.gateway.credit_card.create!(*args)
end
credit(token, transaction_attributes) click to toggle source

NEXT_MAJOR_VERSION remove this method CreditCard.credit has been deprecated in favor of Transaction.credit

# File lib/braintree/credit_card.rb, line 86
def self.credit(token, transaction_attributes)
  warn "[DEPRECATED] CreditCard.credit is deprecated. Use Transaction.credit instead"
  Transaction.credit(transaction_attributes.merge(:payment_method_token => token))
end
credit!(token, transaction_attributes) click to toggle source

NEXT_MAJOR_VERSION remove this method CreditCard.credit has been deprecated in favor of Transaction.credit

# File lib/braintree/credit_card.rb, line 93
def self.credit!(token, transaction_attributes)
  warn "[DEPRECATED] CreditCard.credit is deprecated. Use Transaction.credit instead"
  return_object_or_raise(:transaction) { credit(token, transaction_attributes) }
end
delete(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 98
def self.delete(*args)
  Configuration.gateway.credit_card.delete(*args)
end
expired(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 102
def self.expired(*args)
  Configuration.gateway.credit_card.expired(*args)
end
expiring_between(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 106
def self.expiring_between(*args)
  Configuration.gateway.credit_card.expiring_between(*args)
end
find(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 110
def self.find(*args)
  Configuration.gateway.credit_card.find(*args)
end
from_nonce(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 114
def self.from_nonce(*args)
  Configuration.gateway.credit_card.from_nonce(*args)
end
sale(token, transaction_attributes) click to toggle source

NEXT_MAJOR_VERSION remove this method CreditCard.sale has been deprecated in favor of Transaction.sale

# File lib/braintree/credit_card.rb, line 120
def self.sale(token, transaction_attributes)
  warn "[DEPRECATED] CreditCard.sale is deprecated. Use Transaction.sale instead"
  Configuration.gateway.transaction.sale(transaction_attributes.merge(:payment_method_token => token))
end
sale!(token, transaction_attributes) click to toggle source

NEXT_MAJOR_VERSION remove this method CreditCard.sale has been deprecated in favor of Transaction.sale

# File lib/braintree/credit_card.rb, line 127
def self.sale!(token, transaction_attributes)
  warn "[DEPRECATED] CreditCard.sale is deprecated. Use Transaction.sale instead"
  return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
end
update(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 132
def self.update(*args)
  Configuration.gateway.credit_card.update(*args)
end
update!(*args) click to toggle source
# File lib/braintree/credit_card.rb, line 136
def self.update!(*args)
  Configuration.gateway.credit_card.update!(*args)
end

Protected Class Methods

new(gateway, attributes) click to toggle source
# File lib/braintree/credit_card.rb, line 140
def initialize(gateway, attributes)
  @gateway = gateway
  set_instance_variables_from_hash(attributes)
  @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
  @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
  @verification = _most_recent_verification(attributes)
end

Public Instance Methods

_most_recent_verification(attributes) click to toggle source
# File lib/braintree/credit_card.rb, line 148
def _most_recent_verification(attributes)
  sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
  CreditCardVerification._new(sorted_verifications) if sorted_verifications
end
default?() click to toggle source
# File lib/braintree/credit_card.rb, line 153
def default?
  @default
end
expiration_date() click to toggle source

Expiration date formatted as MM/YYYY

# File lib/braintree/credit_card.rb, line 158
def expiration_date
  "#{expiration_month}/#{expiration_year}"
end
expired?() click to toggle source
# File lib/braintree/credit_card.rb, line 162
def expired?
  @expired
end
inspect() click to toggle source
# File lib/braintree/credit_card.rb, line 166
def inspect
  first = [:token]
  order = first + (self.class._attributes - first)
  nice_attributes = order.map do |attr|
    "#{attr}: #{send(attr).inspect}"
  end
  "#<#{self.class} #{nice_attributes.join(', ')}>"
end
is_network_tokenized?() click to toggle source
# File lib/braintree/credit_card.rb, line 192
def is_network_tokenized?
  @is_network_tokenized
end
masked_number() click to toggle source
# File lib/braintree/credit_card.rb, line 175
def masked_number
  "#{bin}******#{last_4}"
end
nonce() click to toggle source
# File lib/braintree/credit_card.rb, line 179
def nonce
  @nonce ||= PaymentMethodNonce.create(token)
end
venmo_sdk?() click to toggle source

NEXT_MAJOR_VERSION can this be removed? Venmo SDK integration is no more Returns true if the card is associated with Venmo SDK NEXT_MAJOR_VERSION Remove this method The old venmo SDK class has been deprecated

# File lib/braintree/credit_card.rb, line 187
def venmo_sdk?
  warn "[DEPRECATED] The Venmo SDK integration is Unsupported. Please update your integration to use Pay with Venmo instead."
  @venmo_sdk
end