Class: OffsitePayments::Integrations::Realex::Notification

Inherits:
Notification
  • Object
show all
Includes:
Common
Defined in:
lib/offsite_payments/integrations/realex.rb

Constant Summary

Constants included from Common

Common::CURRENCY_SPECIAL_MINOR_UNITS

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods included from Common

#create_signature, #extract_avs_code, #extract_digits, #format_amount, #format_amount_as_float

Methods inherited from Notification

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

Constructor Details

#initialize(post, options = {}) ⇒ Notification


171
172
173
174
# File 'lib/offsite_payments/integrations/realex.rb', line 171

def initialize(post, options={})
  super
  @secret = options[:credential4]
end

Instance Method Details

#authcodeObject


224
225
226
# File 'lib/offsite_payments/integrations/realex.rb', line 224

def authcode
  params['AUTHCODE']
end

#avs_address_resultObject


250
251
252
# File 'lib/offsite_payments/integrations/realex.rb', line 250

def avs_address_result
  params['AVSADDRESSRESULT']
end

#avs_postcode_resultObject


246
247
248
# File 'lib/offsite_payments/integrations/realex.rb', line 246

def avs_postcode_result
  params['AVSPOSTCODERESULT']
end

#calculated_signatureObject


232
233
234
235
# File 'lib/offsite_payments/integrations/realex.rb', line 232

def calculated_signature
  fields = [timestamp, merchant_id, order_id, result, message, pasref, authcode]
  create_signature(fields, @secret)
end

#cavvObject


262
263
264
# File 'lib/offsite_payments/integrations/realex.rb', line 262

def cavv
  params['CAVV']
end

#complete?Boolean


195
196
197
# File 'lib/offsite_payments/integrations/realex.rb', line 195

def complete?
  verified? && status == 'Completed'
end

#currencyObject

Realex does not send back the currency param by default we have sent this additional parameter


187
188
189
# File 'lib/offsite_payments/integrations/realex.rb', line 187

def currency
  params['X-CURRENCY']
end

#cvn_resultObject

Extra data (available from Realex)


242
243
244
# File 'lib/offsite_payments/integrations/realex.rb', line 242

def cvn_result
  params['CVNRESULT']
end

#eciObject


258
259
260
# File 'lib/offsite_payments/integrations/realex.rb', line 258

def eci
  params['ECI']
end

#grossObject


191
192
193
# File 'lib/offsite_payments/integrations/realex.rb', line 191

def gross
  format_amount_as_float(params['AMOUNT'], currency)
end

#merchant_idObject


204
205
206
# File 'lib/offsite_payments/integrations/realex.rb', line 204

def merchant_id
  params['MERCHANT_ID']
end

#messageObject


216
217
218
# File 'lib/offsite_payments/integrations/realex.rb', line 216

def message
  params['MESSAGE']
end

#order_idObject


208
209
210
# File 'lib/offsite_payments/integrations/realex.rb', line 208

def order_id
  params['ORDER_ID']
end

#pasrefObject


220
221
222
# File 'lib/offsite_payments/integrations/realex.rb', line 220

def pasref
  params['PASREF']
end

#resultObject


212
213
214
# File 'lib/offsite_payments/integrations/realex.rb', line 212

def result
  params['RESULT']
end

#signatureObject


228
229
230
# File 'lib/offsite_payments/integrations/realex.rb', line 228

def signature
  params['SHA1HASH']
end

#statusObject

Required Notification methods to define


177
178
179
180
181
182
183
# File 'lib/offsite_payments/integrations/realex.rb', line 177

def status
  if result == '00'
    'Completed'
  else
    'Invalid'
  end
end

#timestampObject

Fields for Realex signature verification


200
201
202
# File 'lib/offsite_payments/integrations/realex.rb', line 200

def timestamp
  params['TIMESTAMP']
end

#verified?Boolean


237
238
239
# File 'lib/offsite_payments/integrations/realex.rb', line 237

def verified?
  signature == calculated_signature
end

#xidObject


266
267
268
# File 'lib/offsite_payments/integrations/realex.rb', line 266

def xid
  params['XID']
end