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 726
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 732
def acknowledge(authcode = nil)
  verified?
end
authcode() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 795
def authcode
  params['AUTHCODE']
end
avs_address_result() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 821
def avs_address_result
  params['AVSADDRESSRESULT']
end
avs_postcode_result() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 817
def avs_postcode_result
  params['AVSPOSTCODERESULT']
end
calculated_signature() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 803
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 833
def cavv
  params['CAVV']
end
checkout_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 779
def checkout_id
  params['CHECKOUT_ID']
end
complete?() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 766
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 758
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 813
def cvn_result
  params['CVNRESULT']
end
eci() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 829
def eci
  params['ECI']
end
gross() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 762
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 736
def item_id
  checkout_id
end
merchant_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 775
def merchant_id
  params['MERCHANT_ID']
end
message() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 791
def message
  params['MESSAGE']
end
order_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 783
def order_id
  params['ORDER_ID']
end
pasref() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 825
def pasref
  params['PASREF']
end
result() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 787
def result
  params['RESULT']
end
signature() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 799
def signature
  params['SHA1HASH']
end
status() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 748
def status
  if result == '00'
    'Completed'
  else
    'Invalid'
  end
end
test?() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 744
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 771
def timestamp
  params['TIMESTAMP']
end
transaction_id() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 740
def transaction_id
  pasref
end
verified?() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 808
def verified?
  signature == calculated_signature
end
xid() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 837
def xid
  params['XID']
end