module StripeMock::CreditCards

Constants

BAD_CARDS

Public Class Methods

attr_value_by_code(type, code) click to toggle source
# File lib/stripe_mock/credit_cards/cards.rb, line 43
def attr_value_by_code(type, code)
  BAD_CARDS.detect do |hash|
    code == hash[:code]
  end[type.to_sym]
end
card_error(card_hash) click to toggle source
# File lib/stripe_mock/credit_cards/cards.rb, line 53
def card_error(card_hash)
  hash = BAD_CARDS.detect do |hash|
    hash.keys.any? do |key|
      !card_hash[key].nil? && card_hash[key] == hash[key]
    end
  end

  unless hash.nil?
    StripeMock.card_failures[hash[:code]]
  end
end
card_number_by_code(code) click to toggle source
# File lib/stripe_mock/credit_cards/cards.rb, line 39
def card_number_by_code(code)
  attr_value_by_code(:number, code)
end
is_erroneous?(card_hash) click to toggle source
# File lib/stripe_mock/credit_cards/cards.rb, line 49
def is_erroneous?(card_hash)
  !card_error(card_hash).nil?
end