Module: Inpay::Config

Defined in:
lib/inpay/config.rb

Class Method Summary collapse

Class Method Details

.flow_urlObject



11
12
13
# File 'lib/inpay/config.rb', line 11

def self.flow_url
  flow_urls[mode]
end

.flow_urlsObject

flow urls



5
6
7
8
9
10
# File 'lib/inpay/config.rb', line 5

def self.flow_urls
  Thread.current[:flow_urls] ||= {
    :test       => "https://test-secure.inpay.com/",
    :production => "https://secure.inpay.com/"
  }
end

.keys_for(action) ⇒ Object

fields



38
39
40
41
42
43
44
45
# File 'lib/inpay/config.rb', line 38

def self.keys_for action
  case action.to_sym
  when :create_invoice
    %w(merchant_id order_id amount currency order_text flow_layout secret_key)
  when :postback
    %w(order_id invoice_reference invoice_amount invoice_currency invoice_created_at invoice_status secret_key)
  end
end

.modeObject



25
26
27
# File 'lib/inpay/config.rb', line 25

def self.mode
  Thread.current[:mode] ||= :test
end

.mode=(new_mode) ⇒ Object

current operation mode



16
17
18
19
20
21
22
23
24
# File 'lib/inpay/config.rb', line 16

def self.mode= new_mode
  new_mode = new_mode.to_sym
  
  unless [:test, :production].include?(new_mode)
    raise ArgumentError.new("Inpay::Config.mode should be either :test or :production (you tried to set it as :#{ new_mode })")
  end
  
  Thread.current[:mode] = new_mode
end

.server_ipsObject



33
34
35
# File 'lib/inpay/config.rb', line 33

def self.server_ips
  Thread.current[:server_ips] ||= []
end

.server_ips=(ips) ⇒ Object

inpay server ips



30
31
32
# File 'lib/inpay/config.rb', line 30

def self.server_ips= ips
  Thread.current[:server_ips] = [ips].flatten
end