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 198 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 249 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 203 def complete? status == 'Completed' end
currency()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 227 def currency params["purchase_currency"].upcase end
gross()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 231 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 236 def gross_cents params["cart"]["total_price_including_tax"] end
item_id()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 207 def item_id order end
payer_email()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 219 def payer_email params["billing_address"]["email"] end
received_at()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 215 def received_at params["completed_at"] end
receiver_email()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 223 def receiver_email params["shipping_address"]["email"] end
status()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 240 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 211 def transaction_id params["reference"] end
Private Instance Methods
order()
click to toggle source
# File lib/offsite_payments/integrations/klarna.rb, line 255 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 260 def parse(post) @raw = post.to_s @params = JSON.parse(post) end