Stripe Connect标准账户开发测试:如何跳过开户流程
解决Stripe Connect测试阶段跳过账户创建流程的方法
是的,你需要在创建Account Link时传入特定参数来启用测试模式下的跳过功能,具体操作如下:
方法1:添加collect: "none"参数
在调用stripe.accountLinks.create时,新增collect: "none"参数,测试模式下会直接跳过Stripe的信息收集页面,自动跳转到你的return_url。修改后的代码如下:
static accountLinkRequest = async (stripeAccountId: string): Promise<Stripe.Response<Stripe.AccountLink>> => { const accountLink: Stripe.Response<Stripe.AccountLink> = await stripe.accountLinks.create({ account: stripeAccountId, refresh_url: `${config.CLIENT_BASE_URL}/account/integrations`, return_url: `${config.CLIENT_BASE_URL}/account/integrations`, type: "account_onboarding", collect: "none" // 测试模式下跳过信息收集流程 }); return accountLink; };
注意:这个参数仅在测试模式下生效,生产环境中该参数会被忽略,仍会正常引导用户完成信息收集。
方法2:预填充测试账户的必填信息
如果你的测试账户需要满足某些合规要求,也可以在创建账户时预先填充测试用的必填字段,这样生成的Account Link会自动完成流程,无需跳转Stripe页面。修改账户创建代码示例:
static accountCreationRequest = async (): Promise<Stripe.Response<Stripe.Account>> => { const account: Stripe.Response<Stripe.Account> = await stripe.accounts.create({ type: "standard", email: "test-user@example.com", business_type: "individual", individual: { first_name: "Test", last_name: "User", email: "test-user@example.com", address: { line1: "123 Test St", city: "Testville", state: "CA", postal_code: "90210", country: "US" }, dob: { day: 1, month: 1, year: 1990 }, phone: "555-555-5555" }, tos_acceptance: { date: Math.floor(Date.now() / 1000), ip: "127.0.0.1" } }); return account; };
填充这些测试信息后,账户已满足Standard账户的基本要求,后续生成的Account Link会直接跳回你的回调地址,无需手动输入任何数据。
内容的提问来源于stack exchange,提问作者user8811409
相关产品推荐
相关产品推荐

