Jonathan McNamara
Jonathan McNamara

Reputation: 1

Does Stripe still allow pre-filling for express accounts? If yes, what is syntax to pass things like email, first name, business name etc

image of initial landing screen where i also want mobile phone pre-filled

Have been following some online tutorials on creating a Stripe Marketplace, have it all configured however I'm having trouble passing details i have collected on a user, ie email as best example, and then having that be pre-filled when a new vendor on my marketplace goes through the Stripe Connect Express onboarding process.

Any help would be great, particularly on how to pass these details in the accountLink that is being sent.

export const makeSeller = async (req, res) => {
    try {
        // 1. find user from db
        const seller = await Seller.findById(req.user._id).exec();
        // 2. if user dont have stripe_account_id yet, then create new
        if (!seller.stripe_account_id) {
            const account = await stripe.accounts.create({ type: 'express' });
            // console.log('ACCOUNT => ', account.id)
            seller.stripe_account_id = account.id;
            seller.save();
        }
        // 3. create account link based on account id (for frontend to complete onboarding)
        let accountLink = await stripe.accountLinks.create({
            account: seller.stripe_account_id,
            refresh_url: process.env.STRIPE_REDIRECT_URL,
            return_url: process.env.STRIPE_REDIRECT_URL,
            type: 'account_onboarding',
        });
        console.log('ACCOUNT LINK', accountLink);
        // 4. pre-fill any info such as email (optional), then send url resposne to frontend
        accountLink = Object.assign(accountLink, {
            'stripe_user[email]': seller.email,
        });
        // 5. then send the account link as response to fronend
        res.send(`${accountLink.url}?${queryString.stringify(accountLink)}`);
    } catch (err) {
        console.log('MAKE SELLER ERR ', err);
    }
};

Upvotes: 0

Views: 1332

Answers (1)

Pompey
Pompey

Reputation: 1354

Stripe allows any of the fields on an Account object to be prefilled! The place to prefill this info is in the stripe.accounts.create call before creating the AccountLinks object, if you prefill the information in the Account object, it will not be collected in the onboarding flow[1].

const account = await stripe.accounts.create({ type: 'express', email: '[email protected]' });

Check out the API doc section on creating an Account object for info on how to populate specific fields[2].

[1] https://stripe.com/docs/connect/express-accounts#create-account

[2] https://stripe.com/docs/api/accounts/create

Upvotes: 2

Related Questions