Class: Saman::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/saman/verify.rb,
lib/saman/authorize.rb,
lib/saman/health_check.rb

Overview

Client class to handle requests

Instance Method Summary collapse

Instance Method Details

#authorize(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/saman/authorize.rb', line 7

def authorize(params)
  config = Saman.configuration
  request_parameters = create_authorize_parameters(params)
  response = send_rest_requests(
    config.authorize_address,
    request_parameters,
    config.retry_count
  )
  raise response[:error] unless response.is_a? RestClient::Response
  authorize_result(response)
end

#authorize_up?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/saman/health_check.rb', line 22

def authorize_up?
  authorize_client = Savon.client(wsdl: Saman.configuration.authorize_wsdl)
  expected_operations_for_authorize = %i[
    request_token
    request_multi_settle_type_token
  ]

  (expected_operations_for_authorize - authorize_client.operations).empty?
rescue StandardError
  return false
end

#health_checkObject



6
7
8
# File 'lib/saman/health_check.rb', line 6

def health_check
  authorize_up? && verify_up?
end

#verify(params) ⇒ Object



7
8
9
10
# File 'lib/saman/verify.rb', line 7

def verify(params)
  return false unless params[:State] == 'OK'
  verify_the_payment(params)
end

#verify_up?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/saman/health_check.rb', line 10

def verify_up?
  verify_client = Savon.client(wsdl: Saman.configuration.verify_wsdl)
  expected_operations_for_verify = %i[
    verify_transaction
    verify_transaction1
  ]

  (expected_operations_for_verify - verify_client.operations).empty?
rescue StandardError
  return false
end