条纹“;没有这样的标记:“;错误


Stripe "No such token: " error

我的条带帐户是用test配置的。并在我的laravel应用程序中使用CCD_ 2密钥。

在发帖时,我正在创建新的stripe user,如果不存在的话,

Stripe::setApiKey(Config::get('constants.features.stripe.secret'));
$token = $input['_token']; 
$customer = Stripe_Customer::create(array(
            "description" => "#{$user->id} / {$user->username} / {$user->email}",
            "source" => $token,
            "email" => $user->email
        ));

创造这样的电荷,

$charge = Stripe_Charge::create(array(
                "amount" => '5000',
                "currency" => "gbp",
                "customer" => $customer->id,
                "description" => 'description',
                "statement_descriptor" => strtoupper("test desc")
            ));

但它返回错误Stripe_InvalidRequestError No such token:

从Laravel输入的_token是CSRF令牌。这不是应该在source字段中传递给条带的令牌。source字段中的令牌应该是stripe.js库生成的令牌,该库允许您在不实际查看卡详细信息的情况下识别客户信用卡。

stripe文档解释了应该如何处理https://stripe.com/docs/stripe.js