class OffsitePayments::Integrations::Klarna::Notification

Public Class Methods

new(post, options = {}) click to toggle source
Calls superclass method OffsitePayments::Notification::new
# File lib/offsite_payments/integrations/klarna.rb, line 182
def initialize(post, options = {})
  super
  @shared_secret = @options[:credential2]
end

Public Instance Methods

acknowledge(authcode = nil) click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 233
def acknowledge(authcode = nil)
  Verifier.new(@options[:authorization_header], @raw, @shared_secret).verify
end
complete?() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 187
def complete?
  status == 'Completed'
end
currency() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 211
def currency
  params["purchase_currency"].upcase
end
gross() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 215
def gross
  amount = Float(gross_cents) / 100
  sprintf("%.2f", amount)
end
gross_cents() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 220
def gross_cents
  params["order_amount"]
end
item_id() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 191
def item_id
  order
end
payer_email() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 203
def payer_email
  params["billing_address"]["email"]
end
received_at() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 199
def received_at
  params["completed_at"]
end
receiver_email() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 207
def receiver_email
  params["shipping_address"]["email"]
end
status() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 224
def status
  case params['status']
  when 'checkout_complete'
    'Completed'
  else
    params['status']
  end
end
transaction_id() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 195
def transaction_id
  params["reference"]
end

Private Instance Methods

order() click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 239
def order
  query = Rack::Utils.parse_nested_query(@options[:query_string])
  query["order"]
end
parse(post) click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 244
def parse(post)
  @raw = post.to_s
  @params = JSON.parse(post)
end