条带错误400 - 不能多次使用条带令牌

时间:2015-06-10 02:54:03

标签: javascript php stripe-payments

我一直在条带信息中心收到错误代码400。看起来我不止一次使用相同的条带令牌,这会产生错误。以下是我的代码。

JS:

CELLID

腓:

DEFINED_TCH_FRQ

有谁可以告诉我为什么我不能向客户收费?我如何多次使用密钥?

2 个答案:

答案 0 :(得分:44)

您确实使用了两次令牌。

首先,在创建客户时。 第二,试图给卡充电时。

相反,您可以创建一个客户,然后在创建费用时将$customer->id传递给Stripe:

$charge = \Stripe\Charge::create(array(
  "amount" => 1000, // amount in cents, again
  "currency" => "cad",
  "customer" => $customer->id,
  "description" => "Example charge")
);

答案 1 :(得分:3)

You have to create the customer to charge him multiple times.

1) Add the Credit card token to customer and create customer

2) Use the customer Id to charge users

if (isset($_POST['stripeToken'])){

        $token = $_POST['stripeToken'];

// Create a Customer
$customer = \Stripe\Customer::create(array(
  "source" => $token,
  "description" => "Example customer")
);

// Charge the Customer instead of the card
\Stripe\Charge::create(array(
  "amount" => 1000, # amount in cents, again
  "currency" => "usd",
  "customer" => $customer->id)
);
    }

for more help visit: https://stripe.com/docs/tutorials/charges