Sha256: 3d4217e8b85a0477fa1f079782de34c9c49b16f2b3abca6ca5c489a2a0022cb5

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

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

      attr_reader :bin, :card_type, :cardholder_name, :customer_location, :expiration_month,
        :expiration_year, :last_4, :token, :prepaid, :healthcare, :durbin_regulated, :debit,
        :commercial, :payroll, :country_of_issuance, :issuing_bank

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

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

      def inspect
        attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid,
        :healthcare, :durbin_regulated, :debit, :commercial, :payroll, :country_of_issuance, :issuing_bank]
        formatted_attrs = attr_order.map do |attr|
          "#{attr}: #{send(attr).inspect}"
        end
        "#<#{formatted_attrs.join(", ")}>"
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
braintree-2.24.0 lib/braintree/transaction/credit_card_details.rb
braintree-2.23.0 lib/braintree/transaction/credit_card_details.rb
braintree-2.22.0 lib/braintree/transaction/credit_card_details.rb
braintree-2.21.0 lib/braintree/transaction/credit_card_details.rb