Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with headers in response params #5174

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/active_merchant/billing/gateways/adyen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -755,18 +755,28 @@ def add_metadata(post, options = {})
post[:metadata].merge!(options[:metadata]) if options[:metadata]
end

def parse(body)
def parse(response)
body = response.body
return {} if body.blank?

JSON.parse(body)
JSON.parse(body).merge(response.each_header.to_h)
end

def handle_response(response)
case response.code.to_i
when 200...300
response
else
raise ResponseError.new(response)
end
end

def commit(action, parameters, options)
begin
raw_response = ssl_post(url(action), post_data(action, parameters), request_headers(options))
response = parse(raw_response)
rescue ResponseError => e
raw_response = e.response.body
raw_response = e.response
response = parse(raw_response)
end

Expand Down
7 changes: 7 additions & 0 deletions test/remote/gateways/remote_adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ def test_successful_authorize
assert_equal 'Authorised', response.message
end

def test_headers_in_response
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert_equal 'Authorised', response.message
refute response.params['content-type'].blank?
end

def test_successful_authorize_with_bank_account
response = @gateway.authorize(@amount, @bank_account, @options)
assert_success response
Expand Down
Loading