Module: VtwebJson::Config

Included in:
Client
Defined in:
lib/vtweb_json/config.rb

Constant Summary collapse

VTWEB_SERVER =

Server

"https://vtweb.veritrans.co.id"
GET_TOKENS_URL =
"/v1/tokens.json"
REDIRECTION_URL =
"/v1/payments.json"
BILLING_DIFFERENT_WITH_SHIPPING =

Params Config

'0'

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vtweb_json/config.rb', line 15

def Config.included(mod)
  class <<self
    template = {
      'merchant_id' => nil,
      'merchant_hash_key' => nil,
      'finish_payment_return_url' => nil,
      'unfinish_payment_return_url' => nil,
      'error_payment_return_url' => nil,
      'vtweb_server' => nil
    }
    
    @@config_env = ::Object.const_defined?(:Rails) ? Rails.env : "development"
    @@config = File.exists?("./config/vtweb.yml") ? YAML.load_file("./config/vtweb.yml") : {}
    @@config['development'] = {} if !@@config['development']
    @@config['production' ] = {} if !@@config['production']
    @@config['development'] = template.clone.merge(@@config['development'])
    @@config['production']  = template.clone.merge(@@config['production'])
  end

  mod.instance_eval <<CODE

  def self.config_env=(env)
    @@config_env = env
  end

  def self.config
    @@config[@@config_env]
  end 
CODE

end