Module: PayTrace::Debug

Defined in:
lib/paytrace/debug.rb

Class Method Summary collapse

Class Method Details

.configure_test(un = "demo123", pw = "demo123", domain = "stage.paytrace.com") ⇒ Object



40
41
42
43
44
45
46
# File 'lib/paytrace/debug.rb', line 40

def self.configure_test(un = "demo123", pw = "demo123", domain = "stage.paytrace.com")
  PayTrace.configure do |config|
    config.user_name = un
    config.password = pw
    config.domain = domain
  end
end

.dump_transactionObject

Helper that loops through the response values and dumps them out



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/paytrace/debug.rb', line 8

def self.dump_transaction
  puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
  response = PayTrace::API::Gateway.last_response_object
  if(response.has_errors?)
    response.errors.each do |key, value|
      puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
    end
  else
    response.values.each do |key, value|
      puts "[RESPONSE] #{key.ljust(20)}#{value}"
    end
  end
end

.log(msg) ⇒ Object



22
23
24
# File 'lib/paytrace/debug.rb', line 22

def self.log(msg)
  puts ">>>>>>           #{msg}"
end

.trace(&block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/paytrace/debug.rb', line 26

def self.trace(&block)
  PayTrace::API::Gateway.debug = true

  begin
    yield
  rescue Exception => e
    puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"

    raise
  else
    dump_transaction
  end
end