Module: Omnipay::ActionController::Helpers

Defined in:
lib/omnipay/railtie.rb

Instance Method Summary collapse

Instance Method Details

#redirect_to_payment(uid, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/omnipay/railtie.rb', line 6

def redirect_to_payment(uid, opts = {})
  base_uri = "#{request.scheme}://#{request.host_with_port}"
  gateway = Omnipay.gateways.find(uid)
  if gateway
    rack_response = gateway.payment_redirection(opts.merge(:base_uri => base_uri))

    self.response_body = rack_response.body
    self.status = rack_response.status
    self.response.headers = rack_response.headers

    return true
  else
    raise ArgumentError.new("Omnipay gateway '#{uid}' not found")
  end
end