diff --git a/lib/stripe/stripe_client.rb b/lib/stripe/stripe_client.rb index 184d25a4d..1434d7fa9 100644 --- a/lib/stripe/stripe_client.rb +++ b/lib/stripe/stripe_client.rb @@ -121,12 +121,11 @@ def execute_request(method, path, url = api_url(path, api_base) body = nil - query_string = nil + query_params = nil case method.to_s.downcase.to_sym when :get, :head, :delete - query_string = Util.encode_parameters(params) if params && params.any? - url += "#{URI.parse(url).query ? '&' : '?'}#{query_string}" unless query_string.nil? + query_params = params else body = if headers[:content_type] && headers[:content_type] == "multipart/form-data" params @@ -148,12 +147,13 @@ def execute_request(method, path, context.idempotency_key = headers["Idempotency-Key"] context.method = method context.path = path - context.query_string = query_string + context.query_params = query_params ? Util.encode_parameters(query_params) : nil http_resp = execute_request_with_rescues(api_base, context) do conn.run_request(method, url, body, headers) do |req| req.options.open_timeout = Stripe.open_timeout req.options.timeout = Stripe.read_timeout + req.params = query_params unless query_params.nil? end end @@ -443,7 +443,7 @@ def log_request(context, num_retries) Util.log_debug("Request details", body: context.body, idempotency_key: context.idempotency_key, - query_string: context.query_string) + query_params: context.query_params) end private :log_request @@ -492,7 +492,7 @@ class RequestLogContext attr_accessor :idempotency_key attr_accessor :method attr_accessor :path - attr_accessor :query_string + attr_accessor :query_params attr_accessor :request_id # The idea with this method is that we might want to update some of diff --git a/test/stripe/invoice_test.rb b/test/stripe/invoice_test.rb index b349fc446..dd145c033 100644 --- a/test/stripe/invoice_test.rb +++ b/test/stripe/invoice_test.rb @@ -87,8 +87,9 @@ class InvoiceTest < Test::Unit::TestCase assert_requested :get, "#{Stripe.api_base}/v1/invoices/upcoming", query: { customer: "cus_123", - :'subscription_items[][plan]' => "gold", - :'subscription_items[][quantity]' => 2, + subscription_items: [ + { plan: "gold", quantity: "2" }, + ], } assert invoice.is_a?(Stripe::Invoice) end diff --git a/test/stripe/stripe_client_test.rb b/test/stripe/stripe_client_test.rb index 1804b29bd..9c17a8fdd 100644 --- a/test/stripe/stripe_client_test.rb +++ b/test/stripe/stripe_client_test.rb @@ -176,7 +176,7 @@ class StripeClientTest < Test::Unit::TestCase Util.expects(:log_debug).with("Request details", body: "", idempotency_key: "abc", - query_string: nil) + query_params: nil) Util.expects(:log_info).with("Response from Stripe API", account: "acct_123",