Code:
var accounts = await stripe.accounts.listExternalAccounts(userSensitiveData.stripe_account_id.S!, {
object: 'bank_account'
})
console.log('accounts:', accounts)
const payout = await stripe.payouts.create({
amount: combined[i].amount * 100, // Amount in the smallest currency unit (e.g., 10000 yen for 100 yen)
currency: 'jpy',
destination: userSensitiveData.stripe_bank_id.S,
source_type: 'bank_account'
});
I can see the bank account with listExternalAccounts.
accounts: {
object: 'list',
data: [
{
id: 'ba_1QDbLrEAwtXI7T4QpEC3MaB0',
object: 'bank_account',
account: 'acct_1QDbLpEAwtXI7T4Q',
account_holder_name: 'Tenna Churiki',
account_holder_type: 'individual',
account_type: 'futsu',
available_payout_methods: [Array],
bank_name: 'STRIPE TEST BANK',
country: 'JP',
currency: 'jpy',
default_for_currency: true,
fingerprint: 'cg0FOuoUMjAmco18',
future_requirements: [Object],
last4: '1234',
metadata: {},
requirements: [Object],
routing_number: '1100000',
status: 'new'
}
],
has_more: false,
url: '/v1/accounts/acct_1QDbLpEAwtXI7T4Q/external_accounts'
}
However, payouts fails with No such external account.
ERROR Error: ji [Error]: No such external account: 'ba_1QDbLrEAwtXI7T4QpEC3MaB0'
at Wi (file:///var/task/index.mjs:38:21669)
at n.toJSON.then.zr.message (file:///var/task/index.mjs:38:30324)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'StripeInvalidRequestError',
raw: {
code: 'resource_missing',
doc_url: 'https://stripe.com/docs/error-codes/resource-missing',
message: "No such external account: 'ba_1QDbLrEAwtXI7T4QpEC3MaB0'",
param: 'destination',
request_log_url: 'https://dashboard.stripe.com/test/logs/req_0n6k8JKCyEpUiW?t=1729817955',
type: 'invalid_request_error',
Isn't the bank account obtained from listExternalAccounts an external account? I also tried passing the account id as a destination which also failed with the same error.
The external account exists on a different Stripe account, which you can tell by having to define the Stripe account you're listing external accounts for i.e. userSensitiveData.stripe_account_id.S!
When you make the request to create the payout, you also need to make the request on the Stripe Account that the external account exists on. You'll want to use the StripeAccount header to do so. See https://stripe.com/docs/connect/authentication.
Example
const payout = await stripe.payouts.create({
amount: combined[i].amount * 100, // Amount in the smallest currency unit (e.g., 10000 yen for 100 yen)
currency: 'jpy',
destination: userSensitiveData.stripe_bank_id.S,
source_type: 'bank_account'
},
{
stripe_account: userSensitiveData.stripe_account_id.S!
});