StripeInvalidRequestError: You must provide an account with capabilities when creating an account link of type "account_onboarding"

Viewed 551

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);
  }
};

1 Answers

The error indicates that the Stripe account which you are creating an account link for does not have any requested capabilities. What you can do is to request for the capabilities [0] when creating the Stripe account :

const account = await stripe.accounts.create({
    type: 'express',
    capabilities: {
        card_payments: {requested: true},
        transfers: {requested: true},
    },
});

You would probably want to write in to Stripe support who will be able to better guide you on the settings required in your Dashboard so that the capabilities are automatically requested when creating new Express accounts : https://support.stripe.com/contact

[0] https://stripe.com/docs/api/accounts/create#create_account-capabilities

Related