首页 > 解决方案 > Stripe 没有显示这样的令牌:tok_xxxxxxx 用于目的地费用

问题描述

我正在尝试创建从我的客户到其中一个连接帐户的目的地费用。

\Stripe\Stripe::setApiKey(STRIPE_SECRET_KEY); //Origin Stripe Secret Key

        try {
            $connectd_account_id = 'acct_XXXXXXX';
            $customer_id = 'cus_XXXXXXX'
            // sharing my customer with connected account and creating a token. 
            $token = \Stripe\Token::create(
                                    ["customer" => $customer_id], //doctor stripe customer id
                                    ["stripe_account" => $connectd_account_id]); //Lab Stripe Account

            // I am receiving response ** No such token: tok_xxxxxxx **
            $charge = \Stripe\Charge::create(array(
                                                "amount" => 10000,
                                                "currency" => 'USD',
                                                "source" => $token->id,
                                                "application_fee_amount" => 2000,
                                                "transfer_data" => [
                                                    "destination" => $connectd_account_id,
                                                ],
                                            )
                                        );
        } catch (Exception $e) {
            $error = $e->getMessage();
        }

每次我收到 没有这样的令牌:tok_xxxxxxx 我在这里找不到什么错误。请帮忙。

标签: phpstripe-payments

解决方案


如果您正在创建目的地费用,则应在您的平台帐户上创建卡令牌和客户及相关对象。您的平台账户是与持卡人交互并处理付款的平台账户,然后在 Stripe 内将资金转移到目标账户。

您的代码似乎试图将保存的卡详细信息从您的平台复制到目标帐户,这不是您对目标费用所做的(只有在您使用直接费用时,您才会这样做,付款在关联帐户,因此需要在那里复制付款信息)。

简而言之,您应该省略创建令牌的代码,而是在创建收费时,传递类似"source" => $customer_id,在您的平台上向客户详细信息收费的内容。


推荐阅读