Module: MerbMerchant::Billing::Integrations::Gestpay::Common

Included in:
Helper, Notification
Defined in:
lib/merb_merchant/billing/integrations/gestpay/common.rb

Constant Summary collapse

VERSION =
"2.0"
ENCRYPTION_PATH =
"/CryptHTTPS/Encrypt.asp"
DECRYPTION_PATH =
"/CryptHTTPS/Decrypt.asp"
DELIMITER =
'*P1*'
CURRENCY_MAPPING =
{
  'EUR' => '242',
  'ITL' => '18',
  'BRL' => '234',
  'USD' => '1',
  'JPY' => '71',
  'HKD' => '103'
}

Instance Method Summary collapse

Instance Method Details

#parse_response(response) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/merb_merchant/billing/integrations/gestpay/common.rb', line 20

def parse_response(response)
  case response
  when /#cryptstring#(.*)#\/cryptstring#/, /#decryptstring#(.*)#\/decryptstring#/
    $1
  when /#error#(.*)#\/error#/
    raise StandardError, "An error occurred retrieving the encrypted string from GestPay: #{$1}"
  else
    raise StandardError, "No response was received by GestPay"
  end
end

#ssl_get(url, path) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/merb_merchant/billing/integrations/gestpay/common.rb', line 31

def ssl_get(url, path)
  uri = URI.parse(url)
  site = Net::HTTP.new(uri.host, uri.port)
  site.use_ssl = true
  site.verify_mode    = OpenSSL::SSL::VERIFY_NONE
  site.get(path).body
end