Class: Adyen::SOAP::Base

Inherits:
Handsoap::Service
  • Object
show all
Defined in:
lib/adyen/soap.rb

Overview

The base class sets up XML namespaces and HTTP authentication for all the Adyen SOAP services

Direct Known Subclasses

PaymentService, RecurringService

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(klass) ⇒ Object



44
45
46
47
48
# File 'lib/adyen/soap.rb', line 44

def self.inherited(klass)
  # The version must be set to construct the request envelopes,
  # the URI wil be set later using the correct Adyen.environment.
  klass.endpoint :version => 1, :uri => 'bogus'
end

Instance Method Details

#on_after_create_http_client(http_client) ⇒ Object

Setup basic auth headers in the HTTP client



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/adyen/soap.rb', line 51

def on_after_create_http_client(http_client)
  debug { |logger| logger.puts "Authorization: #{Adyen::SOAP.username}:#{Adyen::SOAP.password}..." }
  # Handsoap BUG: Setting headers does not work, using a Curb specific method for now.
  # auth = Base64.encode64("#{Adyen::SOAP.username}:#{Adyen::SOAP.password}").chomp
  # http_client.headers['Authorization'] = "Basic #{auth}"
  http_client.userpwd         = "#{Adyen::SOAP.username}:#{Adyen::SOAP.password}"
  # We explicitly set the http_client, curb in this case, to follow the location.
  # By doing so, we avoid the cryptic Curl::Err::TooManyRedirectsError error.
  http_client.follow_location = true
  http_client.max_redirects   = 1
end

#on_before_dispatchObject

Set endpoint URI before dispatch, so that changes in environment are reflected correctly.



79
80
81
# File 'lib/adyen/soap.rb', line 79

def on_before_dispatch
  self.class.endpoint(:uri => self.class::ENDPOINT_URI % Adyen.environment.to_s, :version => 1)
end

#on_create_document(doc) ⇒ Object

Setup XML namespaces for SOAP request body



64
65
66
67
68
# File 'lib/adyen/soap.rb', line 64

def on_create_document(doc)
  doc.alias 'payment',   'http://payment.services.adyen.com'
  doc.alias 'recurring', 'http://recurring.services.adyen.com'
  doc.alias 'common',    'http://common.services.adyen.com'
end

#on_response_document(doc) ⇒ Object

Setup XML namespaces for SOAP response



71
72
73
74
75
# File 'lib/adyen/soap.rb', line 71

def on_response_document(doc)
  doc.add_namespace 'payment',   'http://payment.services.adyen.com'
  doc.add_namespace 'recurring', 'http://recurring.services.adyen.com'
  doc.add_namespace 'common',    'http://common.services.adyen.com'
end