You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Stripe Express账户是否支持预填信息?对应传参实现语法是什么?

问题根因

你当前使用的手动给Account Link拼接stripe_user[email]这类参数的预填方案,是Stripe多年前就已废弃的旧逻辑,现在Stripe Connect Express的所有预填信息,必须在创建/更新对应Connect账户时直接传入,无需额外修改Account Link的参数。

修改方案

1. 调整Stripe账户创建逻辑

你目前创建Express账户时仅传入了type参数,所有已收集到的用户信息都需要在这一步同步传给Stripe,需要预填手机号就新增phone参数即可。

2. 删除无效的URL拼接逻辑

你后续给accountLink追加自定义属性、再把整个对象拼到URL后的逻辑完全无效,还可能导致生成的入驻链接异常,直接返回Stripe返回的accountLink.url即可。

修改后的完整代码

import queryString from 'query-string';
import stripe from '你的stripe初始化文件路径';

export const makeSeller = async (req, res) => {
    try {
        // 1. 从数据库查询用户信息
        const seller = await Seller.findById(req.user._id).exec();
        // 2. 没有Stripe账户ID则新建,已有则可同步更新账户预填信息
        if (!seller.stripe_account_id) {
            // 新建账户时直接传入所有预填信息
            const account = await stripe.accounts.create({ 
                type: 'express',
                email: seller.email,
                // 要预填手机号就加下面这行,字段值替换为你数据库存储的用户手机号
                phone: seller.phone,
                // 如果是个人卖家,还可以预填更多个人相关信息,减少用户填写步骤
                // individual: {
                //   first_name: seller.firstName,
                //   last_name: seller.lastName,
                //   address: {
                //     line1: seller.addressLine1,
                //     postal_code: seller.postalCode,
                //     city: seller.city
                //   }
                // }
            });
            seller.stripe_account_id = account.id;
            await seller.save();
        } else {
            // 可选:如果已有账户的用户信息有更新,同步更新到Stripe,保证预填信息为最新版本
            await stripe.accounts.update(seller.stripe_account_id, {
                email: seller.email,
                phone: seller.phone
            })
        }
        // 3. 生成入驻链接,不需要额外传自定义参数
        const 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',
        });
        // 4. 直接返回入驻链接即可,不需要额外拼接参数
        res.send(accountLink.url);
    } catch (err) {
        console.log('创建卖家账户出错 ', err);
        res.status(500).send('入驻链接生成失败');
    }
};

补充说明

所有支持预填的字段可以参考Stripe官方Accounts接口的参数定义,只要是你平台已经收集到的合法信息,都可以提前传入,有效降低商家入驻的填写成本。

内容的提问来源于stack exchange,提问作者Jonathan McNamara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 03:39:01