class OffsitePayments::Integrations::Klarna::Notification::Verifier

Attributes

digest[R]
header[R]
payload[R]
shared_secret[R]

Public Class Methods

new(header, payload, shared_secret) click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 251
def initialize(header, payload, shared_secret)
  @header, @payload, @shared_secret = header, payload, shared_secret

  @digest = extract_digest
end

Public Instance Methods

verify() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 257
def verify
  digest_matches?
end

Private Instance Methods

digest_matches?() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 268
def digest_matches?
  Klarna.digest(payload, shared_secret) == digest
end
extract_digest() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 263
def extract_digest
  match = header.match(/^Klarna (?<digest>.+)$/)
  match && match[:digest]
end