Class: OffsitePayments::Integrations::Klarna::Notification
Defined Under Namespace
Classes: Verifier
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#amount, #empty!, #iso_currency, #test?, #valid_sender?
Constructor Details
#initialize(post, options = {}) ⇒ Notification
Returns a new instance of Notification.
182
183
184
185
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 182
def initialize(post, options = {})
super
@shared_secret = @options[:credential2]
end
|
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
233
234
235
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 233
def acknowledge(authcode = nil)
Verifier.new(@options[:authorization_header], @raw, @shared_secret).verify
end
|
#complete? ⇒ Boolean
187
188
189
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 187
def complete?
status == 'Completed'
end
|
#currency ⇒ Object
211
212
213
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 211
def currency
params["purchase_currency"].upcase
end
|
#gross ⇒ Object
215
216
217
218
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 215
def gross
amount = Float(gross_cents) / 100
sprintf("%.2f", amount)
end
|
#gross_cents ⇒ Object
220
221
222
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 220
def gross_cents
params["order_amount"]
end
|
#item_id ⇒ Object
191
192
193
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 191
def item_id
order
end
|
#payer_email ⇒ Object
203
204
205
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 203
def payer_email
params["billing_address"]["email"]
end
|
#received_at ⇒ Object
199
200
201
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 199
def received_at
params["completed_at"]
end
|
#receiver_email ⇒ Object
207
208
209
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 207
def receiver_email
params["shipping_address"]["email"]
end
|
#status ⇒ Object
224
225
226
227
228
229
230
231
|
# 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 ⇒ Object
195
196
197
|
# File 'lib/offsite_payments/integrations/klarna.rb', line 195
def transaction_id
params["reference"]
end
|