Class: ActiveMerchant::Billing::Integrations::Verkkomaksut::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/verkkomaksut/notification.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #gross, #gross_cents, #initialize, #valid_sender?

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::Integrations::Notification

Instance Method Details

#acknowledge(authcode) ⇒ Object

Acknowldges the payment. If the authcodes match, returns true.



44
45
46
47
# File 'lib/active_merchant/billing/integrations/verkkomaksut/notification.rb', line 44

def acknowledge(authcode)
  return_authcode = [params["ORDER_NUMBER"], params["TIMESTAMP"], params["PAID"], params["METHOD"], authcode].join("|")
  Digest::MD5.hexdigest(return_authcode).upcase == params["RETURN_AUTHCODE"]
end

#complete?Boolean

Is the payment complete or not. Verkkomaksut only has two statuses: random string or 0000000000 which means pending

Returns:

  • (Boolean)


10
11
12
# File 'lib/active_merchant/billing/integrations/verkkomaksut/notification.rb', line 10

def complete?
  params['PAID'] != "0000000000"
end

#methodObject

Payment method used



20
21
22
# File 'lib/active_merchant/billing/integrations/verkkomaksut/notification.rb', line 20

def method
  params['METHOD']
end

#order_idObject

Order id



15
16
17
# File 'lib/active_merchant/billing/integrations/verkkomaksut/notification.rb', line 15

def order_id
  params['ORDER_NUMBER']
end

#received_atObject

When was this payment received by the client.



25
26
27
# File 'lib/active_merchant/billing/integrations/verkkomaksut/notification.rb', line 25

def received_at
  params['TIMESTAMP']
end

#security_keyObject

Security key got from Verkkomaksut



30
31
32
# File 'lib/active_merchant/billing/integrations/verkkomaksut/notification.rb', line 30

def security_key
  params['RETURN_AUTHCODE']
end

#statusObject

Another way of asking the payment status



35
36
37
38
39
40
41
# File 'lib/active_merchant/billing/integrations/verkkomaksut/notification.rb', line 35

def status
  if complete?
    "PAID"
  else
    "PENDING"
  end
end