stripe: No such external account but the external account do exist

2.3k Views Asked by At

I create an account in stripe under test module by stripe api. And bind a bank account with this account. Go to Stripe dashboard -> connect -> accounts, I could see the account which I created. Click it and to see the detail, I could see the external accounts:

enter image description here

but when I want to create a payout to this bank account:

curl https://api.stripe.com/v1/payouts    \
     -u sk_test_*********:   \  
     -d amount=400     \
     -d currency=usd    \
     -d destination=ba_1CrVQnJziGn15h8UAvSlEUfI    \
     -d source_type=bank_account

It gives me error:

{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such external account: ba_1CrVQnJziGn15h8UAvSlEUfI",
    "param": "destination",
    "type": "invalid_request_error"
 }
}
2

There are 2 best solutions below

0
virtuexru On

Here's the correct code to do this.

When trying to list payouts on a connected account, you have to make the API request authenticating as this account so in addition to the destination bank account ID you need to pass the stripe account ID.

payouts = Stripe::Payout.list(
  {:destination => external_account},
  {:stripe_account => "acct_XXXXXX"},
)
0
Fabiano Arruda On

According to Stripe docs, in order to create Payouts for connected accounts you must specify the connected account on the request:

curl https://api.stripe.com/v1/payouts \
  -u {PLATFORM_SECRET_KEY}: \
  -H "Stripe-Account: {{CONNECTED_STRIPE_ACCOUNT_ID}}" \
  -d amount=1000 \
  -d currency=usd