Class: OffsitePayments::Integrations::Doku::Notification

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

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #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



155
156
157
158
159
160
161
162
163
164
# File 'lib/offsite_payments/integrations/doku.rb', line 155

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)


112
113
114
# File 'lib/offsite_payments/integrations/doku.rb', line 112

def complete?
  status.present?
end

#currencyObject



133
134
135
# File 'lib/offsite_payments/integrations/doku.rb', line 133

def currency
  'IDR'
end

#grossObject



120
121
122
# File 'lib/offsite_payments/integrations/doku.rb', line 120

def gross
  params['AMOUNT']
end

#item_idObject



116
117
118
# File 'lib/offsite_payments/integrations/doku.rb', line 116

def item_id
  params['TRANSIDMERCHANT']
end

#statusObject



124
125
126
127
128
129
130
131
# File 'lib/offsite_payments/integrations/doku.rb', line 124

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.



151
152
153
# File 'lib/offsite_payments/integrations/doku.rb', line 151

def transaction_id
  params['TRANSIDMERCHANT']
end

#typeObject



141
142
143
144
145
146
147
# File 'lib/offsite_payments/integrations/doku.rb', line 141

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

#wordsObject



137
138
139
# File 'lib/offsite_payments/integrations/doku.rb', line 137

def words
  params['WORDS']
end