Description
A TypeError is raised when the API responds with an unsuccessful response
Steps to reproduce
- Install the 'adyen-ruby-api-library'
gem install adyen-ruby-api-library -v 11.0
- open an irb console
- require the gem
require 'adyen-ruby-api-library'
- Create a client instance with invalid credentials:
client = Adyen::Client.new(ws_user: 'foo', ws_password: 'bar', env: :test)
- Issue an
authorise request
client.payment.payments_api.authorise({})
Actual behavior
A TypeError is raised, potentially indicating that the response body isn't being correctly parsed as JSON.
/Users/dani/.rvm/gems/ruby-3.2.2/gems/adyen-ruby-api-library-11.0.0/lib/adyen/client.rb:372:in `[]': no implicit conversion of Symbol into Integer (TypeError)
message = error_details[:detail] || error_details[:message]
^^^^^^^
from /Users/dani/.rvm/gems/ruby-3.2.2/gems/adyen-ruby-api-library-11.0.0/lib/adyen/client.rb:372:in `build_error_message'
from /Users/dani/.rvm/gems/ruby-3.2.2/gems/adyen-ruby-api-library-11.0.0/lib/adyen/client.rb:221:in `call_adyen_api'
from /Users/dani/.rvm/gems/ruby-3.2.2/gems/adyen-ruby-api-library-11.0.0/lib/adyen/services/payment/payments_api.rb:22:in `authorise'
from (irb):5:in `<main>'
from /Users/dani/.rvm/gems/ruby-3.2.2/gems/irb-1.15.2/exe/irb:9:in `<top (required)>'
from /Users/dani/.rvm/gems/ruby-3.2.2/bin/irb:25:in `load'
from /Users/dani/.rvm/gems/ruby-3.2.2/bin/irb:25:in `<main>'
from /Users/dani/.rvm/gems/ruby-3.2.2/bin/ruby_executable_hooks:22:in `eval'
from /Users/dani/.rvm/gems/ruby-3.2.2/bin/ruby_executable_hooks:22:in `<main>'
Expected behavior
An appropriate Adyen::AuthenticationError should be raised.
Code snippet or screenshots (if applicable)
No response
Adyen Ruby API Library version
11.0.0
Ruby language version
3.2.2
Operating System
macOS
Additional context
Having skimmed the code I believe that the issue might be in a missing JSON.parse invoketion with the newly added Adyen::Client#build_error_message method.
Description
A
TypeErroris raised when the API responds with an unsuccessful responseSteps to reproduce
authoriserequestActual behavior
A TypeError is raised, potentially indicating that the response body isn't being correctly parsed as JSON.
Expected behavior
An appropriate
Adyen::AuthenticationErrorshould be raised.Code snippet or screenshots (if applicable)
No response
Adyen Ruby API Library version
11.0.0
Ruby language version
3.2.2
Operating System
macOS
Additional context
Having skimmed the code I believe that the issue might be in a missing
JSON.parseinvoketion with the newly addedAdyen::Client#build_error_messagemethod.