Class: Gestpay::Gateway

Inherits:
Object
  • Object
show all
Includes:
CustomInfo
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

Methods included from CustomInfo

#gestpay_decode, #gestpay_encode

Constructor Details

#initializeGateway

Returns a new instance of Gateway.



16
17
18
19
20
# File 'lib/gestpay/gateway.rb', line 16

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.



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

def client
  @client
end

Instance Method Details

#configObject



11
12
13
# File 'lib/gestpay/gateway.rb', line 11

def config
  Gestpay.config
end

#payment(data) ⇒ Object



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

def payment(data)
  # Custom info must be enabled on Gestpay backoffice interface, by adding new parameters
  data[:custom_info] = gestpay_encode(data[:custom_info]) 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



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

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



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

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