Class: OmniKassa::Response

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

Defined Under Namespace

Classes: ResponseCodeError, SealMismatchError

Constant Summary collapse

RESPONSE_CODES =
{
  0  => :success,
  17 => :cancelled,
  60 => :pending,
  90 => :failed,
  97 => :expired
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Response


13
14
15
16
17
18
# File 'lib/omni_kassa/response.rb', line 13

def initialize(params)
  self.data = params[:Data]
  self.seal = params[:Seal]

  verify_seal!
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount


11
12
13
# File 'lib/omni_kassa/response.rb', line 11

def amount
  @amount
end

#dataObject

Returns the value of attribute data


11
12
13
# File 'lib/omni_kassa/response.rb', line 11

def data
  @data
end

#order_idObject

Returns the value of attribute order_id


11
12
13
# File 'lib/omni_kassa/response.rb', line 11

def order_id
  @order_id
end

#response_codeObject

Returns the value of attribute response_code


11
12
13
# File 'lib/omni_kassa/response.rb', line 11

def response_code
  @response_code
end

#sealObject

Returns the value of attribute seal


11
12
13
# File 'lib/omni_kassa/response.rb', line 11

def seal
  @seal
end

Instance Method Details

#pending?Boolean


20
21
22
# File 'lib/omni_kassa/response.rb', line 20

def pending?
  response == :pending
end

#responseObject


28
29
30
# File 'lib/omni_kassa/response.rb', line 28

def response
  RESPONSE_CODES[response_code] || :unknown_failure
end

#successful?Boolean


24
25
26
# File 'lib/omni_kassa/response.rb', line 24

def successful?
  response == :success
end