0

使用以前使用条带创建的客户创建的令牌进行收费时出现错误。我需要能够多次向用户收费,以便收费可以转到多个目的地,这就是我创建令牌的原因。但是,当尝试使用以下代码向任何人收费时,我收到错误:

致命错误:未捕获的异常“Stripe\Error\InvalidRequest”与消息“没有这样的令牌: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
    )); 

任何帮助将不胜感激,

谢谢

4

1 回答 1

2

在条带中,您获得/创建的任何令牌都是一次,因此您不能两次使用令牌。Stripe 以 3 种方式支持收费。

  1. 使用卡令牌
  2. 使用令牌(你正在做)
  3. 使用客户 ID

因此,在您的情况下,只需使用客户 ID 而不是令牌多次向客户收费。CustomerId 不会过期。

所以内部收费对象使用“客户”字段

你可以在这里看到充电对象条纹

于 2016-08-10T12:24:37.380 回答