Class: OffsitePayments::Integrations::Verkkomaksut::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/verkkomaksut.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object

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



128
129
130
131
# File 'lib/offsite_payments/integrations/verkkomaksut.rb', line 128

def acknowledge(authcode = nil)
  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)


94
95
96
# File 'lib/offsite_payments/integrations/verkkomaksut.rb', line 94

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

#methodObject

Payment method used



104
105
106
# File 'lib/offsite_payments/integrations/verkkomaksut.rb', line 104

def method
  params['METHOD']
end

#order_idObject

Order id



99
100
101
# File 'lib/offsite_payments/integrations/verkkomaksut.rb', line 99

def order_id
  params['ORDER_NUMBER']
end

#received_atObject

When was this payment received by the client.



109
110
111
# File 'lib/offsite_payments/integrations/verkkomaksut.rb', line 109

def received_at
  params['TIMESTAMP']
end

#security_keyObject

Security key got from Verkkomaksut



114
115
116
# File 'lib/offsite_payments/integrations/verkkomaksut.rb', line 114

def security_key
  params['RETURN_AUTHCODE']
end

#statusObject

Another way of asking the payment status



119
120
121
122
123
124
125
# File 'lib/offsite_payments/integrations/verkkomaksut.rb', line 119

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