Stripe提现报错:无对应USD币种外部账户问题求助
问题分析与解决方案
这个错误的核心原因是你搞混了Stripe里**平台提现(Payout)和给客户打款(Transfer/OutboundPayment)**的API用途,同时代码逻辑也没对应到你的真实需求。
为什么会报错?
你调用的\Stripe\Payout::create()是用来把Stripe平台账户中的余额提现到你自己的平台绑定银行账户的API。现在报错“没有对应币种(usd)的外部账户”,说明你的Stripe平台账户还没绑定USD币种的外部银行账户——但这显然不是你代码想要实现的效果,因为你前面创建了客户并给客户添加了银行账户,你的真实需求应该是给这个客户打款,对吧?
代码中的问题点
- 误用
PayoutAPI:Payout是平台自身提现用的,不是给用户打款的 - 没有指定打款目标:即使是给用户打款,也需要明确指定要转到客户的哪个银行账户
修正后的代码
下面是调整后的代码,用Stripe的TransferAPI(旧版稳定API)来实现给客户打款到他的银行账户:
public function payout() { require_once('vendors/stripe-php/init.php'); $stripe = array( "secret_key" => cr("DealConfig.secret_key"), "publishable_key" => cr("DealConfig.publishable_key") ); \Stripe\Stripe::setApiKey($stripe['secret_key']); // 1. 创建客户(如果已有客户ID,可以直接用,不用重复创建) $customer = \Stripe\Customer::create(array( "description" => "Customer for payout" )); $customer_id = $customer->id; // 2. 创建测试银行账户的Token $bank_data = \Stripe\Token::create(array( "bank_account" => array( "country" => "US", "currency" => "usd", "account_holder_name" => "Charlotte Thomas", "account_holder_type" => "individual", "routing_number" => "110000000", // Stripe测试路由号 "account_number" => "000123456789" // Stripe测试账户号 ) )); $bank_token = $bank_data->id; // 3. 将银行账户添加到客户身上 $bank_account = \Stripe\Customer::createSource( $customer_id, ['source' => $bank_token] ); $bank_account_id = $bank_account->id; // 客户的银行账户ID // 4. 使用Transfer API给客户打款(注意金额是分单位,1000 = 10美元) $transfer_data = \Stripe\Transfer::create(array( "amount" => 1000, "currency" => "usd", "destination" => $bank_account_id, // 指定转到客户的这个银行账户 "description" => "Payout to customer Charlotte Thomas" )); echo "<pre>"; print_r($transfer_data); die; }
额外注意事项
- 如果你的Stripe账户是新版API,推荐使用
\Stripe\OutboundPayment::create()替代Transfer,用法类似,只是参数略有不同 - 确保你的Stripe账户已经开启了转账(Transfer)功能,否则会报错
- 测试环境下,只能用Stripe提供的测试银行账户信息,真实账户在测试环境无法使用
- 金额参数是分为单位,比如10美元要传1000
内容的提问来源于stack exchange,提问作者Matiur Rahman Mozumdar
相关产品推荐
相关产品推荐

