Back

Technologies:

javascriptjavascript
node.jsnode.js
avatar
Tolerim
a month ago

How do I retrieve the balance of a Stripe Connect account?

As a developer, I am facing an issue while attempting to retrieve the balance for a connected account in Stripe. Despite making an API call, I received the balance of the platform account instead of the desired connected account balance. It is important to note that I am executing this in the test mode. In the code snippet provided below, we are using the "stripe_account" parameter to specify the connected account, linked with the platform account through the "host" variable:
const balance = await stripe.balance.retrieve({
    stripe_account: host.stripeAccountId,
  });
Additionally, "host" represents the variable containing the aforementioned connected account.
Answers(2)
avatar
Vogi
a month ago
Verified Answer
It seems that you are trying to retrieve the balance of a connected account in Stripe but are receiving the balance of the platform account instead. To retrieve the balance of a connected account, you need to specify the connected account's ID when making the request. You can do this by using the "stripe_account" parameter as follows:
const balance = await stripe.balance.retrieve({
    stripe_account: 'acct_1234567890',
  });
In your case, you can replace 'acct_1234567890' with the ID of your connected account. You can find this ID in your Stripe Dashboard under "Connected accounts" > "Account details" > "API keys".I hope this helps! Let me know if you have any other questions.

Sources

Retrieve accounts balance in stripe not working - Stack OverflowStripe API reference – Connected AccountsTesting Stripe Connect | Stripe DocumentationRetrieve the balance for a Stripe Connect connected account?
avatar
Tolerim
a month ago
When making an API call to retrieve the balance of a connected account in Stripe, you need to pass in the connected account's ID in the stripe_account parameter. In the provided code, the stripe_account parameter is set to host.stripeAccountId which indicates that the ID of the connected account is being passed correctly. However, it seems that the API call is returning the balance of the platform account instead of the connected account. This might be due to the use of the test mode, as test mode only allows balance retrieval for the platform account. To retrieve the balance of a connected account in test mode, you need to use a test API key that is associated with the connected account. You can do this by creating a test mode API key for the connected account, and using that API key to make the balance retrieval API call. To create a test key for a connected account, go to the "API Keys" section in the Stripe Dashboard, and select "Add new API key". In the "Restricted to" section, select the connected account you want to create the key for. Once you have the test key, you can use it to authenticate the API call by setting the stripeAccount parameter to the ID of the connected account and passing in the test API key as the stripeApiKey parameter.
const balance = await stripe.balance.retrieve({
  stripe_account: host.stripeAccountId,
}, {
  stripeAccount: host.stripeAccountId,
  stripeApiKey: 'sk_test_XXXXXXXXXXXXXXXXXXXXXXXX'
});
This should return the balance of the connected account, assuming that the test API key is correctly associated with the connected account.
;