Module: SaferpayRuby::Configuration

Included in:
SaferpayRuby
Defined in:
lib/saferpay_ruby/configuration.rb

Constant Summary collapse

DEFAULTS =
{
  endpoint: URI('https://test.saferpay.com/api/Payment/v1/PaymentPage/Initialize'),
  user_agent: 'Saferpay Ruby Library',
  terminal_id: "1111111",
  customer_id: "2222222", 
  authentication: 'Basic PVBJXzI0OTYxOF84OTI0Mzc2MDpXZWJvbmlzZUxhYkRvdEMwbQ==',  # Base 64 encoded string of 'username:password'
  success_url: "http://localhost:3010/",
  failure_url: "http://localhost:3010/",
  back_link: nil,
  notify_url: nil,
}.freeze
VALID_CONFIG_KEYS =
DEFAULTS.keys.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Make sure we have the default values set when we get ‘extended’



25
26
27
# File 'lib/saferpay_ruby/configuration.rb', line 25

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



35
36
37
# File 'lib/saferpay_ruby/configuration.rb', line 35

def configure
  yield self
end

#optionsObject



20
21
22
# File 'lib/saferpay_ruby/configuration.rb', line 20

def options
  @options = Hash[ * DEFAULTS.map { |key, val| [key, send(key)] }.flatten ].freeze
end

#resetObject



29
30
31
32
33
# File 'lib/saferpay_ruby/configuration.rb', line 29

def reset
  options.each_pair do |key, val|
    send "#{key}=", DEFAULTS[key]
  end
end