Class: Omnipay::RequestPhase

Inherits:
Object
  • Object
show all
Defined in:
lib/omnipay/request_phase.rb

Overview

Class responsible for formatting the redirection in the request phase

Instance Method Summary collapse

Constructor Details

#initialize(request, adapter) ⇒ RequestPhase

Parameters:

  • request (Rack::Request)

    The request corresponding to the redirection from the payment gateway to the application.

  • adapter (Adapter)

    The adapter instance of the gateway having catched this request



9
10
11
12
# File 'lib/omnipay/request_phase.rb', line 9

def initialize(request, adapter)
  @request = request
  @adapter = adapter
end

Instance Method Details

#responseRack::Response

Returns the rack response for redirecting the user to the payment page. Can be a 302 redirect if a GET redirection, or an AutosubmittedForm for POST redirections

Returns:

  • (Rack::Response)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/omnipay/request_phase.rb', line 16

def response
  method, url, params, transaction_id = @adapter.request_phase(amount, adapter_params)

  context = store_context!

  signature = Signer.new(transaction_id, amount, context).signature
  store_signature!(signature)

  if method == 'GET'
    get_redirect_response(url, params)
  elsif method == 'POST'
    post_redirect_response(url, params)
  else
    raise TypeError.new('request_phase returned http method must be \'GET\' or \'POST\'')
  end
end