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::CANADIAN_STATES, Common::COUNTRY_PHONE_NUMBERS, Common::CURRENCY_SPECIAL_MINOR_UNITS, Common::US_STATES

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods included from Common

#add_field, #adjust_phone_number_length, #copy_billing_address, #create_signature, #extract_address_match_indicator, #extract_avs_code, #extract_digits, #format_amount, #format_amount_as_float, #format_phone_number, #get_message, #get_pattern, #lookup_state_code, #validate

Methods inherited from Notification

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

Constructor Details

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

Returns a new instance of Notification.



726
727
728
729
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 726

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

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object

Required Notification methods to define



732
733
734
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 732

def acknowledge(authcode = nil)
  verified?
end

#authcodeObject



795
796
797
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 795

def authcode
  params['AUTHCODE']
end

#avs_address_resultObject



821
822
823
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 821

def avs_address_result
  params['AVSADDRESSRESULT']
end

#avs_postcode_resultObject



817
818
819
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 817

def avs_postcode_result
  params['AVSPOSTCODERESULT']
end

#calculated_signatureObject



803
804
805
806
# 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

#cavvObject



833
834
835
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 833

def cavv
  params['CAVV']
end

#checkout_idObject



779
780
781
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 779

def checkout_id
  params['CHECKOUT_ID']
end

#complete?Boolean

Returns:

  • (Boolean)


766
767
768
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 766

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

#currencyObject

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



758
759
760
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 758

def currency
  params['X-CURRENCY']
end

#cvn_resultObject

Extra data (available from Realex)



813
814
815
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 813

def cvn_result
  params['CVNRESULT']
end

#eciObject



829
830
831
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 829

def eci
  params['ECI']
end

#grossObject



762
763
764
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 762

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

#item_idObject



736
737
738
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 736

def item_id
  checkout_id
end

#merchant_idObject



775
776
777
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 775

def merchant_id
  params['MERCHANT_ID']
end

#messageObject



791
792
793
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 791

def message
  params['MESSAGE']
end

#order_idObject



783
784
785
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 783

def order_id
  params['ORDER_ID']
end

#pasrefObject



825
826
827
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 825

def pasref
  params['PASREF']
end

#resultObject



787
788
789
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 787

def result
  params['RESULT']
end

#signatureObject



799
800
801
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 799

def signature
  params['SHA1HASH']
end

#statusObject



748
749
750
751
752
753
754
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 748

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

#test?Boolean

Returns:

  • (Boolean)


744
745
746
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 744

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

#timestampObject

Fields for Realex signature verification



771
772
773
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 771

def timestamp
  params['TIMESTAMP']
end

#transaction_idObject



740
741
742
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 740

def transaction_id
  pasref
end

#verified?Boolean

Returns:

  • (Boolean)


808
809
810
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 808

def verified?
  signature == calculated_signature
end

#xidObject



837
838
839
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 837

def xid
  params['XID']
end