mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-11 00:01:46 -04:00
Merge pull request #258 from theicfire/chase-array-params-bug
Requests with arrays of dictionaries now properly work
This commit is contained in:
commit
d6dc78d5ce
@ -110,7 +110,7 @@ module Stripe
|
|||||||
result = []
|
result = []
|
||||||
value.each do |elem|
|
value.each do |elem|
|
||||||
if elem.is_a?(Hash)
|
if elem.is_a?(Hash)
|
||||||
result += flatten_params(elem, calculated_key)
|
result += flatten_params(elem, "#{calculated_key}[]")
|
||||||
elsif elem.is_a?(Array)
|
elsif elem.is_a?(Array)
|
||||||
result += flatten_params_array(elem, calculated_key)
|
result += flatten_params_array(elem, calculated_key)
|
||||||
else
|
else
|
||||||
|
@ -95,5 +95,24 @@ module Stripe
|
|||||||
})
|
})
|
||||||
assert c.paid
|
assert c.paid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "properly handle an array or dictionaries" do
|
||||||
|
@mock.expects(:post).with do |url, api_key, params|
|
||||||
|
url == "#{Stripe.api_base}/v1/charges" && api_key.nil? && CGI.parse(params) == {
|
||||||
|
'currency' => ['usd'], 'amount' => ['100'],
|
||||||
|
'source' => ['btcrcv_test_receiver'],
|
||||||
|
'level3[][red]' => ['firstred', 'another'],
|
||||||
|
'level3[][one]' => ['fish'],
|
||||||
|
}
|
||||||
|
end.once.returns(make_response(make_charge))
|
||||||
|
|
||||||
|
c = Stripe::Charge.create({
|
||||||
|
:amount => 100,
|
||||||
|
:source => 'btcrcv_test_receiver',
|
||||||
|
:currency => "usd",
|
||||||
|
:level3 => [{:red => 'firstred'}, {:one => 'fish', :red => 'another'}]
|
||||||
|
})
|
||||||
|
assert c.paid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user