Class: Cardflex::ThreeStepGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/cardflex/three_step_gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway) ⇒ ThreeStepGateway

Returns a new instance of ThreeStepGateway.



5
6
7
8
# File 'lib/cardflex/three_step_gateway.rb', line 5

def initialize(gateway)
  @gateway = gateway
  @config = gateway.config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/cardflex/three_step_gateway.rb', line 3

def config
  @config
end

Instance Method Details

#_handle_intermediate_response(res) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/cardflex/three_step_gateway.rb', line 34

def _handle_intermediate_response(res)
  if res[:response][:result] == '1'
    SuccessResponse.new(:three_step => ThreeStep.new(@gateway, res[:response]))
  else
    ErrorResponse.new(@gateway, res[:response])
  end
end

#_handle_response(res) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/cardflex/three_step_gateway.rb', line 26

def _handle_response(res)
  if res[:response][:result] == '1'
    SuccessResponse.new(:transaction => Transaction.new(@gateway, res[:response]))
  else
    ErrorResponse.new(@gateway, res[:response])
  end
end

#complete(token_id) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
24
# File 'lib/cardflex/three_step_gateway.rb', line 19

def complete(token_id)
  raise ArgumentError, 'you must provide a token_id' unless token_id

  res = @config.http.post(:complete_action => { :token_id => token_id })
  _handle_response(res)
end

#get_form_url(attributes) ⇒ Object

Three Step API

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/cardflex/three_step_gateway.rb', line 11

def get_form_url(attributes)
  root = attributes.keys[0]
  raise ArgumentError, 'missing :redirect_url' unless attributes[root][:redirect_url]

  res = @config.http.post(attributes)
  _handle_intermediate_response(res)
end