class PaylineSDK::Client
Constants
- DIRECT_API
- EXTENDED_API
- HOMO_ENDPOINT
- PAYLINE_NAMESPACE
- PROD_ENDPOINT
- WEB_API
Attributes
attributes[RW]
direct_client[RW]
extended_client[RW]
web_client[RW]
Public Class Methods
new()
click to toggle source
# File lib/payline_sdk/client.rb, line 14 def initialize @env = PaylineSDK.configuration.environment init_clients(PaylineSDK.configuration.file, PaylineSDK.configuration.merchant_id, PaylineSDK.configuration.access_key) end
Protected Instance Methods
clean_response(hash)
click to toggle source
# File lib/payline_sdk/client.rb, line 36 def clean_response(hash) hash.each do |k,v| if v.is_a?(Hash) v = clean_response(v) next end if k == :@xmlns hash.delete(k) end end end
get_client_for_method(method_name)
click to toggle source
# File lib/payline_sdk/client.rb, line 68 def get_client_for_method(method_name) PaylineSDK::Configuration::API[:apis].keys.each do |api| PaylineSDK::Configuration::API[:apis][api][:methods].each do |method| if method[:name] == method_name case api when :web_payment_api return @web_client when :direct_payment_api return @direct_client when :extended_api return @extended_client end end end end return nil end
init_clients(file, merchant_id, access_key, opts = {})
click to toggle source
# File lib/payline_sdk/client.rb, line 48 def init_clients(file, merchant_id, access_key, opts = {}) env = @env endpoint = if @env == :test HOMO_ENDPOINT elsif @env == :production PROD_ENDPOINT end ['web', 'direct', 'extended'].each do |type| client = Savon.client do basic_auth merchant_id, access_key wsdl(file) pretty_print_xml(true) if env == :test namespace(PAYLINE_NAMESPACE) endpoint(endpoint + eval("#{type.upcase}_API")) end instance_variable_set("@#{type}_client", client) end end