class Rmoolah::Transaction

Attributes

address[R]
amount_requested[R]
amount_to_pay[R]
currency_requested[R]
currency_to_pay[R]
guid[R]
ipn[R]
product[R]
received[R]
return_url[R]
status[R]
tx[R]
url[R]

Public Class Methods

fetch(tx) click to toggle source
# File lib/rmoolah/transaction.rb, line 10
def fetch(tx)
  self.new(nil, nil, nil, nil, nil).fetch(tx)
end
new(guid, amount_requested, currency_requested, product, return_url, ipn = nil) click to toggle source
# File lib/rmoolah/transaction.rb, line 29
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

Public Instance Methods

create() click to toggle source
# File lib/rmoolah/transaction.rb, line 38
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) click to toggle source
# File lib/rmoolah/transaction.rb, line 50
def fetch(tx = @tx)
  response = self.class.get("/api/pay/check/#{tx}")
  update!(response.body)
  self
end

Private Instance Methods

update!(json) click to toggle source
# File lib/rmoolah/transaction.rb, line 57
def update!(json)
  h = JSON.parse(json)
  @status           ||= h['status']
  @tx               ||= h['tx']
  @url              ||= h['url']
  @address          ||= h['address']
  @amount_to_pay    ||= h['amount']
  @currency_to_pay  ||= h['currency']
  @received         ||= h['received']
  self
end