Class: ActiveMerchant::Billing::Integrations::Klarna::Notification
- Inherits:
-
Notification
- Object
- Notification
- ActiveMerchant::Billing::Integrations::Klarna::Notification
show all
- Defined in:
- lib/active_merchant/billing/integrations/klarna/notification.rb
Defined Under Namespace
Classes: Verifier
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#amount, #empty!, #test?, #valid_sender?
Constructor Details
#initialize(post, options = {}) ⇒ Notification
Returns a new instance of Notification.
9
10
11
12
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 9
def initialize(post, options = {})
super
@shared_secret = @options[:credential2]
end
|
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
60
61
62
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 60
def acknowledge(authcode = nil)
Verifier.new(@options[:authorization_header], @raw, @shared_secret).verify
end
|
#complete? ⇒ Boolean
14
15
16
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 14
def complete?
status == 'Completed'
end
|
#currency ⇒ Object
38
39
40
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 38
def currency
params["purchase_currency"].upcase
end
|
#gross ⇒ Object
42
43
44
45
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 42
def gross
amount = Float(gross_cents) / 100
sprintf("%.2f", amount)
end
|
#gross_cents ⇒ Object
47
48
49
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 47
def gross_cents
params["cart"]["total_price_including_tax"]
end
|
#item_id ⇒ Object
18
19
20
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 18
def item_id
order
end
|
#payer_email ⇒ Object
30
31
32
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 30
def payer_email
params["billing_address"]["email"]
end
|
#received_at ⇒ Object
26
27
28
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 26
def received_at
params["completed_at"]
end
|
#receiver_email ⇒ Object
34
35
36
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 34
def receiver_email
params["shipping_address"]["email"]
end
|
#status ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 51
def status
case params['status']
when 'checkout_complete'
'Completed'
else
params['status']
end
end
|
#transaction_id ⇒ Object
22
23
24
|
# File 'lib/active_merchant/billing/integrations/klarna/notification.rb', line 22
def transaction_id
params["reference"]
end
|