Class: Tinkoff::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/tinkoff/request.rb

Constant Summary collapse

BASE_URL =
'https://securepay.tinkoff.ru/v2/'

Instance Method Summary collapse

Constructor Details

#initialize(path, params = {}) ⇒ Request

Returns a new instance of Request.



5
6
7
8
# File 'lib/tinkoff/request.rb', line 5

def initialize(path, params = {})
  @url = BASE_URL + path
  @params = params
end

Instance Method Details

#performObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tinkoff/request.rb', line 10

def perform
  prepare_params

  response = HTTParty.post(
    @url,
    body: @params.to_json,
    # debug_output: $stdout,
    :headers => {'Content-Type' => 'application/json'}
  )

  Tinkoff::Payment.new(response.parsed_response)
end