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

时间:2017-08-13 17:00:58

标签: php stripe-connect

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

任何方式,我希望有人已经为此找到了解决方案,并且可以为此提供帮助。

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

我正在创建条纹custom connect accounts,如下所示:

$acct = \Stripe\Account::create(array(
    "country" => "US",
    "type" => "custom",
    "email" => "email@mail.com"
));

然后我像这样添加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"
        )
));

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

现在,我需要做的是能够将已连接的自定义帐户中的资金/付款转移到银行帐户

为此目的,我需要在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.

1 个答案:

答案 0 :(得分: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.""
));