class Upay::Transaction

Public Class Methods

new(args = {}) click to toggle source
# File lib/upay/transaction.rb, line 3
def initialize(args = {})
  args.each do |k,v|
    instance_variable_set("@#{k}", v)
  end
end

Public Instance Methods

capture_and_authorize() click to toggle source
# File lib/upay/transaction.rb, line 39
def capture_and_authorize
  payload = {}
  payload["transaction"] = self.to_hash
  response = Payment.new.submit_transaction(payload)["response"] || {code: "ERROR", error: "something went terribly wrong"}

  if response["code"] == "SUCCESS"
    transaction_response_hash = response["transactionResponse"] || {}
    transaction_response = TransactionResponse.new(transaction_response_hash)
  else
    raise response.to_json.inspect
  end
  transaction_response
end
creditCardTokenId() click to toggle source
# File lib/upay/transaction.rb, line 15
def creditCardTokenId; @creditCardTokenId end
creditCardTokenId=(creditCardTokenId = nil) click to toggle source
# File lib/upay/transaction.rb, line 16
def creditCardTokenId=(creditCardTokenId = nil); @creditCardTokenId = creditCardTokenId; end
deviceSessionId() click to toggle source
# File lib/upay/transaction.rb, line 27
def deviceSessionId; @deviceSessionId end
deviceSessionId=(deviceSessionId = nil) click to toggle source
# File lib/upay/transaction.rb, line 28
def deviceSessionId=(deviceSessionId = nil); @deviceSessionId = deviceSessionId; end
ipAddress() click to toggle source
# File lib/upay/transaction.rb, line 30
def ipAddress; @ipAddress; end
ipAddress=(ipAddress = nil) click to toggle source
# File lib/upay/transaction.rb, line 31
def ipAddress=(ipAddress = nil) @ipAddress = ipAddress end
order() click to toggle source
# File lib/upay/transaction.rb, line 9
def order; @order end
order=(order = nil) click to toggle source
# File lib/upay/transaction.rb, line 10
def order=(order = nil); @order = order; end
payer() click to toggle source
# File lib/upay/transaction.rb, line 12
def payer; @payer end
payer=(payer = nil) click to toggle source
# File lib/upay/transaction.rb, line 13
def payer=(payer = nil); @payer = payer; end
paymentCountry() click to toggle source
# File lib/upay/transaction.rb, line 24
def paymentCountry; @paymentCountry end
paymentCountry=(paymentCountry = nil) click to toggle source
# File lib/upay/transaction.rb, line 25
def paymentCountry=(paymentCountry = nil); @paymentCountry = paymentCountry; end
paymentMethod() click to toggle source
# File lib/upay/transaction.rb, line 21
def paymentMethod; @paymentMethod end
paymentMethod=(paymentMethod = nil) click to toggle source
# File lib/upay/transaction.rb, line 22
def paymentMethod=(paymentMethod = nil); @paymentMethod = paymentMethod; end
to_hash() click to toggle source
# File lib/upay/transaction.rb, line 58
def to_hash
  transaction_hash = self.instance_variables.each_with_object({}) { |var,hash| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var)}
  transaction_hash[:order] = self.order.to_hash if self.order
  transaction_hash[:payer] = self.payer.to_hash if self.payer
  transaction_hash
end
type() click to toggle source
# File lib/upay/transaction.rb, line 18
def type; @type end
type=(type = nil) click to toggle source
# File lib/upay/transaction.rb, line 19
def type=(type = nil); @type = type; end
userAgent() click to toggle source
# File lib/upay/transaction.rb, line 36
def userAgent; @userAgent end
userAgent=(userAgent = nil) click to toggle source
# File lib/upay/transaction.rb, line 37
def userAgent=(userAgent = nil) @userAgent = userAgent; end
valid?() click to toggle source
# File lib/upay/transaction.rb, line 53
def valid?
  validator = TransactionValidator.new
  validator.valid?(self)
end