8
votes

I've gone through the docs and haven't been able to spot a way to query balance info for Stripe managed accounts. Here's the use case: a 3rd party sets up a managed account through my Stripe Connect enabled platform; I create some charge objects on their account after a few customers buy goods/services (so their balance is now positive); now they want a payout BUT I want to query their balance before issuing the transfer to ensure they're not asking for more than is in their account.

Surely I'm missing something obvious. Thanks in advance.

3
The response returns an object like this: { "object": "balance", "available": [ { "currency": "usd", "amount": 0, "source_types": { "card": 0 } } ], "connect_reserved": [ { "currency": "usd", "amount": 0 } ], "livemode": false, "pending": [ { "currency": "usd", "amount": 0, "source_types": { "card": 0 } } ] } Why is the available and pending props an ARRAY? It makes no sense to me!Walter Monecke

3 Answers

4
votes

You should be able to do this by simply issuing a balance retrieval call while authenticating as the connected account, e.g.:

curl https://api.stripe.com/v1/balance \ -H "Authorization: Bearer {PLATFORM_SECRET_KEY}" \ -H "Stripe-Account: {CONNECTED_STRIPE_ACCOUNT_ID}"

14
votes

So for Ruby, based on Ywain's answer, I figured that instead of doing what's documented:

Stripe.api_key = CONNECTED_STRIPE_ACCOUNT_SK
Stripe::Balance.retrieve

a better way, that is not documented, is to do:

Stripe::Balance.retrieve(stripe_account: CONNECTED_STRIPE_ACCOUNT_ID)

as long as the current api_key is your platform account with the managed accounts option enabled.

6
votes

PHP

\Stripe\Balance::retrieve([
    'stripe_account' => CONNECTED_STRIPE_ACCOUNT_ID
]);

Python

stripe.Balance.retrieve(
  stripe_account=CONNECTED_STRIPE_ACCOUNT_ID
)

Ruby

Stripe::Balance.retrieve(
  :stripe_account => CONNECTED_STRIPE_ACCOUNT_ID
)

Node

stripe.balance.retrieve({
  stripe_account: CONNECTED_STRIPE_ACCOUNT_ID
}, function(err, charge) {});