class FioAPI::Payment

Base class for submit payments and waiting for authorization

Attributes

payments[RW]
request[RW]
response[RW]

Public Class Methods

new(payments) click to toggle source
# File lib/base/payment.rb, line 6
def initialize(payments)
  @payments = [payments].flatten
end

Public Instance Methods

import() click to toggle source
# File lib/base/payment.rb, line 14
def import
  self.request ||= FioAPI::Request.post(path, headers: headers, body: { 'file' => file }, parser: FioAPI::ImportResponseDeserializer)
  self.response ||= self.request.parsed_response
  self.request
end
path() click to toggle source
# File lib/base/payment.rb, line 10
def path
  "/import/?token=#{FioAPI.token}&type=xml"
end
success?() click to toggle source
# File lib/base/payment.rb, line 20
def success?
  response.status.error_code.zero?
end

Private Instance Methods

file() click to toggle source
# File lib/base/payment.rb, line 37
def file
  file = Tempfile.new('fio')
  file.write xml
  file.rewind
  file
end
headers() click to toggle source
# File lib/base/payment.rb, line 26
def headers
  {
    'Content-Type' => 'multipart/form-data',
    'boundary' => '-----------RubyMultipartPost'
  }
end
xml() click to toggle source
# File lib/base/payment.rb, line 33
def xml
  FioAPI::Payments::Xml::Root.new(payments).build
end