Class: OffsitePayments::Integrations::DirecPay::Notification

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

Constant Summary collapse

RESPONSE_PARAMS =
['DirecPay Reference ID', 'Flag', 'Country', 'Currency', 'Other Details', 'Merchant Order No', 'Amount']

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

This class inherits a constructor from OffsitePayments::Notification

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object



227
228
229
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 227

def acknowledge(authcode = nil)
  true
end

#complete?Boolean

Returns:

  • (Boolean)


231
232
233
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 231

def complete?
  status == 'Completed' || status == 'Pending'
end

#countryObject



265
266
267
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 265

def country
  params['Country']
end

#currencyObject



261
262
263
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 261

def currency
  params['Currency']
end

#grossObject

the money amount we received in X.2 decimal



257
258
259
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 257

def gross
  params['Amount']
end

#item_idObject



248
249
250
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 248

def item_id
  params['Merchant Order No']
end

#other_detailsObject



269
270
271
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 269

def other_details
  params['Other Details']
end

#parse(post) ⇒ Object

Take the posted data and move the relevant data into a hash



278
279
280
281
282
283
284
285
286
287
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 278

def parse(post)
  super

  values = params['responseparams'].to_s.split('|')
  response_params = values.size == 3 ? ['DirecPay Reference ID', 'Flag', 'Error message'] : RESPONSE_PARAMS
  response_params.each_with_index do |name, index|
    params[name] = values[index]
  end
  params
end

#statusObject



235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 235

def status
  case params['Flag']
  when 'SUCCESS'
    'Completed'
  when 'PENDING'
    'Pending'
  when 'FAIL'
    'Failed'
  else
    'Error'
  end
end

#test?Boolean

Returns:

  • (Boolean)


273
274
275
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 273

def test?
  false
end

#transaction_idObject



252
253
254
# File 'lib/offsite_payments/integrations/direc_pay.rb', line 252

def transaction_id
  params['DirecPay Reference ID']
end