Java调用Stripe API为Connect Account添加BankAccount报错求助
问题排查:Stripe API添加银行账户时参数不识别
错误原因
你当前的代码错误在于参数结构不符合Stripe API的要求:当通过Connect账户的externalAccounts接口创建银行账户时,所有银行账户相关的参数需要嵌套在external_account这个顶层键下,而不是直接放在参数Map的根层级。Stripe API无法识别根层级的account_number、routing_number等字段,所以返回了参数未知的错误。
修正后的代码
Stripe.apiKey = stripePrivate; Account account = Account.retrieve(accountId); Map<String, Object> bankParams = new HashMap<>(); // 嵌套银行账户参数到external_account键下 Map<String, Object> externalAccountParams = new HashMap<>(); externalAccountParams.put("object", "bank_account"); externalAccountParams.put("country", "US"); externalAccountParams.put("currency", "usd"); externalAccountParams.put("routing_number", "110000000"); externalAccountParams.put("account_number", "000123456789"); bankParams.put("external_account", externalAccountParams); BankAccount bankAccount = (BankAccount) account.getExternalAccounts().create(bankParams);
额外说明
- 你使用的测试路由号
110000000和账号000123456789是Stripe官方提供的合法测试值,无需修改 - 无论是Custom还是Express类型的Connect账户,这个参数结构要求都是一致的
- Stripe Java SDK 22.4版本完全支持这个参数格式,无需升级SDK即可正常运行
内容的提问来源于stack exchange,提问作者Ignacio Estevo
相关产品推荐
相关产品推荐

