Class: OffsitePayments::Integrations::Latipay::Notification

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

Instance Method Summary collapse

Constructor Details

#initialize(params, credentials = {}) ⇒ Notification

Returns a new instance of Notification.



205
206
207
208
# File 'lib/offsite_payments/integrations/latipay.rb', line 205

def initialize(params, credentials = {})
  token = params.fetch('Token') { params.fetch('token') }
  @params = QueryInterface.new(credentials.fetch(:api_key), credentials.fetch(:user_id)).call(token)
end

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object

Acknowledge the transaction to Latipay. This method has to be called after a new apc arrives. Latipay will verify that all the information we received are correct and will return a ok or a fail.

Example:

def ipn
  notify = LatipayNotification.new(request.raw_post)

  if notify.acknowledge
    ... process order ... if notify.complete?
  else
    ... log possible hacking attempt ...
  end


241
242
243
# File 'lib/offsite_payments/integrations/latipay.rb', line 241

def acknowledge(authcode = nil)
  true
end

#complete?Boolean

Returns:

  • (Boolean)


210
211
212
# File 'lib/offsite_payments/integrations/latipay.rb', line 210

def complete?
  params['status'] == 'paid'
end

#grossObject

the money amount we received in X.2 decimal.



219
220
221
# File 'lib/offsite_payments/integrations/latipay.rb', line 219

def gross
  params['amount']
end

#statusObject



223
224
225
# File 'lib/offsite_payments/integrations/latipay.rb', line 223

def status
  params['status']
end

#transaction_idObject



214
215
216
# File 'lib/offsite_payments/integrations/latipay.rb', line 214

def transaction_id
  params['order_id']
end