I am stuck with this error on stripe. I am trying to create a login Link for users. I have tried selecting United Kingdom under 'Select where to onboard accounts' on the stripe settings page but still get the same error.
Full error code:
StripeInvalidRequestError: You must provide an account with capabilities when creating an account link of type "account_onboarding" for an account in a country that is not enabled for Express. You can enable GB in your Country and
Capabilities settings at https://dashboard.stripe.com/settings/applications/express
here's my code.
const User = require('../models/User');
const Stripe = require('stripe');
const queryString = require('query-string');
const stripe = Stripe(process.env.STRIPE_SECRET);
exports.createConnectAccount = async (req, res) => {
const user = await User.findById(req.user._id).exec();
try {
if (!user.stripe_account_id) {
const account = await stripe.accounts.create({
type: 'express',
});
user.stripe_account_id = account.id;
user.save();
}
let accountLink = await stripe.accountLinks.create({
account: user.stripe_account_id,
refresh_url: process.env.STRIPE_REDIRECT_URL,
return_url: process.env.STRIPE_REDIRECT_URL,
type: 'account_onboarding',
});
accountLink = Object.assign(accountLink, {
'stripe_user[email': user.email || undefined,
});
console.log(accountLink);
} catch (err) {
console.log(err);
}
};