Include stripe account parameter for setting header.

This commit is contained in:
wangjohn 2014-12-19 11:03:22 -08:00
parent 67da7aa9a7
commit 6990bbd798
2 changed files with 22 additions and 0 deletions

View File

@ -127,6 +127,9 @@ module Stripe
if opts[:idempotency_key]
headers[:idempotency_key] = opts[:idempotency_key]
end
if opts[:stripe_account]
headers[:stripe_account] = opts[:stripe_account]
end
return opts[:api_key], headers
else
raise TypeError.new("parse_opts expects a string or a hash")

View File

@ -67,6 +67,25 @@ module Stripe
end
end
should "send stripe account as header when set" do
stripe_account = "acct_0000"
Stripe.expects(:execute_request).with do |opts|
opts[:headers][:stripe_account] == stripe_account
end.returns(test_response(test_charge))
Stripe::Charge.create({:card => {:number => '4242424242424242'}},
{:stripe_account => stripe_account, :api_key => 'sk_test_local'})
end
should "not send stripe account as header when not set" do
Stripe.expects(:execute_request).with do |opts|
opts[:headers][:stripe_account].nil?
end.returns(test_response(test_charge))
Stripe::Charge.create({:card => {:number => '4242424242424242'}},
'sk_test_local')
end
context "when specifying per-object credentials" do
context "with no global API key set" do
should "use the per-object credential when creating" do