class OffsitePayments::Integrations::RealexOffsite::Helper

Public Class Methods

new(order, account, options = {}) click to toggle source
Calls superclass method
# File lib/offsite_payments/integrations/realex_offsite.rb, line 103
def initialize(order, account, options = {})
  @timestamp   = Time.now.strftime('%Y%m%d%H%M%S')
  @currency    = options[:currency]
  @merchant_id = account
  @sub_account = options[:credential2]
  @secret      = options[:credential3]
  super
  # Credentials
  add_field 'MERCHANT_ID', @merchant_id
  add_field 'ACCOUNT', @sub_account
  # Defaults
  add_field 'AUTO_SETTLE_FLAG', '1'
  add_field 'RETURN_TSS', '1'
  add_field 'TIMESTAMP', @timestamp
  # Realex does not send back CURRENCY param in response
  # however it does echo any other param so we send it twice.
  add_field 'X-CURRENCY', @currency
  add_field 'X-TEST', @test.to_s
  add_field 'ORDER_ID', "#{order}#{@timestamp.to_i}"
end

Public Instance Methods

amount=(amount) click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 128
def amount=(amount)
  add_field 'AMOUNT', format_amount(amount, @currency)
end
billing_address(params={}) click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 132
def billing_address(params={})
  add_field(mappings[:billing_address][:zip], extract_avs_code(params))
  add_field(mappings[:billing_address][:country], lookup_country_code(params[:country]))
end
form_fields() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 124
def form_fields
  sign_fields
end
generate_signature() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 146
def generate_signature
  fields_to_sign = []
  ['TIMESTAMP', 'MERCHANT_ID', 'ORDER_ID', 'AMOUNT', 'CURRENCY'].each do |field|
    fields_to_sign << @fields[field]
  end

  create_signature(fields_to_sign, @secret)
end
shipping_address(params={}) click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 137
def shipping_address(params={})
  add_field(mappings[:shipping_address][:zip], extract_avs_code(params))
  add_field(mappings[:shipping_address][:country], lookup_country_code(params[:country]))
end
sign_fields() click to toggle source
# File lib/offsite_payments/integrations/realex_offsite.rb, line 142
def sign_fields
  @fields.merge!('SHA1HASH' => generate_signature)
end