Class: Rmoolah::Transaction

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rmoolah/transaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(guid, amount_requested, currency_requested, product, return_url, ipn = nil) ⇒ Transaction

Returns a new instance of Transaction.



31
32
33
34
35
36
37
38
# File 'lib/rmoolah/transaction.rb', line 31

def initialize(guid, amount_requested, currency_requested, product, return_url, ipn = nil)
  @guid = guid
  @amount_requested = amount_requested
  @currency_requested = currency_requested
  @product = product
  @return_url = return_url
  @ipn = ipn
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def address
  @address
end

#amount_requestedObject (readonly)

Returns the value of attribute amount_requested.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def amount_requested
  @amount_requested
end

#amount_to_payObject (readonly)

Returns the value of attribute amount_to_pay.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def amount_to_pay
  @amount_to_pay
end

#currency_requestedObject (readonly)

Returns the value of attribute currency_requested.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def currency_requested
  @currency_requested
end

#currency_to_payObject (readonly)

Returns the value of attribute currency_to_pay.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def currency_to_pay
  @currency_to_pay
end

#guidObject (readonly)

Returns the value of attribute guid.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def guid
  @guid
end

#ipnObject (readonly)

Returns the value of attribute ipn.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def ipn
  @ipn
end

#productObject (readonly)

Returns the value of attribute product.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def product
  @product
end

#receivedObject (readonly)

Returns the value of attribute received.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def received
  @received
end

#return_urlObject (readonly)

Returns the value of attribute return_url.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def return_url
  @return_url
end

#statusObject (readonly)

Returns the value of attribute status.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def status
  @status
end

#txObject (readonly)

Returns the value of attribute tx.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def tx
  @tx
end

#urlObject (readonly)

Returns the value of attribute url.



17
18
19
# File 'lib/rmoolah/transaction.rb', line 17

def url
  @url
end

Class Method Details

.fetch(tx) ⇒ Object



12
13
14
# File 'lib/rmoolah/transaction.rb', line 12

def fetch(tx)
  self.new(nil, nil, nil, nil, nil).fetch(tx)
end

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rmoolah/transaction.rb', line 40

def create
  response = self.class.get("/api/pay", query: {
    guid: guid,
    amount: amount_requested,
    currency: currency_requested,
    product: product,
    return: return_url
  })
  update!(response.body)
  self
end

#fetch(tx = @tx) ⇒ Object



52
53
54
55
56
# File 'lib/rmoolah/transaction.rb', line 52

def fetch(tx = @tx)
  response = self.class.get("/api/pay/check/#{tx}")
  update!(response.body)
  self
end