Class: ZaiPayment::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/zai_payment/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
11
12
13
14
15
16
# File 'lib/zai_payment/config.rb', line 8

def initialize
  @environment  = :prelive # or :production
  @client_id    = nil
  @client_secret = nil
  @scope = nil
  @timeout = 30      # General timeout - increased from 10 to 30 seconds
  @open_timeout = 10 # Connection open timeout
  @read_timeout = 30 # Read timeout - new separate configuration
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



5
6
7
# File 'lib/zai_payment/config.rb', line 5

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



5
6
7
# File 'lib/zai_payment/config.rb', line 5

def client_secret
  @client_secret
end

#environmentObject

Returns the value of attribute environment.



5
6
7
# File 'lib/zai_payment/config.rb', line 5

def environment
  @environment
end

#open_timeoutObject

Returns the value of attribute open_timeout.



5
6
7
# File 'lib/zai_payment/config.rb', line 5

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



5
6
7
# File 'lib/zai_payment/config.rb', line 5

def read_timeout
  @read_timeout
end

#scopeObject

Returns the value of attribute scope.



5
6
7
# File 'lib/zai_payment/config.rb', line 5

def scope
  @scope
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/zai_payment/config.rb', line 5

def timeout
  @timeout
end

Instance Method Details

#endpointsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/zai_payment/config.rb', line 24

def endpoints
  case environment.to_sym
  when :prelive
    {
      core_base: 'https://test.api.promisepay.com',
      va_base: 'https://sandbox.au-0000.api.assemblypay.com',
      auth_base: 'https://au-0000.sandbox.auth.assemblypay.com'
    }
  when :production
    {
      core_base: 'https://secure.api.promisepay.com',
      va_base: 'https://au-0000.api.assemblypay.com',
      auth_base: 'https://au-0000.auth.assemblypay.com'
    }
  else
    raise "Unknown environment: #{environment}"
  end
end

#validate!Object



18
19
20
21
22
# File 'lib/zai_payment/config.rb', line 18

def validate!
  raise Errors::ConfigurationError, 'client_id is required' if client_id.nil? || client_id.empty?
  raise Errors::ConfigurationError, 'client_secret is required' if client_secret.nil? || client_secret.empty?
  raise Errors::ConfigurationError, 'scope is required' if scope.nil? || scope.empty?
end