class OffsitePayments::Integrations::Gestpay::Notification

Public Instance Methods

acknowledge(authcode = nil) click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 163
def acknowledge(authcode = nil)
  true
end
complete?() click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 126
def complete?
  status == 'Completed'
end
currency() click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 144
def currency
  # Ruby 1.9 compat
  method = CURRENCY_MAPPING.respond_to?(:key) ? :key : :index
  CURRENCY_MAPPING.send(method, params['PAY1_UICCODE'])
end
gross() click to toggle source

the money amount we received in X.2 decimal.

# File lib/offsite_payments/integrations/gestpay.rb, line 140
def gross
  params['PAY1_AMOUNT']
end
item_id() click to toggle source

The important param

# File lib/offsite_payments/integrations/gestpay.rb, line 131
def item_id
  params['PAY1_SHOPTRANSACTIONID']
end
status() click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 154
def status
  case params['PAY1_TRANSACTIONRESULT']
  when 'OK'
    'Completed'
  else
    'Failed'
  end
end
test?() click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 150
def test?
  false
end
transaction_id() click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 135
def transaction_id
  params['PAY1_BANKTRANSACTIONID']
end

Private Instance Methods

decrypt_data(shop_login, encrypted_string) click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 188
def decrypt_data(shop_login, encrypted_string)
  response = ssl_get(Gestpay.service_url, decryption_query_string(shop_login, encrypted_string))
  encoded_response = parse_response(response)
  parse_delimited_string(encoded_response, DELIMITER, true)
rescue GestpayEncryptionResponseError
  { 'PAY1_TRANSACTIONRESULT' => 'Error' }
end
decryption_query_string(shop_login, encrypted_string) click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 196
def decryption_query_string(shop_login, encrypted_string)
  "#{DECRYPTION_PATH}?a=" + CGI.escape(shop_login) + "&b=" + encrypted_string + "&c=" + CGI.escape(VERSION)
end
parse(query_string) click to toggle source

Take the posted data and move the relevant data into a hash

# File lib/offsite_payments/integrations/gestpay.rb, line 169
def parse(query_string)
  @raw = query_string

  return if query_string.blank?
  encrypted_params = parse_delimited_string(query_string)

  return if encrypted_params['a'].blank? || encrypted_params['b'].blank?
  @params = decrypt_data(encrypted_params['a'], encrypted_params['b'])
end
parse_delimited_string(string, delimiter = '&', unencode_cgi = false) click to toggle source
# File lib/offsite_payments/integrations/gestpay.rb, line 179
def parse_delimited_string(string, delimiter = '&', unencode_cgi = false)
  result = {}
  for line in string.split(delimiter)
    key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
    result[key] = unencode_cgi ? CGI.unescape(value) : value
  end
  result
end