class OffsitePayments::Integrations::RealexOffsite::Notification

Public Class Methods

new(post, options={}) click to toggle source
Calls superclass method OffsitePayments::Notification::new
# File lib/offsite_payments/integrations/realex_offsite.rb, line 174
def initialize(post, options={})
  super
  @secret = options[:credential3]
end

Public Instance Methods

acknowledge(authcode = nil) click to toggle source

Required Notification methods to define

# File lib/offsite_payments/integrations/realex_offsite.rb, line 180
def acknowledge(authcode = nil)
  verified?
end
authcode() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 247
def authcode
  params['AUTHCODE']
end
avs_address_result() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 273
def avs_address_result
  params['AVSADDRESSRESULT']
end
avs_postcode_result() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 269
def avs_postcode_result
  params['AVSPOSTCODERESULT']
end
calculated_signature() click to toggle source
# 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
cavv() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 285
def cavv
  params['CAVV']
end
checkout_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 227
def checkout_id
  params['CHECKOUT_ID']
end
complete?() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 214
def complete?
  verified? && status == 'Completed'
end
currency() click to toggle source

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

# File lib/offsite_payments/integrations/realex_offsite.rb, line 206
def currency
  params['X-CURRENCY']
end
cvn_result() click to toggle source

Extra data (available from Realex)

# File lib/offsite_payments/integrations/realex_offsite.rb, line 265
def cvn_result
  params['CVNRESULT']
end
eci() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 281
def eci
  params['ECI']
end
gross() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 210
def gross
  format_amount_as_float(params['AMOUNT'], currency)
end
item_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 184
def item_id
  checkout_id
end
merchant_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 223
def merchant_id
  params['MERCHANT_ID']
end
message() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 239
def message
  params['MESSAGE']
end
order_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 231
def order_id
  params['ORDER_ID']
end
pasref() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 243
def pasref
  params['PASREF']
end
result() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 235
def result
  params['RESULT']
end
signature() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 251
def signature
  params['SHA1HASH']
end
status() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 196
def status
  if result == '00'
    'Completed'
  else
    'Invalid'
  end
end
test?() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 192
def test?
  params['X-TEST']
end
timestamp() click to toggle source

Fields for Realex signature verification

# File lib/offsite_payments/integrations/realex_offsite.rb, line 219
def timestamp
  params['TIMESTAMP']
end
transaction_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 188
def transaction_id
  pasref
end
verified?() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 260
def verified?
  signature == calculated_signature
end
xid() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 289
def xid
  params['XID']
end