lib/fake_braintree.rb in fake_braintree-0.0.3 vs lib/fake_braintree.rb in fake_braintree-0.0.4

- old
+ new

@@ -1,21 +1,23 @@ require 'fileutils' require 'braintree' require 'sham_rack' require 'fake_braintree/sinatra_app' +require 'fake_braintree/valid_credit_cards' require 'fake_braintree/version' module FakeBraintree class << self @customers = {} @subscriptions = {} @failures = {} @transaction = {} @decline_all_cards = false - attr_accessor :customers, :subscriptions, :failures, :transaction, :decline_all_cards + @verify_all_cards = false + attr_accessor :customers, :subscriptions, :failures, :transaction, :decline_all_cards, :verify_all_cards end def self.activate! Braintree::Configuration.environment = :production Braintree::Configuration.merchant_id = "xxx" @@ -46,11 +48,11 @@ def self.failure?(card_number) self.failures.include?(card_number) end def self.failure_response(card_number) - failure = self.failures[card_number] + failure = self.failures[card_number] || {} failure["errors"] ||= { "errors" => [] } { "message" => failure["message"], "verification" => { "status" => failure["status"], "processor_response_text" => failure["message"], @@ -74,9 +76,13 @@ self.decline_all_cards = true end def self.decline_all_cards? self.decline_all_cards + end + + def self.verify_all_cards! + self.verify_all_cards = true end def self.credit_card_from_token(token) self.customers.values.detect do |customer| next unless customer.key?("credit_cards")