Class: SecureTrading::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/secure_trading/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/secure_trading/response.rb', line 6

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/secure_trading/response.rb', line 4

def response
  @response
end

Instance Method Details

#live?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/secure_trading/response.rb', line 18

def live?
  self.xml["Live"] == "TRUE"
end

#messageObject



22
23
24
# File 'lib/secure_trading/response.rb', line 22

def message
  self.operation_response['Message']
end

#operation_responseObject



26
27
28
# File 'lib/secure_trading/response.rb', line 26

def operation_response
  Util.stringify_values(self.xml["Response"].first["OperationResponse"].first)
end

#raw_responseObject



46
47
48
# File 'lib/secure_trading/response.rb', line 46

def raw_response
  @response
end

#resultObject



34
35
36
# File 'lib/secure_trading/response.rb', line 34

def result
  operation_response['Result'].to_i
end

#success?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/secure_trading/response.rb', line 38

def success?
  result == 1
end

#threed3secure_responseObject



30
31
32
# File 'lib/secure_trading/response.rb', line 30

def threed3secure_response
  Util.stringify_values(self.xml["Response"].first["ThreeDSecure"].first)
end

#transactionObject



42
43
44
# File 'lib/secure_trading/response.rb', line 42

def transaction
  Objects::Transaction.new(:verifier => self.operation_response['TransactionVerifier'], :reference => self.operation_response['TransactionReference'])
end

#typeObject



14
15
16
# File 'lib/secure_trading/response.rb', line 14

def type
  self.xml['Response'].first['Type']
end

#xmlObject



10
11
12
# File 'lib/secure_trading/response.rb', line 10

def xml
  @xml ||= XmlSimple.xml_in(@response)
end