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
# 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'
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



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

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

#autosettle?Boolean

Returns:

  • (Boolean)


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

def autosettle?
  autosettle
end

#hashObject



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

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

#request_typeObject



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

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

#to_xml(&block) ⇒ Object



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

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. RealEx::Config.
    if block_given?
      block.call(r)
    end
    if !comments.empty?
      r.comments do |c|
        comments.each_with_index do |index,comment|
          c.comment(comment, :id => index)
        end
      end
    end
    r.sha1hash hash
  end
end