Class: AbtainBilling::Billing::Integrations::Gestpay::Helper

Inherits:
Helper
  • Object
show all
Includes:
Common
Defined in:
lib/abtain_billing/billing/integrations/gestpay/helper.rb

Constant Summary

Constants included from Common

Common::CURRENCY_MAPPING, Common::DECRYPTION_PATH, Common::DELIMITER, Common::ENCRYPTION_PATH, Common::VERSION

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods included from Common

#parse_response, #ssl_get

Methods inherited from Helper

#add_field, #add_fields, #billing_address, mapping, #shipping_address

Constructor Details

#initialize(order, account, options = {}) ⇒ Helper

English => 2

Spanish		=> 3
French    => 4
Tedesco   => 5


13
14
15
16
# File 'lib/abtain_billing/billing/integrations/gestpay/helper.rb', line 13

def initialize(order, , options = {})
  super
  add_field('PAY1_IDLANGUAGE', 2)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AbtainBilling::Billing::Integrations::Helper

Instance Method Details

#currency=(currency_code) ⇒ Object

Raises:

  • (StandardError)


38
39
40
41
42
43
# File 'lib/abtain_billing/billing/integrations/gestpay/helper.rb', line 38

def currency=(currency_code)
  code = CURRENCY_MAPPING[currency_code]
  					raise StandardError, "Invalid currency code #{currency_code} specified" if code.nil?
  					
  					add_field(mappings[:currency], code)
end

#customer(params = {}) ⇒ Object



33
34
35
36
# File 'lib/abtain_billing/billing/integrations/gestpay/helper.rb', line 33

def customer(params = {})
  add_field(mappings[:customer][:email], params[:email])
  add_field('PAY1_CHNAME', "#{params[:first_name]} #{params[:last_name]}")
end

#encryption_query_stringObject



59
60
61
62
63
64
65
# File 'lib/abtain_billing/billing/integrations/gestpay/helper.rb', line 59

def encryption_query_string
  fields = ['PAY1_AMOUNT', 'PAY1_SHOPTRANSACTIONID', 'PAY1_UICCODE']

  encoded_params = fields.collect{ |field| "#{field}=#{CGI.escape(@fields[field])}" }.join(DELIMITER)

  "#{ENCRYPTION_PATH}?a=" + CGI.escape(@fields['ShopLogin']) + "&b=" + encoded_params + "&c=" + CGI.escape(VERSION)
end

#form_fieldsObject



45
46
47
48
49
50
51
52
# File 'lib/abtain_billing/billing/integrations/gestpay/helper.rb', line 45

def form_fields
  @encrypted_data ||= get_encrypted_string
            
  {
    'a' => @fields['ShopLogin'],
    'b' => @encrypted_data
  }
end

#get_encrypted_stringObject



54
55
56
57
# File 'lib/abtain_billing/billing/integrations/gestpay/helper.rb', line 54

def get_encrypted_string
  response = ssl_get(Gestpay.service_url, encryption_query_string)
  parse_response(response)
end