I am creating an application in which users can add their bank accounts in the application and from admin side I want to send the payouts to their bank accounts. I am using Node.js and Stripe.js (In Test Mode). Please anyone help me to fix this issue.
router.get("/testing-stripe", async (_, res) => {
try {
// Create a Stripe express account
const account = await stripe.accounts.create({
type: "express",
country: "US",
email: "[email protected]",
business_type: "individual",
individual: {
first_name: "Hammad",
last_name: "Umar",
},
capabilities: {
card_payments: { requested: true },
transfers: { requested: true },
},
});
// Create a bank account token
const token = await stripe.tokens.create({
bank_account: {
country: "US",
currency: "usd",
account_holder_name: "Hammad Umar",
account_holder_type: "individual",
routing_number: "110000000",
account_number: "000123456789",
},
});
// Attach the bank account token to the Custom account
const bankAccount = await stripe.accounts.createExternalAccount(
account.id,
{
external_account: token.id,
}
);
// Generate onborading link
const accountLink = await stripe.accountLinks.create({
account: account.id,
refresh_url: "http://localhost:5002/redirect",
return_url: "http://localhost:5002/redirect",
type: "account_onboarding",
});
const payout = await stripe.payouts.create(
{
amount: 5 * 100,
currency: "usd",
destination: bankAccount.id,
source_type: "bank_account",
},
{
stripeAccount: account.id,
}
);
return res.json({
url: accountLink.url,
bankAccountId: bankAccount.id,
stripeAccountId: account.id,
payout,
});
} catch (error) {
console.error("Error creating bank token:", error);
return res.status(500).json({ message: error.message });
}
});
The only issue with this snippet
const payout = await stripe.payouts.create(
{
amount: 5 * 100,
currency: "usd",
destination: bankAccount.id,
source_type: "bank_account",
},
{
stripeAccount: account.id,
}
);
When I hit this API endpoint I got this error.
{
"message": "You have insufficient funds in your Stripe account for this transfer. Your ACH balance is too low. You can use the /v1/balance endpoint to view your Stripe balance (for more details, see stripe.com/docs/api#balance)."
}
I also tried top-up / create charge API for trying add funds in my balance but in vein.