Class: RealEx::Transaction

Inherits:
Object
  • Object
show all
Includes:
Initializer
Defined in:
lib/real_ex/transaction.rb

Direct Known Subclasses

Authorization, Rebate, Recurring::Transaction, Settle, Void

Constant Summary collapse

REQUEST_TYPES =
['auth', 'manual', 'offline', 'tss', 'payer-new', 'payer-edit', 'card-new', 'card-update-card', 'card-cancel-card']

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Initializer

included

Constructor Details

#initialize(hash = {}) ⇒ Transaction

Returns a new instance of Transaction.



10
11
12
13
14
15
16
17
18
# File 'lib/real_ex/transaction.rb', line 10

def initialize(hash = {})
  super(hash)
  self.comments ||= []
  self.autosettle ||= true
  self.currency ||= RealEx::Config.currency || 'EUR'
  self.remote_uri ||= RealEx::Config.remote_uri || '/epage-remote.cgi'
  self.real_vault_uri ||= RealEx::Config.real_vault_uri || '/epage-remote-plugins.cgi'
  self. ||= RealEx::Config.
end

Instance Attribute Details

#authcodeObject

Returns the value of attribute authcode.



6
7
8
# File 'lib/real_ex/transaction.rb', line 6

def authcode
  @authcode
end

#commentsObject

Returns the value of attribute comments.



5
6
7
# File 'lib/real_ex/transaction.rb', line 5

def comments
  @comments
end

#pasrefObject

Returns the value of attribute pasref.



6
7
8
# File 'lib/real_ex/transaction.rb', line 6

def pasref
  @pasref
end

Instance Method Details

#authorize!Object



53
54
55
# File 'lib/real_ex/transaction.rb', line 53

def authorize!
  RealEx::Response.new_from_xml(RealEx::Client.call(remote_uri, to_xml))
end

#autosettle?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/real_ex/transaction.rb', line 24

def autosettle?
  autosettle
end

#hashObject



49
50
51
# File 'lib/real_ex/transaction.rb', line 49

def hash
  RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, order_id, '', '', ''])
end

#request_typeObject



20
21
22
# File 'lib/real_ex/transaction.rb', line 20

def request_type
  self.class.name.split('::').last.downcase
end

#to_xml(&block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/real_ex/transaction.rb', line 28

def to_xml(&block)
  xml = RealEx::Client.build_xml(request_type) do |r|
    r.merchantid RealEx::Config.merchant_id
    r.orderid order_id
    r.authcode authcode if authcode
    r.pasref pasref if pasref
    r. 
    if block_given?
      block.call(r)
    end
    if !comments.empty?
      r.comments do |c|
        comments.each_with_index do |comment,index|
          c.comment(comment, :id => index + 1)
        end
      end
    end
    r.sha1hash hash
  end
end