Class: Cardgate::Transactions

Inherits:
Object
  • Object
show all
Defined in:
lib/cardgate/transactions.rb

Class Method Summary collapse

Class Method Details

.find(transaction_id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cardgate/transactions.rb', line 5

def self.find(transaction_id)
  result = Cardgate::Gateway.connection.get do |req|
    req.url "/rest/v1/transactions/#{transaction_id}/"
    req.headers['Accept'] = 'application/json'
  end

  response = Cardgate::Response.new(result)

  transaction = response.body['transaction']

  if !transaction.empty?
    Cardgate::Transaction.new(transaction)
  else
    raise Cardgate::Exception, 'Transaction was empty'
  end
end