Module: Payzen

Defined in:
lib/payzen.rb,
lib/payzen/config.rb,
lib/payzen/version.rb,
lib/payzen/payment_response.rb

Defined Under Namespace

Classes: Config, PaymentResponse

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.setup {|config| ... } ⇒ Object

Yields:

  • (config)


12
13
14
15
# File 'lib/payzen.rb', line 12

def self.setup
  self.config ||= Config.new
  yield config
end

.signature(params) ⇒ Object



24
25
26
27
28
# File 'lib/payzen.rb', line 24

def self.signature(params)
  string_to_hash = (params.select { |k, v| v && k.to_s.start_with?('vads_') }.
      sort_by(&:first).map(&:second) << config.certificate).join('+')
  Digest::SHA1.hexdigest(string_to_hash)
end

.transaction(params) ⇒ Object



17
18
19
20
21
22
# File 'lib/payzen.rb', line 17

def self.transaction(params)
  params             = config.vads_params.merge(params)
  signature          = signature(params)
  params[:signature] = signature
  params
end