Class: OmniKassa::Request

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

Defined Under Namespace

Classes: RequestError

Constant Summary collapse

KEY_VERSION =

OmniKassa requirement, doesn't do anything

1
INTERFACE_VERSION =

OmniKassa requirement, doesn't do anything

'HP_1.0'
REQUIRED =
:merchant_id, :currency_code, :transaction_reference,
:order_id, :amount, :normal_return_url, :key_version,
:automatic_response_url, :customer_language
OPTIONAL =
:payment_mean_brand_list, :customer_language, :expiration_date

Instance Method Summary collapse

Constructor Details

#initializeRequest


17
18
19
20
21
22
23
24
# File 'lib/omni_kassa/request.rb', line 17

def initialize
  self.key_version = KEY_VERSION

  # Load default settings into the request
  OmniKassa.request_settings.each do |key, value|
    send key.to_s + '=', value
  end
end

Instance Method Details

#performObject


33
34
35
# File 'lib/omni_kassa/request.rb', line 33

def perform
  HTTParty.post(OmniKassa.url, query: query).body
end

#queryObject


41
42
43
44
45
46
47
# File 'lib/omni_kassa/request.rb', line 41

def query
  {
    InterfaceVersion: INTERFACE_VERSION,
    Data: data,
    Seal: seal
  }
end

#transaction_referenceObject


37
38
39
# File 'lib/omni_kassa/request.rb', line 37

def transaction_reference
  @transaction_reference.call(order_id)
end

#valid?Boolean


26
27
28
29
30
31
# File 'lib/omni_kassa/request.rb', line 26

def valid?
  REQUIRED.map do |attr|
    value = send attr
    return false if value.nil?
  end
end