From 10548a49d4793d1db813efad7994e61b9b3ff586 Mon Sep 17 00:00:00 2001 From: Alica Moser Date: Wed, 4 Sep 2019 16:22:48 -0400 Subject: [PATCH] Transfer the request_id from the http_headers to error. When requesting error#request_id it returned nil although the request id was available in the request headers. With version 5 and switch to Net::HTTP this value is now a string, not a symbol which means that the request_id was not stored on the error correctly. --- lib/stripe/errors.rb | 2 +- test/stripe/errors_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stripe/errors.rb b/lib/stripe/errors.rb index d4865655f..c91422c12 100644 --- a/lib/stripe/errors.rb +++ b/lib/stripe/errors.rb @@ -27,7 +27,7 @@ def initialize(message = nil, http_status: nil, http_body: nil, @http_headers = http_headers || {} @json_body = json_body @code = code - @request_id = @http_headers[:request_id] + @request_id = @http_headers["request-id"] @error = construct_error_object end diff --git a/test/stripe/errors_test.rb b/test/stripe/errors_test.rb index 817ea13ef..a32c7685e 100644 --- a/test/stripe/errors_test.rb +++ b/test/stripe/errors_test.rb @@ -22,7 +22,7 @@ class StripeErrorTest < Test::Unit::TestCase e = StripeError.new("message", http_status: 200) assert_equal "(Status 200) message", e.to_s - e = StripeError.new("message", http_status: nil, http_body: nil, json_body: nil, http_headers: { request_id: "request-id" }) + e = StripeError.new("message", http_status: nil, http_body: nil, json_body: nil, http_headers: { "request-id" => "request-id" }) assert_equal "(Request request-id) message", e.to_s end end