lib/stripe/util.rb in stripe-1.30.2 vs lib/stripe/util.rb in stripe-1.30.3
- old
+ new
@@ -114,10 +114,13 @@
gsub('%5B', '[').gsub('%5D', ']')
end
def self.flatten_params(params, parent_key=nil)
result = []
- params.each do |key, value|
+
+ # do not sort the final output because arrays (and arrays of hashes
+ # especially) can be order sensitive, but do sort incoming parameters
+ params.sort_by { |(k, v)| k.to_s }.each do |key, value|
calculated_key = parent_key ? "#{parent_key}[#{key}]" : "#{key}"
if value.is_a?(Hash)
result += flatten_params(value, calculated_key)
elsif value.is_a?(Array)
result += flatten_params_array(value, calculated_key)