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
# 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}"
end

#on_before_dispatchObject

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



75
76
77
# File 'lib/adyen/soap.rb', line 75

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



60
61
62
63
64
# File 'lib/adyen/soap.rb', line 60

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



67
68
69
70
71
# File 'lib/adyen/soap.rb', line 67

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