Class: ActiveMerchant::Billing::Integrations::Doku::Notification

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

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

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

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 54

def acknowledge(authcode = nil)
  case type
  when 'verify'
    words == Digest::SHA1.hexdigest("#{gross}#{@options[:credential2]}#{item_id}")
  when 'notify'
    true
  else
    false
  end

end

#complete?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 11

def complete?
  status.present?
end

#currencyObject



32
33
34
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 32

def currency
  'IDR'
end

#grossObject



19
20
21
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 19

def gross
  params['AMOUNT']
end

#item_idObject



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

def item_id
  params['TRANSIDMERCHANT']
end

#statusObject



23
24
25
26
27
28
29
30
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 23

def status
  case params['RESULT']
  when 'Success'
    'Completed'
  when 'Fail'
    'Failed'
  end
end

#transaction_idObject

no unique ID is generated by Doku at any point in the process, so use the same as the original order number.



50
51
52
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 50

def transaction_id
  params['TRANSIDMERCHANT']
end

#typeObject



40
41
42
43
44
45
46
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 40

def type
  if words && params['STOREID']
    'verify'
  elsif status
    'notify'
  end
end

#wordsObject



36
37
38
# File 'lib/active_merchant/billing/integrations/doku/notification.rb', line 36

def words
  params['WORDS']
end