我在代码中使用Stripe API,但出现错误:您不能多次使用Stripe令牌:tok_1EIw1gKIAV9zC39qQnFXKzi6

时间:2019-03-28 11:57:55

标签: php stripe-payments

我遇到一个错误:

  

客户cus_EmVoBWWrqnWw4W没有ID为tok_1EIw1gKIAV9zC39qQnFXKzi6的链接源。

这是我的代码:

\Stripe\Stripe::setApiKey("sk_test_rUFQ9fpJoK9TlRVJs1nSYd6C");

$user = new User();

$email = $user->getEmail();
//creation du client
$customer = \Stripe\Customer::create(array(
    "email" => $email,
));
$charge = \Stripe\Charge::create(array(
    "amount" => 2000,
    "currency" => "eur",
    "source" => $request ->request->get('stripeToken'),

    "description" => "Stripe connect - Order 36",
    "customer" => $customer->id

));
\Stripe\Stripe::setApiKey("sk_test_rUFQ9fpJoK9TlRVJs1nSYd6C");

$refund = \Stripe\Refund::create([
    'charge' => $charge,
    'amount' => 1000,
]);     

1 个答案:

答案 0 :(得分:0)

您需要save the card to the customer,然后向客户收费。之后,除非客户有多个来源,并且您要使用特定来源,否则您无需将source传递给Charge::create