PHP:条纹连接API不接受卡详细信息?

问题描述 投票:0回答:1

我知道在这里问这个问题可能会在黑暗中抛出一块石头,因为我发现了其他两个类似的问题,但没有任何答案。

无论如何,我希望有人已经为此找到了解决方案并且可以为它提供一个解决方案。

让我首先解释一下这个场景,因为它可能有助于找到解决方案:

我正在创建像这样的条纹custom connect accounts

$acct = \Stripe\Account::create(array(
    "country" => "US",
    "type" => "custom",
    "email" => "[email protected]"
));

然后我像这样添加Bank Accounts

$account->external_accounts->create(
array(
        'external_account' => array(
            "object" => "bank_account",
            "country" => "US",
            "currency" => "usd",
            "account_holder_name" => 'Jane Austen',
            "account_holder_type" => 'individual',
            "routing_number" => "111000025",
            "account_number" => "000123456789"
        )
));

到目前为止一切正常....

现在,我需要做的是能够将连接的自定义帐户中的Money / Payments转移到他们的银行帐户中。

为此,我需要在connetced account上添加一张信用卡,以便卡片详细信息可用于支付银行账户。

所以我继续尝试这个:

$account->external_accounts->create(
array(
        'external_account' => array(
            "object" => "card",
            "exp_month" => 8,
            "exp_year" => 2018,
            "number" => "4012888888881881",
            "currency" => "usd",
            "cvc" => "123"
        )
));

这没用,并给了我这个错误:

Requests made on behalf of a connected account must use card tokens from Stripe.js, but card details were directly provided.

所以我改变了策略并尝试了这个:

$result = \Stripe\Token::create(
                    array(
                        "card" => array(
                        "name" => "Some Name",
                        "exp_month" => 8,
                        "exp_year" => 2018,
                        "number" => "4012888888881881",
                        "currency" => "usd",
                        "cvc" => "123"
                        )
                    ));



$token = $result['id'];


$account->external_accounts->create(
array(
        'external_account' => array(
            "object" => "card",
            "source" => "".$token.""
        )
));

但是,这给了我同样的错误信息!

这非常令人沮丧,因为如果你查看他们自己的API文档,你会清楚地看到他们说:

source required

Either a token, like the ones returned by Stripe.js, or a dictionary containing a user's credit card details (with the options shown below). Stripe will automatically validate the card. 

这可以在这里看到:

https://stripe.com/docs/api#create_card

有人可以就这个问题提出建议吗?

我不能在我的项目中使用stripe.js所以我需要使用API​​。

任何帮助将不胜感激。

提前致谢。

第一编辑:

这是一个奇怪的..我从这里生成了一个条纹卡令牌:

https://codepen.io/fmartingr/pen/pGfhy

请注意,上面的codepen使用stripe.js来生成令牌....

并试图在我的PHP代码中使用令牌,如下所示:

$account->external_accounts->create(
array(
        'external_account' => array(
            "object" => "card",
            "source" => "tok_1AqPXeDQzcw33c71uncYBFdm"
        )
));

但这给了我完全相同的错误:

Requests made on behalf of a connected account must use card tokens from Stripe.js, but card details were directly provided.
php stripe-connect
1个回答
0
投票

请使用它,它将添加您的外部帐户

$result = \Stripe\Token::create(
                array(
                    "card" => array(
                    "name" => "Some Name",
                    "exp_month" => 8,
                    "exp_year" => 2018,
                    "number" => "4012888888881881",
                    "currency" => "usd",
                    "cvc" => "123"
                    )
                ));



$token = $result['id'];

$account->external_accounts->create(
   array(
      'external_account' => "".$token.""
));
© www.soinside.com 2019 - 2024. All rights reserved.