Class: Gestpay::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/gestpay/gateway.rb

Constant Summary collapse

URL =
{
  :test       => 'https://testecomm.sella.it/gestpay/gestpayws/WSs2s.asmx?WSDL',
  :production => 'https://ecomms2s.sella.it/gestpay/gestpayws/WSs2s.asmx?WSDL'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGateway

Returns a new instance of Gateway.



14
15
16
17
18
# File 'lib/gestpay/gateway.rb', line 14

def initialize
  # SOAP Client operations:
  # => [:call_refund_s2_s, :call_read_trx_s2_s, :call_pagam_s2_s, :call_delete_s2_s, :call_settle_s2_s, :call_verifycard_s2_s, :call_check_carta_s2_s, :call_renounce, :call_request_token_s2_s, :call_delete_token_s2_s]
  @client = Savon.client(:wsdl => URL[Gestpay.config.environment])
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



13
14
15
# File 'lib/gestpay/gateway.rb', line 13

def client
  @client
end

Instance Method Details

#configObject



9
10
11
# File 'lib/gestpay/gateway.rb', line 9

def config
  Gestpay.config
end

#payment(data) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/gestpay/gateway.rb', line 30

def payment(data)
  # Custom info must be enabled on Gestpay backoffice interface, by adding new parameters
  data[:custom_info] = data[:custom_info].to_query.gsub('&', '*P1*') if data[:custom_info]
  response = @client.call(:call_pagam_s2_s, soap_options(data))
  response_content = response.body[:call_pagam_s2_s_response][:call_pagam_s2_s_result][:gest_pay_s2_s]
  Result::Payment.new(response_content)
end

#request_token(data, verify = true) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/gestpay/gateway.rb', line 38

def request_token(data, verify=true)
  opts = {
    :request_token => 'MASKEDPAN',
    :with_auth => verify ? 'Y' : 'N'
  }
  response = @client.call(:call_request_token_s2_s, soap_options(data.merge(opts)))
  response_content = response.body[:call_request_token_s2_s_response][:call_request_token_s2_s_result][:gest_pay_s2_s]
  Result::TokenRequest.new(response_content)
end

#soap_options(data) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/gestpay/gateway.rb', line 20

def soap_options(data)
  {
    :message => {
      :shop_login  => config.,
      :uic_code    => config.currency_code,
      :language_id => config.language_code
    }.merge(data)
  }
end