Class: ActiveMerchant::Billing::Integrations::DirecPay::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/direc_pay/notification.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, #valid_sender?

Constructor Details

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

Instance Method Details

#acknowledgeObject



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

def acknowledge
  true
end

#complete?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 14

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

#countryObject



48
49
50
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 48

def country
  params['Country']
end

#currencyObject



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

def currency
  params['Currency']
end

#grossObject

the money amount we received in X.2 decimal



40
41
42
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 40

def gross
  params['Amount']
end

#item_idObject



31
32
33
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 31

def item_id
  params['Merchant Order No']
end

#other_detailsObject



52
53
54
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 52

def other_details
  params['Other Details']
end

#parse(post) ⇒ Object

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



61
62
63
64
65
66
67
68
69
70
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 61

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



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 18

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

#test?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 56

def test?
  false
end

#transaction_idObject



35
36
37
# File 'lib/active_merchant/billing/integrations/direc_pay/notification.rb', line 35

def transaction_id
  params['DirecPay Reference ID']
end