diff --git a/lib/stripe/util.rb b/lib/stripe/util.rb index 47c49f98..86560dd1 100644 --- a/lib/stripe/util.rb +++ b/lib/stripe/util.rb @@ -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") diff --git a/test/stripe/api_resource_test.rb b/test/stripe/api_resource_test.rb index a4147524..9abfdc97 100644 --- a/test/stripe/api_resource_test.rb +++ b/test/stripe/api_resource_test.rb @@ -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