【问题标题】:How to make multiple payments using a token created from a customer using stripe?如何使用从客户使用条带创建的令牌进行多次付款?
【发布时间】:2016-08-31 18:11:28
【问题描述】:

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

致命错误:未捕获的异常“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
    )); 

任何帮助将不胜感激,

谢谢

【问题讨论】:

    标签: php stripe-connect stripe.net


    【解决方案1】:

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

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2020-07-02
      • 2014-12-28
      • 2021-06-10
      • 2020-11-12
      • 2014-06-27
      • 2018-12-11
      • 2015-03-02
      • 2017-03-25
      • 2017-11-20
      相关资源
      最近更新 更多