lib/braintree/credit_card.rb in braintree-4.15.0 vs lib/braintree/credit_card.rb in braintree-4.16.0

- old
+ new

@@ -1,8 +1,8 @@ module Braintree class CreditCard - include BaseModule # :nodoc: + include BaseModule include Braintree::Util::TokenEquality module CardType AmEx = "American Express" CarteBlanche = "Carte Blanche" @@ -23,10 +23,11 @@ All = constants.map { |c| const_get(c) } end module DebitNetwork Accel = "ACCEL" + Maestro = "MAESTRO" Nyce = "NYCE" Pulse = "PULSE" Star = "STAR" Star_Access = "STAR_ACCESS" @@ -122,39 +123,37 @@ def self.update!(*args) Configuration.gateway.credit_card.update!(*args) end - def initialize(gateway, attributes) # :nodoc: + 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 def _most_recent_verification(attributes) - verification = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first - CreditCardVerification._new(verification) if verification + sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first + CreditCardVerification._new(sorted_verifications) if sorted_verifications end - # Returns true if this credit card is the customer's default payment method. def default? @default end # Expiration date formatted as MM/YYYY def expiration_date "#{expiration_month}/#{expiration_year}" end - # Returns true if the credit card is expired. def expired? @expired end - def inspect # :nodoc: + def inspect first = [:token] order = first + (self.class._attributes - first) nice_attributes = order.map do |attr| "#{attr}: #{send(attr).inspect}" end @@ -167,10 +166,11 @@ def nonce @nonce ||= PaymentMethodNonce.create(token) end + # 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 def venmo_sdk? warn "[DEPRECATED] The Venmo SDK integration is Unsupported. Please update your integration to use Pay with Venmo instead." @@ -183,18 +183,18 @@ class << self protected :new end - def self._attributes # :nodoc: + 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 - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end end