使用之前使用stripe创建的客户创建的代币进行收费时,我遇到了一个错误。我需要能够向用户收取多次费用,这样费用才能到达多个目的地,这就是我创建代币的原因。然而,当试图使用以下代码向任何人收费时,我会收到错误:
致命错误:未捕获异常"Stripe''error''InvalidRequest",消息为"No such token:tok_187sfmBqiK1u6WYC3qS20eNu"
$stripe_id和其他变量已经在我的代码中分配,我只是复制/粘贴主要位:
'Stripe'Stripe::setApiKey("sk_mykey-changedforsecurity"); // authorises secret key
$token = $_POST['stripeToken'];
$customer = 'Stripe'Customer::create(array(
"description" => "test customer",
"source" => $token // obtained with Stripe.js
));
$chargetoken = 'Stripe'Token::create(
array("customer" => $customer->id),
array("stripe_account" => $stripe_id) // id of the connected account
);
$charge = 'Stripe'Charge::create(array(
"amount" => $price,
"currency" => "gbp",
"source" => $chargetoken,
"description" => $title,
"application_fee" => 20,
"destination" => $stripe_id
));
任何帮助都将不胜感激,
感谢
在stripe中,您获得/创建的任何令牌都是一次,因此您不能使用令牌两次。Stripe通过三种方式支持收费。
- 使用卡令牌
- 使用令牌(您正在执行)
- 使用客户Id
因此,在您的情况下,只需使用客户Id而不是令牌多次向客户收费。CustomerId不会过期。
所以内部收费对象使用"客户"字段
你可以在这里看到电荷对象条纹