Sha256: dad842198943f6f281e763ff4a2220f2ca3e7fdd588897cf3fea33b29114d198

Contents?: true

Size: 781 Bytes

Versions: 6

Compression:

Stored size: 781 Bytes

Contents

module Braintree
  class Transaction
    class CreditCardDetails # :nodoc:
      include BaseModule

      attr_reader :bin, :card_type, :customer_location, :expiration_month,
        :expiration_year, :last_4, :token

      def initialize(attributes)
        set_instance_variables_from_hash attributes unless attributes.nil?
      end

      def inspect
        attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :customer_location]
        formatted_attrs = attr_order.map do |attr|
          "#{attr}: #{send(attr).inspect}"
        end
        "#<#{formatted_attrs.join(", ")}>"
      end

      def expiration_date
        "#{expiration_month}/#{expiration_year}"
      end

      def masked_number
        "#{bin}******#{last_4}"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
braintree-1.2.1 lib/braintree/transaction/credit_card_details.rb
braintree-1.2.0 lib/braintree/transaction/credit_card_details.rb
braintree-1.1.3 lib/braintree/transaction/credit_card_details.rb
braintree-1.1.2 lib/braintree/transaction/credit_card_details.rb
braintree-1.1.1 lib/braintree/transaction/credit_card_details.rb
braintree-1.1.0 lib/braintree/transaction/credit_card_details.rb