Class: OffsitePayments::Integrations::RealexOffsite::Notification

Inherits:
Notification
  • Object
show all
Includes:
Common
Defined in:
lib/offsite_payments/integrations/realex_offsite.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, #valid_sender?

Constructor Details

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


174
175
176
177
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 174

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

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object

Required Notification methods to define


180
181
182
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 180

def acknowledge(authcode = nil)
  verified?
end

#authcodeObject


247
248
249
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 247

def authcode
  params['AUTHCODE']
end

#avs_address_resultObject


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

def avs_address_result
  params['AVSADDRESSRESULT']
end

#avs_postcode_resultObject


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

def avs_postcode_result
  params['AVSPOSTCODERESULT']
end

#calculated_signatureObject


255
256
257
258
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 255

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

#cavvObject


285
286
287
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 285

def cavv
  params['CAVV']
end

#checkout_idObject


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

def checkout_id
  params['CHECKOUT_ID']
end

#complete?Boolean


214
215
216
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 214

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

#currencyObject

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


206
207
208
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 206

def currency
  params['X-CURRENCY']
end

#cvn_resultObject

Extra data (available from Realex)


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

def cvn_result
  params['CVNRESULT']
end

#eciObject


281
282
283
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 281

def eci
  params['ECI']
end

#grossObject


210
211
212
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 210

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

#item_idObject


184
185
186
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 184

def item_id
  checkout_id
end

#merchant_idObject


223
224
225
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 223

def merchant_id
  params['MERCHANT_ID']
end

#messageObject


239
240
241
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 239

def message
  params['MESSAGE']
end

#order_idObject


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

def order_id
  params['ORDER_ID']
end

#pasrefObject


243
244
245
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 243

def pasref
  params['PASREF']
end

#resultObject


235
236
237
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 235

def result
  params['RESULT']
end

#signatureObject


251
252
253
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 251

def signature
  params['SHA1HASH']
end

#statusObject


196
197
198
199
200
201
202
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 196

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

#test?Boolean


192
193
194
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 192

def test?
  params['X-TEST']
end

#timestampObject

Fields for Realex signature verification


219
220
221
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 219

def timestamp
  params['TIMESTAMP']
end

#transaction_idObject


188
189
190
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 188

def transaction_id
  pasref
end

#verified?Boolean


260
261
262
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 260

def verified?
  signature == calculated_signature
end

#xidObject


289
290
291
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 289

def xid
  params['XID']
end